*
* @todo document (e.g. one-sentence top-level class description).
*/
-class LinksUpdate extends SecondaryDBDataUpdate {
+class LinksUpdate extends SqlDataUpdate {
- /**@{{
- * @private
- */
- var $mId, //!< Page ID of the article linked from
+ // @todo: make members protected, but make sure extensions don't break
+
+ public $mId, //!< Page ID of the article linked from
$mTitle, //!< Title object of the article linked from
- $mParserOutput, //!< Whether to queue jobs for recursive update
+ $mParserOutput, //!< Parser output
$mLinks, //!< Map of title strings to IDs for the links in the document
$mImages, //!< DB keys of the images used, in the array key only
$mTemplates, //!< Map of title strings to IDs for the template references, including broken ones
$mInterlangs, //!< Map of language codes to titles
$mProperties, //!< Map of arbitrary name to value
$mRecursive; //!< Whether to queue jobs for recursive updates
- /**@}}*/
/**
* Constructor
function __construct( $title, $parserOutput, $recursive = true ) {
parent::__construct( );
- if ( !is_object( $title ) ) {
+ if ( !( $title instanceof Title ) ) {
throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
"Please see Article::editUpdates() for an invocation example.\n" );
}
- if ( !is_object( $parserOutput ) ) {
+ if ( !( $parserOutput instanceof ParserOutput ) ) {
throw new MWException( "The calling convention to LinksUpdate::__construct() has changed. " .
"Please see WikiPage::doEditUpdates() for an invocation example.\n" );
}
$this->mTitle = $title;
$this->mId = $title->getArticleID();
+ if ( !$this->mId ) {
+ throw new MWException( "The Title object did not provide an article ID. Perhaps the page doesn't exist?" );
+ }
+
$this->mParserOutput = $parserOutput;
$this->mLinks = $parserOutput->getLinks();
/**
* Update object handling the cleanup of links tables after a page was deleted.
**/
-class LinksDeletionUpdate extends SecondaryDBDataUpdate {
+class LinksDeletionUpdate extends SqlDataUpdate {
- /**@{{
- * @private
- */
- var $mWikiPage; //!< WikiPage the wikipage that was deleted
- /**@}}*/
+ protected $mTitle; //!< Title the title of page that was deleted
/**
* Constructor
* @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__ );
$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() ) {
if ( !$this->mDb->cleanupTriggers() ) {
# Clean up recentchanges entries...
$this->mDb->delete( 'recentchanges',
- array( 'rc_type != ' . RC_LOG,
- 'rc_namespace' => $title->getNamespace(),
- 'rc_title' => $title->getDBkey() ),
- __METHOD__ );
+ array( 'rc_type != ' . RC_LOG,
+ 'rc_namespace' => $title->getNamespace(),
+ 'rc_title' => $title->getDBkey() ),
+ __METHOD__ );
$this->mDb->delete( 'recentchanges',
- array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ),
- __METHOD__ );
+ array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ),
+ __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 )
+ );
+ }
}