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 #3339

Closed
jgerman-bot opened this issue Nov 8, 2024 · 0 comments · Fixed by #3340
Closed

[5.2] Error handling on extension update #3339

jgerman-bot opened this issue Nov 8, 2024 · 0 comments · Fixed by #3340

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#43321 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_installer/src/Model/UpdateModel.php b/administrator/components/com_installer/src/Model/UpdateModel.php
index 92c472a1e2ac5..2cd000b8ca4a0 100644
--- a/administrator/components/com_installer/src/Model/UpdateModel.php
+++ b/administrator/components/com_installer/src/Model/UpdateModel.php
@@ -24,6 +24,7 @@
 use Joomla\Database\Exception\ExecutionFailureException;
 use Joomla\Database\ParameterType;
 use Joomla\Database\QueryInterface;
+use Joomla\Filesystem\Path;
 use Joomla\Utilities\ArrayHelper;
 
 // phpcs:disable PSR1.Files.SideEffects
@@ -358,10 +359,24 @@ public function update($uids, $minimumStability = Updater::STABILITY_STABLE)
                 $update->set('extra_query', $updateSiteInstance->extra_query);
             }
 
-            $this->preparePreUpdate($update, $instance);
-
-            // Install sets state and enqueues messages
-            $res = $this->install($update);
+            try {
+                $this->preparePreUpdate($update, $instance);
+
+                // Install sets state and enqueues messages
+                $res = $this->install($update);
+            } catch (\Throwable $t) {
+                $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'
+                );
+            }
 
             if ($res) {
                 $instance->delete($uid);
diff --git a/administrator/language/en-GB/com_installer.ini b/administrator/language/en-GB/com_installer.ini
index 48f7bf5477eb2..f93f2d1d4e51f 100644
--- a/administrator/language/en-GB/com_installer.ini
+++ b/administrator/language/en-GB/com_installer.ini
@@ -258,6 +258,7 @@ COM_INSTALLER_UNINSTALL_ERROR="Error uninstalling %s."
 COM_INSTALLER_UNINSTALL_ERROR_LOCKED_EXTENSION="The extension \"%1$s\" (ID %2$s) is locked and cannot be uninstalled."
 COM_INSTALLER_UNINSTALL_SUCCESS="Uninstalling the %s was successful."
 COM_INSTALLER_UNPACK_ERROR="Failed to extract file: %s"
+COM_INSTALLER_UPDATE_ERROR="Error updating: %1$s<br>%2$s<br>%3$s<br>"
 COM_INSTALLER_UPDATE_FILTER_SEARCH_DESC="Search in extension name. Prefix with ID:, UID: or EID: to search for an update ID, update site ID or extension ID."
 COM_INSTALLER_UPDATE_FILTER_SEARCH_LABEL="Search Extensions with Updates"
 COM_INSTALLER_UPDATE_FORM_EDIT="Edit Update Site"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants