3 * Base code for update jobs that put some secondary data extracted
4 * from article content into the database.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
25 * Invalidate the cache of a list of pages from a single namespace.
26 * This is intended for use by subclasses.
28 * @param IDatabase $dbw
29 * @param int $namespace Namespace number
30 * @param array $dbkeys
32 public static function invalidatePages( IDatabase
$dbw, $namespace, array $dbkeys ) {
33 if ( $dbkeys === [] ) {
37 $dbw->onTransactionPreCommitOrIdle( function() use ( $dbw, $namespace, $dbkeys ) {
38 // Determine which pages need to be updated.
39 // This is necessary to prevent the job queue from smashing the DB with
40 // large numbers of concurrent invalidations of the same page.
41 $now = $dbw->timestamp();
42 $ids = $dbw->selectFieldValues(
46 'page_namespace' => $namespace,
47 'page_title' => $dbkeys,
48 'page_touched < ' . $dbw->addQuotes( $now )
58 // We still need the page_touched condition, in case the row has changed since
59 // the non-locking select above.
62 [ 'page_touched' => $now ],
65 'page_touched < ' . $dbw->addQuotes( $now )