You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3, because the PR involves multiple files and changes related to event handling in a complex system like Joomla. Understanding the context and ensuring that the new event classes integrate seamlessly with the existing system requires a moderate level of effort.
🧪 Relevant tests
No
⚡ Possible issues
Duplicate Event Dispatch: In UpdateModel.php, the AfterJoomlaUpdateEvent is dispatched twice in close succession within the cleanUp method. This could lead to unintended side effects or duplicate processing. One of these dispatches should likely be removed to prevent potential issues.
Change the parameter type to AfterInstallEvent to match the event being dispatched
The method onExtensionAfterInstall is defined to accept an AbstractExtensionEvent parameter, but it should accept an AfterInstallEvent parameter to match the event being dispatched.
-public function onExtensionAfterInstall(AbstractExtensionEvent $event): void+public function onExtensionAfterInstall(AfterInstallEvent $event): void
Suggestion importance[1-10]: 10
Why: The suggestion correctly identifies a mismatch in the parameter type for the method onExtensionAfterInstall, which should align with the dispatched event type for consistency and correctness.
10
Add a null check for fileCreator before calling its create method
In the onExtensionAfterInstall method, the create method of fileCreator should be called only if the fileCreator is not null to avoid potential null pointer exceptions.
Why: This is a good suggestion to prevent potential null pointer exceptions by ensuring fileCreator is not null before invoking its method, enhancing the robustness of the code.
7
Add a null check for installer before accessing its properties in the onExtensionAfterUninstall method
In the onExtensionAfterUninstall method, add a null check for installer before accessing its properties to prevent potential null pointer exceptions.
Why: Adding a null check for installer is a prudent measure to avoid null pointer exceptions, especially since the method relies on properties of installer. This suggestion improves the safety and reliability of the method.
7
Possible issue
Remove the redundant event dispatch call to avoid triggering the same event twice
The @TODO comment indicates that the event is dispatched twice in the cleanUp method. To avoid redundancy, remove the first dispatch call.
-// @TODO: The event dispatched twice, here and at the end of current method. One of it should be removed.-$app->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate'));+// Trigger event after joomla update.+$app->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate', [+ 'oldVersion' => $oldVersion ?: '',+]));
Suggestion importance[1-10]: 8
Why: The suggestion is valid as it addresses a redundancy issue where an event is dispatched twice in the same method, which could lead to unintended behaviors or performance issues.
8
Maintainability
Use class constants for event names to avoid potential issues with method name changes
To avoid potential issues with method name changes, consider using class constants for the event names in the getSubscribedEvents method.
Why: Using class constants for event names is a good practice for maintainability and avoids hard-coding strings, which can lead to errors if event names change.
7
Enhancement
Add a constructor to the class to initialize properties or perform necessary setup
Add a constructor to the BeforeJoomlaUpdateEvent class to initialize any necessary properties or perform any setup required for the event.
class BeforeJoomlaUpdateEvent extends AbstractJoomlaUpdateEvent
{
+ public function __construct()+ {+ // Initialize properties or perform setup+ parent::__construct();+ }
}
Suggestion importance[1-10]: 5
Why: Adding a constructor might be beneficial for initializing properties or performing setup, but it's not strictly necessary unless there's specific initialization required, which isn't indicated in the PR or the suggestion.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Summary of Changes
Update
extension
andinstaller
plugins to useSubscriberInterface
event classes.Testing Instructions
Test that extension installation works as before.
Joomla update also works as before.
Actual result BEFORE applying this Pull Request
Works
Expected result AFTER applying this Pull Request
Works
Link to documentations
Please select:
PR Type
Enhancement
Description
extension
andinstaller
plugins to useSubscriberInterface
event classes.AbstractJoomlaUpdateEvent
class and its concrete implementationsBeforeJoomlaUpdateEvent
andAfterJoomlaUpdateEvent
.SubscriberInterface
for various extension plugins and updated their methods to use event classes.Changes walkthrough 📝
9 files
UpdateModel.php
Use event classes for Joomla update process
administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
BeforeJoomlaUpdateEvent
andAfterJoomlaUpdateEvent
instead of triggering events directly.CoreEventAware.php
Map Joomla update events to core events
libraries/src/Event/CoreEventAware.php
onJoomlaBeforeUpdate
andonJoomlaAfterUpdate
to the core eventmapping.
AbstractJoomlaUpdateEvent.php
Introduce abstract class for Joomla update events
libraries/src/Event/Extension/AbstractJoomlaUpdateEvent.php
AbstractJoomlaUpdateEvent
for Joomla updateevents.
AfterJoomlaUpdateEvent.php
Add AfterJoomlaUpdateEvent class
libraries/src/Event/Extension/AfterJoomlaUpdateEvent.php
AfterJoomlaUpdateEvent
class extendingAbstractJoomlaUpdateEvent
.BeforeJoomlaUpdateEvent.php
Add BeforeJoomlaUpdateEvent class
libraries/src/Event/Extension/BeforeJoomlaUpdateEvent.php
BeforeJoomlaUpdateEvent
class extendingAbstractJoomlaUpdateEvent
.Finder.php
Implement SubscriberInterface for Finder plugin
plugins/extension/finder/src/Extension/Finder.php
SubscriberInterface
for the Finder extension plugin.Joomla.php
Implement SubscriberInterface for Joomla plugin
plugins/extension/joomla/src/Extension/Joomla.php
SubscriberInterface
for the Joomla extension plugin.NamespaceMap.php
Implement SubscriberInterface for NamespaceMap plugin
plugins/extension/namespacemap/src/Extension/NamespaceMap.php
SubscriberInterface
for the NamespaceMap extension plugin.Override.php
Implement SubscriberInterface for Override plugin
plugins/installer/override/src/Extension/Override.php
SubscriberInterface
for the Override extension plugin.