diff --git a/core/includes/common.inc b/core/includes/common.inc index fbd3812..5eac16e 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2162,7 +2162,7 @@ function url_is_external($path) { /** * Returns TRUE if the given path is currently being viewed. * - * @param $path + * @param string $path * An internal path or external url as could be used by url(). * * @param array $options @@ -2175,21 +2175,26 @@ function url_is_external($path) { * - 'query': An array of query key/value-pairs (without any URL-encoding) to * append to the URL. * - * @return - * Boolean TRUE or FALSE where TRUE indicates an active path. + * @return bool + * Boolean where TRUE indicates an active path. * * @see url() */ function url_is_active($path, $options = array()) { + // Merge in defaults. + $options += array( + 'query' => array(), + 'language' => NULL, + ); + // A path is only active if it corresponds to the current path, the // language of the path is equal to the current language, and if the // query parameters of the url equal those of the current request, since the // same request with different query parameters may yield a different page // (e.g., pagers). - $path_query = drupal_container()->get('request')->query->all(); $path_match = ($path == current_path() || ($path == '' && drupal_is_front_page())); $lang_match = (empty($options['language']) || $options['language']->langcode == language(LANGUAGE_TYPE_URL)->langcode); - $query_match = (empty($options['query']) && empty($path_query)) || ($options['query'] == $path_query); + $query_match = drupal_container()->get('request')->query->all() == $options['query']; return $path_match && $lang_match && $query_match; }