This module allows the user to add menu paths that don't exist on the site (either because they don't *yet* exist, or you've got a multi-server web setup with only part being served via Drupal (but the menus on the Drupal pages need to link to the non-Drupal pages).

http://drupal.org/project/any_menu_path
http://drupal.org/sandbox/caseyc/1670304

git clone --recursive --branch 7.x-1.x caseyc@git.drupal.org:sandbox/caseyc/1670304.git any_menu_path

Drupal version: 7.x

Reviews of other projects for Review Bonus program:

Reviews of other *other* projects for Review Bonus program (Part Duex):

Comments

brazorf’s picture

Status: Needs review » Needs work

Hello there,

1. Developement is under the master branch, you should switch the dev line in a standard named branch like 7.x-1.x and empty the master itself
2. You did not wrap text (@see .module:17 i.e.) in t(), so it's not localized
3. I'ts recommended to delete your variables in hook_uninstall, best practice is placing it in sneaky_menu_path.install file
4. I would suggest you to run ventral and fix those coding issues

Regards,
brazorf

caseyc’s picture

Status: Needs work » Needs review

brazorf, thanks for the review.

1. Done! Branch now at 7.x-1.x and master branch removed.

2. Woops! Done.

3. Added an uninstall function in a .install file

4. No errors reported with ventral now.

Thanks!

andyhawks’s picture

caseyc,

  • Good job cleaning up ventral issues.
  • Have you reviewed the thread at http://drupal.org/node/308263? Please review that thread and point to this module for review; you might offer up this module's checkbox enforcing path validation approach as an adminable setting for 8.x core.
  • Based on thread activity this seems like it will be useful to many people. You might consider changing the name to something less subversive and more descriptive like 'Menu Path Validation Enforcement'.
  • Is the direct $_SESSION manipulation necessary?
caseyc’s picture

Andy, thanks for your feedback.

I considered making the name something along those lines - but aside from my fingers getting upset with me at the thought of typing "drush dl menu_path_validation_enforcement", I think it strikes on something bigger that's important. We aren't bypassing validation, per say. Just one aspect of it, right? So this was designed such that any other validation that is done - or will be done in the validate function will remain. We are just bypassing the relative url aspect of it. I don't know what other things we'd be validating there - but I don't want the module name to be misleading if something new is added to core.

So what would you name it in light of that?

I'll post to the thread regarding the 8.x core for review.

Regarding the SESSION manipulation - we considered a few different approaches and this was the simplest. What might you suggest as an alternative? Would really appreciate your thoughts.

andyhawks’s picture

Status: Needs review » Reviewed & tested by the community

casey,

Yep drush dl menu_path_validation_enforcement is long, maybe any_menu_path? all_your_menu_path_are_belong_to_us ?

The Session manipulation isn't a big deal here, you're doing a simple set and unset here with trusted users. Since you're already storing and retrieving the 'sneaky' mlid array var between validation and submit though, I might've just
appended it to that variable - move the modified mlid's into a nested array and added an 'active' array of uid indexes or something. That's misusing variable_set, yeah, but avoiding session. But again, don't think it really matters.

This looks good to me, setting to RTBC and curious what the community will have to say!

clemens.tolboom’s picture

Regarding $_SESSION

Why not use a #value form item and for validation and submitting use its value and set it though $form_state.

$form['sneaky_menu_path_wanted_value'] = array(
  '#type' => 'value',
  '#value' => 'http://example.com',

Regarding module name:

the module overrides/bypasses the validation and not enforces. Thus I like any_menu_path.

kerasai’s picture

Regarding $_SESSION

I think the cleanest thing to do would be to stick $form_state['values']['link_path'] into $form_state['storage']


function sneaky_menu_path_menu_edit_item_before_validate($form, &$form_state) {
  // remove
  $_SESSION['sneaky_menu_path_link'] = $form_state['values']['link_path'];
  // replace with 
  $form_state['storage']['sneaky_menu_path_link_path'] = $form_state['values']['link_path'];
}

function sneaky_menu_path_menu_edit_menu_submit($form, &$form_state) {
  // remove
  $link_path = $_SESSION['sneaky_menu_path_link'];
  // replace with
  $link_path = $form_state['storage']['sneaky_menu_path_link_path'];
}

There are also some other little things you can do to make the code "cleaner" but those are nit-picky. Nice job on the concept and figuring out how to make it work.

klausi’s picture

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

caseyc’s picture

@andyhawks - module name updated to any_menu_path which I agree is much more suitable, if a little less sneaky ;)

@bmoresafety20 - suggestion taken. Works like a charm.

@klausi - I'll review ASAP and message you when I'm through.

caseyc’s picture

Issue summary: View changes

Updating repo to 7.x-1.x instead of master branch.

mitchell’s picture

Status: Reviewed & tested by the community » Needs work

Great feedback here. Looks like people have really been waiting for this :)

Re module name:
IMHO, this is worth getting some positive feedback that hopefully matches the code reviews' sentiments before going live. I'm partial to making the module name prefix "menu_path" or "menu" and choosing the best concept id for its suffix. Here are a few suggestions: _nocheck, _any, _always_valid, ~_preexisting, or _placeholder. I like the latter most, ie menu_placeholder or menu_path_placeholder. Any Menu Path is descriptive, but I think following naming conventions has tons of benefits.

Re similar efforts (for collaboration sake. none are 'duplicate efforts', so this is good on that front):
I saw Menu Editor also referenced in #308263: Allow privileged users to bypass the validation of menu items. Could you please describe how your approach differs from that module's? This isn't a show stopper for your own work here, but maybe they could factor out that feature if that's what's keeping it unstable. Also, that core issue seems like it really needs some knowledgeable reviewers, so if you could weigh in there with an advisable approach and patch review, I'm sure the core maintainers would really appreciate it.

All in all, this is pretty much rtbc for me.

caseyc’s picture

Thanks mitchell.

a. The Menu Editor module does not provide this feature. It was only mentioned in #308263: Allow privileged users to bypass the validation of menu items to point out that the Menu Editor module would only let you populate menus with content that did not yet exist. By contrast, our module is also meant to point to actual paths outside the Drupal root.

b. The ticket at #308263: Allow privileged users to bypass the validation of menu items is actually for Drupal Core and has been assigned to D8 since January, with requests not to change it back to D6 or D7. Kittens have been threatened. My client has a need for a D7 module. The core patch won't be backported until it's rtbc in D8. They don't have a stable patch yet and the last submission was in January.

Also, I've renamed my module to "any_menu_path" per the suggestions above (even though I realllly like sneaky_menu_path). ;)

caseyc’s picture

Issue summary: View changes

Updated sneaky_menu_path to any_menu_path

caseyc’s picture

Issue summary: View changes

Updating for Review Bonus program

caseyc’s picture

Issue tags: +PAreview: review bonus

Tagging for reviews bonus program.

klausi’s picture

You need to set the status to "needs review" if you want to get a review. See http://drupal.org/node/532400

caseyc’s picture

Status: Needs work » Needs review

Done!

bhosmer’s picture

Status: Needs review » Reviewed & tested by the community

It works as designed and does what it says.

klausi’s picture

Title: Sneaky Menu Path » Any Menu Path
Status: Reviewed & tested by the community » Needs work
Issue tags: -PAreview: review bonus

manual review:

  1. This project is too short to approve you as git vetted user. We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed. However, we can promote this single project manually to a full project for you.
  2. "'#title' => 'No Path Validation',": all user facing text must run through t() for translation.
  3. "variable_get('any_menu_path', array());": why is that variable needed? I don't see the need to store which menu links have circumvented the path validation? It is only useful for the #default_value of the checkbox, but you could simply check on the fly if the path exists. If not, then path validation must have been skipped when the menu link was created.
  4. any_menu_path_menu_edit_menu_submit(): why do you run the query with link_path and link_title, why can't you use mlid from $form or $form_state? And you should use db_select() instead of db_query().

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

bhosmer’s picture

At the risk of just shooting myself in the foot here, I'd like to add a vote that the module is useful. A denial based strictly on how many lines of code might not be a good trend to start towards.

If the module meets standards, has no security issues, and the applicant has shown they are a valuable member of the community, basing denial on an application based just on how many lines of code are in it should be reconsidered.

klausi’s picture

We do not deny short modules, where did you read that? (need to clarify the docs)

We just can't grant the git vetted user role. However, we can promote this single project manually to a full project for the applicant.

bhosmer’s picture

My apologies, I misinterpreted this:

This project is too short to approve you as git vetted user. We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed. However, we can promote this single project manually to a full project for you.

And I had derived some of it from this discussion: http://groups.drupal.org/node/195848

caseyc’s picture

Status: Needs work » Needs review

@klausi:

1) The project is now 170 lines of code after I've added some slick functionality.

2) I t()'d that string.

3) I disagree. It could not be set due to some error, some other contrib module doing things. Anyone can play with that variable in their own form_alter.

In thinking about it, the main reason I did this was so that I could see which paths were being overridden with my module. So I made a new menu_hook with a listing of overridden paths, available in the Configuration menu: admin/config/content/any_menu_path

(README updated accordingly)

This (and my new addition of some permission validation) has put my module over the 120 line threshold.

4) Good catch. Thanks! Fixed!

rupl’s picture

Status: Needs review » Reviewed & tested by the community

This is a great module and I'd really like to see it promoted to a full project. Couple of minor things I noticed:

  1. What do you think about changing the label to "Skip path validation"? It might help first-time users understand more quickly.
  2. On the subject of the variable holding non-existent paths, I really like having the admin config page that lists them so that I could check on it from time to time and clear out paths that have been created and so forth. It's a valuable feature.
  3. Do you think we could re-adjust the core form weights to group the new checkbox with the "Enabled" and "Expanded" options?
    $form['any_menu_path_no_path_valid'] = array(
      '#type' => 'checkbox',
      '#title' => t('No Path Validation'),
      '#description' => t('If this is enabled, Drupal will allow you to enter any path (even non-existent ones).'),
      '#weight' => -1,
    );

    // Set a few weights on the fields provided by core to group this option
    // with the "Enabled" and "Expanded" checkboxes
    $form['link_title']['#weight'] = -5;
    $form['link_path']['#weight'] = -3;

Since none of the above points are show-stoppers in terms of proper module development, I'd say this is RTBC.

klausi’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +PAreview: security

manual review:

  1. "'data' => 'Menu Title'": all user facing text must run through t() for translation. Please check all your strings. Same for "'empty' => 'No menu links overridden with the Any Menu Path module...'," and others.
  2. any_menu_path_view_paths(): this is vulnerable to XSS exploits. If I have a menu item with a title <script>alert('XSSmenu');</script> I get a nasty javascript popup on that page. You need to sanitize user provided input before printing if it has not been sanitized before. Please read http://drupal.org/node/28984 again.
caseyc’s picture

Status: Needs work » Needs review

@rupl:

1) Thanks for the suggestion. Someone actually has brought this up before and I thought that it would be a bit misleading because it actually doesn't skip validation - you'll notice it just skips one part of the validation (the url). So I wouldn't want someone to think any other aspects of validation (especially extra ones provided by some other module in hook_validate) were being skipped.

2) Thanks for the feedback!

3) Done! Added to the module. Thanks for the suggestion.

@klausi

1) Sorry about that. Sloppy on my behalf - wasn't thinking. Fixed there and other places too.

2) Doh! I knew that! I was in all three security sessions at BADcamp too. Wasn't thinking there too. I'm trying to be much more mindful of XSS in my code, so thanks for pointing this out. I'll be hyper aware now.

Thanks for the help!

caseyc’s picture

@clemens.tolboom - once I get unvetted git commit access, my plan is to start contributing a few of the 30 modules I've developed for clients over the past several years.

I'd also like to start contributing to core issues. And when a client wants me to upgrade a module from d6 -> d7, I'm contacting the maintainer to be a co-maintainer (if the project status says it's looking for a co-maintainer).

I'd really like to see some good faith from the community though by approving this module first and giving me unvetted git commit access. I've done everything that's been asked of me and I've followed all the rules. I've patiently worked at this when I've been able since July, including completing the reviews bonus program.

I understand that this is the process, however it's starting to feel a bit defeating...and a bit like the community doesn't really want new contributions from new folks.

bhosmer’s picture

@caseyc

I completely empathize with what you are feeling right now. I went through this same process almost a year ago with a module that I thought would be useful, only to have it denied because another module incorporated similar functionality, only with more complexity and other things the user might not want.

I just went through this same process again, and was approved this time for a different module.

I got frustrated like you the first time, and this second time the process was a little frustrating and discourage, but looking back I am thankful for the experience.

Please stick with it and keep trying.

caseyc’s picture

@bhosmer - thanks for the encouragement! I'll keep at it!

What's the next step on this module? Everything should be in order right? Just needs to be approved and we're good to go?

bhosmer’s picture

Status: Needs review » Reviewed & tested by the community

@caseyrc:

I did a PAReview for you for your latest updates: http://ventral.org/pareview/httpgitdrupalorgsandboxcaseyc1670304git-7x-1x
No errors! Congratulations!

I also downloaded and installed your latest update, and it works as designed.

Also, great forethought in adding this: admin/config/content/any_menu_path which adds that nice extra touch for usability.

Marking RTBC.

Now, if you do three more PAReviews, and no one else raises any issues, Your module should be approved within a week. You just have to be patient for the process.

caseyc’s picture

@bhosmer - thanks!

Three more reviews completed (see page notes).

caseyc’s picture

Issue summary: View changes

Changing wording of review bonus explanation.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, caseyc!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

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.

Thanks to the dedicated reviewer(s) as well.

caseyc’s picture

@klausi, really appreciate it!

bhosmer’s picture

Congratulations!

bhosmer’s picture

Issue summary: View changes

Updating with news review bonus review links.

clemens.tolboom’s picture

Yay :-)

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

Anonymous’s picture

Issue summary: View changes

Added real project path