Skip to content

Commit f17962b

Browse files
author
dezsi-istvan
authored
pre_controller can modify $class / $method
in codeigniter pre_controller methods modifying global $class $method variables modify the route code in codeigniter\framework\system\core\CodeIgniter.php $EXT->call_hook('pre_controller'); $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); $CI = new $class(); with this fix, this behavior will work in testing also
1 parent 295d0c8 commit f17962b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,12 @@ protected function createAndCallController($class, $method, $params, $call_displ
324324
{
325325
ob_start();
326326

327+
$GLOBALS['class'] = $class;
328+
$GLOBALS['method'] = $method;
329+
// pre_controller can modify global $class $method variables to modify route
327330
$this->callHook('pre_controller');
331+
$class = $GLOBALS['class'];
332+
$method = $GLOBALS['method'];
328333

329334
// Run callablePreConstructor
330335
if ($this->callablePreConstructors !== [])

0 commit comments

Comments
 (0)