Oops, injecting the function name caused an extra call in the call

stack.  The test passed, but the actual code failed.  Fixed now.
This commit is contained in:
Bharat Mediratta
2008-11-03 06:02:40 +00:00
parent fa9dda4c01
commit 8a4ab78bfb
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -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";
}