Project:Chaos tool suite (ctools)
Version:6.x-1.9
Component:Page Manager
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I recently updated a D6 site, which has a Panels page, and found that the View and Edit Panels tabs went away. I traced the problem to line 317 in the 6.x-1.9 .../ctools/page_manager/plugins/tasks folder.

The current version (1.9) has the following lines of code (lines 316 and 317):

// Add a fake tab for 'View' so that edit tabs can be added.
if (user_access('administer page manager') && (!isset($page->menu['type']) || !in_array($page->menu['type'], array('tab', 'default tab')))) {

The standard View/Edit tabs usually added as menu_local_tasks are no longer there. The only thing that changed in this line between this version and the previous (1.8) was the addition of the "!" before the "in_array". When I remove the "!" the tabs return.

This change was made without a bug reference or original issue. The change was made by James Gillilad and committed on 07 Sept 11 with the following comment: Because tabs where incorrectly being matched and the "view" task not getting added, the edit task would sometimes end up being the only local task causing it to be hidden by the menu systems logic.

What was the use case that was employeed to verify that the change was needed and the solution worked correctly?

Comments

#1

Status:active» postponed (maintainer needs more info)

Without some specifics about what exactly you found, no one is likely to be able to help you. And it looks like you've done quite a bit of solid research, so simply sharing it here would probably be helpful.

#2

I see the same thing. All of my top-level panel pages have previously added/shown an "Edit Panel" local menu task/tab. It has always appeared next to a simple "View" tab, much like the typical "View" and "Edit" tab for a node, except in this case it is for a panels page. I assume that "View" tab I've always seen was being added by the code in question, surrounded by the "if" check on line 317.

I put some debug information within the "if" statement to see what was contained in $page->menu at that point. Here is a print_r() of my $page->menu that previously used to execute the code within the "if" statement, but now no longer passes the test:

Array
(
    [type] => normal
    [title] => Dashboard
    [name] => primary-links
    [weight] => 0
    [parent] => Array
        (
            [type] => none
            [title] =>
            [name] => navigation
            [weight] => 0
        )

)

This obviously means that $page->menu['type]' is set, so that part of the "if" statement doesn't pass, and the $page->menu['type']=="normal" and therefore the later part of the test also now fails (since the type isn't 'tab' or 'default tab').

The comment above line 317, included in the issue summary, clearly indicates this code should exist to add a "View" tab so that "Edit" tabs can be added, and that is what previously worked with panels. Now, due to this change, the "View" local task does not get added and therefore prevents the "Edit Panel" tab/local task from being added.

Was there any issue or test case which prompted the original change? The change appears to completely contradict the entire purpose for those lines of code. Perhaps panels should be doing something entirely different, but perhaps there was also a different/better solution in the first place. Without more data about the reason for the original change, it feels like this one commit should be rolled back.

For what it's worth, I did a backtrace to see how this code was called. The stack was short, going from menu_execute_active_handler() in index.php to call_user_func_array() in menu.inc with page_manager_page_execute being the function to call. This is presumably because my panel page has directly specified a menu item (the normal "Dashboard" shown above). Although I haven't created a simple test case to reproduce this, I suspect creating any top-level panel page and giving it a menu item would reproduce this situation where "View" and "Edit Panel" no longer appear with 6.x-1.9.

#3

As I re-read the commit comment for this issue, it feels like this change now CAUSES the exact thing which the comment was trying to fix.

Fix logic error sometimes hiding edit local tasks

Because tabs where incorrectly being matched and the "view" task not getting
added, the edit task would sometimes end up being the only local task causing
it to be hidden by the menu systems logic.

The panels "Edit" local tasks is now no longer visible. This code used to properly add the "View" tab, and now it does not. It really feels like this simple logic change in the "if" statement now causes exactly this problem.

If the core problem was that "tabs were incorrectly being matched", then shouldn't the fix be to properly match them?

It feels that either panels has always improperly added the "Edit" tab, or the cause of this commit was improperly adding the "Edit" tab. I only see my situation, and this commit appears to have caused the exact issue it claims to fix.

#4

Thanks for looking at this so quickly.

First, I need to amend my original description. I copied in the line of code from the wrong file, and my description was based on it, so it is backwards. The current page.inc (for 6.x-1.9) has the following line:

if (user_access('administer page manager') && (!isset($page->menu['type']) || in_array($page->menu['type'], array('tab', 'default tab'))))

This line does not have the not (!) operator before the in_array. The 1.8 verions did have the not operator, and it is the version that works for me. So in my description, instead of saying that the tabs returned when I removed the "!", I should have said that they returned when I added the "!" back in.

I'm not exactly sure what else you need, but I can tell you that

a) I have admin premissions on the page manager, so user_access('administer page manager') is true
b) $page->menu['type'] has the value of 'normal', so the !isset($page->menu['type']) is false
c) clearly, 'normal' is not in the array ('tab', 'default tab'), so !in_array($page->menu['type'], array('tab', 'default tab')) is true
d) also for the same reason, in_array($page->menu['type'], array('tab', 'default tab')) would be false, so both of the clauses that are or'ed together would be false, meaning that the block that builds the "fake" tab for 'View' would not execute.

I have uploaded a before and after screen shot from my web site.

AttachmentSizeStatusTest resultOperations
before and after image.png73.9 KBIgnored: Check issue status.NoneNone

#5

Status:postponed (maintainer needs more info)» active

just changing the status back to active since I gave more information, hopefully enough to evaluation the situation.

#6

The commit did fix a large number of cases. I'm not sure why this one isn't included there but I remember there being a lot of moving parts between this code and the menu system. I have a panel setup with a normal item and it isn't getting tabs but changing the negation isn't changing it. I'll continue looking but if it was possible to provide a simple test case I could install in a stock site it would help fix it faster.

#7

Hi James, thanks for getting back to me.

I was able to reproduce the problem from a fresh install of Drupal 6.26. Here are the steps that I followed:

a) setup the drupal-6.26 site
b) add module panels 6.x-3.10 (current version), enabling "Panels" and "Panel nodes"
c) add module ctools 6.x-1.8 (I intentially used the previous version, so that I could create my content using that version), enabling "Choas tools", "Page Manager" and "Stylizer"
d) create panel page, with the following summary values:
Storage: Normal
Status: Enabled
Path: /dashboard
Access: publicly accessible
Menu: Normal menu entry. Title: Dashboard. Menu block: Primary links.
Selection rule: always
Layout: Two column

When I view the /dashboard url, I can see the View and Edit Panel menu items. When I upgrade ctools to 6.x-1.9, these menu items disappear. When I edit line 317 in .../ctools/page_manager/plugins/tasks/page.inc by adding back in the not (!) operator before the "in_array", the menu on my dashboard returns.

Hopefully this is clear enough for you to see the problem as I'm seeing it. Please let me know if there is something more specific that I can add to help.

#8

One last comment. When I upgrade to 6.x-1.10 (which is now the most current version of ctools), I am seeing the same problem.

#9

What happens when you follow the steps in #7, but use 6.x-1.10 or 6.x-1.9 from the start? Are the menus showing ok then?

In #7
@wklyons

When I upgrade ctools to 6.x-1.9, these menu items disappear.

What are the steps *exactly* that you do to upgrade ctools?
Can you list them also... something like:

drush dl .... (or however you download it and replace it, go ahead and write out the steps)
run update.php (I dont know if this should be done here or after clearing the cache...)
drush cc all (or.. go to performance, clear cache... or where ever you go exactly to clear the cache)
go to url for the page /dashboard
reload, clearing the browser cache

#10

Hi YesCT

Thanks for your comments.

To update the ctools instance, I did not run drush, instead I downloaded it and ran update.php.

I tried your suggestion of creating the page in 6.10. When I do this, I do not see the menu items until I go into the Page.inc module and add the not operator back into line 317.

#11

ah! @wklyons you might be able to provide even simpler steps to reproduce that start with 6.10. Doing the upgrade might not be an influence at all.

#12

@wklyons Also, take your clean 6.10 you have with git, make a new branch, make the change in the one line to add the !, and do a git diff to 6.10 to create a patch. Uploading that patch here will make it easier for people to test adding that ! back in. http://drupal.org/node/1424598 is a good place to start. That is the documentation on the "Contributor task: Create a patch for a Drupal Core issue". You have to follow several links through a few pages to get to the git instructions to make the patch, but the documentation is pretty good.

#13

I talked to merlin about this and because of the way the menu system works there's no way to detect some cases where this code would need to be triggered. Because of the admin nature of the tabs and the trailing D6 usage it seems the thing to do it always add the tab if you're an admin. To be clear, just remove the in_array check entirely.

#14

Hi James, thanks for your response.

This sound reasonable to me, and should work fine for all. I will make this change for my client site, and assume that this will be included in a subsequent 6.x update to ctools (I'll be watching for it).

Thanks for your help with this.

#15

Hi James

Well, I spoke too soon, without actually testing your suggestion.

If I only remove the in_array portion of the code, then I still don't get the menu. The line that I'm left with is

if (user_access('administer page manager') && !isset($page->menu['type']))

but this equates to false, since the $page->menu['type'] is set as "normal"

The original line from version 6.x-1.8 reads:

if (user_access('administer page manager') && (!isset($page->menu['type']) || !in_array($page->menu['type'], array('tab', 'default tab'))))

which given that values of the various items equates to ( true && ( false || true )).

In the new version the line reads:

if (user_access('administer page manager') && (!isset($page->menu['type']) || in_array($page->menu['type'], array('tab', 'default tab'))))

which given that values of the various items equates to ( true && ( false || false )).

By removing the "in_array" clause, I'm left with ( true && false ).

#16

Remove the isset as well -- that actually is part of the in array check (it's a notice check) and including it actually worsens the issue.

JUST have the user_access() check.

If this functions, we'll need a patch we can commit.

#17

what merlin said. sorry for not being clear. :)

#18

@wklyons When you try and make a patch for this, ping me, or ask in irc. I think this might be your first time making a patch. It can be tricky the first time. But it is a really good thing to be able to do. :) And check out the doc I linked to in #12.

#19

And here goes the PATCH based on 6.x-1.10!
I faced the issues described, and from merlin's comment

JUST have the user_access() check.

let's give this patch a try.

AttachmentSizeStatusTest resultOperations
panel-edit-tab-1840590-19.patch625 bytesIgnored: Check issue status.NoneNone
nobody click here