Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Undefined index: security when upgrading from 3.3.29 to 3.4.25 #1065

Closed
aaronbushnell opened this issue Feb 15, 2022 · 9 comments
Closed
Labels

Comments

@aaronbushnell
Copy link

Describe the bug

I have a site that, after I updated SEOmatic from 3.3.29 to 3.4.25, the global content control panel area (/admin/seomatic/global/general/en_us) errors out with...

yii\base\ErrorException: Undefined index: security in /../src/vendor/nystudio107/craft-seomatic/src/controllers/SettingsController.php:307
Stack trace:
#0 /../src/vendor/craftcms/cms/src/web/ErrorHandler.php(84): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/...', 307)
#1 /../src/vendor/nystudio107/craft-seomatic/src/controllers/SettingsController.php(307): craft\web\ErrorHandler->handleError(8, 'Undefined index...', '/...', 307, Array)
#2 [internal function]: nystudio107\seomatic\controllers\SettingsController->actionGlobal('general', 'en_us', NULL, NULL)
#3 /../src/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#4 /../src/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#5 /../src/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('global', Array)
#6 /../src/vendor/craftcms/cms/src/web/Application.php(292): yii\base\Module->runAction('seomatic/settin...', Array)
#7 /../src/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('seomatic/settin...', Array)
#8 /../src/vendor/craftcms/cms/src/web/Application.php(277): yii\web\Application->handleRequest(Object(craft\web\Request))
#9 /../src/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#10 /../src/public/index.php(21): yii\base\Application->run()
#11 /.composer/vendor/laravel/valet/server.php(235): require('/...')
#12 {main}

To reproduce

Steps to reproduce the behaviour:

  1. When on SEOmatic 3.3.29, use php craft update seomatic to get to the latest version
  2. Navigate to the Global Content control panel area in SEOmatic after update

Expected behaviour

I expected that, if a table/index is missing, SEOmatic would attempt to create it so that this area is visible and does not error

Versions

  • Plugin version: 3.4.25
  • Craft version: 3.7.32
khalwat pushed a commit that referenced this issue Feb 15, 2022
@khalwat
Copy link
Collaborator

khalwat commented Feb 15, 2022

So... something is not right here. Changes were made that should update your bundles to have the appropriate settings.

Addressed in: c98982f

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop as 3.4.26”,

Then do a composer clear-cache && composer update

@khalwat khalwat closed this as completed Feb 15, 2022
@aaronbushnell
Copy link
Author

Hm, still no dice on this one. If it's helpful I can provide you with the composer.json file and a copy of our database, @khalwat?

@khalwat
Copy link
Collaborator

khalwat commented Feb 15, 2022

@aaronbushnell can you verify for me that this actual code is in the file on the machine you're testing from?

c98982f#diff-c3edda52a0935a5f66e70f65d9b0c895c7073699fcfd3d25cbca22740775eec9R389

It should look like this now:

            // Handle an edge-case where a migration didn't work properly to add SECURITY_TXT_HANDLE
            if (!isset($templateContainers[FrontendTemplates::SECURITY_TXT_HANDLE])) {
                $globalMetaBundle = Seomatic::$plugin->metaBundles->createGlobalMetaBundleForSite($siteId, $metaBundle);
                $templateContainers[FrontendTemplates::SECURITY_TXT_HANDLE] =
                    $globalMetaBundle->frontendTemplatesContainer->data[FrontendTemplates::SECURITY_TXT_HANDLE];
            }
            $variables['securityTemplate'] = $templateContainers[FrontendTemplates::SECURITY_TXT_HANDLE];

And if that code is there, can you show me the error you're seeing now?

@khalwat
Copy link
Collaborator

khalwat commented Feb 15, 2022

Also, verify for me that your src/seomatic-config/globalmeta/FrontendTemplatesContainer.php looks like this:

https://github.com/nystudio107/craft-seomatic/blob/develop/src/seomatic-config/globalmeta/FrontendTemplatesContainer.php#L52

@aaronbushnell
Copy link
Author

Ah, good catch @khalwat! It was the lack of a FrontendTemplates::SECURITY_TXT_HANDLE in the seomatic-config/globalmeta/FrontendTemplatesContainer.php file.

Adding that has me situated here, thanks!

@khalwat
Copy link
Collaborator

khalwat commented Feb 15, 2022

@aaronbushnell You might want to re-install from scratch, it sounds to me like what you have installed is not the full current build, for whatever reason.

@aaronbushnell
Copy link
Author

aaronbushnell commented Feb 15, 2022

Hey @khalwat I think it's just because I have my own src/config/seomatic-config/globalmeta/FrontendTemplatesContainer.php which was lacking the proper security key. Are you thinking that's not the case? Because this is what it was before when it was throwing that error:

<?php


use nystudio107\seomatic\services\FrontendTemplates;
use nystudio107\seomatic\models\FrontendTemplateContainer;

return [
    'name'        => 'Frontend Templates',
    'description' => 'Templates that are rendered on the frontend',
    'handle'      => FrontendTemplates::FRONTENDTEMPLATES_CONTAINER,
    'class'       => (string)FrontendTemplateContainer::class,
    'include'     => true,
    'data'        => [
        FrontendTemplates::HUMANS_TXT_HANDLE => [
            'handle'          => FrontendTemplates::HUMANS_TXT_HANDLE,
            'path'            => 'humans.txt',
            'template'        => '_frontend/pages/humans.twig',
            'controller'      => 'frontend-template',
            'action'          => 'humans',
            'include'         => false,
            'templateString'  => '',
        ],
        FrontendTemplates::ROBOTS_TXT_HANDLE => [
            'handle'          => FrontendTemplates::ROBOTS_TXT_HANDLE,
            'path'            => 'robots.txt',
            'template'        => '_frontend/pages/robots.twig',
            'controller'      => 'frontend-template',
            'action'          => 'robots',
            'include'         => false,
            'templateString'  => '',
        ],
        FrontendTemplates::ADS_TXT_HANDLE => [
            'handle'          => FrontendTemplates::ADS_TXT_HANDLE,
            'path'            => 'ads.txt',
            'template'        => '_frontend/pages/ads.twig',
            'controller'      => 'frontend-template',
            'action'          => 'ads',
            'include'         => false,
            'templateString'  => '',
        ],
    ],
];

@khalwat
Copy link
Collaborator

khalwat commented Feb 15, 2022

Ah yes. That would do it. :)

@aaronbushnell
Copy link
Author

Thanks a bunch for the quick assist here! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants