diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-05-29 21:23:08 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-29 21:23:08 -0700 |
commit | ce285b8feba2f9c495fb153517c2a582421f50e0 (patch) | |
tree | 11d8727061378408bbc16ede888a058ba20542fb /modules/gallery/helpers/MY_url.php | |
parent | cbec883d8a572fd8b94c9db78b652caf1a22de23 (diff) |
Use the relative_path_cache to look up items which should be a faster
query than using the level + the components.
Diffstat (limited to 'modules/gallery/helpers/MY_url.php')
-rw-r--r-- | modules/gallery/helpers/MY_url.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 5e8bfc9e..019e416f 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -38,13 +38,19 @@ class url extends url_Core { return; } - $count = count(Router::$segments); - foreach (ORM::factory("item") - ->where("name", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES)) - ->where("level", $count + 1) - ->find_all() as $match) { - if ($match->relative_path() == html_entity_decode(Router::$current_uri, ENT_QUOTES)) { - $item = $match; + $current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES); + $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find(); + if (!$item->loaded) { + // It's possible that the relative path cache for the item we're looking for is out of date, + // so find it the hard way. + $count = count(Router::$segments); + foreach (ORM::factory("item") + ->where("name", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES)) + ->where("level", $count + 1) + ->find_all() as $match) { + if ($match->relative_path() == $current_uri) { + $item = $match; + } } } |