Problem/Motivation

The menu_set_active_trail() function implies with all its heart that it affects anything that involves the active trail in the menu, when in fact it doesn't actually do anything except affect breadcrumbs.

Breadcrumbs may be set by drupal_set_breadcrumb(), so these two functions are effectively duplicates of each other.

We now have menu_tree_set_path() and menu_tree_get_path() for setting and getting the active menu path.

Proposed resolution

The logic within the redundant and confusingly-named menu_set_active_trail() function should be moved to the menu_get_active_trail() function, where it is used and needed.

Remaining tasks

The patch in #4 is awaiting review.

User interface changes

None.

API changes

The redundant and confusingly-named menu_set_active_trail() function would be removed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pillarsdotnet’s picture

Title: Remove menu_set_active_trail()? » Remove misnamed and useless menu_set_active_trail() function.
Status: Active » Needs review
FileSize
8.83 KB

Patch removes the menu_set_active_trail() function by moving most of its logic into the menu_get_active_trail() function, instead.

pillarsdotnet’s picture

(sigh) one-line correction.

pillarsdotnet’s picture

Issue tags: +Documentation

Tagging for documentation team review of the updated docblocks.

pillarsdotnet’s picture

Updated patch, made considerably smaller by moving menu_get_active_trail() where menu_set_active_trail() used to be.

pillarsdotnet’s picture

Issue summary: View changes

Quote relevant text from parent issue summary.

pillarsdotnet’s picture

Issue summary: View changes

prettifying.

pillarsdotnet’s picture

Issue summary: View changes

Start using summary template.

chx’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Documentation +Needs change record
pillarsdotnet’s picture

Issue tags: -Needs change record
sun’s picture

Status: Reviewed & tested by the community » Needs review

I see three callers to the getter:

http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_get_ac...
http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_get_ac...
http://api.drupal.org/api/drupal/modules--toolbar--toolbar.module/functi...

Without a setter, there's possibly no way to adjust/override/customize the behavior of these callers.

While there is indeed hook_menu_breadcrumb_alter(), there's no equivalent to that regarding menu_get_active_title() or drupal_get_title(). Especially the behavior of the last caller (Toolbar) would effectively be hard-coded and non-customizable.

Changes done via menu_set_active_trail() stick for the remaining execution of the request, and automatically apply to all possible consumers of the trail.

To me it seems like we're removing the ability to easily customize the active trail including all dependent behavior/functionality.

I think this needs more careful reviews.

Especially maintainers of menu-related contributed modules should chime in here; e.g., @JohnAlbin.

--
P.S.: Change notifications should be created after a change was done, not before.

pillarsdotnet’s picture

Status: Needs work » Needs review

P.S.: Change notifications should be created after a change was done, not before.

Which begs the question -- is there any way to unpublish one, once it's created?
EDIT: Figured it out. See #1313844: Please delete http://drupal.org/node/1313534

pillarsdotnet’s picture

To me it seems like we're removing the ability to easily customize the active trail including all dependent behavior/functionality.

The parent issue claims that menu_set_active_trail() does not, in fact, affect the active menu trail; it only affects the breadcrumb trail.

I dunno, personally; I'm just knocking out low-hanging fruit like a good little code-monkey.

JohnAlbin’s picture

Status: Needs review » Needs work

I admit I'm a bit confused why we are removing menu_set_active_trail() but leaving menu_get_active_trail(). Sun's points are valid.

IMO, we need to kill off some pair of menu/breadcrumb/trail functions because we have at least one pair too many. And menu_set/get_active_trail looks like the easiest to knock off.

pillarsdotnet’s picture

Okay; removed change notice. Unfollowing since this isn't likely to go anywhere this year.

xjm’s picture

xjm’s picture

Issue summary: View changes

wordsmithing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Status: Needs work » Closed (duplicate)

Stumbled on this while waiting for a long test to run.

menu_set_active_trail and menu_get_active_trail were removed in #2237963: Remove dead menu system code: menu_get_active_trail() and friends. Therefor, marking this closed as a duplicate.