CakePHP 2.0 - Cake 无法写入文件缓存

发布于 2024-12-07 07:03:18 字数 987 浏览 0 评论 0原文

我正在使用 CakePHP 2.0 RC-1。从 SVN 检查项目后,应用程序开始抱怨它无法将缓存文件写入 tmp/cache 目录。由于这是本地的,我知道该目录是可写的,并且我可以清楚地看到该目录甚至充满了文件,因此该错误有点奇怪。

以下是我遇到的一些错误:

_cake_core_ cache was unable to write 'cake_dev_nb' to File cache

fopen(c:\cake\app\tmp\cache\models\cake_model_default_media) [function.fopen]: failed to open stream: No error [CORE\Cake\Cache\Engine\FileEngine.php, line 127]

没有错误?!是吗?

现在,如果我查看 FileEngine 文件,第 127 行显示为:

if (!$handle = fopen($this->_File->getPathName(), 'c')) {
            return false;
}

通过将“c”替换为“w”,不会遇到错误,并且一切正常。但是,不需要修改核心 Cake 库来解决此问题。让我重复一遍,在我的另一台计算机上,这可以按预期工作,无需编辑核心库。两者都使用Windows操作系统,并且对tmp/cache-folder的读/写权限完全相同。

编辑:这是一个遇到错误输出的网站,我在本地

通过谷歌搜索找到了示例网站。不是我的网站:http://www.12h30.net/credit/

有什么建议吗?

更新:原因如下: 这是因为您的 PHP 版本太低(5.2.6 之前),如评论中的“api55”所述。感谢您的回复。希望这也对您有帮助。

I'm using CakePHP 2.0 RC-1. After checking out the project from SVN, the application is starting to complain that it can't write cache files to the tmp/cache directory. Since this is local, I know the directory is writeable and I can CLEARLY see that the directories are even filled with files, so the error is a bit strange.

Here are some of the errors I've encountered:

_cake_core_ cache was unable to write 'cake_dev_nb' to File cache

fopen(c:\cake\app\tmp\cache\models\cake_model_default_media) [function.fopen]: failed to open stream: No error [CORE\Cake\Cache\Engine\FileEngine.php, line 127]

No error?! Wth?

Now, if I look in the FileEngine file, at line 127 it reads:

if (!$handle = fopen($this->_File->getPathName(), 'c')) {
            return false;
}

By replacing the "c" with "w", no error is encountered and everything works as it should. But, it should not be necessary to modify the core Cake libraries to work around this problem. Let me repeat that on my other computer this works as intended, without editing the core library. Both use the Windows OS and the read/write rights to the tmp/cache-folder is exactly the same.

Edit: Here's a site that experiences the error outputs I'm having locally

Example site found by Googling. Not my site: http://www.12h30.net/credit/

Any suggestions?

Update: Here is why: This is caused if you have a PHP-version that's too low, before 5.2.6, as outlined by "api55" in the comments. Thanks for the reply. Hope this helps you too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

岁月染过的梦 2024-12-14 07:03:18

好吧,就我而言,当我检查我的应用程序时,它没有 /tmp 文件夹。然后我创建了结构(/tmp/cache/models/tmp/cache/persistent),一切运行良好。这发生在我身上,也许 git 忽略空文件夹,所以它们没有被创建。

Well, in my case, when I checked my app, it hadn't the /tmp folder. Then I created the structure (/tmp/cache/models, /tmp/cache/persistent) and all worked well. This happened to me maybe git ignore empty folders, so they weren't created.

违心° 2024-12-14 07:03:18

我遇到了类似的问题,这是因为我对 app/tmp 目录执行了 chown -R www 以使 Cake“正确”运行,而不给予每个人写入权限。看起来在开发过程中使用控制台和网络的唯一方法是给予每个人写入权限,或者将自己添加到 www 组中。

简单的解决方案:

chmod -R 777 应用程序/tmp

chown -R 用户名 app/tmp

使用控制台时

chown -R www app/tmp

使用网络时

I had a similar problem, it was because I had chown -R www to the app/tmp directory to get Cake to run "properly" without giving everyone write privileges. Looks like during development the only way to use the console and the web is to give everyone write privileges, or add yourself to the www group perhaps.

Easy solution:

chmod -R 777 app/tmp

or

chown -R username app/tmp

while using the console and

chown -R www app/tmp

when using the web

鱼忆七猫命九 2024-12-14 07:03:18

只需将正确的 CHMOD776 对我来说效果很好)给 app/tmp

Just give the right CHMOD (776 works fine for me) to app/tmp

淡淡の花香 2024-12-14 07:03:18

对于具有相同错误/警告的 Windows 用户:请确保在提升模式下运行命令提示符;)

for windows users with the same error/warning: make sure you run the command prompt in elevated mode ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文