Closed (works as designed)
Project:
Drupal core
Version:
4.7.3
Component:
base system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Oct 2006 at 21:43 UTC
Updated:
27 Nov 2006 at 22:30 UTC
The decision of a problem have offered at a forum
http://www.drupal.ru/node/2317#comment-9921
please review:
=============
file path.inc:
diff -u path.inc path-NEW.inc
--- path.inc 2006-07-18 14:40:02.000000000 +0300
+++ path-NEW.inc 2006-10-11 00:14:06.000000000 +0300
@@ -1,5 +1,5 @@
<?php
-// $Id: path.inc,v 1.4.2.1 2006/07/18 11:40:02 killes Exp $
+// $Id: path.inc,v 1.4 2006/04/24 19:25:37 dries Exp $
/**
* @file
@@ -13,7 +13,19 @@
/**
* Initialize the $_GET['q'] variable to the proper normal path.
*/
+
function drupal_init_path() {
+global $map_alias;
+ $c=count($map_alias);
+if (empty($c))
+{
+$sql = "Select src,dst FROM {url_alias} ";
+$res=db_query($sql);
+ while( $row=db_fetch_array($res))
+ {
+ $map_alias[$row['src']]=$row['dst'];
+ }
+ }
if (!empty($_GET['q'])) {
$_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
}
@@ -39,42 +51,23 @@
* found.
*/
function drupal_lookup_path($action, $path = '') {
+global $map_alias;
static $map = array();
- static $count = NULL;
-
- if ($count === NULL) {
- $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
- }
-
if ($action == 'wipe') {
$map = array();
}
- elseif ($count > 0 && $path != '') {
+ elseif ($path != '') {
if ($action == 'alias') {
- if (isset($map[$path])) {
- return $map[$path];
- }
- if ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
- $map[$path] = $alias;
- return $alias;
- }
- else {
- $map[$path] = $path;
- }
+ if (!isset($map_alias[$path])) $map_alias[$path]=$path;
+ return $map_alias[$path];
}
elseif ($action == 'source') {
- if ($alias = array_search($path, $map)) {
+ if (is_array($map_alias) and $alias = array_search($path, $map_alias)) {
return $alias;
}
- if (!isset($map[$path])) {
- if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
- $map[$src] = $path;
- return $src;
- }
- }
+ else return False;
}
}
-
return FALSE;
}
============================
The result file path.inc in attachment:
Comments
Comment #1
FiReaNGeL commentedCould you give more details about what this is trying to fix, and how? I fear not many people around here speaks russian :)
Comment #2
dries commentedThis solution only works for sites with a couple of aliases. For sites that have thousands of path aliases, this won't scale.
Comment #3
Zen commentedchanging status as per Dries' comments.
Comment #4
gerhard killesreiter commentedThis was a design decision made in the early stages of the 4.7 development cycle. Not neccessarily the best one for a lot of sites, but nevertheless a design decision.