From 133c652e581b5135d0053be19b0d493184ea4e0c Mon Sep 17 00:00:00 2001 From: Taiwen Jiang Date: Thu, 11 Apr 2013 04:09:32 +0800 Subject: [PATCH] Fixed route bug in path detection --- lib/Pi/Log/Writer/Debugger.php | 2 +- lib/Pi/Mvc/Router/Http/Standard.php | 6 ++++-- usr/theme/default/template/error-404.phtml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Pi/Log/Writer/Debugger.php b/lib/Pi/Log/Writer/Debugger.php index 99831ece33..2d3ab43b3c 100644 --- a/lib/Pi/Log/Writer/Debugger.php +++ b/lib/Pi/Log/Writer/Debugger.php @@ -195,7 +195,7 @@ public function systemInfo() $system['Cache Storage'] = $class; } if (Pi::service()->hasService('module')) { - $system['Module'] = Pi::service('module')->current(); + $system['Module'] = Pi::service('module')->current() ?: 'N/A'; } if (Pi::service()->hasService('theme')) { $system['Theme'] = Pi::service('theme')->current(); diff --git a/lib/Pi/Mvc/Router/Http/Standard.php b/lib/Pi/Mvc/Router/Http/Standard.php index 6836cb079d..54e5ff581a 100644 --- a/lib/Pi/Mvc/Router/Http/Standard.php +++ b/lib/Pi/Mvc/Router/Http/Standard.php @@ -166,8 +166,10 @@ protected function canonizePath(Request $request, $pathOffset = null) $pathLength = strlen($path); if ($this->prefix) { - $prefixLength = strlen($this->prefix); - if ($this->prefix != substr($path, 0, $prefixLength)) { + $prefix = rtrim($this->prefix, $this->paramDelimiter) . $this->paramDelimiter; + $path = rtrim($path, $this->paramDelimiter) . $this->paramDelimiter; + $prefixLength = strlen($prefix); + if ($prefix != substr($path, 0, $prefixLength)) { return null; } $path = substr($path, $prefixLength); diff --git a/usr/theme/default/template/error-404.phtml b/usr/theme/default/template/error-404.phtml index 84f617af50..46cabf27c7 100644 --- a/usr/theme/default/template/error-404.phtml +++ b/usr/theme/default/template/error-404.phtml @@ -45,7 +45,7 @@ && $this->controller_class && $this->controller_class != $this->controller ) { - echo ' (resolves to' . $this->escape($this->controller_class) . ')'; + echo ' (resolves to ' . $this->escape($this->controller_class) . ')'; } ?>