Front end crashing Markdown Notices plugin

Had markdown notices installed and working, then I disabled it. When I tried to enable it again, every time I load a page on the front end, I get this error in
user/plugins/markdown-notices/markdown-notices.php:

Whoops \ Exception \ ErrorException (E_WARNING)
count(): Parameter must be an array or an object that implements Countable

I have tried uninstalling, reinstalling, clearing cache, etc. I just cannot get this error to go away.

@mkovnick, I can only reproduce this error when the setting for level_classes in the following files is not a proper array:

  • user/env/YOURENV/config/plugins/markdown-notices.yaml, or
  • user/config/plugins/markdown-notices.yaml, or
  • user/plugins/markdown-notices/markdown-notices.yaml

Correct array values are:

  • level_classes: [yellow, red, blue, green]
  • level_classes: 
      - yellow
      - red
      - blue
      - green
    

Incorrect values:

  • level_classes:
  • level_classes: 'yellow, red, blue, green'
  • level_classes: yellow, red, blue, green

OK, that got rid of the error, but the highlights are not showing now?

Here is my /user/config/plugins/markdown-notices.yaml file:

enabled: true
built_in_css: true
base_classes: null
level_classes: [yellow, red, blue, green]

By the way, for some reason when I re-enabled it, level_classes was set to null

OK, I got it working, but I am confused.

I found the file at
user/plugins/markdown-notices/markdown-notices.yaml
and edited that, adding [yellow, red, blue, green] where it had been null, and that stopped it from crashing.

But then I saw I also had the file:
user/config/plugins/markdown-notices.yaml
and that had what appeared to be the correct config:

enabled: true
built_in_css: true
base_classes: 'notices'
level_classes: [yellow, red, blue, green]

So I copied the same config to user/plugins/markdown-notices/markdown-notices.yaml and everything works as it should.

So one question:
Why would I have both of those files on a fresh install from yesterday? Is this normal? Should I delete one of the paths?

@mkovnick,

There are three locations for the config file of a plugin:

  • user/env/DOMAIN/config/plugins/markdown-notices.yaml
    See Environment Configuration
  • user/config/plugins/markdown-notices.yaml
  • user/plugins/markdown-notices/markdown-notices.yaml
    Never edit this file, but instead copy it into one of above locations.

This is also the order in which Grav searches for a config setting.

Why would I have both of those files on a fresh install from yesterday?

You don’t have both files after a fresh install.

  • After an initial install, there is only one config file: user/plugins/markdown-notices/markdown-notices.yaml.
    • After re-install, only this file gets overridden.
  • When using Admin and saving the config, depending on the domain of the server/PC, a file is saved either in:
    • user/env/DOMAIN/config/plugins/markdown-notices.yaml, or
    • user/config/plugins/markdown-notices.yaml

Should I delete one of the paths?

No, one is the original plugin’s default config, the other is the altered config. They both have their reason of existence and are each others fallback.