API page: http://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_i...

Based on the following code, the function can return false.

if ($map === FALSE) {
  $router_items[$path] = FALSE;
   return FALSE;
}

Return value

The router item, an associate array corresponding to one row in the menu_router table.

Should be something like:

The router item, an associate array corresponding to one row in the menu_router table, or FALSE.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Title: Function can return false » Document that menu_get_item() can return false
Version: 7.x-dev » 8.x-dev
Issue tags: +Novice, +Needs backport to D7

Thanks for noticing and reporting this! The documentation of the return value should indicate under what conditions FALSE can be returned.

mkadin’s picture

Here you go. Didn't want to repeat the explanation from _menu_translate() docs.

Did a little English work in the _menu_translate() docs as well.

D7 backport coming shortly.

mkadin’s picture

Status: Active » Needs review
mkadin’s picture

D7 patch as well.

Status: Needs review » Needs work

The last submitted patch, drupal-menu-get-item-docs-1802760-4-d7.patch, failed testing.

jhodgdon’s picture

Please read http://drupal.org/node/1319154#multiple-versions regarding uploading D7 patches too soon (however, thanks for the patches!).

Regarding the d8 patch, I think we need to go back up one line and fix one thing:

*   The router item, an associate array corresponding to one row in the

associate -> associative

Also, the whole thing ... well it still seemed a bit confusing to me. With this patch, the @return reads:

The router item, an associate array corresponding to one row in the
menu_router table or FALSE. The value of key map holds the loaded objects.
The value of key access is TRUE if the current user can access this page.
The values for key title, page_arguments, access_arguments, and
theme_arguments will be filled in based on the database values and the
objects loaded. If an error occurs when objects are loaded via
_menu_translate(), FALSE will be returned.

I had a lot of trouble making sense of this paragraph -- I would suggest reworking it like this:

Either the router item or, if an error occurs, FALSE. A router item is an associative array corresponding to...

mkadin’s picture

Status: Needs work » Needs review
FileSize
1.49 KB

Hows this?

jhodgdon’s picture

Status: Needs review » Needs work

Better, thanks! A few small typographical errors:
- There should be only one space after "." at ends of sentences.
- "associate array" => "associative array"
- I think it would be even easier to read if it said "The value *corresponding* to key 'map' is..." etc. (obviously, without the **).

mkadin’s picture

Agreed, I didn't like the way the key value pairs were describe either. Here's a shot at it.

jhodgdon’s picture

Assigned: Unassigned » jhodgdon
Status: Needs work » Reviewed & tested by the community

I like this version much better, thanks! Provisionally RTBC (pending bot), and I'll get it committed sometime soon (probably tomorrow, I'm done with commits for today).

jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks! Committed to 8.x and 7.x.

Automatically closed -- issue fixed for 2 weeks with no activity.