Adds checking of plugin compatibility#12480
Open
JhonathanLepidus wants to merge 5 commits intopkp:mainfrom
Open
Adds checking of plugin compatibility#12480JhonathanLepidus wants to merge 5 commits intopkp:mainfrom
JhonathanLepidus wants to merge 5 commits intopkp:mainfrom
Conversation
Signed-off-by: Jhon <jhon@lepidus.com.br> Signed-off-by: Thiago <thiago@lepidus.com.br>
Signed-off-by: Jhon <jhon@lepidus.com.br> Signed-off-by: Thiago <thiago@lepidus.com.br>
Signed-off-by: Jhon <jhon@lepidus.com.br> Signed-off-by: Thiago <thiago@lepidus.com.br>
Signed-off-by: Jhon <jhon@lepidus.com.br> Signed-off-by: Thiago <thiago@lepidus.com.br>
This was referenced Mar 19, 2026
asmecher
requested changes
Mar 21, 2026
Member
asmecher
left a comment
There was a problem hiding this comment.
Just a few minor comments -- these should be applied to the stable-3_5_0 PR too, please! Feel free to take or leave the stylistic suggestions; they are not important.
classes/site/VersionCheck.php
Outdated
Comment on lines
+162
to
+169
| /** | ||
| * Checks whether the given plugin version is compatible with the current application version. | ||
| * | ||
| * @param array $versionInfo | ||
| * | ||
| * @throws Exception if the plugin version is not compatible | ||
| */ | ||
| public static function checkPluginVersionCompatibility($versionInfo): void |
Member
There was a problem hiding this comment.
This is just stylistic, but unless the self-doc adds something, it's best to just use a typehint.
Suggested change
| /** | |
| * Checks whether the given plugin version is compatible with the current application version. | |
| * | |
| * @param array $versionInfo | |
| * | |
| * @throws Exception if the plugin version is not compatible | |
| */ | |
| public static function checkPluginVersionCompatibility($versionInfo): void | |
| /** | |
| * Checks whether the given plugin version is compatible with the current application version. | |
| * @throws Exception if the plugin version is not compatible | |
| */ | |
| public static function checkPluginVersionCompatibility(array $versionInfo): void |
| throw new Exception(__('manager.plugins.incompatiblePlugin.application')); | ||
| } | ||
|
|
||
| $compatibleVersions = $compatibility[$application->getName()]; |
Member
There was a problem hiding this comment.
I think you'll need to prevent a warning here when there are none for this application:
Suggested change
| $compatibleVersions = $compatibility[$application->getName()]; | |
| $compatibleVersions = $compatibility[$application->getName()] ?? []; |
Member
There was a problem hiding this comment.
(Never mind, I see this is checked above)
classes/site/VersionCheck.php
Outdated
Comment on lines
+184
to
+194
| $hasCompatibleVersion = false; | ||
| foreach ($compatibleVersions as $compatibleVersion) { | ||
| if ($applicationVersion->isCompatible($compatibleVersion)) { | ||
| $hasCompatibleVersion = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!$hasCompatibleVersion) { | ||
| throw new Exception(__('manager.plugins.incompatiblePlugin.version')); | ||
| } |
Member
There was a problem hiding this comment.
Just stylistic, but you can use an early return:
Suggested change
| $hasCompatibleVersion = false; | |
| foreach ($compatibleVersions as $compatibleVersion) { | |
| if ($applicationVersion->isCompatible($compatibleVersion)) { | |
| $hasCompatibleVersion = true; | |
| break; | |
| } | |
| } | |
| if (!$hasCompatibleVersion) { | |
| throw new Exception(__('manager.plugins.incompatiblePlugin.version')); | |
| } | |
| foreach ($compatibleVersions as $compatibleVersion) { | |
| if ($applicationVersion->isCompatible($compatibleVersion)) { | |
| return; // A compatible version was found | |
| } | |
| } | |
| // There was no compatible version found. | |
| throw new Exception(__('manager.plugins.incompatiblePlugin.version')); |
Signed-off-by: Jhon <jhon@lepidus.com.br> Signed-off-by: Thiago <thiago@lepidus.com.br>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request adds a plugin compatibility check before installation or update.
Thus, each plugin must specify in its version.xml file which applications and their respective versions it is compatible with (from 3.6 and beyond).
This is done through a new node called “compatibility.” It works similarly to the method used in the plugin gallery to indicate plugin compatibility.
Example of version.xml of a plugin compatible with OJS and OPS versions 3.6.0-x:
This pull request addresses a feature requirement described in the issue #7531 and was implemented in the context of the 2026's Plugin Sprint :)