Skip to content

Commit

Permalink
Handle Upgrade Fixes #77
Browse files Browse the repository at this point in the history
  • Loading branch information
dakanji committed Aug 31, 2018
1 parent 146dc90 commit fffa89d
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 263 deletions.
4 changes: 2 additions & 2 deletions install/steps/AuthenticateStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class AuthenticateStep extends InstallStep {

if (!file_exists($authFile)) {
if (!$this->_firstTime) {
$templateData['errors'][] = sprintf(_('<b>Error:</b> could not locate <b>authFile.txt</b>. ' . 'Please place it in your <tt>%s/</tt> directory.'), basename($authenticationDir));
$templateData['errors'][] = sprintf('<b>Error:</b> could not locate <b>authFile.txt</b>. Please place it in your <tt>%s/</tt> directory.', basename($authenticationDir));
}
} elseif (!is_readable($authFile)) {
$templateData['errors'][] = _('<b>Error:</b> your <b>authFile.txt</b> file is not readable. ' . 'Please give Gallery read permissions on the file.');
$templateData['errors'][] = '<b>Error:</b> your <b>authFile.txt</b> file is not readable. Please give Gallery read permissions on the file.';
} else {
$fileAuthKey = trim(join('', file($authFile)));

Expand Down
27 changes: 18 additions & 9 deletions install/steps/SystemChecksStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ class SystemChecksStep extends InstallStep {
$templateData['check'][] = array(
'title' => $title,
'warning' => true,
'notice' => sprintf('Your webserver does not support localization. To enable support for ' . 'additional languages please instruct your system administrator to reconfigure PHP with the %sgettext%s option enabled.', '<a href="http://php.net/gettext">', '</a>'),
'notice' => sprintf('Your webserver does not support localization. To enable support for additional languages please instruct your system administrator to reconfigure PHP with the %sgettext%s option enabled.', '<a href="http://php.net/gettext">', '</a>'),
);
} elseif (!function_exists('bind_textdomain_codeset')) {
$templateData['check'][] = array(
'title' => $title,
'warning' => true,
'notice' => sprintf('Your PHP is missing the function %sbind_textdomain_codeset%s. This ' . 'means Gallery may display extended characters for some languages incorrectly.', '<a href="http://php.net/bind_textdomain_codeset">', '</a>'),
'notice' => sprintf('Your PHP is missing the function %sbind_textdomain_codeset%s. This means Gallery may display extended characters for some languages incorrectly.', '<a href="http://php.net/bind_textdomain_codeset">', '</a>'),
);
} elseif (!function_exists('dngettext')) {
$templateData['check'][] = array(
'title' => $title,
'warning' => true,
'notice' => sprintf('Your PHP is missing the function %sdngettext%s. This means Gallery ' . 'will be unable to translate plural forms.', '<a href="http://php.net/dngettext">', '</a>'),
'notice' => sprintf('Your PHP is missing the function %sdngettext%s. This means Gallery will be unable to translate plural forms.', '<a href="http://php.net/dngettext">', '</a>'),
);
} else {
$templateData['check'][] = array(
Expand All @@ -346,7 +346,7 @@ class SystemChecksStep extends InstallStep {
$templateData['check'][] = array(
'title' => 'Zend compatibility mode',
'warning' => true,
'notice' => sprintf('Warning: Your PHP is configured with Zend ze1_compatibility_mode ' . 'which can cause PHP to crash. Click %shere%s to test your PHP. ' . 'If you see "SUCCESS" then your PHP is ok. If you get an ' . 'error or no response then you must turn off ze1_compatibility_mode ' . 'before proceeding.', sprintf('<a href="%s">', INDEX_PHP . '?step=' . $this->_stepNumber . '&amp;zendtest=1'), '</a>'),
'notice' => sprintf('Warning: Your PHP is configured with Zend ze1_compatibility_mode which can cause PHP to crash. Click %shere%s to test your PHP. If you see "SUCCESS" then your PHP is ok. If you get an error or no response then you must turn off ze1_compatibility_mode before proceeding.', sprintf('<a href="%s">', INDEX_PHP . '?step=' . $this->_stepNumber . '&amp;zendtest=1'), '</a>'),
);
}
// skip showing 'success' for this one
Expand All @@ -356,7 +356,7 @@ class SystemChecksStep extends InstallStep {
$templateData['check'][] = array(
'title' => 'putenv() allowed',
'warning' => true,
'notice' => 'Warning: The putenv() function is disabled in your PHP by the <b>' . 'disabled_functions</b> parameter in php.ini. Gallery can function with ' . 'this setting, but on some rare systems Gallery will be unable to run in ' . 'other languages than the system language and English.',
'notice' => 'Warning: The putenv() function is disabled in your PHP by the <b>disabled_functions</b> parameter in php.ini. Gallery can function with this setting, but on some rare systems Gallery will be unable to run in other languages than the system language and English.',
);
}
// skip showing 'success' for this one
Expand Down Expand Up @@ -386,7 +386,7 @@ class SystemChecksStep extends InstallStep {
$templateData['check'][] = array(
'title' => 'Output Buffering Disabled',
'warning' => true,
'notice' => sprintf('Warning: Output buffering is enabled in your PHP by the <b>%s</b> ' . 'parameter(s) in php.ini. Gallery can function with this setting - ' . 'downloading files is even faster - but Gallery might be unable to ' . 'serve large files (e.g. large videos) and run into the memory limit.' . ' Also, some features like the progress bars might not work correctly' . ' if output buffering is enabled unless ini_set() is allowed.', implode(', ', $outputBuffers)),
'notice' => sprintf('Warning: Output buffering is enabled in your PHP by the <b>%s</b> parameter(s) in php.ini. Gallery can function with this setting - downloading files is even faster - but Gallery might be unable to serve large files (e.g. large videos) and run into the memory limit. Also, some features like the progress bars might not work correctly if output buffering is enabled unless ini_set() is allowed.', implode(', ', $outputBuffers)),
);
}
// skip showing 'success' for this one
Expand Down Expand Up @@ -425,7 +425,10 @@ class SystemChecksStep extends InstallStep {
'notice' => 'Manifest Missing or Inaccessible.',
);

$galleryStub->setConfig('systemchecks.fileintegrity', 'Manifest missing or inaccessible.');
$galleryStub->setConfig(
'systemchecks.fileintegrity',
'Manifest missing or inaccessible.'
);
} elseif (empty($manifest['missing']) && empty($manifest['modified']) && empty($manifest['shouldRemove'])) {
$templateData['check'][] = array(
'title' => $title,
Expand All @@ -447,9 +450,15 @@ class SystemChecksStep extends InstallStep {
);

if (empty($manifest['missing']) && empty($manifest['modified'])) {
$galleryStub->setConfig('systemchecks.fileintegrity', 'There are some old files');
$galleryStub->setConfig(
'systemchecks.fileintegrity',
'There are some old files'
);
} else {
$galleryStub->setConfig('systemchecks.fileintegrity', 'There are missing/modified files!');
$galleryStub->setConfig(
'systemchecks.fileintegrity',
'There are missing/modified files!'
);
}
}
$galleryStub->setConfig('systemchecks.issvninstall', $isSvnInstall);
Expand Down
6 changes: 3 additions & 3 deletions upgrade/steps/AuthenticateStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class AuthenticateStep extends UpgradeStep {
public function stepName() {
return _('Authenticate');
return 'Authenticate';
}

public function loadTemplateData(&$templateData) {
Expand Down Expand Up @@ -65,9 +65,9 @@ class AuthenticateStep extends UpgradeStep {
} else {
if (isset($_POST['password_sent'])) {
if (empty($_POST['password'])) {
$templateData['error']['password'] = _('<b>Error:</b> missing password.');
$templateData['error']['password'] = '<b>Error:</b> missing password.';
} elseif ($_POST['password'] != $gallery->getConfig('setup.password')) {
$templateData['error']['password'] = _('<b>Error:</b> invalid password.');
$templateData['error']['password'] = '<b>Error:</b> invalid password.';
GallerySetupUtilities::setLoginAttempts(++$attempts);

if ($attempts > G2_SUPPORT_MAX_LOGIN_ATTEMPTS) {
Expand Down
6 changes: 3 additions & 3 deletions upgrade/steps/CleanCacheStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class CleanCacheStep extends UpgradeStep {
public function stepName() {
return _('Empty Cache');
return 'Empty Cache';
}

public function loadTemplateData(&$templateData) {
Expand Down Expand Up @@ -63,15 +63,15 @@ class CleanCacheStep extends UpgradeStep {
$ret = GalleryCoreApi::removeAllMapEntries('GalleryCacheMap', true);

if ($ret) {
$templateData['errors'][] = _('Unable to clear the page cache');
$templateData['errors'][] = 'Unable to clear the page cache';
$templateData['stackTrace'] .= $ret->getAsHtml();
}

$storage =& $gallery->getStorage();
$ret = $storage->checkPoint();

if ($ret) {
$templateData['errors'][] = _('Unable to commit database transaction');
$templateData['errors'][] = 'Unable to commit database transaction';
$templateData['stackTrace'] .= $ret->getAsHtml();
}

Expand Down
25 changes: 14 additions & 11 deletions upgrade/steps/DatabaseBackupStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DatabaseBackupStep extends UpgradeStep {
public $_progressTitle;

public function stepName() {
return _('Database Backup');
return 'Database Backup';
}

public function isOptional() {
Expand Down Expand Up @@ -65,7 +65,7 @@ class DatabaseBackupStep extends UpgradeStep {

if ($ret) {
$templateData['stackTrace'] = $ret->getAsHtml();
$templateData['errors'][] = _('Error attempting to enable maintenance mode.');
$templateData['errors'][] = 'Error attempting to enable maintenance mode.';
$this->_template->renderHeaderBodyAndFooter($templateData);

return false;
Expand All @@ -76,7 +76,7 @@ class DatabaseBackupStep extends UpgradeStep {

// Set up the progress bar.
$this->_template->renderHeader(true);
$this->_progressTitle = _('Backing up the Gallery database');
$this->_progressTitle = 'Backing up the Gallery database';
$this->_template->renderStatusMessage($this->_progressTitle, '', 0);

$exporter = $storage->getDatabaseExporter();
Expand All @@ -90,7 +90,7 @@ class DatabaseBackupStep extends UpgradeStep {
}
} else {
$templateData['stackTrace'] .= $ret->getAsHtml();
$templateData['errors'][] = _('Errors occurred during the database backup');
$templateData['errors'][] = 'Errors occurred during the database backup';
}

$this->_template->renderStatusMessage($this->_progressTitle, '', 1);
Expand All @@ -99,8 +99,7 @@ class DatabaseBackupStep extends UpgradeStep {
$templateData['storeConfig'] = $gallery->getConfig('storage.config');

if ($this->isComplete()) {
$templateData['bodyFile'] = 'DatabaseBackupSuccess.html';

$templateData['bodyFile'] = 'DatabaseBackupSuccess.html';
$templateData['backupFileName'] = $backupFile;
} else {
$templateData['bodyFile'] = 'DatabaseBackupRequest.html';
Expand All @@ -112,7 +111,7 @@ class DatabaseBackupStep extends UpgradeStep {

if ($ret) {
$templateData['stackTrace'] .= $ret->getAsHtml();
$templateData['errors'][] = _('Error attempting to disable maintenance mode.');
$templateData['errors'][] = 'Error attempting to disable maintenance mode.';
}
}

Expand Down Expand Up @@ -140,24 +139,28 @@ class DatabaseBackupStep extends UpgradeStep {
list($ret, $tableVersions) = $storage->getTableVersions();

if ($ret) {
$templateData['warnings'][] = _('Unable to determine if automated backup is available.');
$templateData['warnings'][] = 'Unable to determine if automated backup is available.';
$templateData['canDoBackup'] = false;
} else {
list($major, $minor) = $tableVersions['Schema'];
$canDoBackup = version_compare("$major.$minor", '1.2', '>=');

if ($canDoBackup) {
// Verify that the type / info fields are populated
$query = 'SELECT [::name] FROM [GallerySchema]
WHERE [::type] in (\'map\', \'entity\')';
$query = '
SELECT
[::name] FROM [GallerySchema]
WHERE
[::type] in (\'map\', \'entity\')';

list($ret, $results) = $storage->search($query, array(), array(
'limit' => array(
'count' => 1,
),
));

if ($ret) {
$templateData['warnings'][] = _('Unable to determine if automated backup is available.');
$templateData['warnings'][] = 'Unable to determine if automated backup is available.';
$canDoBackup = false;
} else {
$canDoBackup = $results->resultCount() > 0;
Expand Down
2 changes: 1 addition & 1 deletion upgrade/steps/FinishedStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class FinishedStep extends UpgradeStep {
public function stepName() {
return _('Finish Upgrade');
return 'Finish Upgrade';
}

public function loadTemplateData(&$templateData) {
Expand Down
Loading

0 comments on commit fffa89d

Please sign in to comment.