Skip to content

Commit

Permalink
[4.0] Joomla Update Silent fails
Browse files Browse the repository at this point in the history
I am not 100% certain that this is the best approach to this. @nikosdion @wilsonge please advise

## The Problem
As reported in # if during an update a sql query fails then the updater quits the sql part of the update process and moves on. The joomla_update log gives no indication that there has been a problem etc.

## Proposed Partial Solution
Adds a Start SQL and End SQL to the logs
If there is an error in the sql then that is written to the logs as well AND it now says End SQL incomplete

### Testing
For the testing we will be using the "Update your site by manually uploading the update package." and to make things quick I have prepared an empty update that you should download and use.

### Before Test 1
Update your install and then check the `administrator\logs\joomla_update.php`
It should look like

### Before Test 2
Update your database to change the value in the #__schemas table so that the version_id is 4.0.0-2018-5-15
Update your install and then check the `administrator\logs\joomla_update.php`
It should look like

### Before Test 3
Update your database to change the value in the #__schemas table so that the version_id is 4.0.3
Update your install and then check the `administrator\logs\joomla_update.php`
It should look like

### After - Test 1
Update your database to change the value in the #__schemas table so that the version_id is 4.0.4

Update your install and then check the `administrator\logs\joomla_update.php`
It should look like

### After -  Test 2
Update your database to change the value in the #__schemas table so that the version_id is 4.0.0-2018-5-15
Update your install and then check the `administrator\logs\joomla_update.php`
It should look like

### Before Test 3
Update your database to change the value in the #__schemas table so that the version_id is 4.0.3
Update your install and then check the `administrator\logs\joomla_update.php`
It should look like
  • Loading branch information
brianteeman committed Dec 30, 2021
1 parent 8ecd5f6 commit 05ea212
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions administrator/language/en-GB/lib_joomla.ini
Expand Up @@ -648,6 +648,9 @@ JLIB_INSTALLER_NOT_ERROR="If the error is related to the installation of TinyMCE
JLIB_INSTALLER_NOTICE_LANG_RESET_USERS="Language set to Default for %d users."
JLIB_INSTALLER_NOTICE_LANG_RESET_USERS_1="Language set to Default for the user."
JLIB_INSTALLER_PURGED_UPDATES="Cleared updates."
JLIB_INSTALLER_SQL_BEGIN="Start of SQL updates."
JLIB_INSTALLER_SQL_END="End of SQL updates."
JLIB_INSTALLER_SQL_END_NOT_COMPLETE="End of SQL updates - INCOMPLETE."
JLIB_INSTALLER_UNINSTALL="Uninstall"
JLIB_INSTALLER_UPDATE="Update"
JLIB_INSTALLER_UPDATE_LOG_QUERY="Ran query from file %1$s. Query text: %2$s."
Expand Down
3 changes: 3 additions & 0 deletions language/en-GB/lib_joomla.ini
Expand Up @@ -647,6 +647,9 @@ JLIB_INSTALLER_NOT_ERROR="If the error is related to the installation of TinyMCE
JLIB_INSTALLER_NOTICE_LANG_RESET_USERS="Language set to Default for %d users."
JLIB_INSTALLER_NOTICE_LANG_RESET_USERS_1="Language set to Default for the user."
JLIB_INSTALLER_PURGED_UPDATES="Cleared updates."
JLIB_INSTALLER_SQL_BEGIN="Start of SQL updates."
JLIB_INSTALLER_SQL_END="End of SQL updates."
JLIB_INSTALLER_SQL_END_NOT_COMPLETE="End of SQL updates - INCOMPLETE."
JLIB_INSTALLER_UNINSTALL="Uninstall"
JLIB_INSTALLER_UPDATE="Update"
JLIB_INSTALLER_UPDATE_LOG_QUERY="Ran query from file %1$s. Query text: %2$s."
Expand Down
12 changes: 9 additions & 3 deletions libraries/src/Installer/Installer.php
Expand Up @@ -1173,6 +1173,7 @@ public function parseSchemaUpdates(\SimpleXMLElement $schema, $eid)
{
$version = '0.0.0';
}
Log::add(Text::_('JLIB_INSTALLER_SQL_BEGIN'), Log::INFO, 'Update');

foreach ($files as $file)
{
Expand Down Expand Up @@ -1200,19 +1201,22 @@ public function parseSchemaUpdates(\SimpleXMLElement $schema, $eid)
// Process each query in the $queries array (split out of sql file).
foreach ($queries as $query)
{
$queryString = (string) $query;
$queryString = str_replace(array("\r", "\n"), array('', ' '), substr($queryString, 0, 80));

try
{
$db->setQuery($query)->execute();
}
catch (ExecutionFailureException $e)
{
Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $e->getMessage()), Log::WARNING, 'jerror');
Log::add(Text::sprintf('JLIB_INSTALLER_UPDATE_LOG_QUERY', $file, $queryString), Log::INFO, 'Update');
Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $e->getMessage()), Log::INFO, 'Update');
Log::add(Text::_('JLIB_INSTALLER_SQL_END_NOT_COMPLETE'), Log::INFO, 'Update');

return false;
}

$queryString = (string) $query;
$queryString = str_replace(array("\r", "\n"), array('', ' '), substr($queryString, 0, 80));
Log::add(Text::sprintf('JLIB_INSTALLER_UPDATE_LOG_QUERY', $file, $queryString), Log::INFO, 'Update');

$update_count++;
Expand Down Expand Up @@ -1248,6 +1252,8 @@ public function parseSchemaUpdates(\SimpleXMLElement $schema, $eid)

return false;
}
Log::add(Text::_('JLIB_INSTALLER_SQL_END'), Log::INFO, 'Update');

}
}
}
Expand Down

0 comments on commit 05ea212

Please sign in to comment.