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

Bug: Fatal error: Uncaught TypeError: CodeIgniter\HTTP\IncomingRequest::getPostMaxSize(): Return value must be #9258

Closed
juanma386 opened this issue Nov 5, 2024 · 2 comments

Comments

@juanma386
Copy link

PHP Version

8.2

CodeIgniter4 Version

4.5.5

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

No response

What happened?

Fatal error: Uncaught TypeError: CodeIgniter\HTTP\IncomingRequest::getPostMaxSize(): Return value must be of type int, float returned in C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php:180 Stack trace: #0 C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php(145): CodeIgniter\HTTP\IncomingRequest->getPostMaxSize() #1 C:\laragon\www\codeigniterweb\system\Config\Services.php(572): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\SiteURI), 'php://input', Object(CodeIgniter\HTTP\UserAgent)) #2 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(312): CodeIgniter\Config\Services::incomingrequest(Object(Config\App), false) #3 C:\laragon\www\codeigniterweb\system\Config\Services.php(528): CodeIgniter\Config\BaseService::__callStatic('incomingrequest', Array) #4 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(312): CodeIgniter\Config\Services::request(NULL, false) #5 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(251): CodeIgniter\Config\BaseService::__callStatic('request', Array) #6 C:\laragon\www\codeigniterweb\system\Config\Services.php(524): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL) #7 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(312): CodeIgniter\Config\Services::request() #8 C:\laragon\www\codeigniterweb\system\Debug\Exceptions.php(129): CodeIgniter\Config\BaseService::__callStatic('request', Array) #9 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(TypeError)) #10 {main} thrown in C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php on line 180

Fatal error: Uncaught TypeError: CodeIgniter\HTTP\IncomingRequest::getPostMaxSize(): Return value must be of type int, float returned in C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php:180 Stack trace: #0 C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php(145): CodeIgniter\HTTP\IncomingRequest->getPostMaxSize() #1 C:\laragon\www\codeigniterweb\system\Config\Services.php(572): CodeIgniter\HTTP\IncomingRequest->__construct(Object(Config\App), Object(CodeIgniter\HTTP\SiteURI), 'php://input', Object(CodeIgniter\HTTP\UserAgent)) #2 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(312): CodeIgniter\Config\Services::incomingrequest(Object(Config\App), false) #3 C:\laragon\www\codeigniterweb\system\Config\Services.php(528): CodeIgniter\Config\BaseService::__callStatic('incomingrequest', Array) #4 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(312): CodeIgniter\Config\Services::request(NULL, false) #5 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(251): CodeIgniter\Config\BaseService::__callStatic('request', Array) #6 C:\laragon\www\codeigniterweb\system\Config\Services.php(524): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL) #7 C:\laragon\www\codeigniterweb\system\Config\BaseService.php(312): CodeIgniter\Config\Services::request() #8 C:\laragon\www\codeigniterweb\system\Debug\Exceptions.php(129): CodeIgniter\Config\BaseService::__callStatic('request', Array) #9 C:\laragon\www\codeigniterweb\system\Debug\Exceptions.php(252): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #10 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #11 {main} thrown in C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php on line 180

Steps to Reproduce

  1. Download zip oficial on website 4.5.5
  2. Unzip
  3. php spark key:generate
  4. composer install
  5. setup .env
  6. inner on website enviroment

Expected Output

Welcome message leading page default

Anything else?

Inner this solution to solve problem, make check an update package please to next update team.

file locate: C:\laragon\www\codeigniterweb\system\HTTP\IncomingRequest.php


    private function getPostMaxSize(): int
    {
        $postMaxSize = ini_get('post_max_size');

        return (int) match (strtoupper(substr($postMaxSize, -1))) {
            'G'     => str_replace('G', '', $postMaxSize) * 1024 ** 3,
            'M'     => str_replace('M', '', $postMaxSize) * 1024 ** 2,
            'K'     => str_replace('K', '', $postMaxSize) * 1024,
            default => $postMaxSize,
        };
    }

next of the issue new on version 4.5.5 downloaded of oficial link website fixed problem.

@juanma386 juanma386 added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 5, 2024
@neznaika0
Copy link
Contributor

See ini_get('post_max_size') in php.ini
After exponentiation, there should be a integer

@michalsn
Copy link
Member

michalsn commented Nov 5, 2024

This is not a bug but probably a misconfiguration on the user side.

The post_max_size parameter only allows int values + optional shortcuts for byte values. Therefore, specifying a float value is not supported.

@michalsn michalsn removed the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants