0
votes

I am debugging a Joomla site, using old Joomla 2.5 . On the move to php 5.4 we encountered the widely discussed strict standards errors. Most have been easy to fix. I have one last error that is proving more difficult.

Strict Standards: Declaration of JCacheControllerView::get() should be compatible with JCacheController::get($id, $group = NULL) in /home/XXXXXX/public_testing/libraries/joomla/cache/controller/view.php on line 137

Research shows advice such as this: Declaration of Methods should be Compatible with Parent Methods in PHP

JCacheController defines

public function get($id, $group = null)

JCacheControllerView extends JCacheController and defines:

public function get(&$view, $method, $id = false, $wrkarounds = true)

So I tried changing the declarations to have the same parameters and same default values: JCacheController defines

public function get($id=false, $group = null, &$view = null, $method = null, $wrkarounds = true)

JCacheControllerView extends JCacheController and defines:

public function get(&$view = null, $method = null, $id = false, $wrkarounds = true, $group = null)

Which results in:

Strict Standards: Declaration of JCacheControllerView::get() should be compatible with JCacheController::get($id = false, $group = NULL, &$view = NULL, $method = NULL, $wrkarounds = true) in /home/freedibl/public_testing/libraries/joomla/cache/controller/view.php on line 137

Could this be because the parameters are not in the same order? How could I fix this without altering the original method calls? Both methods are widely used, and it would be difficult to change every call to either one throughout joomla.

1

1 Answers

0
votes

The order of parameters doesn't matter for PHP interpreter per se as it doesn't check parameters compatibility by name. But you have different types of parameters. Some of them are references and some are variables - this makes declarations incompatible.

So, you actually can fix this problem by changing the parameters order so the types match in both declarations.

Is $view parameter an object or a simple type? If it's an object, you probably don't have to pass it as a reference at all.