I'm able to reproduce:
I've used following code to mock: test.php
PHP
- <?php
- use iMSCP\Update\UpdateDatabaseAbstract;
- use iMSCP_Registry as Registry;
- define('IMSCP_SETUP', true);
- require_once '/var/www/imscp/gui/library/imscp-lib.php';
- class TestUpdate extends UpdateDatabaseAbstract
- {
- protected $lastUpdate = 272;
- public function __construct()
- {
- parent::__construct();
- // Reset revision to r270 (last from 1.5.x branch)
- $this->dbConfig['DATABASE_REVISION'] = 270;
- }
- // Reset structure back to pre r267 update
- protected function r271() {
- return [
- $this->dropTable('old_php_ini'),
- $this->dropIndexByName('php_ini', 'unique_php_ini'),
- $this->addIndex('php_ini', 'admin_id', 'KEY'),
- $this->addIndex('php_ini', 'domain_id', 'KEY'),
- $this->addIndex('php_ini', 'domain_type', 'KEY')
- ];
- }
- // Update structure as done in update r267
- protected function r272()
- {
- if (($renameQuery = $this->renameTable('php_ini', 'old_php_ini')) !== NULL) {
- execute_query($renameQuery);
- }
- if (!$this->isKnownTable('php_ini')) {
- execute_query('CREATE TABLE php_ini LIKE old_php_ini');
- }
- if (($dropQueries = $this->dropIndexByColumn('php_ini', 'admin_id'))) {
- foreach ($dropQueries as $dropQuery) {
- execute_query($dropQuery);
- }
- }
- if (($dropQueries = $this->dropIndexByColumn('php_ini', 'domain_id'))) {
- foreach ($dropQueries as $dropQuery) {
- execute_query($dropQuery);
- }
- }
- if (($dropQuery = $this->dropIndexByColumn('php_ini', 'domain_type'))) {
- foreach ($dropQueries as $dropQuery) {
- execute_query($dropQuery);
- }
- }
- return [
- $this->addIndex('php_ini', ['admin_id', 'domain_id', 'domain_type'], 'UNIQUE', 'unique_php_ini'),
- 'INSERT IGNORE INTO php_ini SELECT * FROM old_php_ini',
- $this->dropTable('old_php_ini')
- ];
- }
- }
- function upddb_process()
- {
- $dbUpdater = new TestUpdate();
- print "Last applied update: {$dbUpdater->getLastAppliedUpdate()}\n";
- print "Next update: {$dbUpdater->getLastUpdate()}\n";
- if ($dbUpdater->getLastAppliedUpdate() > $dbUpdater->getLastUpdate()) {
- throw new iMSCP_Exception('An i-MSCP downgrade attempt has been detected. Downgrade is not supported.');
- }
- if (!$dbUpdater->applyUpdates()) {
- fwrite(STDERR, sprintf("[ERROR] %s\n", $dbUpdater->getError()));
- exit(1);
- }
- }
- try {
- if (version_compare(PHP_VERSION, '7', '<')) {
- upddb_process();
- } else {
- try {
- upddb_process();
- } catch (Throwable $e) {
- throw new Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
- } catch (Exception $e) {
- $prevException = $e->getPrevious();
- fwrite(STDERR, sprintf("[ERROR] %s \n\nStack trace:\n\n%s\n",$e->getMessage(),($prevException) ? $prevException->getTraceAsString() : $e->getTraceAsString()
- ));
- exit(1);
- }
Now, I'll be able to fix the issue