Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Upgrader
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 21 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @todo MAKE DATABASE CHECK RUN BEFORE EVERYTHING ELSE
|
||||
@@ -32,29 +32,10 @@ class _Upgrade
|
||||
public static function systemRequirements()
|
||||
{
|
||||
$return = Install::systemRequirements();
|
||||
|
||||
/* MySQL Version */
|
||||
$mysqlVersion = \IPS\Db::i()->server_info;
|
||||
if ( version_compare( $mysqlVersion, '5.1.3' ) >= 0 )
|
||||
{
|
||||
$return['requirements']['MySQL'][] = array(
|
||||
'success' => TRUE,
|
||||
'message' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_success', FALSE, array( 'sprintf' => array( $mysqlVersion ) ) )
|
||||
);
|
||||
|
||||
if ( version_compare( $mysqlVersion, '5.6.2' ) == -1 AND !mb_strpos( $mysqlVersion, "MariaDB" ) )
|
||||
{
|
||||
$return['advice'][] = \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_advice', FALSE, array( 'sprintf' => array( $mysqlVersion ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['requirements']['MySQL'][] = array(
|
||||
'success' => FALSE,
|
||||
'message' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_fail', FALSE, array( 'sprintf' => array( $mysqlVersion ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* MySQL Requirements */
|
||||
$return = array_merge_recursive( $return, static::mysqlRequirements( ) );
|
||||
|
||||
/* Writeables */
|
||||
if( \IPS\Db::i()->checkForTable('core_file_storage') )
|
||||
{
|
||||
@@ -65,7 +46,15 @@ class _Upgrade
|
||||
{
|
||||
try
|
||||
{
|
||||
$class = \IPS\File::getClass( $k );
|
||||
try
|
||||
{
|
||||
$class = \IPS\File::getClass( $k );
|
||||
}
|
||||
catch( \RuntimeException $e )
|
||||
{
|
||||
throw new \RuntimeException( 'no_filestorage_class', 115115 );
|
||||
}
|
||||
|
||||
if ( !isset( $fileSystemItems[ $class->configurationId ] ) )
|
||||
{
|
||||
if ( method_exists( $class, 'testSettings' ) )
|
||||
@@ -81,10 +70,13 @@ class _Upgrade
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$fileSystemItems[ $class->configurationId ] = array(
|
||||
'success' => FALSE,
|
||||
'message' => $e->getMessage()
|
||||
);
|
||||
if( $e->getCode() !== 115115 )
|
||||
{
|
||||
$fileSystemItems[ $class->configurationId ] = array(
|
||||
'success' => FALSE,
|
||||
'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +99,41 @@ class _Upgrade
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check MySQL Requirements
|
||||
*
|
||||
* @param \IPS\Db|NULL $db DB Object to use for version check
|
||||
* @return array
|
||||
*/
|
||||
public static function mysqlRequirements( $db=NULL )
|
||||
{
|
||||
/* MySQL Version */
|
||||
$return = array();
|
||||
$mysqlVersion = $db ? $db->server_info : \IPS\Db::i()->server_info;
|
||||
$requirements = json_decode( file_get_contents( \IPS\ROOT_PATH . '/applications/core/data/requirements.json' ), TRUE );
|
||||
if ( version_compare( $mysqlVersion, $requirements['mysql']['required'] ) >= 0 )
|
||||
{
|
||||
$return['requirements']['MySQL']['version'] = array(
|
||||
'success' => TRUE,
|
||||
'message' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_success', FALSE, array( 'sprintf' => array( $mysqlVersion ) ) )
|
||||
);
|
||||
|
||||
if ( version_compare( $mysqlVersion, $requirements['mysql']['recommended'] ) == -1 AND !mb_strpos( $mysqlVersion, "MariaDB" ) )
|
||||
{
|
||||
$return['advice'][] = \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_advice', FALSE, array( 'sprintf' => array( $mysqlVersion, $requirements['mysql']['recommended'] ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['requirements']['MySQL']['version'] = array(
|
||||
'success' => FALSE,
|
||||
'message' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_fail', FALSE, array( 'sprintf' => array( $mysqlVersion, $requirements['mysql']['required'], $requirements['mysql']['recommended'] ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Percentage of *this step* completed (used for the progress bar)
|
||||
@@ -140,7 +167,7 @@ class _Upgrade
|
||||
public function process( $data )
|
||||
{
|
||||
/* Start */
|
||||
if ( $data === 0 )
|
||||
if ( ! $data )
|
||||
{
|
||||
$data = array( 0 => 1 );
|
||||
}
|
||||
@@ -158,6 +185,11 @@ class _Upgrade
|
||||
{
|
||||
/* Set the we're setting up flag */
|
||||
static::setUpgradingFlag( TRUE );
|
||||
|
||||
if ( function_exists('opcache_reset') )
|
||||
{
|
||||
@opcache_reset();
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the log */
|
||||
@@ -180,26 +212,23 @@ class _Upgrade
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
\IPS\Data\Store::i()->clearAll();
|
||||
|
||||
/* Clear theme caches */
|
||||
/* Clear theme cache for default theme */
|
||||
try
|
||||
{
|
||||
foreach( \IPS\Theme::themes() as $id => $theme )
|
||||
{
|
||||
$theme->buildResourceMap();
|
||||
$theme->saveSet();
|
||||
}
|
||||
$theme = \IPS\Theme::load( \IPS\Theme::defaultTheme() );
|
||||
$theme->buildResourceMap();
|
||||
$theme->saveSet();
|
||||
|
||||
\IPS\Theme::deleteCompiledCss();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error : " . $e->getMessage() . "\n" . $e->getTraceAsString(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( $e, 'upgrade_error' );
|
||||
}
|
||||
|
||||
|
||||
/* Make all disk template caches stale */
|
||||
\IPS\Theme::resetAllCacheKeys();
|
||||
|
||||
/* Remove the flag */
|
||||
static::setUpgradingFlag( FALSE );
|
||||
|
||||
@@ -338,11 +367,7 @@ class _Upgrade
|
||||
$_SESSION['lastJsonIndex'] = 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Step1 Loop: " . json_encode( $data ), 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Step1 Loop: " . json_encode( $data ), 'upgrade' );
|
||||
|
||||
/* Re-initialize $extra variable */
|
||||
$extra = array();
|
||||
@@ -379,25 +404,27 @@ class _Upgrade
|
||||
|
||||
$this->customTitle = "Upgrading database (" . ucfirst( $app ) . ': Upgrade ID ' . $extra['_current'] . '-' . $lastSqlId . ')';
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Upgrading database for app: " . $app, 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Upgrading database for app: " . $app, 'upgrade' );
|
||||
|
||||
$_SESSION['lastSqlError'] = null;
|
||||
|
||||
try
|
||||
{
|
||||
$fetched = \IPS\Application::load( $app )->installDatabaseUpdates( $extra['_current'], $lastSqlId, 10, !\IPS\Request::i()->run_anyway );
|
||||
$fetched = \IPS\Application::load( $app )->installDatabaseUpdates( $extra['_current'], ( \IPS\Request::i()->run_anyway ) ? $lastSqlId - 0.1 : $lastSqlId, 10, !\IPS\Request::i()->run_anyway );
|
||||
|
||||
if( isset( \IPS\Request::i()->mr_continue ) AND \IPS\Request::i()->mr_continue )
|
||||
{
|
||||
$fetched = array( 'count' => $fetched['count'] );
|
||||
}
|
||||
|
||||
if( isset( \IPS\Request::i()->mr_continue ) AND \IPS\Request::i()->mr_continue )
|
||||
{
|
||||
$fetched = array( 'count' => $fetched['count'] );
|
||||
}
|
||||
|
||||
$extra['lastSqlId'] = $_SESSION['lastJsonIndex'];
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( (int) $fetched['count'] . ' queries run, last ID ' . $_SESSION['lastJsonIndex'], 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( (int) $fetched['count'] . ' queries run, last ID ' . $_SESSION['lastJsonIndex'], 'upgrade' );
|
||||
}
|
||||
catch( \IPS\Db\Exception $ex )
|
||||
{
|
||||
@@ -412,11 +439,7 @@ class _Upgrade
|
||||
|
||||
$_SESSION['lastSqlError'] = $message . ' ' . $queryRun;
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error: " . $message . ' ' . $queryRun . "\n" . $ex->getTraceAsString(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( "Error: " . $message . ' ' . $queryRun . "\n" . $ex->getTraceAsString(), 'upgrade_error' );
|
||||
|
||||
/* Throw so ajax returns 500 and stops upgrader */
|
||||
throw $ex;
|
||||
@@ -425,9 +448,9 @@ class _Upgrade
|
||||
/* Queries to run manually */
|
||||
if( is_array( $fetched['queriesToRun'] ) and count( $fetched['queriesToRun'] ) )
|
||||
{
|
||||
$mr = \IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => $app, 'extra' => array( 'lastSqlId' => $_SESSION['lastJsonIndex'], '_current' => $extra['_current'] ) ) );
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => $app, 'extra' => array( 'lastSqlId' => $_SESSION['lastJsonIndex'], '_current' => $extra['_current'] ) ) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms' )->queries( $fetched['queriesToRun'], \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => $mr ) ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms' )->queries( $fetched['queriesToRun'], \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -445,7 +468,13 @@ class _Upgrade
|
||||
/* All done, allow code to finish this foreach and process below */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* The "run anyway" button uses the same URL as the "I have run, continue" button which increments the upgrade step count, but this means that the run anyway step never actually runs */
|
||||
if ( isset( \IPS\Request::i()->run_anyway ) and $upgradeStep > 1 )
|
||||
{
|
||||
$upgradeStep--;
|
||||
}
|
||||
|
||||
/* Get the object */
|
||||
$_className = "\\IPS\\{$app}\\setup\\upg_{$extra['_current']}\\Upgrade";
|
||||
$_methodName = "step{$upgradeStep}";
|
||||
@@ -453,7 +482,7 @@ class _Upgrade
|
||||
if( class_exists( $_className ) )
|
||||
{
|
||||
$upgrader = new $_className;
|
||||
|
||||
|
||||
/* If the next step exists, run it */
|
||||
if( method_exists( $upgrader, $_methodName ) )
|
||||
{
|
||||
@@ -485,11 +514,7 @@ class _Upgrade
|
||||
$_SESSION['lastSqlError'] = $message . ' ' . $queryRun;
|
||||
$_SESSION['updatedData'] = array_merge( $data, array( 'extra' => $extra ), array( 'extra' => array( '_current' => $extra['_current'], '_upgradeStep' => $upgradeStep ) ) );
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "(Upgrader " . $_methodName . ") " . $message . ' ' . $queryRun . $ex->getTraceAsString(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( "(Upgrader " . $_methodName . ") " . $message . ' ' . $queryRun . $ex->getTraceAsString(), 'upgrade_error' );
|
||||
|
||||
/* Throw so ajax returns 500 and stops upgrader */
|
||||
throw $ex;
|
||||
@@ -502,11 +527,7 @@ class _Upgrade
|
||||
$_SESSION['lastSqlError'] = $message;
|
||||
$_SESSION['updatedData'] = array_merge( $data, array( 'extra' => $extra ), array( 'extra' => array( '_current' => $extra['_current'], '_upgradeStep' => $upgradeStep ) ) );
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "(Upgrader " . $_methodName . ") " . $message, 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( "(Upgrader " . $_methodName . ") " . $message, 'upgrade_error' );
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
@@ -604,11 +625,7 @@ class _Upgrade
|
||||
{
|
||||
foreach( $_versionApps as $_versionApp )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Running finish step for: {$_versionApp} version {$_versionId}", 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Running finish step for: {$_versionApp} version {$_versionId}", 'upgrade' );
|
||||
|
||||
/* Get the object */
|
||||
$_className = "\\IPS\\{$_versionApp}\\setup\\upg_{$_versionId}\\Upgrade";
|
||||
@@ -655,8 +672,8 @@ class _Upgrade
|
||||
$toRun = \IPS\core\Setup\Upgrade::runManualQueries( $changesToMake );
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
$mr = \IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => $app, 'extra' => array( '_upgradeStep' => 2 ) ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => $mr ) ) );
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => $app, 'extra' => array( '_upgradeStep' => 2 ) ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr ) ) );
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -704,11 +721,7 @@ class _Upgrade
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( $e, 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $ex ){}
|
||||
\IPS\Log::log( $e, 'upgrade_error' );
|
||||
|
||||
throw $e;
|
||||
}
|
||||
@@ -716,11 +729,7 @@ class _Upgrade
|
||||
/* Update application data */
|
||||
if( file_exists( \IPS\ROOT_PATH . '/applications/' . $app . '/data/application.json' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Installing application data for " . $app, 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Installing application data for " . $app, 'upgrade' );
|
||||
|
||||
$application = json_decode( file_get_contents( \IPS\ROOT_PATH . '/applications/' . $app . '/data/application.json' ), TRUE );
|
||||
|
||||
@@ -740,11 +749,7 @@ class _Upgrade
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error: Missing app data", 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( "Error: Missing app data", 'upgrade_error' );
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack( 'err_missing_app_data', FALSE, array( 'sprintf' => array( $app ) ) ) );
|
||||
}
|
||||
} );
|
||||
@@ -760,11 +765,7 @@ class _Upgrade
|
||||
{
|
||||
return $this->appLoop( $data, function( $app )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Installing settings, tasks and keywords for " . $app, 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Installing settings, tasks and keywords for " . $app, 'upgrade' );
|
||||
|
||||
\IPS\Application::load( $app )->installSettings();
|
||||
\IPS\Application::load( $app )->installTasks();
|
||||
@@ -780,6 +781,32 @@ class _Upgrade
|
||||
*/
|
||||
protected function step5( $data )
|
||||
{
|
||||
if(!\IPS\Db::i()->select( 'lang_id', 'core_sys_lang', 'lang_short LIKE "ru_RU%"')->count()) {
|
||||
|
||||
$max = \IPS\Db::i()->select( 'MAX(lang_order)', 'core_sys_lang' )->first();
|
||||
/* Insert the actual language */
|
||||
|
||||
$insertId = \IPS\Db::i()->insert( 'core_sys_lang', array(
|
||||
'lang_short' => 'ru_RU',
|
||||
'lang_title' => "Русский (RU)",
|
||||
'lang_isrtl' => 0,
|
||||
'lang_order' => ++$max
|
||||
)
|
||||
);
|
||||
|
||||
/* Copy over language strings */
|
||||
$default = \IPS\Lang::defaultLanguage();
|
||||
$prefix = \IPS\Db::i()->prefix;
|
||||
$defaultStmt = \IPS\Db::i()->prepare( "INSERT INTO `{$prefix}core_sys_lang_words` ( `lang_id`, `word_app`, `word_key`, `word_default`, `word_custom`, `word_default_version`, `word_custom_version`, `word_js`, `word_export` ) SELECT {$insertId} AS `lang_id`, `word_app`, `word_key`, `word_default`, NULL AS `word_custom`, `word_default_version`, NULL AS `word_custom_version`, `word_js`, `word_export` FROM `{$prefix}core_sys_lang_words` WHERE `lang_id`={$default} AND `word_export`=1" );
|
||||
$defaultStmt->execute();
|
||||
$customStmt = \IPS\Db::i()->prepare( "INSERT INTO `{$prefix}core_sys_lang_words` ( `lang_id`, `word_app`, `word_key`, `word_default`, `word_custom`, `word_default_version`, `word_custom_version`, `word_js`, `word_export` ) SELECT {$insertId} AS `lang_id`, `word_app`, `word_key`, `word_default`, `word_custom`, `word_default_version`, `word_custom_version`, `word_js`, `word_export` FROM `{$prefix}core_sys_lang_words` WHERE `lang_id`={$default} AND `word_export`=0" );
|
||||
$customStmt->execute();
|
||||
|
||||
unset( \IPS\Data\Store::i()->languages );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
}
|
||||
return $this->appLoop( $data, function( $app ) use ($data)
|
||||
{
|
||||
if ( !isset( $data[2] ) )
|
||||
@@ -791,19 +818,11 @@ class _Upgrade
|
||||
{
|
||||
$inserted = \IPS\Application::load( $app )->installLanguages( $data[2], 250 );
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Inserted language keys for " . $app . ", offset of " . $data[2], 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Inserted language keys for " . $app . ", offset of " . $data[2], 'upgrade' );
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Step 5, " . $app . ' ' . $ex->getMessage(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( "Step 5, " . $app . ' ' . $ex->getMessage(), 'upgrade_error' );
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
@@ -850,20 +869,12 @@ class _Upgrade
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error : " . $e->getMessage() . "\n" . $e->getTraceAsString(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( $e, 'upgrade_error' );
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Installed theme settings for " . $app, 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Installed theme settings for " . $app, 'upgrade' );
|
||||
|
||||
return null;
|
||||
} );
|
||||
@@ -892,11 +903,7 @@ class _Upgrade
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error : " . $e->getMessage() . "\n" . $e->getTraceAsString(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( $e, 'upgrade_error' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
@@ -932,20 +939,12 @@ class _Upgrade
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error : " . $e->getMessage() . "\n" . $e->getTraceAsString(), 'upgrade_error' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::log( $e, 'upgrade_error' );
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Installed templates for " . $app . ", offset of " . $data[2], 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Installed templates for " . $app . ", offset of " . $data[2], 'upgrade' );
|
||||
|
||||
if ( $inserted )
|
||||
{
|
||||
@@ -976,11 +975,7 @@ class _Upgrade
|
||||
|
||||
$inserted = \IPS\Application::load( $app )->installJavascript( $data[2], 150 );
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Installed javascript for " . $app, 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Installed javascript for " . $app, 'upgrade' );
|
||||
|
||||
if ( $inserted )
|
||||
{
|
||||
@@ -1051,6 +1046,7 @@ class _Upgrade
|
||||
* @return TRUE|\IPS\Db\Exception
|
||||
* @note We ignore some database errors that shouldn't prevent us from continuing.
|
||||
* @li 1050: Can't rename a table as it already exists
|
||||
* @li 1051: Can't drop a table because it doesn't exist
|
||||
* @li 1060: Can't add a column as it already exists
|
||||
* @li 1062: Can't add an index as index already exists
|
||||
* @li 1062: Can't add a row as PKEY already exists
|
||||
@@ -1082,7 +1078,7 @@ class _Upgrade
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
{
|
||||
if ( ! in_array( $e->getCode(), array( 1050, 1060, 1061, 1062, 1091 ) ) )
|
||||
if ( ! in_array( $e->getCode(), array( 1007, 1008, 1050, 1060, 1061, 1062, 1091, 1051 ) ) )
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
@@ -1124,31 +1120,45 @@ class _Upgrade
|
||||
/**
|
||||
* Run manual queries, that may be rather large
|
||||
*
|
||||
* @param array $queries Array of queries in the following format ( table => x, query = x );
|
||||
* @note We ignore some database errors that shouldn't prevent us from continuing.
|
||||
* @li 1007: Can't create database because it already exists
|
||||
* @li 1008: Can't drop database because it does not exist
|
||||
* @li 1050: Can't rename a table as it already exists
|
||||
* @li 1060: Can't add a column as it already exists
|
||||
* @li 1062: Can't add an index as index already exists
|
||||
* @li 1062: Can't add a row as PKEY already exists
|
||||
* @li 1069: MyISAM has maxed out number of allowed indexes per table
|
||||
* @li 1091: Can't drop key or column because it does not exist
|
||||
* @param array $queries Array of queries in the following format ( table => x, query = x, db => null ); Supply an \IPS\Db object as db if necessary (i.e. remote archiving)
|
||||
* @return array
|
||||
*/
|
||||
public static function runManualQueries( $queries )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->mr_continue ) AND \IPS\Request::i()->mr_continue )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$toReturn = array();
|
||||
$tableCounts = array();
|
||||
|
||||
foreach( $queries as $id => $data )
|
||||
{
|
||||
if ( ! isset( $tableCounts[ $data['table'] ] ) and \IPS\Db::i()->checkForTable( $data['table'] ) )
|
||||
$database = ( isset( $data['db'] ) ) ? $data['db'] : \IPS\Db::i();
|
||||
|
||||
if ( ! isset( $tableCounts[ $data['table'] ] ) and $database->checkForTable( $data['table'] ) )
|
||||
{
|
||||
$tableCounts[ $data['table'] ] = \IPS\Db::i()->select( 'count(*)', $data['table'] )->first();
|
||||
$tableCounts[ $data['table'] ] = $database->select( 'count(*)', $data['table'] )->first();
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $queries as $id => $data )
|
||||
{
|
||||
$database = ( isset( $data['db'] ) ) ? $data['db'] : \IPS\Db::i();
|
||||
|
||||
if( !\IPS\Request::i()->run_anyway and isset( $tableCounts[ $data['table'] ] ) AND $tableCounts[ $data['table'] ] > \IPS\UPGRADE_MANUAL_THRESHOLD )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_INFO )->write( "Big table " . $data['table'] . ", storing query to run manually", 'upgrade' );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
\IPS\Log::debug( "Big table " . $data['table'] . ", storing query to run manually", 'upgrade' );
|
||||
|
||||
$toReturn[] = $data['query'];
|
||||
|
||||
@@ -1156,7 +1166,19 @@ class _Upgrade
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->query( $data['query'] );
|
||||
try
|
||||
{
|
||||
$database->query( $data['query'] );
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
{
|
||||
/* If the error isn't important we should ignore it and is consistent with \Application::installDatabaseUpdates() */
|
||||
if( !in_array( $e->getCode(), array( 1007, 1008, 1050, 1060, 1061, 1062, 1069, 1091 ) ) )
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1172,7 +1194,7 @@ class _Upgrade
|
||||
{
|
||||
$cutOff = 30;
|
||||
|
||||
if( $maxExecution = @ini_get( 'max_execution_time' ) AND $maxExecution < $cutOff )
|
||||
if( $maxExecution = @ini_get( 'max_execution_time' ) AND $maxExecution > 0 AND $maxExecution < $cutOff )
|
||||
{
|
||||
$cutOff = $maxExecution;
|
||||
}
|
||||
@@ -1216,7 +1238,9 @@ class _Upgrade
|
||||
*/
|
||||
public static function adjustMultipleRedirect( $changes )
|
||||
{
|
||||
$mr = json_decode( urldecode( base64_decode( \IPS\Request::i()->mr ) ), TRUE );
|
||||
$key = 'mr-' . md5( (string) \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
$mr = isset( $_SESSION[ $key ] ) ? $_SESSION[ $key ] : NULL;
|
||||
$mr = $mr ? json_decode( $mr, TRUE ) : NULL;
|
||||
|
||||
foreach( $changes as $k => $v )
|
||||
{
|
||||
@@ -1233,8 +1257,8 @@ class _Upgrade
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Request::i()->mr = base64_encode( urlencode( json_encode( $mr ) ) );
|
||||
$_SESSION[ $key ] = json_encode( $mr );
|
||||
|
||||
return \IPS\Request::i()->mr;
|
||||
return $_SESSION[ $key ];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user