Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pre_controller can't modify $class / $method #394

Merged
merged 1 commit into from
Dec 26, 2022

Conversation

xalagu
Copy link
Contributor

@xalagu xalagu commented May 13, 2022

in codeigniter pre_controller methods modifying global $class $method variables can 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

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
@kenjis
Copy link
Owner

kenjis commented May 13, 2022

Can you show a minimum sample code to modify $class $method variables ?
Or please send a PR to https://github.com/kenjis/ci-app-for-ci-phpunit-test

@xalagu
Copy link
Contributor Author

xalagu commented May 13, 2022

function pre_controller_hook_verify_permissions() {
  if( not_have_permission() ){
	$GLOBALS['class'] = 'MY_auth_access_denied'; //new controller
	$GLOBALS['method'] = 'index'; //new method
  }
}

@kenjis kenjis merged commit 4f6c34a into kenjis:3.x Dec 26, 2022
@kenjis kenjis changed the title pre_controller can modify $class / $method fix: pre_controller can't modify $class / $method Dec 26, 2022
@kenjis kenjis added the bug label Dec 26, 2022
@kenjis
Copy link
Owner

kenjis commented Dec 26, 2022

Thank you for sending this PR.
I released as v3.0.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants