To understand what's going on here let's start with search. When you search for 'foo' you want to see tabs that point to 'search/node/foo' and 'search/user/foo'. This requires some facility that rewrites the links when they are rendered. Instead of using a 'rewrite callback/arguments' we are using 'search/node/[search_get_keys]'. There are similar challenges when rendering the link for 'my account', 'my blog', 'my recent posts' in the menu or as a tab -- they need to change the wildcard in the link to the current user id.
So, we have node edit defined as 'node/[node_from_arg]/edit' and we need to determine whether we want to display this tab or not. To do that, we need to load the node specified by the arg and node_access it. This is what map callback did until now, but I decided it to be simpler if I roll this activity inside node_from_arg -- this way, you need to specify one function and that handles both operations.
Actually, three, because for the function user_from_arg , we needed to distinct between links in tabs (user/[user_from_arg]/edit) and the menu (my account, blog). Otherwise, you either would nto be able to view other user than the current or you won't have tabs for the current user.
The issue title comes from the fact that the various _from_arg functions are very similar.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | menu_60.patch | 54.71 KB | webchick |
| #27 | menu_59.patch | 53.5 KB | webchick |
| #25 | menu_58.patch | 54.11 KB | webchick |
| #23 | menu_57.patch | 53.5 KB | chx |
| #22 | menu_56.patch | 53.74 KB | chx |
Comments
Comment #1
chx commentedDoh. The new schema.
Comment #2
webchickThis is a re-roll with a missing comma in the install file and missing < in tracker.module.
asimmonds and I were testing and found a few different issues:
- No "my recent posts" tab in tracker
- node/#/edit doesn't work
- admin/content/taxonomy/edit/vocabulary/vid is a 404.
Comment #3
chx commented% joins map callback in the graveyard per Dries' request -- we now have one unified syntax, if you want a generic wildcard, then you write something like
book/export/[]/[]. And, a few more fixes.Comment #4
webchickThis patch includes asimmond's fix for the forum admin pages, as well as some documentation for the _menu_access function that chx and I worked on.
Comment #5
dries commentedDoes that fix all problems or are there still some open issues? Will this require a second tabs patch?
I'll test this patch ASAP.
One small thing, looking at the patch, the syntax {foo} might be slightly more intuitive than [foo]. No need to change that now, but probably something we'll want to gather some feedback about.
Comment #6
chx commentedThis adds back all primary tabs. N-levels of tabs is the final touch -- I can roll that into this if you want. It's not hard, requires no API change.
Comment #7
chx commentedN levels of tabs. There is no point in implementing just two. The difference to the previous patches is very small, I just added a loop to the tabs.
Comment #8
chx commentedUgh. That was uploaded from my old CVS checkout. Here is the real one, from my bzr working tree.
Comment #9
chx commentedNow, the N-levels of tabs seem to work -- with the previous patch, if you were on a secondary tab , the primary did not appear. Now it does. We inspect the all levels above and below where we stand now. So, for user/1/edit/test we inspect tabs user/1/edit/test/* and then user/1/edit/* and then for user/1/* and that's it
Comment #10
chx commentedErm, my index.php change sneaked in, otherwise same.
Comment #11
chx commentedNow we only two operations. The menu builder now runs three passes but the actual work is not more, just arranged in a different fashion. The first pass rips out the callback from paths so in pass 2 & 3 we do not have a separate
user/[user_current]anduser/[user_from_arg]but just one pathuser/[]the one used for matching anyways. Note that pass 1 is almost exclusively router stuff while pass 2 only deals with menu stuff. The split in pass 3 is also very visible. The pieces are coming together.Comment #12
chx commentedMore comments.
Comment #13
chx commentedThis patch is the result of the sheer brilliance of Steven and my attempts to realize his genius thoughts. Now you have paths like
node/%node/editwithout any helper functions. It's magic :) actually, it utilizes node_load. I tested with user, node and search tabs.Comment #14
chx commentedSystem.install
Comment #15
chx commentedAccording to forngren this is RTBC he tested all the tabs aside from the outline and the category tab but those I checked . Also, we have a Selenium test in the making -- stay tuned.
Comment #16
forngren commentedYes, patched tested and approved.
(subscribing)
Comment #17
chx commentedTheme fix.
Comment #18
dries commentedThis seems like special-case code that needs to be removed. I'd prefer to have a clean and well-definied API rather than one that exploits certain accidentical patterns in the code. Maybe the _load should not be removed, but then we'd still need to unify _from_arg and _load. Having two ways to accomplish something does more harm than good.
Comment #19
chx commentedthe _from_arg and the _load are two different things. The best example is, I believe forum_from_arg , which is quite different from forum_load . However the order was wrong , now _from_arg overrides _load as it should be.
Comment #20
dries commentedI don't understand. Can you explain this more/better?
Comment #21
chx commentedNo. Please read forum_load and forum_from_arg. You will see two functions that are absolutely different.
Comment #22
chx commentedI rather give in than debate over this, from_arg is gone for good. As this was a search-and-replace operation retesting is not necessary. The following files are changed from the previous patch: menu.inc , forum.module, filter.module, user.module
Comment #23
chx commentedThis let me simplify the menu_translate function. Yay.
Comment #24
asimmonds commentedWith the anonymous user, I get:
* warning: Invalid argument supplied for foreach() in .\modules\user\user.module on line 57.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT * FROM users u WHERE in .\includes\database.mysql.inc on line 172.
For the anonymous user, user_current_to_arg() returns a 0, which is not placed into $path_map in _menu_translate() so user_current_load() is then called with a empty string.
Wrapping a isset() around this $return in _menu_translate() seems to fix it for this.
Comment #25
webchickI can confirm asimmonds's findings. Here's a patch with the isset() added.
The only remaining bug I could find was that profile categories don't seem to show up. To reproduce, enable profile module, add some field, and go to user/1/edit. The tab to edit the field isn't there.
Comment #26
webchickBtw, I tested this pretty thoroughly to thank chx for all the time he spent on the elusive login issue; I enabled all core modules (except menu), hit all URLs with tabs on them, including previous troublespots (tracker, search, forum), so I'm pretty sure once this is fixed, this sucker's ready to go.
Comment #27
webchickHere's above patch without settings.php. :P
Did some more digging... looks like menu_rebuild() isn't being called when profile fields are created, since after putting that in index.php it worked fine. Still investigating.
Comment #28
webchickOK I think this does it. I added a menu_rebuild() right after the cache_clear_all() in profile_field_form_submit.
Marking back for review.
Comment #29
dries commentedCommittah-ed! :)
Comment #30
(not verified) commented