Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Error handling on extension update #43321

Merged
merged 11 commits into from
Nov 7, 2024
19 changes: 16 additions & 3 deletions administrator/components/com_installer/src/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Joomla\Database\DatabaseQuery;
use Joomla\Database\Exception\ExecutionFailureException;
use Joomla\Database\ParameterType;
use Joomla\Filesystem\Path;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
Expand Down Expand Up @@ -363,10 +364,22 @@ public function update($uids, $minimumStability = Updater::STABILITY_STABLE)
$update->set('extra_query', $updateSiteInstance->extra_query);
}

$this->preparePreUpdate($update, $instance);
try {
$this->preparePreUpdate($update, $instance);

// Install sets state and enqueues messages
$res = $this->install($update);
// Install sets state and enqueues messages
$res = $this->install($update);
}
catch (\Throwable $t)
{
Quy marked this conversation as resolved.
Show resolved Hide resolved
$res = false;

Factory::getApplication()->enqueueMessage(Text::sprintf('COM_INSTALLER_UPDATE_ERROR',
$instance->name,
$t->getMessage(),
(JDEBUG ? str_replace(JPATH_ROOT, 'JROOT', Path::clean($t->getFile())) . ':' . $t->getLine() : '')),
'error');
Quy marked this conversation as resolved.
Show resolved Hide resolved
}
BrainforgeUK marked this conversation as resolved.
Show resolved Hide resolved

if ($res) {
$instance->delete($uid);
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ COM_INSTALLER_UPDATE_FILTER_SEARCH_LABEL="Search Extensions with Updates"
COM_INSTALLER_UPDATE_FORM_EDIT="Edit Update Site"
COM_INSTALLER_UPDATE_MISSING_DOWNLOADKEY_LABEL_N="%d extension updates cannot be installed until you <a href=\"%s\">enter their corresponding Download Keys</a>."
COM_INSTALLER_UPDATE_MISSING_DOWNLOADKEY_LABEL_N_1="One extension update cannot be installed until you <a href=\"%2$s\">enter its Download Key</a>."
COM_INSTALLER_ERROR="Error updating: %1$s<br>%2$s<br>%3$s<br>"
BrainforgeUK marked this conversation as resolved.
Show resolved Hide resolved
COM_INSTALLER_UPDATE_TABLE_CAPTION="Extensions with Updates"
COM_INSTALLER_UPDATESITE_DISABLE="Disable update site"
COM_INSTALLER_UPDATESITE_DISABLED="Disabled update site"
Expand Down