Skip to content
Snippets Groups Projects
Commit 029b6b91 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #196862 by earnie et al: make drupal_lookup_path() a tad faster by...

- Patch #196862 by earnie et al: make drupal_lookup_path() a tad faster by eliminating an SQL query.
parent 43aa968f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -46,20 +46,15 @@ function drupal_init_path() {
function drupal_lookup_path($action, $path = '', $path_language = '') {
global $language;
// $map is an array with language keys, holding arrays of Drupal paths to alias relations
static $map = array(), $no_src = array(), $count;
static $map = array(), $no_src = array();
$path_language = $path_language ? $path_language : $language->language;
// Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
if (!isset($count)) {
$count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
}
if ($action == 'wipe') {
$map = array();
$no_src = array();
}
elseif ($count > 0 && $path != '') {
elseif (module_exists('path') && $path != '') {
if ($action == 'alias') {
if (isset($map[$path_language][$path])) {
return $map[$path_language][$path];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment