File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,7 +168,13 @@ public static function get_rest_parent($uri=false) {
168168 */
169169 public static function parse_rest_path ($ uri =false , $ SERVER_SCRIPT_NAME =false /* unit test only */ ) {
170170 if ( ! $ SERVER_SCRIPT_NAME ) $ SERVER_SCRIPT_NAME = $ _SERVER ["SCRIPT_NAME " ]; // /py4e/koseu.php
171- if ( ! $ uri ) $ uri = $ _SERVER ['REQUEST_URI ' ]; // /py4e/lessons/intro/happy
171+ if ( ! $ uri ) {
172+ // Handle missing REQUEST_URI (e.g., CLI mode or certain web server configs)
173+ if ( !isset ($ _SERVER ['REQUEST_URI ' ]) ) {
174+ return false ;
175+ }
176+ $ uri = $ _SERVER ['REQUEST_URI ' ]; // /py4e/lessons/intro/happy
177+ }
172178 // Remove Query string...
173179 $ pos = strpos ($ uri , '? ' );
174180 if ( $ pos !== false ) $ uri = substr ($ uri ,0 ,$ pos );
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ public function testParseController() {
8989 // Running from the wrong directory
9090 $ this ->assertEquals (U::parse_rest_path ('/a/b/c ' ,'/x/koseu.php ' ), false );
9191
92+ // Test that rest_path also returns false when parse_rest_path returns false
93+ $ CFG ->wwwroot = "http://www.example.com:8888/tsugi " ;
94+ $ this ->assertEquals (U::rest_path ('/a/b/c ' ,'/x/koseu.php ' ), false );
95+
9296 // Object version...
9397 $ CFG ->wwwroot = "http://www.example.com:8888/tsugi " ;
9498 $ path = U::rest_path ('/py4e/lessons/intro?x=2 ' ,'/py4e/koseu.php ' );
You can’t perform that action at this time.
0 commit comments