3 * See docs/deferred.txt
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * Abstract base class for update jobs that put some secondary data extracted
21 * from article content into the database.
23 abstract class SecondaryDBDataUpdate
extends SecondaryDataUpdate
{
28 var $mDb, //!< Database connection reference
29 $mOptions; //!< SELECT options to be used (array)
35 * @param $title Title of the page we're updating
36 * @param $parserOutput ParserOutput: output from a full parse of this page
37 * @param $recursive Boolean: queue jobs for recursive updates?
39 public function __construct( Title
$title, ParserOutput
$parserOutput ) {
40 global $wgAntiLockFlags;
42 parent
::__construct( $title, $parserOutput );
44 if ( $wgAntiLockFlags & ALF_NO_LINK_LOCK
) {
45 $this->mOptions
= array();
47 $this->mOptions
= array( 'FOR UPDATE' );
49 $this->mDb
= wfGetDB( DB_MASTER
);
53 * Invalidate the cache of a list of pages from a single namespace
55 * @param $namespace Integer
56 * @param $dbkeys Array
58 public function invalidatePages( $namespace, $dbkeys ) {
59 if ( !count( $dbkeys ) ) {
64 * Determine which pages need to be updated
65 * This is necessary to prevent the job queue from smashing the DB with
66 * large numbers of concurrent invalidations of the same page
68 $now = $this->mDb
->timestamp();
70 $res = $this->mDb
->select( 'page', array( 'page_id' ),
72 'page_namespace' => $namespace,
73 'page_title IN (' . $this->mDb
->makeList( $dbkeys ) . ')',
74 'page_touched < ' . $this->mDb
->addQuotes( $now )
77 foreach ( $res as $row ) {
78 $ids[] = $row->page_id
;
80 if ( !count( $ids ) ) {
86 * We still need the page_touched condition, in case the row has changed since
87 * the non-locking select above.
89 $this->mDb
->update( 'page', array( 'page_touched' => $now ),
91 'page_id IN (' . $this->mDb
->makeList( $ids ) . ')',
92 'page_touched < ' . $this->mDb
->addQuotes( $now )