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.
The documentation for the menu_unserialize function describes a $data parameter of array('view', 1) then describes a return value that would be appropriate to a $data parameter of array('node_load',1). Also, the api filters triggered by the 'unserialize(' appear to be corrupting part of the descriptive text. Trivial patch to fix both problems attached.
Comment | File | Size | Author |
---|---|---|---|
#10 | 408882-10.patch | 2.95 KB | jhodgdon |
#8 | 408882-8.patch | 2.96 KB | jhodgdon |
#5 | 408882.patch | 2.97 KB | jhodgdon |
menu.inc_.patch | 683 bytes | pillarsdotnet | |
Comments
Comment #1
brianV CreditAttribution: brianV commentedTrivial patch. Documentation now matches function. RTBC
Comment #2
Gábor HojtsyGet committed to Drupal 7 and backport after that please.
Comment #3
webchickHm. While I agree this is fixing a bug in the documentation, I wonder if we could instead re-phrase the docs here so they... make any sort of sense. ;)
"if $data is a serialized array('view', 1) and $map is array('node', '12345') then 'view' will not be changed because it is not an integer, but 1 will as it is an integer."
Um. What? :)
This whole function documentation could stand to be re-written so that it answers the questions:
1. What the heck does this do?
2. Why the heck would I ever want to use it?
3. What's a thorough example of how core is using it? (I kind of get what it's alluding to here, but not quite)
pillarsdotnet, any chance you're up for this, since you obviously understand the function well enough to spot errors in its documentation?
Comment #4
pillarsdotnet CreditAttribution: pillarsdotnet commented@Gabor -- Sorry; don't know if D7 even has the same function. Still trying to wrap my head around D6, months after the upgrade.
@webchick -- Yeah, the explanation threw me, too. I had to hand-simulate the code to figure it out, and thee weeks later I neither exactly remember nor wish to repeat the experience. IIRC, the function is used internally to convert menu_router database records to PHP class data which is then cached. There's no reason to use it outside that context.
Finding and fixing problems like this one is a side-effect of my usual debugging strategy:
if (!assert("something-assumed-to-be-true")) { dump-backtrace-to-log; dump-relevant-variables-to-log; temporary-workaround; }
The next time I get to step 3, I promise to try and document my findings a bit better. Unfortunately, that won't help the D7 guys, but I'm not smart enough to brave D7 on a production website. Not yet.
Comment #5
jhodgdonHow about this version?
Comment #7
jhodgdon#5: 408882.patch queued for re-testing.
Comment #8
jhodgdonThe patch above no longer applied. Here's a reroll. I also fixed a couple of other issues, like wrapping the lines closer to 80 characters, and fixing wording in a couple of spots.
This still needs review. THe last patch was about a year old. Hmph.
Comment #10
jhodgdondoh!
Comment #12
jhodgdon#10: 408882-10.patch queued for re-testing.
Comment #13
jhodgdonNot sure what "failed to drop checkout database" means, but I don't think it was due to this patch?
Comment #14
jhodgdon#10: 408882-10.patch queued for re-testing.
Comment #15
jhodgdon#10: 408882-10.patch queued for re-testing.
Comment #16
mr.baileysReviewed the patch and found it to be a great improvement over the current documentation for
menu_unserialize
.The new documentation does a good job of answering the questions raised by webchick in #3 (although this is a function that has little use outside of the Drupal's menu internals, so the question "Why the heck would I ever use it?" is probably best answered with "You shouldn't" :), and contrary to the existing docs the updated text actually makes sense after carefully reading it. As an added bonus it adds the missing one-line summary.
We could expand even further and give an actual example:
... but for a function that's used only by Drupal core itself, I think the last paragraph is sufficient.
Comment #17
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.