X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinksUpdate.php;h=3e8e362c7a818d4df1389839345f2cab55eb04b7;hb=906a1ba51f149d659e270597e4b964cc8c550357;hp=0712ac807bf31fcde527b4eb4affa1afc7d48904;hpb=575019d19c99e12615a4d76c98779799a7137f0c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 0712ac807b..3e8e362c7a 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -39,8 +39,6 @@ class LinksUpdate extends SqlDataUpdate { $mCategories, //!< Map of category names to sort keys $mInterlangs, //!< Map of language codes to titles $mProperties, //!< Map of arbitrary name to value - $mDb, //!< Database connection reference - $mOptions, //!< SELECT options to be used (array) $mRecursive; //!< Whether to queue jobs for recursive updates /** @@ -71,6 +69,7 @@ class LinksUpdate extends SqlDataUpdate { } $this->mParserOutput = $parserOutput; + $this->mLinks = $parserOutput->getLinks(); $this->mImages = $parserOutput->getImages(); $this->mTemplates = $parserOutput->getTemplates(); @@ -817,7 +816,7 @@ class LinksUpdate extends SqlDataUpdate { **/ class LinksDeletionUpdate extends SqlDataUpdate { - protected $mPage; //!< WikiPage the wikipage that was deleted + protected $mTitle; //!< Title the title of page that was deleted /** * Constructor @@ -826,18 +825,22 @@ class LinksDeletionUpdate extends SqlDataUpdate { * @param $parserOutput ParserOutput: output from a full parse of this page * @param $recursive Boolean: queue jobs for recursive updates? */ - function __construct( WikiPage $page ) { + function __construct( Title $title ) { parent::__construct( ); - $this->mPage = $page; + $this->mTitle = $title; + + if ( !$title->getArticleID() ) { + throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" ); + } } /** * Do some database updates after deletion */ public function doUpdate() { - $title = $this->mPage->getTitle(); - $id = $this->mPage->getId(); + $title = $this->mTitle; + $id = $title->getArticleID(); # Delete restrictions for it $this->mDb->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__ ); @@ -850,7 +853,7 @@ class LinksDeletionUpdate extends SqlDataUpdate { $cats [] = $row->cl_to; } - $this->mPage->updateCategoryCounts( array(), $cats ); + $this->updateCategoryCounts( array(), $cats ); # If using cascading deletes, we can skip some explicit deletes if ( !$this->mDb->cascadingDeletes() ) { @@ -881,4 +884,16 @@ class LinksDeletionUpdate extends SqlDataUpdate { __METHOD__ ); } } + + /** + * Update all the appropriate counts in the category table. + * @param $added array associative array of category name => sort key + * @param $deleted array associative array of category name => sort key + */ + function updateCategoryCounts( $added, $deleted ) { + $a = WikiPage::factory( $this->mTitle ); + $a->updateCategoryCounts( + array_keys( $added ), array_keys( $deleted ) + ); + } }