0

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

All

I have this error...I am using RokSprocket, Joomla and received the above error... It seems to have originated from

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);

Any idea how to fix this.

Craig
  • 9,335
  • 2
  • 34
  • 38
Hello Universe
  • 3,248
  • 7
  • 50
  • 86

2 Answers2

2

Making Joomla compatible with the strict requirements are still work in progress. The core has come a long way on that road, but many extension developers are still not aware of current best practices.

Development Environment

Stay with the maximum error_level, just repair the broken code by prepending the function keyword with public static. You'll loose that on updates, but your VCS will help you to re-fix that quickly.

Production Environment

On productive systems, error_reporting can be lowered to not include strict warnings. Configure the server to log errors instead of displaying them.

nibra
  • 3,958
  • 2
  • 20
  • 34
0

K2ModelItemlist::getCategoryTree not defined as static. There for you got that error message.

Yes, you can define it as static yourself inside file components/com_k2/models/itemlist.php

function getCategoryTree($categories) // line 576

replace with

static function getCategoryTree($categories)

But you must remember every your own patch of foreign components cause you can lose it after upgrading.

sectus
  • 15,605
  • 5
  • 55
  • 97
  • I suggest you fill in bug report/ issue so the fixes are merged into official distribution of extension: [getk2: Issues](https://code.google.com/p/getk2/issues/list). You'll help others with same problem and don't have to worry about losing changes after upgrades. – piotr_cz May 14 '13 at 07:20
  • @piotr_cz, it's not issue of k2, they use it right. It's issue of RokSprocket and they [already know about it](http://www.rockettheme.com/forum/index.php?f=611&t=195649&p=959880&hilit=getCategoryTree&rb_v=viewtopic#p959880). – sectus May 14 '13 at 08:20
  • Probably you are right. Solution would then be to get model instance `$model = JModelLegacy::getInstance('ItemList', 'K2Model', array('ignore_request' => true));` and access it's method: `$categories = $model->getCategoryTree($match);` Moreover require_once should be replaced with `JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_k2/models', 'K2Model');` – piotr_cz May 14 '13 at 09:22