3 * Updater for link tracking tables after a page edit.
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
24 * See docs/deferred.txt
26 * @todo document (e.g. one-sentence top-level class description).
28 class LinksUpdate
extends SqlDataUpdate
{
30 // @todo: make members protected, but make sure extensions don't break
32 public $mId, //!< Page ID of the article linked from
33 $mTitle, //!< Title object of the article linked from
34 $mParserOutput, //!< Parser output
35 $mLinks, //!< Map of title strings to IDs for the links in the document
36 $mImages, //!< DB keys of the images used, in the array key only
37 $mTemplates, //!< Map of title strings to IDs for the template references, including broken ones
38 $mExternals, //!< URLs of external links, array key only
39 $mCategories, //!< Map of category names to sort keys
40 $mInterlangs, //!< Map of language codes to titles
41 $mProperties, //!< Map of arbitrary name to value
42 $mDb, //!< Database connection reference
43 $mOptions, //!< SELECT options to be used (array)
44 $mRecursive; //!< Whether to queue jobs for recursive updates
49 * @param $title Title of the page we're updating
50 * @param $parserOutput ParserOutput: output from a full parse of this page
51 * @param $recursive Boolean: queue jobs for recursive updates?
54 function __construct( $title, $parserOutput, $recursive = true ) {
55 parent
::__construct( false ); // no implicit transaction
57 if ( !( $title instanceof Title
) ) {
58 throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
59 "Please see Article::editUpdates() for an invocation example.\n" );
62 if ( !( $parserOutput instanceof ParserOutput
) ) {
63 throw new MWException( "The calling convention to LinksUpdate::__construct() has changed. " .
64 "Please see WikiPage::doEditUpdates() for an invocation example.\n" );
67 $this->mTitle
= $title;
68 $this->mId
= $title->getArticleID();
71 throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" );
74 $this->mParserOutput
= $parserOutput;
76 $this->mLinks
= $parserOutput->getLinks();
77 $this->mImages
= $parserOutput->getImages();
78 $this->mTemplates
= $parserOutput->getTemplates();
79 $this->mExternals
= $parserOutput->getExternalLinks();
80 $this->mCategories
= $parserOutput->getCategories();
81 $this->mProperties
= $parserOutput->getProperties();
82 $this->mInterwikis
= $parserOutput->getInterwikiLinks();
84 # Convert the format of the interlanguage links
85 # I didn't want to change it in the ParserOutput, because that array is passed all
86 # the way back to the skin, so either a skin API break would be required, or an
87 # inefficient back-conversion.
88 $ill = $parserOutput->getLanguageLinks();
89 $this->mInterlangs
= array();
90 foreach ( $ill as $link ) {
91 list( $key, $title ) = explode( ':', $link, 2 );
92 $this->mInterlangs
[$key] = $title;
95 foreach ( $this->mCategories
as &$sortkey ) {
96 # If the sortkey is longer then 255 bytes,
97 # it truncated by DB, and then doesn't get
98 # matched when comparing existing vs current
99 # categories, causing bug 25254.
100 # Also. substr behaves weird when given "".
101 if ( $sortkey !== '' ) {
102 $sortkey = substr( $sortkey, 0, 255 );
106 $this->mRecursive
= $recursive;
108 wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
112 * Update link tables with outgoing links from an updated article
114 public function doUpdate() {
115 global $wgUseDumbLinkUpdate;
117 wfRunHooks( 'LinksUpdate', array( &$this ) );
118 if ( $wgUseDumbLinkUpdate ) {
119 $this->doDumbUpdate();
121 $this->doIncrementalUpdate();
123 wfRunHooks( 'LinksUpdateComplete', array( &$this ) );
126 protected function doIncrementalUpdate() {
127 wfProfileIn( __METHOD__
);
130 $existing = $this->getExistingLinks();
131 $this->incrTableUpdate( 'pagelinks', 'pl', $this->getLinkDeletions( $existing ),
132 $this->getLinkInsertions( $existing ) );
135 $existing = $this->getExistingImages();
137 $imageDeletes = $this->getImageDeletions( $existing );
138 $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes,
139 $this->getImageInsertions( $existing ) );
141 # Invalidate all image description pages which had links added or removed
142 $imageUpdates = $imageDeletes +
array_diff_key( $this->mImages
, $existing );
143 $this->invalidateImageDescriptions( $imageUpdates );
146 $existing = $this->getExistingExternals();
147 $this->incrTableUpdate( 'externallinks', 'el', $this->getExternalDeletions( $existing ),
148 $this->getExternalInsertions( $existing ) );
151 $existing = $this->getExistingInterlangs();
152 $this->incrTableUpdate( 'langlinks', 'll', $this->getInterlangDeletions( $existing ),
153 $this->getInterlangInsertions( $existing ) );
155 # Inline interwiki links
156 $existing = $this->getExistingInterwikis();
157 $this->incrTableUpdate( 'iwlinks', 'iwl', $this->getInterwikiDeletions( $existing ),
158 $this->getInterwikiInsertions( $existing ) );
161 $existing = $this->getExistingTemplates();
162 $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ),
163 $this->getTemplateInsertions( $existing ) );
166 $existing = $this->getExistingCategories();
168 $categoryDeletes = $this->getCategoryDeletions( $existing );
170 $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes,
171 $this->getCategoryInsertions( $existing ) );
173 # Invalidate all categories which were added, deleted or changed (set symmetric difference)
174 $categoryInserts = array_diff_assoc( $this->mCategories
, $existing );
175 $categoryUpdates = $categoryInserts +
$categoryDeletes;
176 $this->invalidateCategories( $categoryUpdates );
177 $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
180 $existing = $this->getExistingProperties();
182 $propertiesDeletes = $this->getPropertyDeletions( $existing );
184 $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes,
185 $this->getPropertyInsertions( $existing ) );
187 # Invalidate the necessary pages
188 $changed = $propertiesDeletes +
array_diff_assoc( $this->mProperties
, $existing );
189 $this->invalidateProperties( $changed );
191 # Refresh links of all pages including this page
192 # This will be in a separate transaction
193 if ( $this->mRecursive
) {
194 $this->queueRecursiveJobs();
197 wfProfileOut( __METHOD__
);
201 * Link update which clears the previous entries and inserts new ones
202 * May be slower or faster depending on level of lock contention and write speed of DB
203 * Also useful where link table corruption needs to be repaired, e.g. in refreshLinks.php
205 protected function doDumbUpdate() {
206 wfProfileIn( __METHOD__
);
208 # Refresh category pages and image description pages
209 $existing = $this->getExistingCategories();
210 $categoryInserts = array_diff_assoc( $this->mCategories
, $existing );
211 $categoryDeletes = array_diff_assoc( $existing, $this->mCategories
);
212 $categoryUpdates = $categoryInserts +
$categoryDeletes;
213 $existing = $this->getExistingImages();
214 $imageUpdates = array_diff_key( $existing, $this->mImages
) +
array_diff_key( $this->mImages
, $existing );
216 $this->dumbTableUpdate( 'pagelinks', $this->getLinkInsertions(), 'pl_from' );
217 $this->dumbTableUpdate( 'imagelinks', $this->getImageInsertions(), 'il_from' );
218 $this->dumbTableUpdate( 'categorylinks', $this->getCategoryInsertions(), 'cl_from' );
219 $this->dumbTableUpdate( 'templatelinks', $this->getTemplateInsertions(), 'tl_from' );
220 $this->dumbTableUpdate( 'externallinks', $this->getExternalInsertions(), 'el_from' );
221 $this->dumbTableUpdate( 'langlinks', $this->getInterlangInsertions(),'ll_from' );
222 $this->dumbTableUpdate( 'iwlinks', $this->getInterwikiInsertions(),'iwl_from' );
223 $this->dumbTableUpdate( 'page_props', $this->getPropertyInsertions(), 'pp_page' );
225 # Update the cache of all the category pages and image description
226 # pages which were changed, and fix the category table count
227 $this->invalidateCategories( $categoryUpdates );
228 $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
229 $this->invalidateImageDescriptions( $imageUpdates );
231 # Refresh links of all pages including this page
232 # This will be in a separate transaction
233 if ( $this->mRecursive
) {
234 $this->queueRecursiveJobs();
237 wfProfileOut( __METHOD__
);
240 function queueRecursiveJobs() {
241 global $wgUpdateRowsPerJob;
242 wfProfileIn( __METHOD__
);
244 $cache = $this->mTitle
->getBacklinkCache();
245 $batches = $cache->partition( 'templatelinks', $wgUpdateRowsPerJob );
247 wfProfileOut( __METHOD__
);
251 foreach ( $batches as $batch ) {
252 list( $start, $end ) = $batch;
254 'table' => 'templatelinks',
258 $jobs[] = new RefreshLinksJob2( $this->mTitle
, $params );
260 Job
::batchInsert( $jobs );
262 wfProfileOut( __METHOD__
);
268 function invalidateCategories( $cats ) {
269 $this->invalidatePages( NS_CATEGORY
, array_keys( $cats ) );
273 * Update all the appropriate counts in the category table.
274 * @param $added array associative array of category name => sort key
275 * @param $deleted array associative array of category name => sort key
277 function updateCategoryCounts( $added, $deleted ) {
278 $a = WikiPage
::factory( $this->mTitle
);
279 $a->updateCategoryCounts(
280 array_keys( $added ), array_keys( $deleted )
287 function invalidateImageDescriptions( $images ) {
288 $this->invalidatePages( NS_FILE
, array_keys( $images ) );
296 private function dumbTableUpdate( $table, $insertions, $fromField ) {
297 $this->mDb
->delete( $table, array( $fromField => $this->mId
), __METHOD__
);
298 if ( count( $insertions ) ) {
299 # The link array was constructed without FOR UPDATE, so there may
300 # be collisions. This may cause minor link table inconsistencies,
301 # which is better than crippling the site with lock contention.
302 $this->mDb
->insert( $table, $insertions, __METHOD__
, array( 'IGNORE' ) );
307 * Update a table by doing a delete query then an insert query
313 function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
314 if ( $table == 'page_props' ) {
315 $fromField = 'pp_page';
317 $fromField = "{$prefix}_from";
319 $where = array( $fromField => $this->mId
);
320 if ( $table == 'pagelinks' ||
$table == 'templatelinks' ||
$table == 'iwlinks' ) {
321 if ( $table == 'iwlinks' ) {
322 $baseKey = 'iwl_prefix';
324 $baseKey = "{$prefix}_namespace";
326 $clause = $this->mDb
->makeWhereFrom2d( $deletions, $baseKey, "{$prefix}_title" );
333 if ( $table == 'langlinks' ) {
334 $toField = 'll_lang';
335 } elseif ( $table == 'page_props' ) {
336 $toField = 'pp_propname';
338 $toField = $prefix . '_to';
340 if ( count( $deletions ) ) {
341 $where[] = "$toField IN (" . $this->mDb
->makeList( array_keys( $deletions ) ) . ')';
347 $this->mDb
->delete( $table, $where, __METHOD__
);
349 if ( count( $insertions ) ) {
350 $this->mDb
->insert( $table, $insertions, __METHOD__
, 'IGNORE' );
355 * Get an array of pagelinks insertions for passing to the DB
356 * Skips the titles specified by the 2-D array $existing
357 * @param $existing array
360 private function getLinkInsertions( $existing = array() ) {
362 foreach( $this->mLinks
as $ns => $dbkeys ) {
363 $diffs = isset( $existing[$ns] )
364 ?
array_diff_key( $dbkeys, $existing[$ns] )
366 foreach ( $diffs as $dbk => $id ) {
368 'pl_from' => $this->mId
,
369 'pl_namespace' => $ns,
378 * Get an array of template insertions. Like getLinkInsertions()
379 * @param $existing array
382 private function getTemplateInsertions( $existing = array() ) {
384 foreach( $this->mTemplates
as $ns => $dbkeys ) {
385 $diffs = isset( $existing[$ns] ) ?
array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
386 foreach ( $diffs as $dbk => $id ) {
388 'tl_from' => $this->mId
,
389 'tl_namespace' => $ns,
398 * Get an array of image insertions
399 * Skips the names specified in $existing
400 * @param $existing array
403 private function getImageInsertions( $existing = array() ) {
405 $diffs = array_diff_key( $this->mImages
, $existing );
406 foreach( $diffs as $iname => $dummy ) {
408 'il_from' => $this->mId
,
416 * Get an array of externallinks insertions. Skips the names specified in $existing
417 * @param $existing array
420 private function getExternalInsertions( $existing = array() ) {
422 $diffs = array_diff_key( $this->mExternals
, $existing );
423 foreach( $diffs as $url => $dummy ) {
424 foreach( wfMakeUrlIndexes( $url ) as $index ) {
426 'el_from' => $this->mId
,
428 'el_index' => $index,
436 * Get an array of category insertions
438 * @param $existing array mapping existing category names to sort keys. If both
439 * match a link in $this, the link will be omitted from the output
443 private function getCategoryInsertions( $existing = array() ) {
444 global $wgContLang, $wgCategoryCollation;
445 $diffs = array_diff_assoc( $this->mCategories
, $existing );
447 foreach ( $diffs as $name => $prefix ) {
448 $nt = Title
::makeTitleSafe( NS_CATEGORY
, $name );
449 $wgContLang->findVariantLink( $name, $nt, true );
451 if ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
453 } elseif ( $this->mTitle
->getNamespace() == NS_FILE
) {
459 # Treat custom sortkeys as a prefix, so that if multiple
460 # things are forced to sort as '*' or something, they'll
461 # sort properly in the category rather than in page_id
463 $sortkey = Collation
::singleton()->getSortKey(
464 $this->mTitle
->getCategorySortkey( $prefix ) );
467 'cl_from' => $this->mId
,
469 'cl_sortkey' => $sortkey,
470 'cl_timestamp' => $this->mDb
->timestamp(),
471 'cl_sortkey_prefix' => $prefix,
472 'cl_collation' => $wgCategoryCollation,
480 * Get an array of interlanguage link insertions
482 * @param $existing Array mapping existing language codes to titles
486 private function getInterlangInsertions( $existing = array() ) {
487 $diffs = array_diff_assoc( $this->mInterlangs
, $existing );
489 foreach( $diffs as $lang => $title ) {
491 'll_from' => $this->mId
,
500 * Get an array of page property insertions
501 * @param $existing array
504 function getPropertyInsertions( $existing = array() ) {
505 $diffs = array_diff_assoc( $this->mProperties
, $existing );
507 foreach ( $diffs as $name => $value ) {
509 'pp_page' => $this->mId
,
510 'pp_propname' => $name,
511 'pp_value' => $value,
518 * Get an array of interwiki insertions for passing to the DB
519 * Skips the titles specified by the 2-D array $existing
520 * @param $existing array
523 private function getInterwikiInsertions( $existing = array() ) {
525 foreach( $this->mInterwikis
as $prefix => $dbkeys ) {
526 $diffs = isset( $existing[$prefix] ) ?
array_diff_key( $dbkeys, $existing[$prefix] ) : $dbkeys;
527 foreach ( $diffs as $dbk => $id ) {
529 'iwl_from' => $this->mId
,
530 'iwl_prefix' => $prefix,
539 * Given an array of existing links, returns those links which are not in $this
540 * and thus should be deleted.
541 * @param $existing array
544 private function getLinkDeletions( $existing ) {
546 foreach ( $existing as $ns => $dbkeys ) {
547 if ( isset( $this->mLinks
[$ns] ) ) {
548 $del[$ns] = array_diff_key( $existing[$ns], $this->mLinks
[$ns] );
550 $del[$ns] = $existing[$ns];
557 * Given an array of existing templates, returns those templates which are not in $this
558 * and thus should be deleted.
559 * @param $existing array
562 private function getTemplateDeletions( $existing ) {
564 foreach ( $existing as $ns => $dbkeys ) {
565 if ( isset( $this->mTemplates
[$ns] ) ) {
566 $del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates
[$ns] );
568 $del[$ns] = $existing[$ns];
575 * Given an array of existing images, returns those images which are not in $this
576 * and thus should be deleted.
577 * @param $existing array
580 private function getImageDeletions( $existing ) {
581 return array_diff_key( $existing, $this->mImages
);
585 * Given an array of existing external links, returns those links which are not
586 * in $this and thus should be deleted.
587 * @param $existing array
590 private function getExternalDeletions( $existing ) {
591 return array_diff_key( $existing, $this->mExternals
);
595 * Given an array of existing categories, returns those categories which are not in $this
596 * and thus should be deleted.
597 * @param $existing array
600 private function getCategoryDeletions( $existing ) {
601 return array_diff_assoc( $existing, $this->mCategories
);
605 * Given an array of existing interlanguage links, returns those links which are not
606 * in $this and thus should be deleted.
607 * @param $existing array
610 private function getInterlangDeletions( $existing ) {
611 return array_diff_assoc( $existing, $this->mInterlangs
);
615 * Get array of properties which should be deleted.
616 * @param $existing array
619 function getPropertyDeletions( $existing ) {
620 return array_diff_assoc( $existing, $this->mProperties
);
624 * Given an array of existing interwiki links, returns those links which are not in $this
625 * and thus should be deleted.
626 * @param $existing array
629 private function getInterwikiDeletions( $existing ) {
631 foreach ( $existing as $prefix => $dbkeys ) {
632 if ( isset( $this->mInterwikis
[$prefix] ) ) {
633 $del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis
[$prefix] );
635 $del[$prefix] = $existing[$prefix];
642 * Get an array of existing links, as a 2-D array
646 private function getExistingLinks() {
647 $res = $this->mDb
->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
648 array( 'pl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
650 foreach ( $res as $row ) {
651 if ( !isset( $arr[$row->pl_namespace
] ) ) {
652 $arr[$row->pl_namespace
] = array();
654 $arr[$row->pl_namespace
][$row->pl_title
] = 1;
660 * Get an array of existing templates, as a 2-D array
664 private function getExistingTemplates() {
665 $res = $this->mDb
->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
666 array( 'tl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
668 foreach ( $res as $row ) {
669 if ( !isset( $arr[$row->tl_namespace
] ) ) {
670 $arr[$row->tl_namespace
] = array();
672 $arr[$row->tl_namespace
][$row->tl_title
] = 1;
678 * Get an array of existing images, image names in the keys
682 private function getExistingImages() {
683 $res = $this->mDb
->select( 'imagelinks', array( 'il_to' ),
684 array( 'il_from' => $this->mId
), __METHOD__
, $this->mOptions
);
686 foreach ( $res as $row ) {
687 $arr[$row->il_to
] = 1;
693 * Get an array of existing external links, URLs in the keys
697 private function getExistingExternals() {
698 $res = $this->mDb
->select( 'externallinks', array( 'el_to' ),
699 array( 'el_from' => $this->mId
), __METHOD__
, $this->mOptions
);
701 foreach ( $res as $row ) {
702 $arr[$row->el_to
] = 1;
708 * Get an array of existing categories, with the name in the key and sort key in the value.
712 private function getExistingCategories() {
713 $res = $this->mDb
->select( 'categorylinks', array( 'cl_to', 'cl_sortkey_prefix' ),
714 array( 'cl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
716 foreach ( $res as $row ) {
717 $arr[$row->cl_to
] = $row->cl_sortkey_prefix
;
723 * Get an array of existing interlanguage links, with the language code in the key and the
724 * title in the value.
728 private function getExistingInterlangs() {
729 $res = $this->mDb
->select( 'langlinks', array( 'll_lang', 'll_title' ),
730 array( 'll_from' => $this->mId
), __METHOD__
, $this->mOptions
);
732 foreach ( $res as $row ) {
733 $arr[$row->ll_lang
] = $row->ll_title
;
739 * Get an array of existing inline interwiki links, as a 2-D array
740 * @return array (prefix => array(dbkey => 1))
742 protected function getExistingInterwikis() {
743 $res = $this->mDb
->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
744 array( 'iwl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
746 foreach ( $res as $row ) {
747 if ( !isset( $arr[$row->iwl_prefix
] ) ) {
748 $arr[$row->iwl_prefix
] = array();
750 $arr[$row->iwl_prefix
][$row->iwl_title
] = 1;
756 * Get an array of existing categories, with the name in the key and sort key in the value.
760 private function getExistingProperties() {
761 $res = $this->mDb
->select( 'page_props', array( 'pp_propname', 'pp_value' ),
762 array( 'pp_page' => $this->mId
), __METHOD__
, $this->mOptions
);
764 foreach ( $res as $row ) {
765 $arr[$row->pp_propname
] = $row->pp_value
;
771 * Return the title object of the page being updated
774 public function getTitle() {
775 return $this->mTitle
;
779 * Returns parser output
781 * @return ParserOutput
783 public function getParserOutput() {
784 return $this->mParserOutput
;
788 * Return the list of images used as generated by the parser
791 public function getImages() {
792 return $this->mImages
;
796 * Invalidate any necessary link lists related to page property changes
799 private function invalidateProperties( $changed ) {
800 global $wgPagePropLinkInvalidations;
802 foreach ( $changed as $name => $value ) {
803 if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
804 $inv = $wgPagePropLinkInvalidations[$name];
805 if ( !is_array( $inv ) ) {
806 $inv = array( $inv );
808 foreach ( $inv as $table ) {
809 $update = new HTMLCacheUpdate( $this->mTitle
, $table );
818 * Update object handling the cleanup of links tables after a page was deleted.
820 class LinksDeletionUpdate
extends SqlDataUpdate
{
822 protected $mPage; //!< WikiPage the wikipage that was deleted
827 * @param $page WikiPage Page we are updating
829 function __construct( WikiPage
$page ) {
830 parent
::__construct( false ); // no implicit transaction
832 $this->mPage
= $page;
834 if ( !$page->exists() ) {
835 throw new MWException( "Page ID not known, perhaps the page doesn't exist?" );
840 * Do some database updates after deletion
842 public function doUpdate() {
843 $title = $this->mPage
->getTitle();
844 $id = $this->mPage
->getId();
846 # Delete restrictions for it
847 $this->mDb
->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__
);
849 # Fix category table counts
851 $res = $this->mDb
->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__
);
853 foreach ( $res as $row ) {
854 $cats [] = $row->cl_to
;
857 $this->mPage
->updateCategoryCounts( array(), $cats );
859 # If using cascading deletes, we can skip some explicit deletes
860 if ( !$this->mDb
->cascadingDeletes() ) {
861 $this->mDb
->delete( 'revision', array( 'rev_page' => $id ), __METHOD__
);
863 # Delete outgoing links
864 $this->mDb
->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__
);
865 $this->mDb
->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__
);
866 $this->mDb
->delete( 'categorylinks', array( 'cl_from' => $id ), __METHOD__
);
867 $this->mDb
->delete( 'templatelinks', array( 'tl_from' => $id ), __METHOD__
);
868 $this->mDb
->delete( 'externallinks', array( 'el_from' => $id ), __METHOD__
);
869 $this->mDb
->delete( 'langlinks', array( 'll_from' => $id ), __METHOD__
);
870 $this->mDb
->delete( 'iwlinks', array( 'iwl_from' => $id ), __METHOD__
);
871 $this->mDb
->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__
);
872 $this->mDb
->delete( 'page_props', array( 'pp_page' => $id ), __METHOD__
);
875 # If using cleanup triggers, we can skip some manual deletes
876 if ( !$this->mDb
->cleanupTriggers() ) {
877 # Clean up recentchanges entries...
878 $this->mDb
->delete( 'recentchanges',
879 array( 'rc_type != ' . RC_LOG
,
880 'rc_namespace' => $title->getNamespace(),
881 'rc_title' => $title->getDBkey() ),
883 $this->mDb
->delete( 'recentchanges',
884 array( 'rc_type != ' . RC_LOG
, 'rc_cur_id' => $id ),
890 * Update all the appropriate counts in the category table.
891 * @param $added array associative array of category name => sort key
892 * @param $deleted array associative array of category name => sort key
894 function updateCategoryCounts( $added, $deleted ) {
895 $a = WikiPage
::factory( $this->mTitle
);
896 $a->updateCategoryCounts(
897 array_keys( $added ), array_keys( $deleted )