缓存插件和具有重复名称的正常控制器 [英] Caching plugin and normal controllers with duplicate names

查看:131
本文介绍了缓存插件和具有重复名称的正常控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与缓存,插件和重复模型名称在Cake 2.0中有关的问题。我的应用程序有几个控制器只包含公开使用的操作(视图,索引和等效)。数据由作为插件添加的CMS管理,插件的控制器的某些名称是相同的。

I'm running into a problem related to caching, plugins and duplicate model names in Cake 2.0. My application has several controllers containing only actions for public use (view, index and equivalents). The data is managed by a CMS which is added as a plugin, some names of the plugin's controller are the same.

例如,我有一个PostsController在我的应用程序和一个PostsController的插件。插件控制器扩展 PluginAppController ,公共控制器按照手册扩展 AppController 。一旦缓存被启动(通过将 debug 设置为 0 ),问题就开始了。 Cake尝试在控制器中访问不存在的添加操作,它扩展了 AppController ,公共应用程序尝试访问方法从 PluginAppController

For example, I have a PostsController in my application and a PostsController for the plugin. The plugin controller extends PluginAppController and the public controller extends AppController as per the manual. As soon as caching is kicked in (by setting debug to 0) the problems start. Cake tries to access a non-existing add action in the controller which extends AppController and the public application tries to access methods from the PluginAppController.

我不明白为什么Cake会这样做,它会创建各种错误空白页,丢失的会话),这些都没有正确记录。一切都运行良好,而应用程序仍然运行在Cake 1.3和2.0生产模式。

I don't understand why Cake would do this and it creates all kinds of errors (blank pages, lost sessions) which aren't logged properly as well. Everything was working well while the app still ran on Cake 1.3 and also in 2.0 production mode.

文件 cake_core_file_map / tmp / cache / persistent / 目录似乎是导致的问题。一旦我删除这个和重新加载任何一个视图,它正确渲染。因此,过程如下:

The file cake_core_file_map in the /tmp/cache/persistent/ directory seems to be causing the issue. As soon as I remove this and reload either of the views, it renders correctly. So the procedure is as follows:


  • 加载 http://www.example.com/admin/posts successfully;

  • 载入 http://www.example.com/posts ;

  • 清除缓存(或只是cake_core_file_map);

  • 加载 http://www.example.com/posts 已成功;

  • 载入 http://www.example.com/admin/posts 无法正确加载)。

  • Load http://www.example.com/admin/posts successfully;
  • Load http://www.example.com/posts (it fails to render);
  • Clear the cache (or just cake_core_file_map);
  • Load http://www.example.com/posts successfully;
  • Load http://www.example.com/admin/posts (which now fails to load properly).

我的猜测是Cake无法保存对插件和主应用程序路径的正确引用 cake_core_file_map ,但我不知道如何强迫Cake在这方面表现得很好。

My guess is Cake fails to save the correct references to the plugin and main application paths in cake_core_file_map, but I have no clue how to force Cake to behave nicely in that regard.

有人知道如何阻止Cake将插件的控制器与名称重复的其他控制器混淆。

Does anybody know how to stop Cake from confusing the plugin's controllers with the other ones with duplicate names?

EDIT

此问题可能与Cake中的错误有关,因为此报告提到类似的问题, cake_core_file_map 。修正提到了这里不能正常工作。

This issue might be related to a bug in Cake, as this report mentions similar problems and cake_core_file_map as well. The fix mentioned here doesn't work unfortunately.

EDIT 2
确实有一些自定义路由,这在Cake 1.3中正常工作。这是来自 routes.php

Router::connect('/plugin_name', array('plugin' => 'plugin_name', 'controller' => 'users', 'action' => 'login'));
Router::connect('/admin/*', array('plugin' => 'plugin_name', 'controller' => 'posts', 'action' => 'index'));


推荐答案

这是一个已知的问题不要让它烦人),并且只会在下一个主要版本中修复,根据这个Cake bug报告

This turns out to be a known issue (which doesn't make it less annoying) and will only be fixed in a next major release, as per this Cake bug report.

PHP 5.2没有命名空间支持,显然需要Cake支持重复的类名。 PHP 5.3有命名空间支持,Cake 3.0将需要该版本。

PHP 5.2 doesn't have namespace support which is apparently needed for Cake to support duplicate classnames. PHP 5.3 has namespace support and Cake 3.0 will require that version.

这篇关于缓存插件和具有重复名称的正常控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆