summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-03 06:02:40 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-03 06:02:40 +0000
commit8a4ab78bfb0bbf49e0a1db1e9e0576712bb04bc2 (patch)
treefdf7a83e7524936982740cfcbdd0957ce01ba3e9
parentfa9dda4c01a1ebb1af34e51fb36c2b3f27eb8d6e (diff)
Oops, injecting the function name caused an extra call in the call
stack. The test passed, but the actual code failed. Fixed now.
-rw-r--r--core/helpers/theme.php9
-rw-r--r--core/tests/Theme_Test.php2
2 files changed, 7 insertions, 4 deletions
diff --git a/core/helpers/theme.php b/core/helpers/theme.php
index 2146f322..5aa568c7 100644
--- a/core/helpers/theme.php
+++ b/core/helpers/theme.php
@@ -21,9 +21,12 @@ class theme_Core {
public static $debug_backtrace = "debug_backtrace";
public static function url($path) {
- $caller = array_shift(call_user_func(theme::$debug_backtrace));
- $calling_file = $caller['file'];
- $theme_name = substr($caller['file'], strlen(THEMEPATH));
+ // Using debug_backtrace() sucks. But I don't know of another way to get
+ // the location of the caller without forcing them to pass it in as an argument, which
+ // makes for a crappy API.
+ $backtrace = call_user_func(theme::$debug_backtrace);
+ $calling_file = $backtrace[1]['file'];
+ $theme_name = substr($calling_file, strlen(THEMEPATH));
$theme_name = substr($theme_name, 0, strcspn($theme_name, "/"));
return url::base() . "themes/{$theme_name}/$path";
}
diff --git a/core/tests/Theme_Test.php b/core/tests/Theme_Test.php
index b8f702f3..5b568b19 100644
--- a/core/tests/Theme_Test.php
+++ b/core/tests/Theme_Test.php
@@ -29,6 +29,6 @@ class Theme_Test extends Unit_Test_Case {
}
public function _fake_debug_backtrace() {
- return array(array('file' => THEMEPATH . "fake_theme/views/some_file.html.php"));
+ return array(array(), array('file' => THEMEPATH . "fake_theme/views/some_file.html.php"));
}
} \ No newline at end of file