Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I just rebuilt my dev environment, and on install, the admin/workbench throws an error:
Notice: Undefined index: #contextual_links in contextual_pre_render_links() (line 140 of /Applications/MAMP/htdocs/drupal-7-workbench/modules/contextual/contextual.module).
And the contextual links for the Views don't work. There seems to be a mismatch between the use of 'contextual_links' and '#contextual_links' in the render array, but I can't figure out how to correct for it.
See workbench_content() and theme_workbench_element() compared to http://api.drupal.org/api/drupal/modules!contextual!contextual.module/fu...
Comments
Comment #1
agentrickardThis patch removes the error, but the contextual Views links are still broken.
Comment #2
robeano CreditAttribution: robeano commentedYep, I'm noticing this too. The PHP Notice occurs only when there is no content on the site.
Contextual links are broken still broken.
Comment #3
hass CreditAttribution: hass commentedHow can I reproduce this and what contextual links are broken? I have not seen it and all my contextual links seems working.
Comment #4
agentrickardThis does seem to be fixed now. I suspect some other change corrected the issue.
Comment #5
agentrickardFor some reason, however, the links appear in an odd place. Which may be why I missed them.
Comment #6
bbinkovitz CreditAttribution: bbinkovitz commentedI think it must be a mistake that this was marked "Closed (cannot reproduce)" since several people are able to reproduce it. I, for one, have encountered it just now on my fresh sandbox.
Comment #7
hass CreditAttribution: hass commentedAre you able to describe how and under what url? Maybe add screenshots, too.
Comment #8
bbinkovitz CreditAttribution: bbinkovitz commentedWhenever I visit /admin/workbench, the next page that I visit after I close the overlay looks like this. (Screenshot attached).
Enabled contrib modules are: CTools, Devel, Git Deploy, Views 7.x-3.x-dev, and Workbench 7.x-1.2.
Comment #9
hass CreditAttribution: hass commentedYou do not have WBM or WBA installed?
Comment #10
hass CreditAttribution: hass commentedHow about the patch from #1?
Comment #11
bbinkovitz CreditAttribution: bbinkovitz commentedI do not have WBM or WBA on this particular test site.
I still get the errors when I try the patch in #1. Only disabling the contextual module seems to get rid of it.
Comment #12
hass CreditAttribution: hass commentedComment #13
bbinkovitz CreditAttribution: bbinkovitz commentedI got the patch to apply and wrote some tests.
Attached you'll find the patch with tests, as well as tests only. The tests will not fail without the patch, however, they will display exceptions as shown in the attached screenshot. With the patch applied, the tests will pass without exceptions.
I have so far not observed misplacement of the contextual links.
Comment #14
bbinkovitz CreditAttribution: bbinkovitz commentedComment #15
hass CreditAttribution: hass commentedWe need to rerole for #1388220: Actions Missing in My Edits. Additional I think there is something wrong with this patch.
I believe it need to be
$output[$key]
only. The rest is handled byviews_add_contextual_links()
. I say this only codewise, so it's not tested yet, but I give it a try. By prefixing the name with a sharp you made it falling back to sane defaults if I'm not totally wrong.Comment #16
hass CreditAttribution: hass commentedI'm still totally unable to repro this warnings. I have installed only workbench module and no WBA or WBM. Drupal 7.18
Comment #17
drupalmonkey CreditAttribution: drupalmonkey commentedI had this same issue, but I didn't have views_ui enabled. After enabling Views UI, the error went away. (This is without using any of the aforementioned patches on this thread).
Does anyone get the error WITH Views UI enabled? The contextual link code should check for Views UI anyway, and that made it into a commit on this issue: http://drupal.org/node/1388220
Comment #18
hass CreditAttribution: hass commentedOk, reproduced it. Views UI need to be disabled and
if (module_exists('contextual') && module_exists('views_ui')) {
need to be roled back toif (module_exists('contextual')) {
for repro. So, this is a duplicate of #1388220: Actions Missing in My Edits.Comment #19
hass CreditAttribution: hass commentedStop, there are tests inside.
Comment #20
hass CreditAttribution: hass commentedComment #21
hass CreditAttribution: hass commentedComment #22
hass CreditAttribution: hass commented$this->drupalGet('admin/workbench')
Contextual links are not appearing. This is JS, isn't it? I'm out for tonight... looks not testable :-(.
Comment #24
bbinkovitz CreditAttribution: bbinkovitz commentedThe test I posted doesn't test whether the contextual links are in the right place or even whether they work. Rather, the test generates errors without the patch, and does not generate errors when the patch is applied. That is all.
Comment #25
bbinkovitz CreditAttribution: bbinkovitz commented#13: 1727284-workbench-contextual-tests-only-13.patch queued for re-testing.
Comment #26
bbinkovitz CreditAttribution: bbinkovitz commentedThe commit that fixed #1388220: Actions Missing in My Edits also resolved this problem for me. Queued the tests from #13 for re-testing because I think they will not produce errors on the latest codebase.
Update: they now pass with no errors. I believe this is fixed.
Comment #27
bbinkovitz CreditAttribution: bbinkovitz commentedComment #28
bbinkovitz CreditAttribution: bbinkovitz commentedEr, what I meant was... #1388220: Actions Missing in My Edits
Comment #29
hass CreditAttribution: hass commented#21 needs work.
Comment #30
bbinkovitz CreditAttribution: bbinkovitz commentedI'm confused. What needs work? Is it not true that pulling the latest dev resolves this issue?
Comment #31
drupalmonkey CreditAttribution: drupalmonkey commentedI think hass wants to get the tests in. I'm not sure they work correctly yet though.
Comment #32
hass CreditAttribution: hass commentedYep, I'd like to get the tests in for future.
Comment #33
realityloop#16: workbench_1727284+Contextual+links+error+on+Drupal+7.15.patch queued for re-testing.
Comment #34
gilsbert CreditAttribution: gilsbert commentedHi.
I tested patch #16 and it is working.
Will it be added to the official release?
Regards,
Gilsberty
Comment #35
BarisW CreditAttribution: BarisW commentedI've pulled the latest dev and the issue is gone. So the Needs work only applies to getting the tests in, the rest is not needed.
Comment #36
ebeyrent CreditAttribution: ebeyrent commentedUsing the latest stable version (7.x-1.2) and with Views UI disabled, I'm getting the warnings:
Warning: Invalid argument supplied for foreach() in contextual_pre_render_links()
To recreate, add a view of some sort with a page display, add a tab menu that appears within workbench (admin/workbench/my-view).
Any chance of getting this fixed soon? I don't like to have Views UI enabled on production, but I also dislike warnings and errors.
Comment #37
ebeyrent CreditAttribution: ebeyrent commentedAny updates on this?
Comment #38
mkhamash CreditAttribution: mkhamash commentedPatch #1 does the trick and it seems fairly logical.
Comment #39
vids CreditAttribution: vids commentedPatch from #1 works perfectly fine for me.
Comment #40
ElliotFriend CreditAttribution: ElliotFriend at St. Louis Christian College commentedPatch #1 also works for us. We're in the same situation as you, @ebeyrent: Workbench 7.x-1.2, views_ui disabled. Works great!
Comment #41
leolandotan CreditAttribution: leolandotan as a volunteer and at Promet Source commentedI'm also having this issue and as stated by @bbinkovitz on comment #8, this can be reproduced by going to the admin/content/workbench page or just visit the page more than once like just refresh the page the error them is shown.
Indeed the patch in comment #1 removed the error.
Some modules versions used
Comment #42
joaocsilva CreditAttribution: joaocsilva as a volunteer commentedIn my case the module views_ui was disabled and for some reason it was causing the problem.
Without any patch and enabling the module views_ui the error went away.
Maybe it can help someone.