Revert "Split FakeMaintenance and LoggedUpdateMaintenance to their own files"
This reverts commit 2cdeb26d0c.
Reason for revert: broke roughly all scripts extending LoggedUpdateMaintenance.
Bug: T246754
Change-Id: Icfe3da924c364b4b4f9286871aeb0aa9f1bbff1a
This commit is contained in:
parent
2cdeb26d0c
commit
7def03fe80
5 changed files with 69 additions and 110 deletions
|
|
@ -195,6 +195,7 @@
|
|||
any new occurrences.
|
||||
-->
|
||||
<exclude-pattern>*/maintenance/dumpIterator\.php</exclude-pattern>
|
||||
<exclude-pattern>*/maintenance/Maintenance\.php</exclude-pattern>
|
||||
<exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
|
||||
<exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
|
||||
<exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ $wgAutoloadLocalClasses = [
|
|||
'FSFileOpHandle' => __DIR__ . '/includes/libs/filebackend/fileophandle/FSFileOpHandle.php',
|
||||
'FSLockManager' => __DIR__ . '/includes/libs/lockmanager/FSLockManager.php',
|
||||
'FakeConverter' => __DIR__ . '/languages/TrivialLanguageConverter.php',
|
||||
'FakeMaintenance' => __DIR__ . '/maintenance/includes/FakeMaintenance.php',
|
||||
'FakeMaintenance' => __DIR__ . '/maintenance/Maintenance.php',
|
||||
'FakeResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php',
|
||||
'FatalError' => __DIR__ . '/includes/exception/FatalError.php',
|
||||
'FauxRequest' => __DIR__ . '/includes/FauxRequest.php',
|
||||
|
|
@ -800,7 +800,7 @@ $wgAutoloadLocalClasses = [
|
|||
'LogPage' => __DIR__ . '/includes/logging/LogPage.php',
|
||||
'LogPager' => __DIR__ . '/includes/logging/LogPager.php',
|
||||
'LoggedOutEditToken' => __DIR__ . '/includes/user/LoggedOutEditToken.php',
|
||||
'LoggedUpdateMaintenance' => __DIR__ . '/maintenance/includes/LoggedUpdateMaintenance.php',
|
||||
'LoggedUpdateMaintenance' => __DIR__ . '/maintenance/Maintenance.php',
|
||||
'LoginHelper' => __DIR__ . '/includes/specials/helpers/LoginHelper.php',
|
||||
'LoginSignupSpecialPage' => __DIR__ . '/includes/specialpage/LoginSignupSpecialPage.php',
|
||||
'MSCompoundFileReader' => __DIR__ . '/includes/libs/mime/MSCompoundFileReader.php',
|
||||
|
|
|
|||
|
|
@ -1722,3 +1722,69 @@ abstract class Maintenance {
|
|||
require_once __DIR__ . '/../tests/common/TestsAutoLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fake maintenance wrapper, mostly used for the web installer/updater
|
||||
*/
|
||||
class FakeMaintenance extends Maintenance {
|
||||
protected $mSelf = "FakeMaintenanceScript";
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for scripts that perform database maintenance and want to log the
|
||||
* update in `updatelog` so we can later skip it
|
||||
*/
|
||||
abstract class LoggedUpdateMaintenance extends Maintenance {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addOption( 'force', 'Run the update even if it was completed already' );
|
||||
$this->setBatchSize( 200 );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$db = $this->getDB( DB_MASTER );
|
||||
$key = $this->getUpdateKey();
|
||||
|
||||
if ( !$this->hasOption( 'force' )
|
||||
&& $db->selectRow( 'updatelog', '1', [ 'ul_key' => $key ], __METHOD__ )
|
||||
) {
|
||||
$this->output( "..." . $this->updateSkippedMessage() . "\n" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !$this->doDBUpdates() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->insert( 'updatelog', [ 'ul_key' => $key ], __METHOD__, [ 'IGNORE' ] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message to show that the update was done already and was just skipped
|
||||
* @return string
|
||||
*/
|
||||
protected function updateSkippedMessage() {
|
||||
$key = $this->getUpdateKey();
|
||||
|
||||
return "Update '{$key}' already logged as completed. Use --force to run it again.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual work. All child classes will need to implement this.
|
||||
* Return true to log the update as done or false (usually on failure).
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function doDBUpdates();
|
||||
|
||||
/**
|
||||
* Get the update key name to go in the update log table
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getUpdateKey();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @ingroup Maintenance
|
||||
* @defgroup Maintenance Maintenance
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fake maintenance wrapper, mostly used for the web installer/updater
|
||||
*/
|
||||
class FakeMaintenance extends Maintenance {
|
||||
protected $mSelf = "FakeMaintenanceScript";
|
||||
|
||||
public function execute() {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @ingroup Maintenance
|
||||
* @defgroup Maintenance Maintenance
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for scripts that perform database maintenance and want to log the
|
||||
* update in `updatelog` so we can later skip it
|
||||
*/
|
||||
abstract class LoggedUpdateMaintenance extends Maintenance {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addOption( 'force', 'Run the update even if it was completed already' );
|
||||
$this->setBatchSize( 200 );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$db = $this->getDB( DB_MASTER );
|
||||
$key = $this->getUpdateKey();
|
||||
|
||||
if ( !$this->hasOption( 'force' )
|
||||
&& $db->selectRow( 'updatelog', '1', [ 'ul_key' => $key ], __METHOD__ )
|
||||
) {
|
||||
$this->output( "..." . $this->updateSkippedMessage() . "\n" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !$this->doDBUpdates() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->insert( 'updatelog', [ 'ul_key' => $key ], __METHOD__, [ 'IGNORE' ] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message to show that the update was done already and was just skipped
|
||||
* @return string
|
||||
*/
|
||||
protected function updateSkippedMessage() {
|
||||
$key = $this->getUpdateKey();
|
||||
|
||||
return "Update '{$key}' already logged as completed. Use --force to run it again.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual work. All child classes will need to implement this.
|
||||
* Return true to log the update as done or false (usually on failure).
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function doDBUpdates();
|
||||
|
||||
/**
|
||||
* Get the update key name to go in the update log table
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getUpdateKey();
|
||||
}
|
||||
Loading…
Reference in a new issue