Skip to content

Bug: Unhandled False in FileHandler #9573

Closed
@marshmallowfox

Description

@marshmallowfox

PHP Version

8.3, 8.2

CodeIgniter4 Version

4.6.0

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

Database

PostgreSQL 15

What happened?

In system/Cache/Handlers/FileHandler.php, inside the getItem() method, the call to file_get_contents() can return false, which currently leads to a fatal error that crashes the application without any explanatory message. It would be preferable to:

Detect when file_get_contents() returns false.
In that case, ignore the cached file and regenerate the cache entry.
Emit a clear warning to the console indicating that reading the cache failed, so developers aren’t left with a silent crash.

Steps to Reproduce

  1. Make cache unreadable (for example, no permissions)
  2. Try to get it

Expected Output

Warning or error in console, no crash, recalculate of cache

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions