Welcome Guest, Not a member yet? Register   Sign In
Filter Issue for version 4.5.0
#1

Hello,
I have a filter issue in version 4.5.0. It is working fine in version 4.4.8, but as soon as I upgraded to version 4.5.0, the following errors came up.

TypeError
str_contains(): Argument #1 ($haystack) must be of type string, null given


SYSTEMPATH\Debug\Toolbar.php at line 436

429 . 'data-time="' . $time . '" '
430 . 'src="' . site_url() . '?debugbar"></script>'
431 . '<script ' . csp_script_nonce() . ' id="debugbar_dynamic_script"></script>'
432 . '<style ' . csp_style_nonce() . ' id="debugbar_dynamic_style"></style>'
433 . $kintScript
434 . PHP_EOL;
435
436 if (str_contains($response->getBody(), '<head>')) {
437 $response->setBody(
438 preg_replace(
439 '/<head>/',
440 '<head>' . $script,
441 $response->getBody(),
442 1
443 )


My CIFilter Code is as follows:

Code:
public function before(RequestInterface $request, $arguments = null)
    {
        if( $arguments[0] == 'guest'){
            if( CIAuth::check()){
                return redirect()->route('admin.home');
            }            
        }

        if( $arguments[0] == 'auth'){
            if( !CIAuth::check()){
                return redirect()->route('admin.login.form')->with('fail', 'You must be logged in first.');
            }
        }
    }

And also my route code is as follows:

Code:
$routes->group('admin', static function($routes){

    $routes->group('',['filter'=>'cifilter:auth'], static function($routes){
        
        $routes->get('home','AdminController::index',['as'=>'admin.home']);
        $routes->get('logout','AdminController::logoutHandler',['as'=>'admin.logout']);
    });

    $routes->group('',['filter'=>'cifilter:guest'], static function($routes){
      
        $routes->get('login','AuthController::loginForm',['as'=>'admin.login.form']);
        $routes->post('login','AuthController::loginHandler',['as'=>'admin.login.handler']);
    });
});
Reply
#2

See https://github.com/codeigniter4/CodeIgni...ssues/8730
Reply




Theme © iAndrew 2016 - Forum software by © MyBB