MediaWiki  1.30.0
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 
40  $dbw->onTransactionIdle(
41  function () use ( $dbw, $namespace, $dbkeys ) {
42  $services = MediaWikiServices::getInstance();
43  $lbFactory = $services->getDBLoadBalancerFactory();
44  // Determine which pages need to be updated.
45  // This is necessary to prevent the job queue from smashing the DB with
46  // large numbers of concurrent invalidations of the same page.
47  $now = $dbw->timestamp();
48  $ids = $dbw->selectFieldValues(
49  'page',
50  'page_id',
51  [
52  'page_namespace' => $namespace,
53  'page_title' => $dbkeys,
54  'page_touched < ' . $dbw->addQuotes( $now )
55  ],
56  __METHOD__
57  );
58 
59  if ( !$ids ) {
60  return;
61  }
62 
63  $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
64  $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
65  foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
66  $dbw->update(
67  'page',
68  [ 'page_touched' => $now ],
69  [
70  'page_id' => $idBatch,
71  'page_touched < ' . $dbw->addQuotes( $now ) // handle races
72  ],
73  __METHOD__
74  );
75  $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
76  }
77  },
78  __METHOD__
79  );
80  }
81 }
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
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:40
Wikimedia\Rdbms\IDatabase\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
$services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title 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:2198
PurgeJobUtils
Definition: PurgeJobUtils.php:26
Wikimedia\Rdbms\IDatabase\update
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
Wikimedia\Rdbms\IDatabase\onTransactionIdle
onTransactionIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
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.
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
array
the array() calling protocol came about after MediaWiki 1.4rc1.