codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.38k stars 1.9k forks source link

Bug: Calling Services::validation() in the controller on development environment makes memory allocation exhausted (?) if google\apiclient:^2.15 is installed #8120

Closed rikiins closed 1 year ago

rikiins commented 1 year ago

PHP Version

8.2

CodeIgniter4 Version

4.4.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MySQL (Oracle) 8.0.30 on win64

What happened?

If i have google/apiclient ^2.15 installed, and validation helper Config\Services::validation() is called, for example in Login controller it will load the page very slow and in the end it will throw this error :

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21558616 bytes) in \htdocs\SimpleDrive\vendor\codeigniter4\framework\system\ThirdParty\Kint\Renderer\RichRenderer.php on line 363

Example controller that will produce the behaviour :

class Account extends BaseController
{
    private $validation;

    public function __construct()
    {
        if (session()->get('is_logged_in')) {
            redirect()->to('Home');
        }

        $this->validation = \Config\Services::validation();
    }

    public function Login(): string
    {
        $data['validation'] = $this->validation;

        return view('Account/Login', $data);
    }
}

Steps to Reproduce

  1. Install CI 4 through composer create-project codeigniter4/appstarter MyProject
  2. Create controller that calls \Config\Services::validation(), for example Login controller
  3. Install PHP google apiclient through composer require google/apiclient:^2.15
  4. Open the url that points to the controller that called validation helper previously
  5. Bug appeared, but it won't if i changed the CI_ENVIRONMENT to production

Expected Output

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21558616 bytes) in \htdocs\SimpleDrive\vendor\codeigniter4\framework\system\ThirdParty\Kint\Renderer\RichRenderer.php on line 363

Anything else?

image

neznaika0 commented 1 year ago

Disable Toolbar in app/Config/Filters and refresh page?

rikiins commented 1 year ago

Add this to the $globals, and worked as usual. Thanks!

    'after' => [
        'toolbar' => [
            'except' => [
                'Controller1/Method',
                'Controller2/Method'
            ]
        ],
        // 'honeypot',
        // 'secureheaders',
    ]