- Patch #619566 by sun: performance improvement: don't invoke hook_url_outbound_alter() if there's nothing to invoke.
parent
342ebd7776
commit
54db3af335
|
@ -2370,6 +2370,8 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
|
||||||
* alternative than url().
|
* alternative than url().
|
||||||
*/
|
*/
|
||||||
function url($path = NULL, array $options = array()) {
|
function url($path = NULL, array $options = array()) {
|
||||||
|
static $url_outbound;
|
||||||
|
|
||||||
// Merge in defaults.
|
// Merge in defaults.
|
||||||
$options += array(
|
$options += array(
|
||||||
'fragment' => '',
|
'fragment' => '',
|
||||||
|
@ -2392,7 +2394,14 @@ function url($path = NULL, array $options = array()) {
|
||||||
$original_path = $path;
|
$original_path = $path;
|
||||||
|
|
||||||
// Allow other modules to alter the outbound URL and options.
|
// Allow other modules to alter the outbound URL and options.
|
||||||
|
// Since PHP code cannot be unloaded, we statically cache the implementations
|
||||||
|
// of hook_url_outbound_alter() and only invoke them in case there are any.
|
||||||
|
if (!isset($url_outbound)) {
|
||||||
|
$url_outbound = (bool) module_implements('url_outbound_alter');
|
||||||
|
}
|
||||||
|
if ($url_outbound) {
|
||||||
drupal_alter('url_outbound', $path, $options, $original_path);
|
drupal_alter('url_outbound', $path, $options, $original_path);
|
||||||
|
}
|
||||||
|
|
||||||
if ($options['fragment']) {
|
if ($options['fragment']) {
|
||||||
$options['fragment'] = '#' . $options['fragment'];
|
$options['fragment'] = '#' . $options['fragment'];
|
||||||
|
|
Loading…
Reference in New Issue