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: Crash on php 8.4 on TimeTrait::createFromTimestamp() usage #9348

Closed
samsonasik opened this issue Dec 29, 2024 · 3 comments
Closed

Bug: Crash on php 8.4 on TimeTrait::createFromTimestamp() usage #9348

samsonasik opened this issue Dec 29, 2024 · 3 comments

Comments

@samsonasik
Copy link
Member

samsonasik commented Dec 29, 2024

PHP Version

8.4

CodeIgniter4 Version

4.5.6

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

No response

What happened?

I just tried latest CodeIgniter 4.5.6 in my module, and in php 8.4, it cause error:

 Runtime:       PHP 8.4.2 with Xdebug 3.5.0-dev
Configuration: /home/runner/work/ci4-album/ci4-album/phpunit.xml.dist

PHP Fatal error:  Declaration of CodeIgniter\I18n\TimeTrait::createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null) must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp): static in /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/I18n/TimeTrait.php on line 268
PHP Fatal error:  Uncaught Error: Class "CodeIgniter\I18n\Time" not found in /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/HTTP/ResponseTrait.php:398
Stack trace:
#0 /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/HTTP/ResponseTrait.php(376): CodeIgniter\HTTP\Response->sendHeaders()
#1 /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/Debug/ExceptionHandler.php(83): CodeIgniter\HTTP\Response->send()
#2 /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/Debug/Exceptions.php(162): CodeIgniter\Debug\ExceptionHandler->handle()
#3 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler()
#4 {main}
  thrown in /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/HTTP/ResponseTrait.php on line 398
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Fatal error: Declaration of CodeIgniter\I18n\TimeTrait::createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null) must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp): static in /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/I18n/TimeTrait.php on line 268

Fatal error: Uncaught Error: Class "CodeIgniter\I18n\Time" not found in /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/HTTP/ResponseTrait.php:398
Stack trace:
#0 /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/HTTP/ResponseTrait.php(376): CodeIgniter\HTTP\Response->sendHeaders()
#1 /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/Debug/ExceptionHandler.php(83): CodeIgniter\HTTP\Response->send()
#2 /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/Debug/Exceptions.php(162): CodeIgniter\Debug\ExceptionHandler->handle()
#3 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler()
#4 {main}
  thrown in /home/runner/work/ci4-album/ci4-album/vendor/codeigniter4/framework/system/HTTP/ResponseTrait.php on line 398

https://github.com/samsonasik/ci4-album/actions/runs/12532301581/job/34950890792?pr=19

see PR: samsonasik/ci4-album#19

Steps to Reproduce

at github action above.

Expected Output

should not crash.

Anything else?

No response

@samsonasik samsonasik added the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 29, 2024
@samsonasik
Copy link
Member Author

samsonasik commented Dec 29, 2024

see https://3v4l.org/5rcSN , return type seems also needed to be changed to static, see without return type https://3v4l.org/INmps and with full param and return type changed https://3v4l.org/JOMF1

or add #[ReturnTypeWillChange] like other method

@kenjis
Copy link
Member

kenjis commented Dec 29, 2024

PHP 8.4 requires CodeIgniter 4.6.0 or later. See #9116

@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 29, 2024
@samsonasik
Copy link
Member Author

Ok, closing then ;)

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

2 participants