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 $mRecursive; //!< Whether to queue jobs for recursive updates
47 * @param $title Title of the page we're updating
48 * @param $parserOutput ParserOutput: output from a full parse of this page
49 * @param $recursive Boolean: queue jobs for recursive updates?
51 function __construct( $title, $parserOutput, $recursive = true ) {
52 parent
::__construct( );
54 if ( !( $title instanceof Title
) ) {
55 throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
56 "Please see Article::editUpdates() for an invocation example.\n" );
59 if ( !( $parserOutput instanceof ParserOutput
) ) {
60 throw new MWException( "The calling convention to LinksUpdate::__construct() has changed. " .
61 "Please see WikiPage::doEditUpdates() for an invocation example.\n" );
64 $this->mTitle
= $title;
65 $this->mId
= $title->getArticleID();
68 throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" );
71 $this->mParserOutput
= $parserOutput;
73 $this->mLinks
= $parserOutput->getLinks();
74 $this->mImages
= $parserOutput->getImages();
75 $this->mTemplates
= $parserOutput->getTemplates();
76 $this->mExternals
= $parserOutput->getExternalLinks();
77 $this->mCategories
= $parserOutput->getCategories();
78 $this->mProperties
= $parserOutput->getProperties();
79 $this->mInterwikis
= $parserOutput->getInterwikiLinks();
81 # Convert the format of the interlanguage links
82 # I didn't want to change it in the ParserOutput, because that array is passed all
83 # the way back to the skin, so either a skin API break would be required, or an
84 # inefficient back-conversion.
85 $ill = $parserOutput->getLanguageLinks();
86 $this->mInterlangs
= array();
87 foreach ( $ill as $link ) {
88 list( $key, $title ) = explode( ':', $link, 2 );
89 $this->mInterlangs
[$key] = $title;
92 foreach ( $this->mCategories
as &$sortkey ) {
93 # If the sortkey is longer then 255 bytes,
94 # it truncated by DB, and then doesn't get
95 # matched when comparing existing vs current
96 # categories, causing bug 25254.
97 # Also. substr behaves weird when given "".
98 if ( $sortkey !== '' ) {
99 $sortkey = substr( $sortkey, 0, 255 );
103 $this->mRecursive
= $recursive;
105 wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
109 * Update link tables with outgoing links from an updated article
111 public function doUpdate() {
112 global $wgUseDumbLinkUpdate;
114 wfRunHooks( 'LinksUpdate', array( &$this ) );
115 if ( $wgUseDumbLinkUpdate ) {
116 $this->doDumbUpdate();
118 $this->doIncrementalUpdate();
120 wfRunHooks( 'LinksUpdateComplete', array( &$this ) );
123 protected function doIncrementalUpdate() {
124 wfProfileIn( __METHOD__
);
127 $existing = $this->getExistingLinks();
128 $this->incrTableUpdate( 'pagelinks', 'pl', $this->getLinkDeletions( $existing ),
129 $this->getLinkInsertions( $existing ) );
132 $existing = $this->getExistingImages();
134 $imageDeletes = $this->getImageDeletions( $existing );
135 $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes,
136 $this->getImageInsertions( $existing ) );
138 # Invalidate all image description pages which had links added or removed
139 $imageUpdates = $imageDeletes +
array_diff_key( $this->mImages
, $existing );
140 $this->invalidateImageDescriptions( $imageUpdates );
143 $existing = $this->getExistingExternals();
144 $this->incrTableUpdate( 'externallinks', 'el', $this->getExternalDeletions( $existing ),
145 $this->getExternalInsertions( $existing ) );
148 $existing = $this->getExistingInterlangs();
149 $this->incrTableUpdate( 'langlinks', 'll', $this->getInterlangDeletions( $existing ),
150 $this->getInterlangInsertions( $existing ) );
152 # Inline interwiki links
153 $existing = $this->getExistingInterwikis();
154 $this->incrTableUpdate( 'iwlinks', 'iwl', $this->getInterwikiDeletions( $existing ),
155 $this->getInterwikiInsertions( $existing ) );
158 $existing = $this->getExistingTemplates();
159 $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ),
160 $this->getTemplateInsertions( $existing ) );
163 $existing = $this->getExistingCategories();
165 $categoryDeletes = $this->getCategoryDeletions( $existing );
167 $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes,
168 $this->getCategoryInsertions( $existing ) );
170 # Invalidate all categories which were added, deleted or changed (set symmetric difference)
171 $categoryInserts = array_diff_assoc( $this->mCategories
, $existing );
172 $categoryUpdates = $categoryInserts +
$categoryDeletes;
173 $this->invalidateCategories( $categoryUpdates );
174 $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
177 $existing = $this->getExistingProperties();
179 $propertiesDeletes = $this->getPropertyDeletions( $existing );
181 $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes,
182 $this->getPropertyInsertions( $existing ) );
184 # Invalidate the necessary pages
185 $changed = $propertiesDeletes +
array_diff_assoc( $this->mProperties
, $existing );
186 $this->invalidateProperties( $changed );
188 # Refresh links of all pages including this page
189 # This will be in a separate transaction
190 if ( $this->mRecursive
) {
191 $this->queueRecursiveJobs();
194 wfProfileOut( __METHOD__
);
198 * Link update which clears the previous entries and inserts new ones
199 * May be slower or faster depending on level of lock contention and write speed of DB
200 * Also useful where link table corruption needs to be repaired, e.g. in refreshLinks.php
202 protected function doDumbUpdate() {
203 wfProfileIn( __METHOD__
);
205 # Refresh category pages and image description pages
206 $existing = $this->getExistingCategories();
207 $categoryInserts = array_diff_assoc( $this->mCategories
, $existing );
208 $categoryDeletes = array_diff_assoc( $existing, $this->mCategories
);
209 $categoryUpdates = $categoryInserts +
$categoryDeletes;
210 $existing = $this->getExistingImages();
211 $imageUpdates = array_diff_key( $existing, $this->mImages
) +
array_diff_key( $this->mImages
, $existing );
213 $this->dumbTableUpdate( 'pagelinks', $this->getLinkInsertions(), 'pl_from' );
214 $this->dumbTableUpdate( 'imagelinks', $this->getImageInsertions(), 'il_from' );
215 $this->dumbTableUpdate( 'categorylinks', $this->getCategoryInsertions(), 'cl_from' );
216 $this->dumbTableUpdate( 'templatelinks', $this->getTemplateInsertions(), 'tl_from' );
217 $this->dumbTableUpdate( 'externallinks', $this->getExternalInsertions(), 'el_from' );
218 $this->dumbTableUpdate( 'langlinks', $this->getInterlangInsertions(),'ll_from' );
219 $this->dumbTableUpdate( 'iwlinks', $this->getInterwikiInsertions(),'iwl_from' );
220 $this->dumbTableUpdate( 'page_props', $this->getPropertyInsertions(), 'pp_page' );
222 # Update the cache of all the category pages and image description
223 # pages which were changed, and fix the category table count
224 $this->invalidateCategories( $categoryUpdates );
225 $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
226 $this->invalidateImageDescriptions( $imageUpdates );
228 # Refresh links of all pages including this page
229 # This will be in a separate transaction
230 if ( $this->mRecursive
) {
231 $this->queueRecursiveJobs();
234 wfProfileOut( __METHOD__
);
237 function queueRecursiveJobs() {
238 global $wgUpdateRowsPerJob;
239 wfProfileIn( __METHOD__
);
241 $cache = $this->mTitle
->getBacklinkCache();
242 $batches = $cache->partition( 'templatelinks', $wgUpdateRowsPerJob );
244 wfProfileOut( __METHOD__
);
248 foreach ( $batches as $batch ) {
249 list( $start, $end ) = $batch;
251 'table' => 'templatelinks',
255 $jobs[] = new RefreshLinksJob2( $this->mTitle
, $params );
257 Job
::batchInsert( $jobs );
259 wfProfileOut( __METHOD__
);
265 function invalidateCategories( $cats ) {
266 $this->invalidatePages( NS_CATEGORY
, array_keys( $cats ) );
270 * Update all the appropriate counts in the category table.
271 * @param $added array associative array of category name => sort key
272 * @param $deleted array associative array of category name => sort key
274 function updateCategoryCounts( $added, $deleted ) {
275 $a = WikiPage
::factory( $this->mTitle
);
276 $a->updateCategoryCounts(
277 array_keys( $added ), array_keys( $deleted )
284 function invalidateImageDescriptions( $images ) {
285 $this->invalidatePages( NS_FILE
, array_keys( $images ) );
293 private function dumbTableUpdate( $table, $insertions, $fromField ) {
294 $this->mDb
->delete( $table, array( $fromField => $this->mId
), __METHOD__
);
295 if ( count( $insertions ) ) {
296 # The link array was constructed without FOR UPDATE, so there may
297 # be collisions. This may cause minor link table inconsistencies,
298 # which is better than crippling the site with lock contention.
299 $this->mDb
->insert( $table, $insertions, __METHOD__
, array( 'IGNORE' ) );
304 * Update a table by doing a delete query then an insert query
310 function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
311 if ( $table == 'page_props' ) {
312 $fromField = 'pp_page';
314 $fromField = "{$prefix}_from";
316 $where = array( $fromField => $this->mId
);
317 if ( $table == 'pagelinks' ||
$table == 'templatelinks' ||
$table == 'iwlinks' ) {
318 if ( $table == 'iwlinks' ) {
319 $baseKey = 'iwl_prefix';
321 $baseKey = "{$prefix}_namespace";
323 $clause = $this->mDb
->makeWhereFrom2d( $deletions, $baseKey, "{$prefix}_title" );
330 if ( $table == 'langlinks' ) {
331 $toField = 'll_lang';
332 } elseif ( $table == 'page_props' ) {
333 $toField = 'pp_propname';
335 $toField = $prefix . '_to';
337 if ( count( $deletions ) ) {
338 $where[] = "$toField IN (" . $this->mDb
->makeList( array_keys( $deletions ) ) . ')';
344 $this->mDb
->delete( $table, $where, __METHOD__
);
346 if ( count( $insertions ) ) {
347 $this->mDb
->insert( $table, $insertions, __METHOD__
, 'IGNORE' );
352 * Get an array of pagelinks insertions for passing to the DB
353 * Skips the titles specified by the 2-D array $existing
354 * @param $existing array
357 private function getLinkInsertions( $existing = array() ) {
359 foreach( $this->mLinks
as $ns => $dbkeys ) {
360 $diffs = isset( $existing[$ns] )
361 ?
array_diff_key( $dbkeys, $existing[$ns] )
363 foreach ( $diffs as $dbk => $id ) {
365 'pl_from' => $this->mId
,
366 'pl_namespace' => $ns,
375 * Get an array of template insertions. Like getLinkInsertions()
376 * @param $existing array
379 private function getTemplateInsertions( $existing = array() ) {
381 foreach( $this->mTemplates
as $ns => $dbkeys ) {
382 $diffs = isset( $existing[$ns] ) ?
array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
383 foreach ( $diffs as $dbk => $id ) {
385 'tl_from' => $this->mId
,
386 'tl_namespace' => $ns,
395 * Get an array of image insertions
396 * Skips the names specified in $existing
397 * @param $existing array
400 private function getImageInsertions( $existing = array() ) {
402 $diffs = array_diff_key( $this->mImages
, $existing );
403 foreach( $diffs as $iname => $dummy ) {
405 'il_from' => $this->mId
,
413 * Get an array of externallinks insertions. Skips the names specified in $existing
414 * @param $existing array
417 private function getExternalInsertions( $existing = array() ) {
419 $diffs = array_diff_key( $this->mExternals
, $existing );
420 foreach( $diffs as $url => $dummy ) {
421 foreach( wfMakeUrlIndexes( $url ) as $index ) {
423 'el_from' => $this->mId
,
425 'el_index' => $index,
433 * Get an array of category insertions
435 * @param $existing array mapping existing category names to sort keys. If both
436 * match a link in $this, the link will be omitted from the output
440 private function getCategoryInsertions( $existing = array() ) {
441 global $wgContLang, $wgCategoryCollation;
442 $diffs = array_diff_assoc( $this->mCategories
, $existing );
444 foreach ( $diffs as $name => $prefix ) {
445 $nt = Title
::makeTitleSafe( NS_CATEGORY
, $name );
446 $wgContLang->findVariantLink( $name, $nt, true );
448 if ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
450 } elseif ( $this->mTitle
->getNamespace() == NS_FILE
) {
456 # Treat custom sortkeys as a prefix, so that if multiple
457 # things are forced to sort as '*' or something, they'll
458 # sort properly in the category rather than in page_id
460 $sortkey = Collation
::singleton()->getSortKey(
461 $this->mTitle
->getCategorySortkey( $prefix ) );
464 'cl_from' => $this->mId
,
466 'cl_sortkey' => $sortkey,
467 'cl_timestamp' => $this->mDb
->timestamp(),
468 'cl_sortkey_prefix' => $prefix,
469 'cl_collation' => $wgCategoryCollation,
477 * Get an array of interlanguage link insertions
479 * @param $existing Array mapping existing language codes to titles
483 private function getInterlangInsertions( $existing = array() ) {
484 $diffs = array_diff_assoc( $this->mInterlangs
, $existing );
486 foreach( $diffs as $lang => $title ) {
488 'll_from' => $this->mId
,
497 * Get an array of page property insertions
498 * @param $existing array
501 function getPropertyInsertions( $existing = array() ) {
502 $diffs = array_diff_assoc( $this->mProperties
, $existing );
504 foreach ( $diffs as $name => $value ) {
506 'pp_page' => $this->mId
,
507 'pp_propname' => $name,
508 'pp_value' => $value,
515 * Get an array of interwiki insertions for passing to the DB
516 * Skips the titles specified by the 2-D array $existing
517 * @param $existing array
520 private function getInterwikiInsertions( $existing = array() ) {
522 foreach( $this->mInterwikis
as $prefix => $dbkeys ) {
523 $diffs = isset( $existing[$prefix] ) ?
array_diff_key( $dbkeys, $existing[$prefix] ) : $dbkeys;
524 foreach ( $diffs as $dbk => $id ) {
526 'iwl_from' => $this->mId
,
527 'iwl_prefix' => $prefix,
536 * Given an array of existing links, returns those links which are not in $this
537 * and thus should be deleted.
538 * @param $existing array
541 private function getLinkDeletions( $existing ) {
543 foreach ( $existing as $ns => $dbkeys ) {
544 if ( isset( $this->mLinks
[$ns] ) ) {
545 $del[$ns] = array_diff_key( $existing[$ns], $this->mLinks
[$ns] );
547 $del[$ns] = $existing[$ns];
554 * Given an array of existing templates, returns those templates which are not in $this
555 * and thus should be deleted.
556 * @param $existing array
559 private function getTemplateDeletions( $existing ) {
561 foreach ( $existing as $ns => $dbkeys ) {
562 if ( isset( $this->mTemplates
[$ns] ) ) {
563 $del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates
[$ns] );
565 $del[$ns] = $existing[$ns];
572 * Given an array of existing images, returns those images which are not in $this
573 * and thus should be deleted.
574 * @param $existing array
577 private function getImageDeletions( $existing ) {
578 return array_diff_key( $existing, $this->mImages
);
582 * Given an array of existing external links, returns those links which are not
583 * in $this and thus should be deleted.
584 * @param $existing array
587 private function getExternalDeletions( $existing ) {
588 return array_diff_key( $existing, $this->mExternals
);
592 * Given an array of existing categories, returns those categories which are not in $this
593 * and thus should be deleted.
594 * @param $existing array
597 private function getCategoryDeletions( $existing ) {
598 return array_diff_assoc( $existing, $this->mCategories
);
602 * Given an array of existing interlanguage links, returns those links which are not
603 * in $this and thus should be deleted.
604 * @param $existing array
607 private function getInterlangDeletions( $existing ) {
608 return array_diff_assoc( $existing, $this->mInterlangs
);
612 * Get array of properties which should be deleted.
613 * @param $existing array
616 function getPropertyDeletions( $existing ) {
617 return array_diff_assoc( $existing, $this->mProperties
);
621 * Given an array of existing interwiki links, returns those links which are not in $this
622 * and thus should be deleted.
623 * @param $existing array
626 private function getInterwikiDeletions( $existing ) {
628 foreach ( $existing as $prefix => $dbkeys ) {
629 if ( isset( $this->mInterwikis
[$prefix] ) ) {
630 $del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis
[$prefix] );
632 $del[$prefix] = $existing[$prefix];
639 * Get an array of existing links, as a 2-D array
643 private function getExistingLinks() {
644 $res = $this->mDb
->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
645 array( 'pl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
647 foreach ( $res as $row ) {
648 if ( !isset( $arr[$row->pl_namespace
] ) ) {
649 $arr[$row->pl_namespace
] = array();
651 $arr[$row->pl_namespace
][$row->pl_title
] = 1;
657 * Get an array of existing templates, as a 2-D array
661 private function getExistingTemplates() {
662 $res = $this->mDb
->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
663 array( 'tl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
665 foreach ( $res as $row ) {
666 if ( !isset( $arr[$row->tl_namespace
] ) ) {
667 $arr[$row->tl_namespace
] = array();
669 $arr[$row->tl_namespace
][$row->tl_title
] = 1;
675 * Get an array of existing images, image names in the keys
679 private function getExistingImages() {
680 $res = $this->mDb
->select( 'imagelinks', array( 'il_to' ),
681 array( 'il_from' => $this->mId
), __METHOD__
, $this->mOptions
);
683 foreach ( $res as $row ) {
684 $arr[$row->il_to
] = 1;
690 * Get an array of existing external links, URLs in the keys
694 private function getExistingExternals() {
695 $res = $this->mDb
->select( 'externallinks', array( 'el_to' ),
696 array( 'el_from' => $this->mId
), __METHOD__
, $this->mOptions
);
698 foreach ( $res as $row ) {
699 $arr[$row->el_to
] = 1;
705 * Get an array of existing categories, with the name in the key and sort key in the value.
709 private function getExistingCategories() {
710 $res = $this->mDb
->select( 'categorylinks', array( 'cl_to', 'cl_sortkey_prefix' ),
711 array( 'cl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
713 foreach ( $res as $row ) {
714 $arr[$row->cl_to
] = $row->cl_sortkey_prefix
;
720 * Get an array of existing interlanguage links, with the language code in the key and the
721 * title in the value.
725 private function getExistingInterlangs() {
726 $res = $this->mDb
->select( 'langlinks', array( 'll_lang', 'll_title' ),
727 array( 'll_from' => $this->mId
), __METHOD__
, $this->mOptions
);
729 foreach ( $res as $row ) {
730 $arr[$row->ll_lang
] = $row->ll_title
;
736 * Get an array of existing inline interwiki links, as a 2-D array
737 * @return array (prefix => array(dbkey => 1))
739 protected function getExistingInterwikis() {
740 $res = $this->mDb
->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
741 array( 'iwl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
743 foreach ( $res as $row ) {
744 if ( !isset( $arr[$row->iwl_prefix
] ) ) {
745 $arr[$row->iwl_prefix
] = array();
747 $arr[$row->iwl_prefix
][$row->iwl_title
] = 1;
753 * Get an array of existing categories, with the name in the key and sort key in the value.
757 private function getExistingProperties() {
758 $res = $this->mDb
->select( 'page_props', array( 'pp_propname', 'pp_value' ),
759 array( 'pp_page' => $this->mId
), __METHOD__
, $this->mOptions
);
761 foreach ( $res as $row ) {
762 $arr[$row->pp_propname
] = $row->pp_value
;
768 * Return the title object of the page being updated
771 public function getTitle() {
772 return $this->mTitle
;
776 * Returns parser output
778 * @return ParserOutput
780 public function getParserOutput() {
781 return $this->mParserOutput
;
785 * Return the list of images used as generated by the parser
788 public function getImages() {
789 return $this->mImages
;
793 * Invalidate any necessary link lists related to page property changes
796 private function invalidateProperties( $changed ) {
797 global $wgPagePropLinkInvalidations;
799 foreach ( $changed as $name => $value ) {
800 if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
801 $inv = $wgPagePropLinkInvalidations[$name];
802 if ( !is_array( $inv ) ) {
803 $inv = array( $inv );
805 foreach ( $inv as $table ) {
806 $update = new HTMLCacheUpdate( $this->mTitle
, $table );
815 * Update object handling the cleanup of links tables after a page was deleted.
817 class LinksDeletionUpdate
extends SqlDataUpdate
{
819 protected $mTitle; //!< Title the title of page that was deleted
824 * @param $page WikiPage Page we are updating
826 function __construct( Title
$title ) {
827 parent
::__construct( );
829 $this->mTitle
= $title;
831 if ( !$title->getArticleID() ) {
832 throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" );
837 * Do some database updates after deletion
839 public function doUpdate() {
840 $title = $this->mTitle
;
841 $id = $title->getArticleID();
843 # Delete restrictions for it
844 $this->mDb
->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__
);
846 # Fix category table counts
848 $res = $this->mDb
->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__
);
850 foreach ( $res as $row ) {
851 $cats [] = $row->cl_to
;
854 $this->updateCategoryCounts( array(), $cats );
856 # If using cascading deletes, we can skip some explicit deletes
857 if ( !$this->mDb
->cascadingDeletes() ) {
858 $this->mDb
->delete( 'revision', array( 'rev_page' => $id ), __METHOD__
);
860 # Delete outgoing links
861 $this->mDb
->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__
);
862 $this->mDb
->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__
);
863 $this->mDb
->delete( 'categorylinks', array( 'cl_from' => $id ), __METHOD__
);
864 $this->mDb
->delete( 'templatelinks', array( 'tl_from' => $id ), __METHOD__
);
865 $this->mDb
->delete( 'externallinks', array( 'el_from' => $id ), __METHOD__
);
866 $this->mDb
->delete( 'langlinks', array( 'll_from' => $id ), __METHOD__
);
867 $this->mDb
->delete( 'iwlinks', array( 'iwl_from' => $id ), __METHOD__
);
868 $this->mDb
->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__
);
869 $this->mDb
->delete( 'page_props', array( 'pp_page' => $id ), __METHOD__
);
872 # If using cleanup triggers, we can skip some manual deletes
873 if ( !$this->mDb
->cleanupTriggers() ) {
874 # Clean up recentchanges entries...
875 $this->mDb
->delete( 'recentchanges',
876 array( 'rc_type != ' . RC_LOG
,
877 'rc_namespace' => $title->getNamespace(),
878 'rc_title' => $title->getDBkey() ),
880 $this->mDb
->delete( 'recentchanges',
881 array( 'rc_type != ' . RC_LOG
, 'rc_cur_id' => $id ),
887 * Update all the appropriate counts in the category table.
888 * @param $added array associative array of category name => sort key
889 * @param $deleted array associative array of category name => sort key
891 function updateCategoryCounts( $added, $deleted ) {
892 $a = WikiPage
::factory( $this->mTitle
);
893 $a->updateCategoryCounts(
894 array_keys( $added ), array_keys( $deleted )