22 use Wikimedia\ScopedCallback;
51 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
53 'Cannot override ' . __CLASS__ .
'default instance in operation.'
57 self::$instance = $store;
58 return new ScopedCallback(
function ()
use ( $previousValue ) {
59 self::$instance = $previousValue;
67 if ( self::$instance ===
null ) {
68 self::$instance =
new self();
92 if ( $this->
cache->getSize() < $size ) {
93 $this->
cache->resize( $size );
116 if ( is_array( $propertyNames ) ) {
119 $propertyNames = [ $propertyNames ];
126 foreach ( $goodIDs
as $pageID ) {
127 foreach ( $propertyNames
as $propertyName ) {
129 if ( $propertyValue ===
false ) {
130 $queryIDs[] = $pageID;
134 $values[$pageID][$propertyName] = $propertyValue;
136 $values[$pageID] = $propertyValue;
152 'pp_page' => $queryIDs,
153 'pp_propname' => $propertyNames
159 $pageID = $row->pp_page;
160 $propertyName = $row->pp_propname;
161 $propertyValue = $row->pp_value;
162 $this->
cacheProperty( $pageID, $propertyName, $propertyValue );
164 $values[$pageID][$propertyName] = $propertyValue;
166 $values[$pageID] = $propertyValue;
191 foreach ( $goodIDs
as $pageID ) {
193 if ( $pageProperties ===
false ) {
194 $queryIDs[] = $pageID;
196 $values[$pageID] = $pageProperties;
200 if ( $queryIDs != [] ) {
210 'pp_page' => $queryIDs,
216 $pageProperties = [];
218 $pageID = $row->pp_page;
219 if ( $currentPageID != $pageID ) {
220 if ( $pageProperties != [] ) {
222 $values[$currentPageID] = $pageProperties;
224 $currentPageID = $pageID;
225 $pageProperties = [];
227 $pageProperties[$row->pp_propname] = $row->pp_value;
229 if ( $pageProperties != [] ) {
231 $values[$pageID] = $pageProperties;
248 $pageID =
$title->getArticleID();
254 $pageID =
$titles->getArticleID();
270 if ( $this->
cache->has( $pageID, $propertyName, self::CACHE_TTL ) ) {
271 return $this->
cache->get( $pageID, $propertyName );
273 if ( $this->
cache->has( 0, $pageID, self::CACHE_TTL ) ) {
274 $pageProperties = $this->
cache->get( 0, $pageID );
275 if ( isset( $pageProperties[$propertyName] ) ) {
276 return $pageProperties[$propertyName];
289 if ( $this->
cache->has( 0, $pageID, self::CACHE_TTL ) ) {
290 return $this->
cache->get( 0, $pageID );
303 $this->
cache->set( $pageID, $propertyName, $propertyValue );
313 $this->
cache->clear( $pageID );
314 $this->
cache->set( 0, $pageID, $pageProperties );