verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Migrations fail / Rebuild project config fails - "Class "verbb\iconpicker\helpers\Formie" not found" #58

Closed magicspon closed 1 year ago

magicspon commented 1 year ago

Describe the bug

Heyo,

My deployments are failing due to issues with migrations. I tried rebuilding my config on my local setup, i was hit with the following error

Class "verbb\iconpicker\helpers\Formie" not found
1. in /app/vendor/verbb/icon-picker/src/helpers/ProjectConfigHelper.phpat line 31
2. in /app/vendor/verbb/icon-picker/src/helpers/ProjectConfigHelper.php at line 18– verbb\iconpicker\helpers\ProjectConfigHelper::_getIconSetsData()
12131415161718192021222324    // =========================================================================

    public static function rebuildProjectConfig(): array
    {
        $configData = [];

        $configData['icon-sets'] = self::_getIconSetsData();

        return array_filter($configData);
    }

    // Private Methods
3. in /app/vendor/verbb/icon-picker/src/IconPicker.php at line 157– verbb\iconpicker\helpers\ProjectConfigHelper::rebuildProjectConfig()
151152153154155156157158159160161162163        $projectConfigService
            ->onAdd(IconSets::CONFIG_ICON_SETS_KEY . '.{uid}', [$iconSetsService, 'handleChangedIconSet'])
            ->onUpdate(IconSets::CONFIG_ICON_SETS_KEY . '.{uid}', [$iconSetsService, 'handleChangedIconSet'])
            ->onRemove(IconSets::CONFIG_ICON_SETS_KEY . '.{uid}', [$iconSetsService, 'handleDeletedIconSet']);

        Event::on(ProjectConfig::class, ProjectConfig::EVENT_REBUILD, function(RebuildConfigEvent $event) {
            $event->config['icon-picker'] = ProjectConfigHelper::rebuildProjectConfig();
        });
    }

    private function _registerRedactorPlugins(): void
    {
        if (class_exists(RichText::class)) {
4. verbb\iconpicker\IconPicker::verbb\iconpicker\{closure}(craft\events\RebuildConfigEvent)
5. in /app/vendor/yiisoft/yii2/base/Event.php at line 312– call_user_func(Closure, craft\events\RebuildConfigEvent)
6. in /app/vendor/yiisoft/yii2/base/Component.php at line 642– [yii\base\Event::trigger](https://www.yiiframework.com/doc-2.0/yii-base-event.html#trigger()-detail)('craft\services\ProjectConfig', 'rebuild', craft\events\RebuildConfigEvent)
7. in /app/vendor/craftcms/cms/src/services/ProjectConfig.php at line 1195– [yii\base\Component::trigger](https://www.yiiframework.com/doc-2.0/yii-base-component.html#trigger()-detail)('rebuild', craft\events\RebuildConfigEvent)
1189119011911192119311941195119611971198119912001201        $config[self::PATH_VOLUMES] = $this->_getVolumeData();

        // Fire a 'rebuild' event
        $event = new RebuildConfigEvent([
            'config' => $config,
        ]);
        $this->trigger(self::EVENT_REBUILD, $event);

        // Process the changes
        foreach ($event->config as $path => $value) {
            $this->set($path, $value, 'Project config rebuild', false, true);
        }

8. in /app/vendor/craftcms/cms/src/controllers/ProjectConfigController.php at line 90– craft\services\ProjectConfig::rebuild()
84858687888990919293949596        $projectConfig = Craft::$app->getProjectConfig();

        if ($projectConfig->readOnly) {
            throw new ForbiddenHttpException('Rebuilding the project config is not allowed while it’s in read-only mode.');
        }

        $projectConfig->rebuild();
        $this->setSuccessFlash(Craft::t('app', 'Project config rebuilt successfully.'));
        return $this->redirectToPostedUrl();
    }

    /**
     * Downloads the loaded project config as a zip file.
9. craft\controllers\ProjectConfigController::actionRebuild()
10. in /app/vendor/yiisoft/yii2/base/InlineAction.php at line 57– call_user_func_array([craft\controllers\ProjectConfigController, 'actionRebuild'], [])
11. in /app/vendor/yiisoft/yii2/base/Controller.php at line 178– [yii\base\InlineAction::runWithParams](https://www.yiiframework.com/doc-2.0/yii-base-inlineaction.html#runWithParams()-detail)(['site' => 'default'])
12. in /app/vendor/yiisoft/yii2/base/Module.php at line 552– [yii\base\Controller::runAction](https://www.yiiframework.com/doc-2.0/yii-base-controller.html#runAction()-detail)('rebuild', ['site' => 'default'])
13. in /app/vendor/craftcms/cms/src/web/Application.php at line 301– [yii\base\Module::runAction](https://www.yiiframework.com/doc-2.0/yii-base-module.html#runAction()-detail)('project-config/rebuild', ['site' => 'default'])
295296297298299300301302303304305306307     * @param string $route
     * @param array $params
     * @return Response|null The result of the action, normalized into a Response object
     */
    public function runAction($route, $params = []): ?BaseResponse
    {
        $result = parent::runAction($route, $params);

        if ($result === null || $result instanceof Response) {
            return $result;
        }

        $response = $this->getResponse();
14. in /app/vendor/craftcms/cms/src/web/Application.php at line 625– craft\web\Application::runAction('project-config/rebuild', ['site' => 'default'])
619620621622623624625626627628629630631        if ($request->getIsActionRequest()) {
            $route = implode('/', $request->getActionSegments());

            try {
                Craft::debug("Route requested: '$route'", __METHOD__);
                $this->requestedRoute = $route;
                return $this->runAction($route, $_GET);
            } catch (Throwable $e) {
                $this->_unregisterDebugModule();
                if ($e instanceof InvalidRouteException) {
                    throw new NotFoundHttpException(Craft::t('yii', 'Page not found.'), $e->getCode(), $e);
                }
                throw $e;
15. in /app/vendor/craftcms/cms/src/web/Application.php at line 280– craft\web\Application::_processActionRequest(craft\web\Request)
274275276277278279280281282283284285286                    throw new ForbiddenHttpException();
                }
            }
        }

        // If this is an action request, call the controller
        if (($response = $this->_processActionRequest($request)) !== null) {
            return $response;
        }

        // If we’re still here, finally let Yii do its thing.
        try {
            return parent::handleRequest($request);
16. in /app/vendor/yiisoft/yii2/base/Application.php at line 384– craft\web\Application::handleRequest(craft\web\Request)
17. in /app/web/index.php at line 26– [yii\base\Application::run](https://www.yiiframework.com/doc-2.0/yii-base-application.html#run()-detail)()
20212223242526define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
// ...

// Load and run Craft
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php';
$app->run();
$_GET = [
    'site' => 'default',
];

$_POST = [
    'action' => 'project-config/rebuild',
    'CRAFT_CSRF_TOKEN' => 'cadqsa5h5HL_TipxCU_XB-HZ3On46cQYKQLs5qKuFnmHrcpXBITrBHUfGkNYjKTVvwNt5nX1yzvKJsnvqcRUdLL1XmsUvFGTqGAl5MjOknfEBdwwP-MEycTjKNUk4vQe6dgfoBYX1vgLRyIR9GXRLL6IeFUlR53ME-7EpgWzJQGulk1jw2LN173ZVEDVwXXvMUC4JNEFyJ0FuxOGfnNEejalToSPqLi_2LdNR0uNrY_gZi2-zPwTU_e8Zgl7InBg6sfijTFVh03N-QmrQqjay_FiR9eXO18nhGCkkQNDgav48E_wN-sGC9s0rf2ATbYS0Jcr2OovkC4h5p0zElR-jVa1c9_xSAwQNOS-WouS0lT0FHL7-AQCiE-Dp-ngNXaRlga4UzyJ',
];

$_COOKIE = [
    '5f5ff957a2b8471c4b0f882b9a904639_username' => '2546714b99d52dd58b20f2ae3598abb07023cea280ab27093d8a68bcbadb6b81a:2:{i:0;s:41:"5f5ff957a2b8471c4b0f882b9a904639_username";i:1;s:13:"dave.stockley";}',
    '__stripe_mid' => '7e3e502e-590a-49ca-8620-7228a029f404f8207d',
    'CraftSessionId' => 'd10ca847f41546bfa209403432d56f1b',
    '5f5ff957a2b8471c4b0f882b9a904639_identity' => '3f05a395c7f26581ca0d39f9f5881802642aef68f2673fd5ce2eb814818956d9a:2:{i:0;s:41:"5f5ff957a2b8471c4b0f882b9a904639_identity";i:1;s:159:"[1,"[\\"RI58Scifriq08ZQd3dKhFYcDgLHGQswx6ZrKehs49ZUWkmARKk_O7tj14dtp2tV4yIN0-bUwizhW8R7AToiDvJm4-4ygICyOkzcW\\",null,\\"f3997c2268393c3e44db9d6171c7d192\\"]",3600]";}',
    'CRAFT_CSRF_TOKEN' => '5f0d9e768547e0897f01f1e3e4d7ab320c26188db61d514d1c06d54ea945ee80a:2:{i:0;s:16:"CRAFT_CSRF_TOKEN";i:1;s:147:"Uvoy3d_ay0Y5syrIeVtQG1sUnIaK-NpT9a6DWsWb|d838fc7228a8822ada5b563ebe438179cfec6b84276480d9cec62c51200860e8Uvoy3d_ay0Y5syrIeVtQG1sUnIaK-NpT9a6DWsWb|1";}',
];

$_SESSION = [
    'a3409f2f7ad002412b0d969b119646d8__flash' => [
        'cp-notice' => -1,
    ],
    'a3409f2f7ad002412b0d969b119646d8__auth_access' => [
        'seomaticPreviewAuthorizationKey36009',
        'previewElement:74',
        'saveAssets:1',
        'saveAssets:7',
        'editStructure:4',
        'previewDraft:1404',
        'seomaticPreviewAuthorizationKey74',
        'seomaticPreviewAuthorizationKey38446',
        'previewDraft:1947',
        'seomaticPreviewAuthorizationKey15',
        'previewElement:15',
        'seomaticPreviewAuthorizationKey38452',
        'previewDraft:1953',
    ],
    'cp-notice' => 'Icon set cache re-generation started.',
    '5f5ff957a2b8471c4b0f882b9a904639__token' => 'RI58Scifriq08ZQd3dKhFYcDgLHGQswx6ZrKehs49ZUWkmARKk_O7tj14dtp2tV4yIN0-bUwizhW8R7AToiDvJm4-4ygICyOkzcW',
    '5f5ff957a2b8471c4b0f882b9a904639__id' => 1,
    '__authKey' => '["RI58Scifriq08ZQd3dKhFYcDgLHGQswx6ZrKehs49ZUWkmARKk_O7tj14dtp2tV4yIN0-bUwizhW8R7AToiDvJm4-4ygICyOkzcW",null,"f3997c2268393c3e44db9d6171c7d192"]',
    '5f5ff957a2b8471c4b0f882b9a904639__expire' => 1669290087,
    '__duration' => 3600,
];

Steps to reproduce

  1. Update all plugins (including formie and icon-picker)
  2. Rebuild project config

Craft CMS version

4.3.3

Plugin version

2.0.1

Multi-site?

No

Additional context

image

engram-design commented 1 year ago

Whoops, not sure how that got in there. Fixed in 2.0.2

magicspon commented 1 year ago

wowsa, thanks for the speedy update

I'm able to rebuild my config with no problems. But i'm still having issues with the deployment.

any idea if this could be related?

Backing up the database ... done
*** applying m221116_000000_migrate_iconsets
Exception: Changes to the project config are not possible while in read-only mode. (/home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/craftcms/cms/src/services/ProjectConfig.php:503)
#0 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/craftcms/cms/src/services/ProjectConfig.php(475): craft\services\ProjectConfig->_setInternal()
#1 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/verbb/icon-picker/src/services/IconSets.php(186): craft\services\ProjectConfig->set()
#2 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/verbb/icon-picker/src/migrations/m221116_000000_migrate_iconsets.php(139): verbb\iconpicker\services\IconSets->saveIconSet()
#3 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/verbb/icon-picker/src/migrations/m221116_000000_migrate_iconsets.php(39): verbb\iconpicker\migrations\m221116_000000_migrate_iconsets->getOrCreateSet()
#4 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/craftcms/cms/src/db/Migration.php(49): verbb\iconpicker\migrations\m221116_000000_migrate_iconsets->safeUp()
#5 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#6 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/craftcms/cms/src/console/controllers/MigrateController.php(360): yii\console\controllers\BaseMigrateController->migrateUp()
#7 [internal function]: craft\console\controllers\MigrateController->actionAll()
#8 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#9 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#10 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#11 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction()
#12 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#13 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction()
#14 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#15 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest()
#16 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#17 /home/******ENCRYPTED******/staging-******ENCRYPTED******/releases/844cc6a3bbc20e0a47c9b80c0700922a6eed1e9d/craft(27): yii\base\Application->run()
#18 {main}
*** failed to apply m221116_000000_migrate_iconsets (time: 0.041s)
0 from 1 migrations were applied.
Migration failed. The rest of the migrations are canceled.
engram-design commented 1 year ago

Have you run all the updates locally first?

magicspon commented 1 year ago

i only rebuilt the project config.

magicspon commented 1 year ago

sorted

re-ran composer then craft up

engram-design commented 1 year ago

Should also be fixed in 2.0.3 due to some missing project config checks.