MediaWiki  1.32.5
PurgeJobUtils.php
Go to the documentation of this file.
1 <?php
25 
35  public static function invalidatePages( IDatabase $dbw, $namespace, array $dbkeys ) {
36  if ( $dbkeys === [] ) {
37  return;
38  }
39  $fname = __METHOD__;
40 
42  $dbw,
43  __METHOD__,
44  function () use ( $dbw, $namespace, $dbkeys, $fname ) {
45  $services = MediaWikiServices::getInstance();
46  $lbFactory = $services->getDBLoadBalancerFactory();
47  // Determine which pages need to be updated.
48  // This is necessary to prevent the job queue from smashing the DB with
49  // large numbers of concurrent invalidations of the same page.
50  $now = $dbw->timestamp();
51  $ids = $dbw->selectFieldValues(
52  'page',
53  'page_id',
54  [
55  'page_namespace' => $namespace,
56  'page_title' => $dbkeys,
57  'page_touched < ' . $dbw->addQuotes( $now )
58  ],
59  $fname
60  );
61 
62  if ( !$ids ) {
63  return;
64  }
65 
66  $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
67  $ticket = $lbFactory->getEmptyTransactionTicket( $fname );
68  foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
69  $dbw->update(
70  'page',
71  [ 'page_touched' => $now ],
72  [
73  'page_id' => $idBatch,
74  'page_touched < ' . $dbw->addQuotes( $now ) // handle races
75  ],
76  $fname
77  );
78  $lbFactory->commitAndWaitForReplication( $fname, $ticket );
79  }
80  }
81  ) );
82  }
83 }
AutoCommitUpdate
Deferrable Update for closure/callback updates that should use auto-commit mode.
Definition: AutoCommitUpdate.php:9
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
Definition: DeferredUpdates.php:79
PurgeJobUtils\invalidatePages
static invalidatePages(IDatabase $dbw, $namespace, array $dbkeys)
Invalidate the cache of a list of pages from a single namespace.
Definition: PurgeJobUtils.php:35
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\IDatabase\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
array
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))
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:121
PurgeJobUtils
Definition: PurgeJobUtils.php:26
Wikimedia\Rdbms\IDatabase\update
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
Wikimedia\Rdbms\IDatabase\addQuotes
addQuotes( $s)
Adds quotes and backslashes.
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Wikimedia\Rdbms\IDatabase\selectFieldValues
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
$services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2278
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23