* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
+ * @file
+ */
+
+/**
+ * See docs/deferred.txt
+ *
* @todo document (e.g. one-sentence top-level class description).
*/
- class LinksUpdate {
+ 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, //!< Parser output
$mLinks, //!< Map of title strings to IDs for the links in the document
}
}
}
-}
+
+ /**
+ * Update object handling the cleanup of links tables after a page was deleted.
+ **/
+ class LinksDeletionUpdate extends SqlDataUpdate {
+
+ protected $mPage; //!< WikiPage the wikipage that was deleted
+
+ /**
+ * Constructor
+ *
+ * @param $title Title of the page we're updating
+ * @param $parserOutput ParserOutput: output from a full parse of this page
+ * @param $recursive Boolean: queue jobs for recursive updates?
+ */
+ function __construct( WikiPage $page ) {
+ parent::__construct( );
+
+ $this->mPage = $page;
+ }
+
+ /**
+ * Do some database updates after deletion
+ */
+ public function doUpdate() {
+ $title = $this->mPage->getTitle();
+ $id = $this->mPage->getId();
+
+ # Delete restrictions for it
+ $this->mDb->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__ );
+
+ # Fix category table counts
+ $cats = array();
+ $res = $this->mDb->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ );
+
+ foreach ( $res as $row ) {
+ $cats [] = $row->cl_to;
+ }
+
+ $this->mPage->updateCategoryCounts( array(), $cats );
+
+ # If using cascading deletes, we can skip some explicit deletes
+ if ( !$this->mDb->cascadingDeletes() ) {
+ $this->mDb->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
+
+ # Delete outgoing links
+ $this->mDb->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'categorylinks', array( 'cl_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'templatelinks', array( 'tl_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'externallinks', array( 'el_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'langlinks', array( 'll_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'iwlinks', array( 'iwl_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ );
+ $this->mDb->delete( 'page_props', array( 'pp_page' => $id ), __METHOD__ );
+ }
+
+ # If using cleanup triggers, we can skip some manual deletes
+ 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__ );
+ $this->mDb->delete( 'recentchanges',
+ array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ),
+ __METHOD__ );
+ }
+ }
++}