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

The "Return value" section for the function says:

An array which contains the ancestors and placeholders. Placeholders simply contain as many '%s' as the ancestors.

This needs to be changed simply to:

An array which contains the ancestors.

Comments

jamix’s picture

Attaching the patch.

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

Thanks! We need to change the documentation of the whole function though, not just the return value. For instance, the first line says:

Returns the ancestors (and relevant placeholders) for any given path.

and that is no longer correct. The function documentation in general has some grammar issues and doesn't make a lot of sense to me... maybe it could be rewritten better?

Also, we have to patch Drupal 8.x first, then backport the patch to 7.x.

malcomio’s picture

Version: 8.0.x-dev » 7.x-dev
Issue summary: View changes

menu_get_ancestors doesn't exist in D8 any more

sivaji_ganesh_jojodae’s picture

Status: Needs work » Needs review
StatusFileSize
new939 bytes

Fixed return value and example. Propose as how the whole documentation could be changed,

/**
 * Returns the ancestors (and relevant placeholders) for any given path.
 *
 * For example, the ancestors of node/12345/edit are:
 * - node/12345/edit
 * - node/12345/%
 * - node/%/edit
 * - node/12345
 * - node/%
 * - node
 *
 * To generate these, we will use binary numbers. Each bit represents a
 * part of the path. If the bit is 1, then it represents the original
 * value while 0 means wildcard. If the path is node/12/edit/foo
 * then the 1011 bitstring represents node/%/edit/foo where % means that
 * any argument matches that part. We limit ourselves to using binary
 * numbers that correspond the patterns of wildcards of router items that
 * actually exists. This list of 'masks' is built in menu_rebuild().
 *
 * @param $parts
 *   An array of path parts; for the above example,
 *   array('node', '12345', 'edit').
 *
 * @return
 *   An array which contains the ancestors.
 */
jhodgdon’s picture

Status: Needs review » Needs work

Thanks! This does not address comment #2 fully though.

jhodgdon’s picture

Also it is not necessary to paste the final result into a comment. Just upload the patch file next time. Thanks!

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.