No Code Attached Yet
avatar rogernclarke
rogernclarke
23 Nov 2022

Joomla allows to use different primary key names for tables. This has not been honoured in the JsonApiView::displayItem() function.

Steps to reproduce the issue

Create a new API accessing data from a component which has a table with a primary key which is not called 'id'.
The view class for the API extends Joomla\CMS\MVC\View\JsonApiView.
Execute the API GET for a specific item id which exists in the table.

Expected result

The item should be returned by the webservice.

Actual result

Warning: Undefined property: Joomla\CMS\Object\CMSObject::$id in
/home/customer/www/dev4.spindata.co.uk/public_html/libraries/src/MVC/View/JsonApiView.php on line 218

This is because line 218 of the displayItem()function in Joomla\CMS\MVC\View\JsonApiView checks if $item->id is null, but $item->id does not exist:

if ($item->id === null) {
throw new RouteNotFoundException('Item does not exist');
}

System information (as much as possible)

Joomla version 4.2.5

Additional comments

avatar rogernclarke rogernclarke - open - 23 Nov 2022
avatar rogernclarke rogernclarke - change - 23 Nov 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 23 Nov 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Nov 2022
avatar alikon
alikon - comment - 25 Nov 2022

see #39309

avatar richard67 richard67 - change - 25 Nov 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-11-25 09:33:32
Closed_By richard67
avatar richard67 richard67 - close - 25 Nov 2022
avatar richard67
richard67 - comment - 25 Nov 2022

Closing as having a pull request. Please test #39309 . Thanks in advance.

avatar alikon alikon - change - 9 Apr 2024
Status Closed New
Closed_Date 2022-11-25 09:33:32
Closed_By richard67
avatar alikon alikon - reopen - 9 Apr 2024

Add a Comment

Login with GitHub to post a comment