Merge "New hook for filters on Special:Contributions form"
[lhc/web/wiklou.git] / maintenance / deleteOrphanedRevisions.php
index f0a9692..5f08b5a 100644 (file)
@@ -34,7 +34,8 @@ require_once __DIR__ . '/Maintenance.php';
 class DeleteOrphanedRevisions extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Maintenance script to delete revisions which refer to a nonexisting page";
+               $this->addDescription(
+                       'Maintenance script to delete revisions which refer to a nonexisting page' );
                $this->addOption( 'report', 'Prints out a count of affected revisions but doesn\'t delete them' );
        }
 
@@ -43,13 +44,14 @@ class DeleteOrphanedRevisions extends Maintenance {
 
                $report = $this->hasOption( 'report' );
 
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->begin( __METHOD__ );
+               $dbw = $this->getDB( DB_MASTER );
+               $this->beginTransaction( $dbw, __METHOD__ );
                list( $page, $revision ) = $dbw->tableNamesN( 'page', 'revision' );
 
                # Find all the orphaned revisions
                $this->output( "Checking for orphaned revisions..." );
-               $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id WHERE page_namespace IS NULL";
+               $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id "
+                       . "WHERE page_namespace IS NULL";
                $res = $dbw->query( $sql, 'deleteOrphanedRevisions' );
 
                # Stash 'em all up for deletion (if needed)
@@ -62,7 +64,7 @@ class DeleteOrphanedRevisions extends Maintenance {
 
                # Nothing to do?
                if ( $report || $count == 0 ) {
-                       $dbw->commit( __METHOD__ );
+                       $this->commitTransaction( $dbw, __METHOD__ );
                        exit( 0 );
                }
 
@@ -72,7 +74,7 @@ class DeleteOrphanedRevisions extends Maintenance {
                $this->output( "done.\n" );
 
                # Close the transaction and call the script to purge unused text records
-               $dbw->commit( __METHOD__ );
+               $this->commitTransaction( $dbw, __METHOD__ );
                $this->purgeRedundantText( true );
        }
 
@@ -80,8 +82,8 @@ class DeleteOrphanedRevisions extends Maintenance {
         * Delete one or more revisions from the database
         * Do this inside a transaction
         *
-        * @param $id Array of revision id values
-        * @param $dbw DatabaseBase class (needs to be a master)
+        * @param array $id Array of revision id values
+        * @param DatabaseBase $dbw DatabaseBase class (needs to be a master)
         */
        private function deleteRevs( $id, &$dbw ) {
                if ( !is_array( $id ) ) {