【问题标题】:Laravel - Auth getting stuck on reading session fileLaravel - Auth 卡在读取会话文件上
【发布时间】:2018-12-08 03:46:39
【问题描述】:

希望你过得好

我试图在我的 Laravel 5.6 项目中添加一个配置文件表,并且我也在使用 spatie\Laravel-Permission 包。它工作正常,但是在我运行了一些迁移(与用户无关)之后,它开始登录失败。奇怪的是,如果我注册一个新用户,它会正确登录,但永远不会使用 /login 路由(我使用的是 Laravel 的 Auth 脚手架)。

调试项目后,我想出了失败的方法,它是读取会话的东西:

MyProject\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php

<?php
namespace Illuminate\Filesystem;

use ErrorException;
use FilesystemIterator;
use Symfony\Component\Finder\Finder;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Filesystem\FileNotFoundException;

class Filesystem{
    // ...
    public function get($path, $lock = false)
    {
        if ($this->isFile($path)) {
            return $lock ? $this->sharedGet($path) : file_get_contents($path); // <-- The failing line
        }

        throw new FileNotFoundException("File does not exist at path {$path}");
    }
    // ...
}

一旦到达该行,调试器停止,浏览器没有得到响应,dd() 函数没有被触发......我还尝试调试 sharedGet($path) 方法,它返回值,但回到上面的方法,它就停止了。

此外,php_error.log 文件在每次请求时都会大大增加(最多 500MB/请求),以至于我使用的任何编辑器都无法打开它(SublimeText、NetBeans)。

我的想法是apache在读取文件时可能内存不足,但是会话文件的权重只有1k,所以没有多大意义。

有人可以提供任何线索吗?谢谢

--编辑:

我尝试安装一个仅包含 Auth 模块和 spatie/laravel-permission 包的全新 laravel proyect,但我注意到了相同的行为:它注册并记录用户,但在注销后,我不再能够使用任何用户登录。

【问题讨论】:

  • 您可以尝试使用记事本打开文件。此外,一个问题可能是会话的路径或 laravel 访问它的能力。
  • 你的/tmp满了吗?
  • 使用命令行读取日志:less php_error.log or more php_error.log or tail -n 200 php_error.log.
  • @hungrykoala 路径很好,它还可以将内容存储在变量中。返回后卡住了
  • @Ohgodwhy 有足够的空间,我有 100GB 空闲

标签: php laravel session


【解决方案1】:

如果有人遇到同样的错误:

我可以通过备份我的所有项目/数据库并使用最新版本的 php 重新安装 wampserver 来解决这个问题(到这个答案的时候,它是 7.2.4)并重新安装 Laravel(幸运的是,项目刚刚开始),它仅将 vlucas/phpdotenv 包从 2.4.0 更新到 2.5.0 和 phpunittest。

有了这个更新,我现在可以正常登录用户,现在让我们看看它是否可以正常使用 spatie/laravel-permission 包和我需要添加的配置文件表。

【讨论】:

    猜你喜欢
    • 2019-12-10
    • 1970-01-01
    • 2015-01-17
    • 2018-05-07
    • 1970-01-01
    • 2015-06-19
    • 1970-01-01
    • 2017-05-23
    • 2018-03-25
    相关资源
    最近更新 更多