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
If you run php craft plugin/install --all as part of your project setup script, it will abort the installation of any plugin that throws an exception during the install process:
While this might seem reasonable, there are soft errors (such as being unable to register a Twig extension) that can happen as part of the install process.
For example, when SEOmatic is installed, it ends up rendering Twig as part of the install process, as discussed here:
Normally this is fine, because either Twig is already initialized, or it's part of a single CLI install of SEOmatic, so harm if Twig then gets initialized.
However as part of a bulk install via php craft plugin/install --all there are other plugins that get installed after it, and thus fail to install via the CLI.
What I propose is that instead of just considering all exceptions to mean that the plugin couldn't be installed, make an exception for the \LogicException exception that is thrown by Twig:
publicfunctionaddExtension(ExtensionInterface$extension): void
{
$class = \get_class($extension);
if ($this->initialized) {
thrownew \LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $class));
}
if (isset($this->extensions[$class])) {
thrownew \LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $class));
}
$this->extensions[$class] = $extension;
}
...and treat that as a "soft" exception that is safe to complete the installation of the plugin.
Whilst I realize this seems like asking you to work around a quirk of SEOmatic, I've gone through many iterations of how I could potentially fix or special-case this, and none are particularly satisfying.
It's also in some ways a state introduced by the php craft plugin/install --all command that did not exist prior, in that plugins are installed one after the other in the same request, something that never happened prior.
I'm open to ideas on other ways to affect a fix as well.
Steps to reproduce
Have SEOmatic and another plugin that installs after SEOmatic (alphabetically) that installs a Twig extension in your composer.json
Do php craft plugin/install --all
Expected behavior
Plugins would all install
Actual behavior
Plugins that register a Twig extension after SEOmatic fail to install.
Craft CMS version
4.4.x
PHP version
8.1
Operating system and version
n/a
Database type and version
n/a
Image driver and version
n/a
Installed plugins and versions
SEOmatic 4.0.24
The text was updated successfully, but these errors were encountered:
What happened?
Description
If you run
php craft plugin/install --all
as part of your project setup script, it will abort the installation of any plugin that throws an exception during the install process:https://github.com/craftcms/cms/blob/develop/src/console/controllers/PluginController.php#L280
While this might seem reasonable, there are soft errors (such as being unable to register a Twig extension) that can happen as part of the install process.
For example, when SEOmatic is installed, it ends up rendering Twig as part of the install process, as discussed here:
nystudio107/craft-seomatic#1312
Normally this is fine, because either Twig is already initialized, or it's part of a single CLI install of SEOmatic, so harm if Twig then gets initialized.
However as part of a bulk install via
php craft plugin/install --all
there are other plugins that get installed after it, and thus fail to install via the CLI.What I propose is that instead of just considering all exceptions to mean that the plugin couldn't be installed, make an exception for the
\LogicException
exception that is thrown by Twig:https://github.com/twigphp/Twig/blob/3.x/src/ExtensionSet.php#L127
...and treat that as a "soft" exception that is safe to complete the installation of the plugin.
Whilst I realize this seems like asking you to work around a quirk of SEOmatic, I've gone through many iterations of how I could potentially fix or special-case this, and none are particularly satisfying.
It's also in some ways a state introduced by the
php craft plugin/install --all
command that did not exist prior, in that plugins are installed one after the other in the same request, something that never happened prior.I'm open to ideas on other ways to affect a fix as well.
Steps to reproduce
composer.json
php craft plugin/install --all
Expected behavior
Plugins would all install
Actual behavior
Plugins that register a Twig extension after SEOmatic fail to install.
Craft CMS version
4.4.x
PHP version
8.1
Operating system and version
n/a
Database type and version
n/a
Image driver and version
n/a
Installed plugins and versions
SEOmatic 4.0.24
The text was updated successfully, but these errors were encountered: