bad hook data getting captured

joachim - July 15, 2009 - 14:31
Project:Module Builder
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

translation_link_alter
custom_url_rewrite_outbound is not a hook, it's a function you can add to settings.php to alter all links generated by Drupal. This function is called from url(). This function is called very frequently (100+ times per page) so performance is critical.

#1

joachim - July 15, 2009 - 16:50

*sigh*
This is because we now have non-hooks in core.php and so the regexp will need rewriting to be a bit more robust.

While I'm at it, the way it gets called could do with tidying up too.

#2

joachim - July 16, 2009 - 19:31
Title:screwy hooks» bad hook data getting captured
Status:active» fixed

Changed the regexp to check the function begins with 'hook' and make sure we get the comments that belong to the function:

  $pattern = '[
      / \* \* \n    # start phpdoc
    ( \ \* .* ) \n  # first line of phpdoc: capture
  (?: \ \* .* \n )* # lines of phpdoc
      \ \* /  \n    # end phpdoc
    ( function \ ( hook_\w* ) .* ) \  { # function declaration: capture both entire declaration and name
  ]mx'; 

Added whitespace and comments for better maintainability.

Subsequent commits will refactor the code around this.

#3

System Message - July 30, 2009 - 19:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.