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

sfAutoload produces a PHP warning on unlink file #129

Open
fruit opened this issue Jun 2, 2016 · 5 comments
Open

sfAutoload produces a PHP warning on unlink file #129

fruit opened this issue Jun 2, 2016 · 5 comments

Comments

@fruit
Copy link

fruit commented Jun 2, 2016

When the debug mode is ON, sometimes this line:

sfAutoload.class.php#L134

produced error message:

PHP Warning:  unlink(/project/cache/api/dev/config/config_autoload.yml.php): No such file or directory in /project/vendor/lexpress/symfony1/lib/autoload/sfAutoload.class.php on line 134
PHP Stack trace:
PHP   1. {main}() /project/web/api_dev.php:0
PHP   2. sfContext->dispatch() /project/web/api_dev.php:14
PHP   3. sfFrontWebController->dispatch() /project/vendor/lexpress/symfony1/lib/util/sfContext.class.php:171
...
PHP  26. class_exists() /project/vendor/lexpress/doctrine1/lib/Doctrine/Record/Generator.php:164
PHP  27. spl_autoload_call() /project/vendor/lexpress/doctrine1/lib/Doctrine/Record/Generator.php:164
PHP  28. sfAutoloadAgain->autoload() /project/vendor/lexpress/doctrine1/lib/Doctrine/Record/Generator.php:164
PHP  29. sfAutoload->reloadClasses() /project/vendor/lexpress/symfony1/lib/autoload/sfAutoloadAgain.class.php:95
PHP  30. unlink() /project/vendor/lexpress/symfony1/lib/autoload/sfAutoload.class.php:134

I know, this it not good approach, but placing a @ before unlink will solve the issue.

Also, file_exists can be replaced with is_file (it's a correct way to check file existence)

@j0k3r
Copy link
Contributor

j0k3r commented Jun 2, 2016

Yeah as far as I remember, I also got that error from time to time and I still didn't understand why if the previous condition about file_exists is true this error appear when trying to remove the file ... 😶

@fruit
Copy link
Author

fruit commented Jun 2, 2016

Because file state is cached during single PHP request...

I would add a clearstatcache(); call here:

File: sfApplicationConfiguration.class.php#L113

$this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
sfAutoload::getInstance()->register();
if ($this->isDebug())
{
   clearstatcache(); // HERE
   sfAutoloadAgain::getInstance()->register();
}

@fruit fruit changed the title sfAutoload produced PHP warning on unlink file sfAutoload produces a PHP warning on unlink file Jun 2, 2016
@fruit
Copy link
Author

fruit commented Jun 2, 2016

Or somewhere here:

File: sfAutoload.class.php#L132

if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
{
   unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
   clearstatcache(); // HERE
}

@JohannesTyra
Copy link

This warning will appear on reloading data sometimes.

<b>Warning</b>: unlink(/var/www/xxx/cache/api/test/config/config_autoload.yml.php): No such file or directory in <b>/var/www/xxx/vendor/friendsofsymfony1/symfony1/lib/autoload/sfAutoload.class.php</b> on line <b>136</b><br />

This error is still open, would it make sense to fix it?

@fruit
Copy link
Author

fruit commented Jan 21, 2023

no longer relevant to me

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