ryancramerdesign / ProcessWire

Our repository has moved to https://github.com/processwire – please head there for the latest version.
https://processwire.com
Other
727 stars 201 forks source link

log->prune() warnings in php-fpm environment #1699

Open lparikka opened 8 years ago

lparikka commented 8 years ago

We have problems with $log->prune() function. Our environment is chrooted php-fpm and normal operations (image upload, sessions etc.) work without problems. But when using $log->prune('ipuserdb_log.txt',30); we get errors in Apache error-log like this:

FastCGI: server "/php-fpm-lehti" stderr: PHP message: PHP Warning: unlink(/www/web/site/assets/logs/ipuserdb_log.txt): No such file or directory in /www/web/wire/core/FileLog.php on line 482 FastCGI: server "/php-fpm-lehti" stderr: PHP message: PHP Warning: rename(/www/web/site/assets/logs/ipuserdb_log.txt.new,/www/web/site/assets/logs/ipuserdb_log.txt): No such file or directory in /www/web/wire/core/FileLog.php on line 483

Could this be a problem in prune implementation or is this a problem with our chroot-environment?

PW version 2.7.2.

ryancramerdesign commented 8 years ago

I'm not sure about this one, as I don't have the environment to duplicate it. But the first thing I would check is your permissions on your site/assets/logs/ directory to make sure Apache can write to the directory. Also, if using $log->prune() from the API, double check that it isn't somehow getting called twice.

lparikka commented 8 years ago

The permissions are ok for anyone to write. The method is called only once like this: $log->save('ipuserdb_log', $message); $log->prune('ipuserdb_log', 30);

The real path to the file is /data/www/server.com/www/web/site/assets/logs/ipuserdb_log. The php5-fpm environment chroot the php to /www/web/site/assets/logs. For some reason the prune-method doesn't find the file in that path even though all the other PW stuff seems to work normally.