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
The latest commit aimed at fixing migrations breaks the installer: 3e8b370. When installing the plugin, the following exception gets thrown:
*** installing promptly
PHP Compile Error 'yii\base\ErrorException' with message 'Cannot declare class MostlySerious\Promptly\Migrations\Install, because the name is already in use'
in /var/www/html/vendor/mostlyserious/craft-promptly/src/migrations/Install.php:0
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
This happens because CraftCMS calls requires_once on the default Install migration of a plugin (https://github.com/craftcms/cms/blob/develop/src/base/Plugin.php#L317). But because the Plugin class of promptly already declares the class by requiring it, the exception gets thrown. It goes through the following flow:
A user runs php craft plugin/install promptly
Craft boots
Craft loads the Plugin class of promptly
The class requires MostlySerious\Promptly\Migrations\Install
PHP compiler crashes because the class was already declared
That's also why the exception only happens on a fresh install.
A quick solution would be to just extract all code in MostlySerious\Promptly\Migrations\Install::safeUp(); to some static helper class so you can call that in your Plugin.php and Install doesn't get declared again.
The text was updated successfully, but these errors were encountered:
@ddnetters Thanks for calling this out. Craft's way of handling install migrations is basically made to not make sense. I've reverted this change and made the assumption that the only reason the table wasn't installing before is that the migrations directory was capitalized and Pixel & Tonic apparently hate PSR-4 standards. ¯_(ツ)_/¯
Let me know if you have any issue with the most recent update. This did install as expected for me on a completely fresh install so I have to believe it's fixed now, ha.
The latest commit aimed at fixing migrations breaks the installer: 3e8b370. When installing the plugin, the following exception gets thrown:
This happens because CraftCMS calls
requires_once
on the defaultInstall
migration of a plugin (https://github.com/craftcms/cms/blob/develop/src/base/Plugin.php#L317). But because thePlugin
class of promptly already declares the class by requiring it, the exception gets thrown. It goes through the following flow:php craft plugin/install promptly
Plugin
class of promptlyMostlySerious\Promptly\Migrations\Install
Plugin::install()
require_once "/var/www/html/vendor/mostlyserious/craft-promptly/src/migrations/Install.php";
(https://github.com/craftcms/cms/blob/develop/src/base/Plugin.php#L317)That's also why the exception only happens on a fresh install.
A quick solution would be to just extract all code in
MostlySerious\Promptly\Migrations\Install::safeUp();
to some static helper class so you can call that in yourPlugin.php
andInstall doesn't get declared again
.The text was updated successfully, but these errors were encountered: