An error occurs on attempting to add meta tags via the custom Views admin pages.
Way to reproduce:
1. Install clean Drupal 8.3.2 (simplytest.me)
2. Install and enable token, metatag, metatag_views
3. Go to /admin/config/search/metatag/views and click "add"
3. Try to add a metatag for a view.
After clicking the "Submit" button the following error appears:
InvalidArgumentException: The configuration property display.default.display_options.display_extenders.metatag_display_extender.metatags.robots.index doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 74 of core/lib/Drupal/Core/Config/Schema/ArrayElement.php).
Issue fork metatag-2883718
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
idiaz.ronceroExact same error here.
Comment #3
Mytko Enko CreditAttribution: Mytko Enko commentedI have tried on clean installation on simplytest.me and nothing works. Strange that not so many people face that problem.
Comment #4
ckaotikI'm working on a fix for this, stay tuned :)
Comment #5
ckaotikPlease review the attached patch.
The problem was that the
robots
metatag needs processing before it can be saved. This processing was added to the ViewsDisplayExtender, but not to the custom administration forms thatmetatag_views
provides. This is probably the reason why the error was not reported more widely.You might need to update the base metatags before translating works correctly, I haven't tried that.
Comment #6
Mytko Enko CreditAttribution: Mytko Enko commented@ckaotik Thank you, I have tried to apply the patch... after pressing submit button page /meatags/view become unavailable, log message is:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "metatag_views.metatags.translate_overview" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 190 of drupal\core\lib\Drupal\Core\Routing\RouteProvider.php).
Comment #7
ckaotikStrange, the patch does not touch the routes at all. Have you rebuilt the cache after enabling
metatag_views
?Comment #8
Mytko Enko CreditAttribution: Mytko Enko commentedYes, I've tried few times on different projects. Always use
drush cr
. Same problem. I think when I add a view metatag without editing there is "success" message, but nothing appears on the list. And when I add view metatag with values it crashes, and crashes every time I try to see the list of views metatags metatag/viewsComment #9
DamienMcKenna@mytko: Please remove your current files from the metatag directory and expand this archive instead, then clear the caches and see if the problem persists. Thanks.
Comment #10
Mytko Enko CreditAttribution: Mytko Enko commented@DamienMcKenna: still the same
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "metatag_views.metatags.translate_overview" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 190 of drupal\core\lib\Drupal\Core\Routing\RouteProvider.php).
Comment #11
DamienMcKennaAre you sure the Metatag Views module is still enabled?
Comment #12
rhormens CreditAttribution: rhormens at CI&T commentedComment #13
rhormens CreditAttribution: rhormens at CI&T commentedHi guys,
I can not reproduce the bug in these versions.
Please see screencast below.
Comment #14
rhormens CreditAttribution: rhormens at CI&T commentedComment #15
ivavictoriaThe "RouteNotFoundException" error happens to me on the Metatag Views page: /admin/config/search/metatag/views
Upon enabling the Metatag Views module, that page works fine.
But, after adding metatags to a view (as shown in the screencast in comment #13), if I try to re-visit the Metatag Views page, I get the error.
Comment #16
dietr_ch CreditAttribution: dietr_ch at EntityOne commentedI suspect the module has an implicit dependency to
config_translation
.MetatagViewsController
does not seem to check it before trying to load the translations route.Do you have
config_translation
enabled?Dietrich
Comment #17
Mytko Enko CreditAttribution: Mytko Enko commented@rhormens thanks a lot for the gif. I have only tried to add view metatag on metatag's settings page drupalroot/admin/config/search/metatag/views (just like @Aurif3x) and it was crashing (and still crashing). But when I tried to ad it on actual view editing page it worked!
Comment #18
james.williams CreditAttribution: james.williams at ComputerMinds commentedAdding the metatag works fine now, but it's then on viewing the subsequent /admin/config/search/metatag/views page that the missing route error shows up, because one of the 'operations' links for each view is to the translate_overview page. That will only exist if the config_translation module is enabled (which it's not for me), so I agree with dietr_ch.
Comment #19
james.williams CreditAttribution: james.williams at ComputerMinds commentedHere's a patch :-)
Comment #20
DamienMcKennaAdding a test.
Comment #21
DamienMcKennaIt's kinda annoying that it's saying the branch tests fail when the default test instance for the 8.x-1.x branch is against 8.3.x, which fully pass, rather than the 8.4.x tests which fail. Grr. I've set the module tests against 8.3.x to rerun, so hopefully them passing will kick it back into gear.
Comment #22
DamienMcKennaOk, the tests are green. This is strange, though, as it was suggested the error was because the config translation module was required, which doesn't seem to be the case. Any thoughts?
Comment #23
greenmother CreditAttribution: greenmother commentedThanks DamienMcKenna, patch worked for me.
Comment #24
DamienMcKennaBefore committing this I'd like to find exactly what is causing the failures. The tests-only fine in #20 isn't failing, so there's an additional aspect to this that I'm not catching quite yet. Any thoughts?
Comment #25
hdotnet CreditAttribution: hdotnet commentedSymfony\Component\Routing\Exception\RouteNotFoundException: Route "metatag_views.metatags.translate_overview" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 190 of core/lib/Drupal/Core/Routing/RouteProvider.php).
Solved by uninstalling and reinstall metatags_views (with patch #20 still). So far seems to be working as expected.
HTH
Comment #26
DamienMcKennaFor anyone who hasn't fixed their site yet ;-) could you please test clearing your site's caches after applying the patch to see if the route error mentioned in #25 is still there or if the cache-clearing skips past that problem. Thanks.
Comment #27
ericshell CreditAttribution: ericshell as a volunteer commentedI ran into the same issue as #25 after applying the patch in #20.
Clearing the cache does not resolve the issue.
I uninstalled and reinstalled the views_metatags module (without reverting my configured displays) and it still did not work. The previously configured displays were still there after reinstallation. Reverting and recreating still produced the breaking error.
Reverting all displays before uninstalling and reinstalling and reconfiguring did not work either.
Full error when trying to edit a display:
I get this behavior for each display that I create.
Comment #28
eastdrive CreditAttribution: eastdrive commentedCan confirm the same issue as #25 and #27
Comment #29
DamienMcKennaI've just spent some time testing Metatag Views on a copy of a production site with 8.3.4 that has translations running and have not run into any problems, and then did the same on both barebones 8.3.x and 8.4.x installations. None of the installations had any problems.
Both of the barebones installations had the latest core releases, they just had the "Standard" installation profile applied and then Token, Metatag and Metatag Views were installed. The production site last had its contrib modules updated in April-ish (CTools was still 8.x-3.0-alpha27).
This doesn't mean I do not believe you about there being a problem, it means I want to spend more time digging through to working out what the actual cause us so that we can have a test that demonstrates the error and then show how the patch fixes it.
Comment #30
hdotnet CreditAttribution: hdotnet commentedI'm getting the exact same error out of the box
Comment #31
DamienMcKennaOh wow, I hadn't noticed that entire section existed. Doh.
Yeah, that system needs some tests.
What I suggest doing for now is to add meta tags directly to the views themselves rather than via the separate config pages.
Comment #32
pacproduct CreditAttribution: pacproduct at Makina Corpus commentedWas facing the same
InvalidArgumentException
kind of error when trying to enable 'follow, noindex' on my views. Patch #20 fixed the issue for me. Thanks!Comment #33
danquah CreditAttribution: danquah at Reload commentedI'm trying to track down the cause of an error I'm getting after upgrading to 8.4 and running drush updb. The pattern is exactly as described in https://www.drupal.org/node/2914958 (that is, I update core and then run drush updb), but the error-message I'm getting is identical to the one in the description of this issue (with the exception of the name of the view that is).
Any chance the two are related? Could there be something in 8.4 that provokes the this issue?
The patch in #20 does not help.
Comment #34
danquah CreditAttribution: danquah at Reload commentedJust to clarify. The site I where getting the exception on has two views with a metatag configuration on a view. The site is currently running on (core) 8.3, and if I upgrade to 8.4 and do a drush updb I get the exception even with the patch from #20. The exception is thrown in the last part of update-db where core re-saves amongst other things all views.
The patch _does_ allow me to save the view manually both on 8.3 and 8.4. In other words, the patch seems to be handling the situation where the view is saved from the backend, but not the case where it is saved programmatically. The post update-db save of views seems to be handled from views_post_update_revision_metadata_fields() which triggers a $view->save() on all views on the site.
My current workaround to get the site upgraded is
- Save a copy of relevant metatag_display_extender sections in the views exported .yml files
- Remove the metatag configuration from the configuration
- Re-import the configuration
- Upgrade to 8.4 and run the update-hooks
- Reapply the metatag_display_extender configurations
This way I get a site that works just fine just as long as no-one saves any views programatically :)
Look forward to progress on this issue, please advice if I can help with eg. more tests.
Comment #35
james.williams CreditAttribution: james.williams at ComputerMinds commentedHi @danquah, please can you confirm exactly what the error message you get is?
Comment #36
danquah CreditAttribution: danquah at Reload commentedAh yes, sure thing:
Comment #37
danquah CreditAttribution: danquah at Reload commentedAnd just to set the context, the view in question has a display called "overview" which is why the config-string reads "display.overview" and not "display.default" as the one in the description of this issue.
Comment #38
ckaotikThe error means that the data the system is trying to save for the
robots
metatag (likely the array['index' => 'index']
as created by the checkboxes form element) does not match the configuration schema (which expects a string'index'
).This is ususally the case if form values are stored directly, without processing by the MetatagTagManager. We do this when saving the core View form or the metatag specific form, using the following checks:
If you run into this error when running update scripts, you either had a broken configuration before updating the view, or we missed a way of saving the view. The views_post_update_revision_metadata_fields update hook only re-saves the View using
Entity::save
, we should be able to handle that.I am wondering ... is your View translated, and have you maybe just edited one language version but one of the others still contains invalid values?
Comment #39
danquah CreditAttribution: danquah at Reload commentedThe site does have translation and configuration translation enabled, but I just checked and we only have a configuration for that view in the "root" configuration folder and not in the language/da subfolder. Might that be a problem?
With regards to the view already being broken, it might very well be, anything in particular I should be looking for in the config export (I can also attach the .yml if it helps and is relevant for the issue).
As far as I can tell from our SCM we where running metatag 1.0-beta12 when the configuration for that view was last exported, so that might also be a source of the problem.
That being said, I still get the Exception if I apply the patch from #20, export the configuration, and then upgrade to core 8.4 and run updb....
Comment #40
ckaotikThat shouldn't be a problem.
If you could post the
metatag_display_extender
section, that might help.Comment #41
danquah CreditAttribution: danquah at Reload commentedHere you go
views.view.badges.yml:
Comment #42
ckaotikYeah, that's definitely the broken structure that was used while we were still working on the metatag_views feature (see #2563647-105: Views integration). To fix it, you can repeat what @Peacog did or directly edit your View's configuration and change the robots part to just
robots: ''
. To edit, you can use Devel's "Config Editor" feature or the core import/export.Re-submitting the metatag part on the View or in the separate metatag form might also work.
Comment #43
danquah CreditAttribution: danquah at Reload commentedThat did the trick. I removed the metatag section from the view, configured it manually again and did an export. The newly exported configuration survived the updatedb without any problems.
Thanks! :)
Comment #44
ckaotikSo, we're now back to #31: Adding tests for the Metatag custom UI at
/admin/config/search/metatag/views
.Comment #45
Anas_maw CreditAttribution: Anas_maw at Vardot commentedI can confirm patch 20 worked for me, thanks.
Comment #46
mpark CreditAttribution: mpark commentedIt's horrible that this patch isn't still included in the module. This is a default necessary.
Comment #47
sassafrass CreditAttribution: sassafrass as a volunteer commentedUsing Drupal 8.4.3, I applied this patch (#20) to the latest dev branch of Metatag
and got the following error on my site:Fatal error: Class 'Drupal\metatag\Plugin\Field\FieldType\MetatagFieldItem' not found in mysite/docroot/core/modules/field/src/FieldStorageConfigStorage.php on line 159.
Disregard the above error, it was because the patch would not apply to the metatag dev version I was trying to apply it to.
I applied the patch manually, and it fixed the issue. However, the patch does need to be re-rolled if used against the latest dev branch.
Comment #48
sassafrass CreditAttribution: sassafrass as a volunteer commentedThe attached patch is my version of #20 re-rolled against the latest dev version that I downloaded via git clone.
Comment #49
mpark CreditAttribution: mpark commentedThanks :-)
Comment #50
DamienMcKennaLets check in with the testbot again.
Comment #52
Jaesin CreditAttribution: Jaesin at Chapter Three commentedAnother re-roll of #20.
Comment #53
chegor CreditAttribution: chegor at OAO Solution Spark commentedLooks ok.
Comment #54
ABaier CreditAttribution: ABaier commentedI can also confirm this issue.
I could not create metatags for views from
/admin/config/search/metatag/views
, which resulted in the error from the issue's description. After successfully adding some metatags from the views UI the config page /admin/config/search/metatag/views was not available anymore resulting in the error from #10.The patch from #52 applied against 8.x-1.4 and brought the config page back, showing me the view overridden from within the views UI, but still gives me the error after trying to edit it using the dropbutton.
Comment #55
NiklanConfirm the issue. Patch #52 is not fix it. When I press apply, AJAX returns 500 error:
Comment #56
joerch CreditAttribution: joerch as a volunteer commentedsubscribe
Confirm the described issue.
Comment #57
ckaotikWe've strayed quite a bit from the original report, so I'll try to summarize what we've discovered so far.
robots
This was fixed in #5.
metatag_views.metatags.translate_overview
popped up in #6This was due to an assumption that the
config_translation
is always available (it's not) and has been addressed in various patches since then, #52 being the most recent.website
plugin error in #55This has not been addressed yet. We should first figure out if this is related, or maybe a different issue altogether.
This whole issue is further complicated by the fact that there are two locations for configuring views metatags, and thus two locations for translating them.
at
/admin/config/search/metatag/views/{VIEW_ID}/{DISPLAY_ID}/edit
and translation at
/admin/config/search/metatag/views/{VIEW_ID}/{DISPLAY_ID}/translate
if usingconfig_translation
at
/admin/structure/views/view/{VIEW_ID}/edit/{DISPLAY_ID}
in the middle column under "Meta-Tags"and translation at
/admin/structure/views/view/{VIEW_ID}/translate
if usingconfig_translation
To further investigate the issue, please post which error you encounter, and under which conditions (which config form, with or without config_translation etc.). Please also be aware that modules that extend the metatag tags might influence your problem. Otherwise we might never get to the bottom of this.
Comment #58
DamienMcKennaClarifying the problem to make it easier to find as it keeps coming up.
Comment #59
DamienMcKennaFYI I'm working to hide the separate Metatag-Views admin pages in #2956199: Remove separate admin pages for Views integration, as a way of avoiding this problem until we can fix it properly.
Comment #60
DamienMcKennaJust to be clear: the next release (8.x-1.5) will not have the separate admin pages for managing configurations for Views as a temporary solution until we can fix this issue.
Here are two patches - one file just recovers the removed Yaml files, and another combines that with the patch from #52.
Comment #61
DamienMcKennaI split off the test change from #20 into #2956227: Test improvements from 2883718-20 because as-is it's not really related to this problem.
Comment #62
DamienMcKennaThinking out loud here - does anyone actually want to use the separate Views admin pages or should we just replace it with a single configurable default listed on the main defaults page, then leave the individual views to be managed on their own?
Comment #63
ckaotikPersonally, having a separate config just for the metatags allows us to pass setting up metatags (or translating them) to project management or in some cases even to the client themselves. We wouldn't give either access to edit our views, as there's a lot more that could go wrong.
Comment #64
DamienMcKenna@ckaotik: Ok, that's a valid use case.
Lets focus this on just making all those pages work properly again.
Comment #65
Chris Burge CreditAttribution: Chris Burge commentedRerolled #60 against HEAD. It looks like the following code is already committed (which causes #60 to fail to apply):
Comment #66
DamienMcKennaThanks @ChrisBurge.
Comment #67
ckaotikThanks @ChrisBurge for the reroll!
I've a suggestion to make: How about we use the default metatag translation ui that editors already know from content edit forms? I've attached a patch and some before/after screenshots for how this could work (unless I've messed up the patch file). This would allow for more complex form elements by providers and allows to use the regular tag groups.
Groups for tags that have not been set in the original language are displayed but without any inputs - or we could of course remove those groups. We could also disable the original language, but either way changes on that side of the form are not saved. We could also apply this to the views ui.
How do you feel about this? (we can always fallback to #65)
Comment #68
DamienMcKennaPlease note the following: #2981549: Separate Metatag configuration from Views definition
Comment #69
bceyssensRerolled #65 against 8.x-1.7. Parts of the code have been moved or are already committed.
Comment #70
Ruedische CreditAttribution: Ruedische at werk21 commentedThank you for the patch. Unfortunately, we still had a few problems: Originally we were using Metatag 8.x-1.2 and enabled metatag_views when we got the error message shown in the issue summary. We then updated to metatag 8.x-1.7 and applied the patch from #2883718-69: Reenable custom Views admin pages. After clearing all caches, the views tab appeared on the metatag settings page and we were able to add a new configuration for a view. After adding a configuration, we were redirected to the views tab and got a success message, but the configuration did not appear on the page. Also, the metatags we configured were not added to the view in question. We cleared all caches again, but that didn't help. Upon looking at a configuration export, we saw that the metatags we configured were successfully added to the views configuration. We then uninstalled the metatag_views module and enabled it again immediately. Now, the configuration we added earlier was displayed on the views tab and the metatags were visible on the views page as configured. When we exported the configuration again, an update was shown for the views.settings.yml. Is the patch maybe missing an update hook to work with earlier existing installations of metatag_views?
Comment #71
FeyP CreditAttribution: FeyP as a volunteer and at werk21 commentedWith the patch in #69 I get a RouteNotFoundException: Route "metatag_views.metatags.translate_overview" does not exist. when editing metatag_views configuration, if the
config_translation
module is not enabled. Attached is a patch to fix this. #70 still needs to be addressed, though.Comment #72
james.williams CreditAttribution: james.williams at ComputerMinds commentedThanks FeyP, that works well for me. It's interesting that the local task didn't used to cause the problem in the same way; but I could totally imagine something has changed in Drupal/Symfony's route/task handling since my patch back in #19.
Comment #73
svetoslav.dragoev CreditAttribution: svetoslav.dragoev at FFW commentedRerolled #71 against 8.x-1.9.
Comment #74
svetoslav.dragoev CreditAttribution: svetoslav.dragoev at FFW commentedRerolled #71 against 8.x-1.9.
Sorry, #73 was not fully exported.
Comment #75
svetoslav.dragoev CreditAttribution: svetoslav.dragoev at FFW commentedRerolled #71 against 8.x-1.9 - full.
Comment #76
svetoslav.dragoev CreditAttribution: svetoslav.dragoev at FFW commentedRerolled #71 against 8.x-1.9. Missing empty line at the end of patch fix.
Comment #77
svetoslav.dragoev CreditAttribution: svetoslav.dragoev at FFW commentedRerolled #71 against 8.x-1.9.
Comment #78
arsn CreditAttribution: arsn commented#77 seems to work however displays a duplicate admin/config/search/metatag tab.
Here in French:
Comment #79
DamienMcKennaSo, I think this is back to the olde Needs Tests thing. With test coverage we can plan out exactly what we expect to happen, then make sure the code does that.
Comment #80
rynnnner CreditAttribution: rynnnner commentedThis patch doesn't install for me on 8.x-1.13.
Comment #81
ckaotikRerolled for 8.x-1.13, still needs tests.
Comment #82
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedAdded a functional test as per the steps to reproduce. Please review!
Comment #83
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com commentedI have been testing the UI and the translation tab for views meta-tags does not work. It throws like this:
Error: Call to undefined method Symfony\Component\HttpFoundation\RequestStack::get() in Drupal\metatag_views\Controller\MetatagViewsTranslationController->itemPage() (line 85 of modules/contrib/metatag/metatag_views/src/Controller/MetatagViewsTranslationController.php).
The reason is this commit:
https://git.drupalcode.org/project/metatag/-/commit/f76d3fa9008bd91bd18c...
which replaces
with:
in
metatag_views/src/Controller/MetatagViewsTranslationController.php
$this->requestStack
is instantiated like this:$container->get('request_stack')
in the create method of the controller, whereas\Drupal::request()
is actually doing this:The patch simply adds the
->getCurrentRequest()
part in the controller as well as a simple test just for this case. It also adds a helper method to the trait to create a view (might be helpful for other tests).There are still more tests to be written, but just adding a small brick :).
Comment #85
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com commentedI did not add the new files to the patch... Reuploading.
Comment #86
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com commentedI have fixed the doubled tabs problem - it was caused by the duplicated entries in the yaml files. Also added Views to the menu (next to Global and Settings).
Comment #89
metalbotereroll...
Comment #90
Ruedische CreditAttribution: Ruedische at werk21 commentedRe-Roll against 2.0.x/2.0.0