Skip to content
New issue

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

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

Already on GitHub? # to your account

Error with ProjectConfig after settings changed #152

Closed
JonnyBR12 opened this issue Mar 30, 2020 · 19 comments · Fixed by #162
Closed

Error with ProjectConfig after settings changed #152

JonnyBR12 opened this issue Mar 30, 2020 · 19 comments · Fixed by #162

Comments

@JonnyBR12
Copy link

Hey @riasvdv

We had Scout working fine but after unticking 'Sync' in the CMS settings, we now get the following error below. Have you seen this before?

Only way to get back in the CMS is to remove the Scout line from phpMyAdmin. Then, I remove it from the plugins list but when installing again, I get the same issue. I'm using the set-up file as per the docs that was working initially with the correct channels.

If you can point me in the right direction, that would be great.

Craft CMS 3.4.11, PHP 7.3

PHP Notice – yii\base\ErrorException Undefined offset: 1
vendor/craftcms/cms/src/helpers/ProjectConfig.php line 275

Screenshot 2020-03-30 at 17 44 34

@joshangell
Copy link

I hit this issue as well on a live site (doh), to fix it for me I removed all the rows from the projectconfig table that had a path starting with plugins.scout.settings.

I’m going to debug it locally now and see if I can reproduce it at all ...

@JonnyBR12
Copy link
Author

Ha, yeah I did the same thing just earlier and not long re-installed - I think we had almost 300 rows in there in the projectconfig table. I found it out by searching the database for any mentions of 'scout'.

@martinhellwagner
Copy link

martinhellwagner commented Apr 15, 2020

Same thing happening to me – both on my local environment and on our Staging environment.

@martinhellwagner
Copy link

@timkelty

Any news on this? It's turning out to be a major problem on our systems because it renders every environment unusable after each deploy – we have to fix it manually by editing the Craft CMS source code in the ProjectConfig.php file in the vendor folder.

@martinhellwagner
Copy link

@timkelty
@riasvdv

Checking in again on this issue – any news?

@rianconley
Copy link

rianconley commented May 19, 2020

@timkelty
@riasvdv

I'm having the same issue with this plugin. The error occurred after updating the scout settings. It broke the whole site. I tried completely removing the plugin and then re-installing it but the error persists.

How am I supposed to resolve this?

@tehtrav
Copy link

tehtrav commented Jun 2, 2020

Same thing happened to me. My local site completely died after I clicked "Save" in the Scout settings control panel.

@leevigraham
Copy link

+1… just got bitten by this.

@martinhellwagner
Copy link

@timkelty
@riasvdv

Can you already provide an update for this? This issue is open for over 2 months and multiple people are affected by it. 🤔

@rsanchez
Copy link

I've seen this issue with a different plugin...makes me think it's a Craft issue.

@timkelty
Copy link
Collaborator

Sorry for the delay here, been dealing with a newborn. 👶

I've seen this issue with a different plugin...makes me think it's a Craft issue.

As @rsanchez said, this appears to be a Craft issue: craftcms/cms#5525

Good news, I'm able to reproduce it.
I'm pretty sure anyone using the settings in CP would be similarly affected.

Since Scout requires you to have a config/scout.php anyway, I'd suggest everyone just use that for all their settings, and not save settings in the CP.

For those of you that are stuck with a broken site, I'll try and work on the quickest way to get your sites back.

@martinhellwagner
Copy link

For what it's worth, I've modified the function unpackAssociativeArray in the file ProjectConfig.php in order to get in working. Of course this is overwritten when composer packages are installed anew.

    public static function unpackAssociativeArray(array $array, bool $recursive = true): array
    {
        if (isset($array[ProjectConfigService::CONFIG_ASSOC_KEY])) {
            $associative = [];
            if (!empty($array[ProjectConfigService::CONFIG_ASSOC_KEY])) {
                foreach ($array[ProjectConfigService::CONFIG_ASSOC_KEY] as $items) {
                    if (sizeof($items) > 1) { // Necessary because of problem with Scout
                        $associative[$items[0]] = $items[1];
                    }
                }
            }
            $array = $associative;
        }

        if ($recursive) {
            foreach ($array as &$value) {
                if (is_array($value)) {
                    $value = static::unpackAssociativeArray($value, true);
                }
            }
        }

        return $array;
    }

@timkelty
Copy link
Collaborator

timkelty commented Jun 13, 2020

Here's how I could get it back locally after saving settings in the CP:

  • Truncate the project config table TRUNCATE TABLE craft_projectconfig;
  • delete the entire plugins.scout.settings node in your project.yaml
  • Clear caches. Note - you may have to do this manually if you craft command is still throwing errors. In my case I had to restart my redis container. If you're using the default file cache, delete your storage folder.
  • run craft project-config/sync --force
  • You should be back running, just don't save Scout settings from the CP or it will happen again.

Since a config/scout.php is already required for indices…I'm considering just dropping CP settings all together. Really the only thing you might want to do on a whim is toggle sync, but you could effectively do that by just disabling Scout as well…

@brandonkelly
Copy link
Contributor

The way Scout 2 is storing nested objects in its field settings would have been problematic even before project config.

I’ve just submitted #162 which should fix this error going forward.

@ryanirelan
Copy link

This appeared for me even while running the latest Scout release. Has anyone else seen this? Completely hosed a production site.

@sidoneill
Copy link

@ryanirelan (and anyone else who, like me, was still having an issue even with the new release) the issue likely that you still have the offending nested objects stored in your projectconfig table. Look for and delete the plugins.scout.settings rows and you should be good to go (and no longer sweating every update).

@davidhellmann
Copy link

Wow, Installed the Scout Plugin and kills my entire ENV. Not funny. Any Ideas if there a solution for this problems?

@timkelty
Copy link
Collaborator

@davidhellmann with this same error?

@davidhellmann
Copy link

Hey @timkelty

yes with the Undefined offset: 1 error.

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

Successfully merging a pull request may close this issue.