laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.22k stars 10.91k forks source link

Warning unlinking non-existent session file in tinker #22514

Closed phpguru closed 6 years ago

phpguru commented 6 years ago

Description:

Minor issue. When using Auth::attempt( ) in tinker and using the Filesystem session driver, a PHP warning is displayed trying to unlink non-existent session file.

Steps To Reproduce:

# php artisan tinker
Psy Shell v0.8.16 (PHP 7.1.11 — cli) by Justin Hileman
>>> Auth::attempt(['email' => 'you@yoursite.com', 'password' => 'yourpassword'])
PHP Warning: unlink(/Projects/myproject/storage/framework/sessions/yC9WluwkHxFwxkzIn2tLzBNo44FUCxn2HUSsno6d): No such file or directory in /Projects/myproject/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 183

Just need to check if file_exists or is_file before unlinking to avoid warning. The @ symbol in the try-catch around lines 182-188 doesn't suppress the warning.

sisve commented 6 years ago

Why doesn't @ suppress the warning? Do you have screaming enabled in xdebug? Using file_exists/is_file is still susceptible for racing conditions where two parallel requests attempt to delete the same file.

vicmarconi commented 6 years ago

When using Auth::login(User::first()) (or any user), PHP warns about unlinking an non-existing file.

Auth::login($u)
PHP Warning:  unlink(/Workspace/Project/storage/framework/sessions/bxH9ZY08LSB61t8Mx2DjkF1Olj03Pn6aW20DDBiG): No such file or directory in /Workspace/Project/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 18
3ynm commented 6 years ago

Same here:

>>> \Auth::loginUsingId(1)
PHP Warning:  unlink(/home/hacktivista/Development/form.report/app/private/storage/framework/sessions/lSMSUrnuunbehdGW2KW33R0bMuQ2YoeUl8FmSwpL): No such file or directory in /home/hacktivista/Development/form.report/app/private/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 183
mizan-cs commented 6 years ago

same problem

sisve commented 6 years ago

@mizan-cs Are you using xdebug with screaming enabled? Check the xdebug.scream setting.

https://xdebug.org/docs/all_settings

faozimipa commented 6 years ago

is any body have a solusion to this problem?

sisve commented 6 years ago

There is no solution to the problem because no-one is bothered to answer that very simple and specific question; Do you have screaming enabled in xdebug?

xdebug.scream Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1 If this setting is 1, then Xdebug will disable the @ (shut-up) operator so that notices, warnings and errors are no longer hidden.

Source: https://xdebug.org/docs/all_settings

You can find your setting in your configuration, or by doing var_dump(ini_get('xdebug.scream'));. Make sure you do it in the correct environment; preferably once in the terminal and once from a controller called via http, just to be sure that it's disabled in both.

@phpguru @vicmarconi @mizan-cs @faozimipa You're welcome to report your result in this issue. If you have screaming enabled, disable it. If you have screaming disabled, then there's an issue we need to debug further.

3ynm commented 6 years ago

I can confirm that screaming is disabled in my case image

aristarchusSkywatcher commented 6 years ago

same here on laravel 5.6.20 and PHP 7.1.17

markvesterskov commented 6 years ago

skaermbillede 2018-05-31 kl 20 39 59

Laravel v5.6.7 and PHP 7.2 on Homestead.

Another buzz for this issue.

It might be just a nuisance, but I have a slight hunch that it might be causing my queues to silently fail, because i have issues running them on my Homestead box whenever something session-touchy is involved. They get called but die silently.

Even tried updating php.ini's error_reporting to only E_ERROR on both FPM and CLI, to no avail.

BautistaJB commented 6 years ago

Same problem here, using PHP 7.0 and Laravel 5.4.

I realized this problem was in my project because the authentication stopped working when I installed the project in a new environment. Then I tried using Auth::attempt directly from php artisan tinker and saw the "unlink warning":

image

Just to be sure, I tried to fix it adding this lines where the error ocurrs (vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:183):

image

Now the Warning is gone, but I cannot still log in my app.

aristarchusSkywatcher commented 5 years ago

Same problem here with PHP 7.1.17 and Laravel 5.6.18.

I haven't enabled xdebug yet.

martijnimhoff commented 5 years ago

Also having this problem: php 7.2.15 and Laravel v5.6.39

marcosdipaolo commented 5 years ago

any solution?

not using xdebug here

jeremiahsherrill commented 5 years ago

also looking for a solution

riyuk commented 5 years ago

@sisve @themsaid this error even occurs in forge - where no xdebug is present.

marcosdipaolo commented 5 years ago

What was the answer to this problem?

riyuk commented 5 years ago

See my Ticket on honeybadger. This error is supressed by default (with a @). You will get errors anyway if you have defined a custom error reporter or use xdebug it seems.