Open ghost opened 6 years ago
So after some research, I think I've narrowed the issue down to this bit of code: https://github.com/backdrop-contrib/metatag/blob/1.x-1.x/metatag.module#L1313
From my testing, the $options
array already has a defaults
key, so by using the +
array operator, the new defaults (metatag_config_load_with_defaults($instance)
) are totally ignored.
I could be wrong, but hopefully this helps points someone in the right direction for a fix.
EDIT: Oh and the new defaults are needed when checking if a metatag is saved or not (metatags are ignored if they're empty and have no default - hence my issue: I removed the value (so it's empty), and the defaults aren't being pulled in properly so it thinks there isn't a default and it's ignored).
I was troubleshooting Metatag for someone on the forum: https://forum.backdropcms.org/forum/newbie-problem-metatag
And this issue looks very similar. I haven't figured out why the defaults for Open Graph keep being used but wanted to tie these issues together.
The same I reported here: https://github.com/backdrop-contrib/metatag/issues/51
Although I have to say that I cannot reproduce this problem with the latest version. I just changed a default value and it remains after saving.
Following the steps in the issue description, I can reproduce this problem in the current version still. Like @BWPanda suggests, this seems to have to do with a default value ([site:name]
) being set, but when an empty-string is submitted, the empty string is not saved to config, then the default value gets used.
I think what needs to be done is that metatag_metatags_form_submit()
needs to save empty values if they differ from the defaults. I found that manually modifying metatag.instance.global.json
to have an empty string does suppress the og:site_name
value entirely.
This does not seem to be specific to the Open Graph module, but rather any metatags that have defaults specified.
Describe your issue
You cannot remove default Open Graph metatag values.
Steps to reproduce
Actual behavior
The 'Site name' metatag is still set to '[site:name]'
Expected behavior
The 'Site name' metatag should be empty/blank
Further details
I tested this with core metatags (e.g. 'Page title' under 'Basic Tags') and it works (you can remove default values). So the issue seems to be specific to the Open Graph metatags (haven't tested with other sub-modules).