严格标准:非静态方法(joomla和链轮)


Strict Standards: Non-static method (joomla and roksprocket)

Strict Standards: Non-static method K2ModelItemlist::getCategoryTree() should not be called statically, assuming $this from incompatible context in C:'xampp'htdocs'virgin'components'com_roksprocket'lib'RokSprocket'Provider'K2'Filter.php on line 151

我有这个错误…我正在使用RokSprocket, Joomla并收到上述错误…它似乎起源于

protected function category($data)
{
if(file_exists(JPATH_SITE.'/components/com_k2/models/itemlist.php'))
require_once (JPATH_SITE.'/components/com_k2/models/itemlist.php');
$wheres = array();
foreach($data as $match){
$categories = K2ModelItemlist::getCategoryTree($match);

有办法解决这个问题吗

使Joomla与严格的要求兼容仍在进行中。在这条道路上,核心已经走了很长一段路,但许多扩展开发人员仍然不知道当前的最佳实践。

开发环境

保持最大的error_level,只是通过在function关键字前面加上public static来修复损坏的代码。你会在更新时丢失,但是你的VCS会帮助你快速修复。

生产环境

在生产系统上,error_reporting可以降低到不包含严格的警告。配置服务器记录错误而不是显示错误

K2ModelItemlist::getCategoryTree未定义为静态。看到错误信息了吧。

是的,你可以在文件components/com_k2/models/itemlist.php

中把它定义为静态
function getCategoryTree($categories) // line 576

替换为

static function getCategoryTree($categories)

但是你必须记住你自己的补丁,因为你可能会在升级后丢失它。