Strict Standards: Declaration of ..\Pagination::_item_active() should be compatible with JPagination

informdk

New Member
Hi,

Only for your known, with Joomla PHP error_reporting set to maximum, after upgrade to fabrick 3.8.1. with Joomla 3.7.5. on viewing a list appears this warning:

Strict Standards: Declaration of Fabrik\Helpers\Pagination::_item_active() should be compatible
with JPagination::_item_active(JPaginationObject $item) in
X:\XXXXX\libraries\fabrik\fabrik\Helpers\Pagination.php on line 42 Strict Standards:
Declaration of Fabrik\Helpers\Pagination::_item_inactive() should be compatible
with JPagination::_item_inactive(JPaginationObject $item) in Pagination.php on line 42

With error_reporting set to default on Joomla Server Configuration, no warning appears so it's solved! Maybe it's useful the warning for your development. Thank you for fabrick!
 
As far as I can see reading the code for both Fabrik and current Joomla they are compatible, though the namespace in Joomla's code is implied whilst that in Fabrik is (understandably) explicit.

Fabrik: protected function _item_active(\Joomla\CMS\Pagination\PaginationObject $item)
Joomla: namespace Joomla\CMS\Pagination; protected function _item_active(PaginationObject $item)

I assume that this is triggered by the form being different.

There is a "use \JPaginationObject;" at the beginning of "libraries/fabrik/fabrik/Helpers/Pagination.php", so perhaps if this was changed to "use \Joomla\CMS\Pagination\PaginationObject;" and then the function definition to "protected function _item_active(PaginationObject $item)" this Strict Standards error would go away.

@informdk: Would you be willing to test this and submit a PR if it works?
 
The problem is that J! changed that function definition in 3.8, which is when I had to change it:

https://github.com/Fabrik/fabrik/co...ba47908#diff-dea897ff768cb9d89490d73943d81dfb

So the code as-is now is 3.8 (and 4.x) compatible, and doesn't toss that strict warning. If we change it back to JPaginationObject, it won't toss the warning in 3.7, but will in 3.8.

So no, no PR. It is what it is. It'll barf in 'strict' logging on < 3.8. Which is an irritation on dev sites, but strict logging is only for developers, so it's not an issue on live sites.

-- hugh
 
Hugh: I wasn't suggesting that we reverted your change, but instead that we changed the "use" statement at the beginning of the file from "use \JPaginationObject;" to "use \Joomla\CMS\Pagination\PaginationObject;" - but I am not knowledgeable enough about use of namespaces in Joomla to know if this will break backwards compatibility.

That said, for users still on J3.7.x, this probably wouldn't fix it anyway.
 
Nope, wouldn't help. All the 'use' statement at the top does is allow you to not prepend the full namespace, so ...

Code:
use \Joomla\CMS\Pagination;

protected function _item_active(PaginationObject $item)

... is the same as ...

Code:
protected function _item_active(\Joomla\CMS\Pagination\PaginationObject $item)

Just to complicate things, JPaginationObject (which used to be the class name) is now an alias for the new, namespaced class, which is registered as an alias in J!'s classmap:

Code:
JLoader::registerAlias('JPaginationObject', '\\Joomla\\CMS\\Pagination\\PaginationObject', '5.0');

... where registerAlias() internally does a PHP class_alias(). This is part of J!'s compat library, for the move to namespacing. So code that use JPaginationObject (or whatever) will still work.

But ... due to a peculiarity of PHP, although the alias should be synonymous, if you use it as a typehint in a function, it isn't. So because they changed the typehint to the "real" namespaced name, even though the JPaginationObject is an alias to the same thing, PHP doesn't consider it to be the same for the purposes of extending / overriding a class, hence the warning.

-- hugh
 
I try REALLY hard to keep us compatible with at least the previous two versions of J!, and on the whole it is, but occasionally J! throw a curveball. In this case, it won't break anything, and only shows up if you enable 'strict' logging.

But yeah, on the whole, it's always best to run them in matching pairs.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top