Module name

Alias Hierarchy

Sandbox link

http://drupal.org/sandbox/djac/1331114

Git Repository

git clone --branch 6.x-1.x http://git.drupal.org/sandbox/djac/1331114.git alias_hierarchy

Drupal core

6.x

Notes

  • Although the initial commit to git is recent, this module has been used in a production environment since December 2010.
  • Versioned as beta1 because ideally, we would use a custom token defined by the module. I ran into issues when trying to implement the token, so this remains as a to-do.

Description

Alias Hierarchy regenerates a node's URL/path alias and then recursively updates any children nodes. The module is also triggered when changes are made to menu items.

The Alias Hierarchy module makes use of the Pathauto module and extends its functionality. The idea behind the module is that we want node aliases to match the menu system's structure. This can be accomplished with Pathauto alone, however, there are scenarios where aliases do not get updated correctly to match changes made to a node.

Alias Hierarchy addresses those scenarios by implementing the following:

1) regenerate a node's alias if the node is moved in the menu system.

2) regenerate children aliases after editing a node or moving a node in the menu system.

3) allow for a 'custom alias' field, where users are able to change the last string in a node's alias.

The alias will be generated first using the custom alias. If it is blank, the menu title will be used. If that is blank, the node title is used as a default.

Comments

chakrapani’s picture

Status: Needs review » Needs work

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

  • Run coder to check your style, some issues were found (please check the Drupal coding standards):
    Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards
    
    sites/all/modules/pareview_temp/test_candidate/alias_hierarchy.module:
     +5: [minor] There should be no trailing spaces
     +25: [minor] There should be no trailing spaces
     +26: [minor] There should be no trailing spaces
     +95: [minor] There should be no trailing spaces
     +124: [minor] There should be no trailing spaces
     +125: [minor] There should be no trailing spaces
     +138: [minor] There should be no trailing spaces
     +143: [minor] There should be no trailing spaces
     +173: [minor] There should be no trailing spaces
     +196: [minor] There should be no trailing spaces
     +200: [minor] There should be no trailing spaces
     +216: [minor] There should be no trailing spaces
     +234: [minor] There should be no trailing spaces
     +249: [minor] There should be no trailing spaces
     +272: [minor] There should be no trailing spaces
     +273: [minor] There should be no trailing spaces
     +274: [minor] There should be no trailing spaces
     +275: [minor] There should be no trailing spaces
     +307: [minor] There should be no trailing spaces
     +316: [normal] String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms
     +317: [normal] String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms
     +320: [normal] String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms
     +336: [normal] String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms
     +385: [minor] There should be no trailing spaces
     +397: [minor] There should be no trailing spaces
     +424: [minor] There should be no trailing spaces
     +431: [minor] There should be no trailing spaces
    
    Status Messages:
     Coder found 1 projects, 1 files, 4 normal warnings, 23 minor warnings, 0 warnings were flagged to be ignored
    
  • Remove "version" from the info file, it will be added by drupal.org packaging automatically.
  • ./alias_hierarchy.module: The description on the line after the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    256- * If the mlid is the lowest for the given link path.
    482- */
    
  • Bad line endings were found, always use unix style terminators. See http://drupal.org/coding-standards#indenting
    ./alias_hierarchy.info:    ASCII text, with CRLF line terminators
    alias_hierarchy.info
    

This automated report was generated with PAReview.sh, your friendly project application review script. Go and review some other project applications, so we can get back to yours sooner.

djac’s picture

Status: Needs work » Needs review

Thanks chakrapani. I moved the code into the 6.x-1.x branch and applied the fixes that you outlined above.

patrickd’s picture

djac’s picture

Status: Needs work » Needs review
197 | ERROR | Doc comment for var $all_children does not match actual variable
| | name &$all_children at position 1
437 | ERROR | Doc comment for var $context does not match actual variable name
| | &$context at position 2

The only remaining 2 warnings are asking that I add & before variable names in @param documentation. I've skipped removing the & after seeing recent Drupal 8 core code where the & is being removed.

jthorson’s picture

Status: Needs review » Needs work

For the most part, things look pretty good.

My only concern would be with the possibility of XSS attacks ... the most likely culprit being inside of alias_hierarchy_form_alter:

// Display the path prefix (the part that goes before the custom alias).
$parent_menu_link = menu_link_load($node->menu['plid']);
$parent_alias = '';
if (!empty($parent_menu_link['link_path'])) {
  $parent_alias .= drupal_get_path_alias($parent_menu_link['link_path'], $node->language) . '/';
}
$form['path']['path_prefix'] = array(
  '#type' => 'textfield',
  '#title' => t('Path prefix'),
  '#default_value' => $parent_alias,
  '#description' => t("The prefix cannot be changed and is derived from the node's parents."),
  '#weight' => -1,
  '#disabled' => TRUE,
);

In this case, I'm not sure you can fully trust the drupal_get_path_alias() function to return 'safe' text; as the alias may be user-supplied, and Drupal's common pattern is to sanitize on output instead of input.

It felt like you may have been missing more check_plain() calls, but I'm assuming that pathauto_cleanstring() takes care of sanitization.

Other than that ... toss a sanitization function around $parent_alias (or explain why it isn't needed), and this is pretty much ready for an RTBC status.

Thanks for your patience, and sorry for the wait!

jthorson’s picture

Status: Needs work » Reviewed & tested by the community

Okay ... being a textfield, the above should be okay.

Let's pass this on to the Git Admins. :)

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Looks great.

Thanks for your contribution, djac! Welcome to the community of project contributors on drupal.org.

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Specify branch in git clone command.