Skip to content

Uncaught ErrorException on debug.css path #9509

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

Closed
paulalbinson opened this issue Apr 9, 2025 · 7 comments
Closed

Uncaught ErrorException on debug.css path #9509

paulalbinson opened this issue Apr 9, 2025 · 7 comments

Comments

@paulalbinson
Copy link

paulalbinson commented Apr 9, 2025

PHP Version

8.4

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

No response

What happened?

app/Views/errors/html/production.php:10 produces a PHP Fatal error: Uncaught ErrorException due to the line attempting to unlink app/Views/errors/html/debug.css, which is failed as the folder is not writable, nor should it be, This is not the intended action.

The problematic code is:

<style>
        <?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style>

This should pull the contents of this file into a style tag; however, as the error shows, it appears to be triggering an unlink of the file for some reason.

Steps to Reproduce

See above.

Expected Output

Loading of CSS

Anything else?

No response

@paulalbinson paulalbinson added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 9, 2025
@paulbalandan paulbalandan changed the title Bug: Uncaught ErrorException on debug.css path Apr 9, 2025
@paulbalandan
Copy link
Member

Can you provide more context on this, like reproduction steps?

By the first look on this, it seems you just need to chown the directory (which I think should already have been).

@paulbalandan paulbalandan added waiting for info Issues or pull requests that need further clarification from the author and removed bug Verified issues on the current code behavior or pull requests that will fix them labels Apr 9, 2025
@paulbalandan
Copy link
Member

No response received. Closing.

@paulalbinson
Copy link
Author

Sorry for the delay in responding. Reproduction steps are in the original post. Why would I need to chown the directory? This is meant to be code to include some CSS, not to delete a file, hence the issue report. If this code were to work properly, it'd read the file and place its contents into a CSS style tag, rather than what it actually does, which is attempt to unlink the CSS file. I will not give the folder deletion rights, as there should be no deletions happening in this folder; the CSS files should be read, and there are read permissions for them.

@paulbalandan
Copy link
Member

Sorry for the confusion. For the reproduction steps, I meant to ask the whole context on what's happening or what are you doing before the crash occurred.

@paulalbinson
Copy link
Author

As per the purpose of this code which provides a page when errors occur, informing the user that the page ran into trouble, this problem occurs whenever an error page is triggered.

@paulbalandan
Copy link
Member

Here's a reproducer I have done:

  1. Run composer create-project codeigniter4/appstarter ci4-app
  2. cd ci4-app
  3. cp env .env
  4. Ensure we're on production
$ ./spark env

CodeIgniter v4.6.1 Command Line Tool - Server Time: 2025-05-02 17:18:01 UTC+00:00

Your environment is currently set as production.

  1. Induce an error in the home controller:
<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index(): string
    {
        return $a;
        // return view('welcome_message');
    }
}
  1. Run ./spark serve
Image

Error appears as expected.

Unless you can give us clear reproduction steps (which I have asked for twice now), then there's hardly any help we could provide you.

@paulbalandan paulbalandan removed the waiting for info Issues or pull requests that need further clarification from the author label May 2, 2025
@paulalbinson
Copy link
Author

Thanks. I tested it with your test and all is fine and weirdly the problem has vanished from the site I was having an issue with, so I don't know what fixed it as I don't think I changed anything to fix it, most odd. Many thanks.

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