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

Typed property Casbin\WebmanPermission\Model\LaravelRuleModel::$store must not be accessed before initialization in D:\www\backend2\vendor\casbin\webman-permission\src\Model\LaravelRuleModel.php:90 #7

Closed
skeam-tj opened this issue Dec 16, 2022 · 4 comments
Labels
question Further information is requested

Comments

@skeam-tj
Copy link

Error: Typed property Casbin\WebmanPermission\Model\LaravelRuleModel::$store must not be accessed before initialization in D:\www\backend2\vendor\casbin\webman-permission\src\Model\LaravelRuleModel.php:90
Stack trace:
#0 D:\www\backend2\vendor\casbin\webman-permission\src\Adapter\LaravelDatabaseAdapter.php(99): Casbin\WebmanPermission\Model\LaravelRuleModel->getAllFromCache()
#1 D:\www\backend2\vendor\casbin\casbin\src\CoreEnforcer.php(363): Casbin\WebmanPermission\Adapter\LaravelDatabaseAdapter->loadPolicy()
#2 D:\www\backend2\vendor\casbin\casbin\src\CoreEnforcer.php(223): Casbin\CoreEnforcer->loadPolicy()
#3 D:\www\backend2\vendor\casbin\casbin\src\CoreEnforcer.php(156): Casbin\CoreEnforcer->initWithModelAndAdapter()
#4 D:\www\backend2\vendor\casbin\webman-permission\src\Permission.php(73): Casbin\CoreEnforcer->__construct()
#5 D:\www\backend2\support\bootstrap.php(109): Casbin\WebmanPermission\Permission::start()
#6 D:\www\backend2\vendor\workerman\webman-framework\src\support\App.php(97): require_once('...')
#7 D:\www\backend2\vendor\workerman\workerman\Worker.php(2454): support\App::support{closure}()
#8 D:\www\backend2\vendor\workerman\workerman\Worker.php(1453): Workerman\Worker->run()
#9 D:\www\backend2\vendor\workerman\workerman\Worker.php(1396): Workerman\Worker::forkWorkersForWindows()
#10 D:\www\backend2\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#11 D:\www\backend2\vendor\workerman\webman-framework\src\support\App.php(124): Workerman\Worker::runAll()
#12 D:\www\backend2\start.php(4): support\App::run()

@Tinywan
Copy link
Member

Tinywan commented Dec 16, 2022

@Tinywan Tinywan added the question Further information is requested label Dec 16, 2022
@skeam-tj
Copy link
Author

请参考文档 https://www.workerman.net/doc/webman/db/tutorial.html 安装 illuminate/database

已经安装了,这个问题是在使用 casbin/webman-permission 这个组件时,开启了cache才报错,报错代码文件位置:
vendor\casbin\webman-permission\src\Model\LaravelRuleModel.php【line: 90】

return $this->store->remember($this->config('cache.key'), $this->config('cache.ttl'), $get);

上面那个 $this->store 没有被初始化

@Tinywan
Copy link
Member

Tinywan commented Dec 16, 2022

Laravel 的ORM 我不怎么使用,欢迎提交PR

lyt8384 added a commit to lyt8384/webman-permission that referenced this issue Feb 22, 2023
* feat:  增加了多套配置,可以使用client指定使用那套。 php-casbin#8
* refactor: 去掉了在框架初始化的时候就注入监听,改为按需初始化 php-casbin#6
* fix: 去掉了Laravel的缓存,保持和TP一样 php-casbin#7
* refactor:  调整了一些LaravelAdapter里用法。

已知问题:
* 测试待补充
* 调整未测试(主要因为着急,本身项目里已造了轮子,所以没拿回去测试)
@lyt8384
Copy link
Contributor

lyt8384 commented Mar 13, 2023

请参考文档 https://www.workerman.net/doc/webman/db/tutorial.html 安装 illuminate/database

已经安装了,这个问题是在使用 casbin/webman-permission 这个组件时,开启了cache才报错,报错代码文件位置: vendor\casbin\webman-permission\src\Model\LaravelRuleModel.php【line: 90】

return $this->store->remember($this->config('cache.key'), $this->config('cache.ttl'), $get);

上面那个 $this->store 没有被初始化

去掉了ORM Cache,目前与TP一样了。

@Tinywan Tinywan closed this as completed Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants