octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.
https://octobercms.com/
Other
11.03k stars 2.21k forks source link

Enabled plugins are sometimes added to storage/cms/disabled.json #3009

Closed ghost closed 4 years ago

ghost commented 7 years ago
Expected behavior

storage/cms/disabled.json is a true reflection of the plugins that are disabled in manage plugins

Actual behavior

Occasionally, I see plugins that are not disabled added to storage/cms/disabled.json - this breaks the functionality of one of my clients sites.

Reproduce steps

This happens intermittently upon save in the back end and isn't tied to any particular plug-in.

October build

october/backend v1.0.419

It's a tricky one to catch so any pointers on where to start looking, perhaps around how disabled.json gets built up would be appreciated.

LukeTowers commented 7 years ago

Are you disabling any of those plugins in your cms.php config file? https://github.com/octobercms/october/blob/master/modules/system/classes/PluginManager.php#L469

Otherwise, the only thing I can think of is that the client is accidentally disabling the plugins, as the UX for managing the enabled state of the plugins right now isn't the greatest.

nizzac commented 7 years ago

@LukeTowers - Nope, the plugin isn't being disabled in the config file and the client doesn't have access to that area of the back end.

LukeTowers commented 7 years ago

@edhardie @neilcarpenter1 Bizarre. Well the link posted earlier is how that file gets generated, so I would look there to start with

ghost commented 7 years ago

Yep, bizzare indeed. Like a say it's only occasional, but when it happens all plugins in the back end show as enabled yet two make their way into the disabled.json file.

I'll have a look at the file you linked and see if I can dig up any more information. Thanks for the nudge in the right direction 😃

Denoder commented 6 years ago

I wanted to take a look at this problem but im not getting an replicated issues with it. @LukeTowers if the PR i submitted works for this then we can close this. @edhardie ill need yo to test this when it is pushed,

abdulla-allaith commented 6 years ago

I'm facing the same issue, some plugins are getting added to disabled.json automatically "intermittently" as @edhardie described.

LukeTowers commented 6 years ago

@abdulla-allaith are you able to nail down the process to a set of reproducible steps? We can't do anything unless we can reliably reproduce the issue.

ghost commented 6 years ago

Hi all. @Teranode I can have a go at testing for you if you've got some code I can run. I've got this very hacky temporary fix in place in modules/system/classes/PluginManager.php

protected function loadDisabled()
    {
        $path = $this->metaFile;

        if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
            foreach ($configDisabled as $disabled) {
                $this->disabledPlugins[$disabled] = true;
            }
        }

        if (File::exists($path)) {
            $disabled = json_decode(File::get($path), true) ?: [];
            if ($disabled['MyOwn.Plugin']) { unset($disabled['MyOwn.Plugin']); }
            if ($disabled['RainLab.GoogleAnalytics']) { unset($disabled['RainLab.GoogleAnalytics']); }
            $this->disabledPlugins = array_merge($this->disabledPlugins, $disabled);
        }
        else {
            $this->writeDisabled();
        }
    }

With those two being the plugins that caused problems.

@abdulla-allaith we might be able to narrow this down a bit further now it's not just me and @neilcarpenter1 seeing this. What OS and PHP version are you running? Which plugins do you have installed and which are the ones that get added to the disabled.json?

abdulla-allaith commented 6 years ago

@edhardie Sorry I just found out my issue is different, in which I have disabled plugins and I was not able to re-enable them. Even if I deleted them from disabled.json they always came back. I found the solution in #2714 and my plugins are now enabled and they do not get disabled like before.

LukeTowers commented 4 years ago

Closing as it has been over a month since any activity on this occurred and we are trying to figure out what issues are still relevant. If this is still something that you would like to see through to fruition please respond and we can get the ball rolling.