MediaWiki REL1_28
Go to the documentation of this file.
34 public static function invalidatePages( IDatabase $dbw, $namespace, array $dbkeys ) {
35 if ( $dbkeys === [] ) {
36 return;
37 }
40 function () use ( $dbw, $namespace, $dbkeys ) {
41 $services = MediaWikiServices::getInstance();
42 $lbFactory = $services->getDBLoadBalancerFactory();
43 // Determine which pages need to be updated.
44 // This is necessary to prevent the job queue from smashing the DB with
45 // large numbers of concurrent invalidations of the same page.
46 $now = $dbw->timestamp();
47 $ids = $dbw->selectFieldValues(
48 'page',
49 'page_id',
50 [
51 'page_namespace' => $namespace,
52 'page_title' => $dbkeys,
53 'page_touched < ' . $dbw->addQuotes( $now )
54 ],
55 __METHOD__
56 );
58 if ( !$ids ) {
59 return;
60 }
62 $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
63 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
64 foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
65 $dbw->update(
66 'page',
67 [ 'page_touched' => $now ],
68 [
69 'page_id' => $idBatch,
70 'page_touched < ' . $dbw->addQuotes( $now ) // handle races
71 ],
72 __METHOD__
73 );
74 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
75 }
76 },
77 __METHOD__
78 );
79 }
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
MediaWikiServices is the service locator for the application scope of MediaWiki.
static invalidatePages(IDatabase $dbw, $namespace, array $dbkeys)
Invalidate the cache of a list of pages from a single namespace.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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:2207
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:37
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:34
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
addQuotes( $s)
Adds quotes and backslashes.
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[])
A SELECT wrapper which returns a list of single field values from result rows.
onTransactionIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.