Joomla allows to use different primary key names for tables. This has not been honoured in the JsonApiView::displayItem() function.
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.
The item should be returned by the webservice.
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');
}
Joomla version 4.2.5
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-11-25 09:33:32 |
Closed_By | ⇒ | richard67 |
Status | Closed | ⇒ | New |
Closed_Date | 2022-11-25 09:33:32 | ⇒ | |
Closed_By | richard67 | ⇒ |
It seems we need in file https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/MVC/View/JsonApiView.php a similar fix as it has been made in file https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/MVC/View/FormView.php with PR #39067 .