MediaWiki REL1_33
HistoryBlobStub.php
Go to the documentation of this file.
1<?php
33 protected static $blobCache = [];
34
36 public $mOldId;
37
39 public $mHash;
40
42 public $mRef;
43
48 function __construct( $hash = '', $oldid = 0 ) {
49 $this->mHash = $hash;
50 }
51
57 function setLocation( $id ) {
58 $this->mOldId = $id;
59 }
60
65 function setReferrer( $id ) {
66 $this->mRef = $id;
67 }
68
73 function getReferrer() {
74 return $this->mRef;
75 }
76
80 function getText() {
81 if ( isset( self::$blobCache[$this->mOldId] ) ) {
82 $obj = self::$blobCache[$this->mOldId];
83 } else {
85 $row = $dbr->selectRow(
86 'text',
87 [ 'old_flags', 'old_text' ],
88 [ 'old_id' => $this->mOldId ]
89 );
90
91 if ( !$row ) {
92 return false;
93 }
94
95 $flags = explode( ',', $row->old_flags );
96 if ( in_array( 'external', $flags ) ) {
97 $url = $row->old_text;
98 $parts = explode( '://', $url, 2 );
99 if ( !isset( $parts[1] ) || $parts[1] == '' ) {
100 return false;
101 }
102 $row->old_text = ExternalStore::fetchFromURL( $url );
103
104 }
105
106 if ( !in_array( 'object', $flags ) ) {
107 return false;
108 }
109
110 if ( in_array( 'gzip', $flags ) ) {
111 // This shouldn't happen, but a bug in the compress script
112 // may at times gzip-compress a HistoryBlob object row.
113 $obj = unserialize( gzinflate( $row->old_text ) );
114 } else {
115 $obj = unserialize( $row->old_text );
116 }
117
118 if ( !is_object( $obj ) ) {
119 // Correct for old double-serialization bug.
120 $obj = unserialize( $obj );
121 }
122
123 // Save this item for reference; if pulling many
124 // items in a row we'll likely use it again.
125 $obj->uncompress();
126 self::$blobCache = [ $this->mOldId => $obj ];
127 }
128
129 return $obj->getItem( $this->mHash );
130 }
131
137 function getHash() {
138 return $this->mHash;
139 }
140}
141
142// phpcs:ignore Generic.CodeAnalysis.UnconditionalIfStatement.Found
143if ( false ) {
144 // Blobs generated by MediaWiki < 1.5 on PHP 4 were serialized with the
145 // class name coerced to lowercase. We can improve efficiency by adding
146 // autoload entries for the lowercase variants of these classes (T166759).
147 // The code below is never executed, but it is picked up by the AutoloadGenerator
148 // parser, which scans for class_alias() calls.
149 class_alias( HistoryBlobStub::class, 'historyblobstub' );
150}
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Pointer object for an item within a CGZ blob stored in the text table.
setLocation( $id)
Sets the location (old_id) of the main object to which this object points.
getReferrer()
Gets the location of the referring object.
static array $blobCache
One-step cache variable to hold base blobs; operations that pull multiple revisions may often pull mu...
__construct( $hash='', $oldid=0)
getHash()
Get the content hash.
setReferrer( $id)
Sets the location (old_id) of the referring object.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
const DB_REPLICA
Definition defines.php:25