This function was previously included as part of the drupal_lookup_path() optimization: maintain a whitelist of Drupal paths patch. Unfortunately, that patch eventually took off into a very different direction, which removed this very handy function.

What does this function do? -> "Check if a path matches any pattern in a set of patterns."
Prototype: function drupal_path_match($path, $patterns);

Really simple, but oh so handy. There's only one use case in core, in block.module's "do/don't show block on these Drupal paths" functonality. But it's obvious that it can be used in many modules as a granularity mechanism.
I do realize it's a bit late for this to get in, but it's a really simple change, which can easily be verified to be working (by testing the aforementioned block.module functionality).
To be fair, this is actually not even new code. I'm just refactoring existing code.

Gábor Hojtsy had confirmed that he wanted to see this function in Drupal 6, so I hope that it will still be accepted :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kkaefer’s picture

Status: Needs review » Reviewed & tested by the community

Code looks good. Patch makes sense. Applies cleanly. Functions as announced. Ready to be committed.

Gábor Hojtsy’s picture

"FALSE if otherwise" should be "FALSE otherwise" I think.

Wim Leers’s picture

FileSize
2.47 KB

I think both are valid:

"foo if X happens, bar if otherwise"
OR
"foo if X happens, bar otherwise"

Anyway, updated patch attached.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

OK, we have drupal_lookup_path(), drupal_init_path(), drupal_lookup_path(), drupal_get_path() and friends, so why name this drupal_path_match() instead of drupal_match_path()?

Wim Leers’s picture

FileSize
2.47 KB

Fixed.

Wim Leers’s picture

Status: Needs work » Needs review

Forgot to update status.

Gábor Hojtsy’s picture

Status: Needs review » Fixed

Ok, committed, thanks.

Wim Leers’s picture

Yay! Thanks :)

moshe weitzman’s picture

Yay indeed.

Anonymous’s picture

Status: Fixed » Closed (fixed)