No Code Attached Yet bug
avatar Razzo1987
Razzo1987
31 Jul 2023

Steps to reproduce the issue

Install the attached simple extension: alias_test.zip
Create a new article from admin panel:
image
The body contains 0 as intemid

Update the article:
image
Now the body contains the real ID

Create the article from API Post:
image
the itemid is empty (instead 0)

Expected result

the API call also must have an ID with 0 on new item.
I do not test yet the update via API.

Actual result

no value in the $item->id

System information (as much as possible)

Bug find in Joomla 4.4

Additional comments

it is important because some plugins use this check:

if (!is_array($data) || empty($item->id) || empty($data['com_fields'])) {

but is have not the same result in API post

avatar Razzo1987 Razzo1987 - open - 31 Jul 2023
avatar joomla-cms-bot joomla-cms-bot - change - 31 Jul 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 31 Jul 2023
avatar Razzo1987 Razzo1987 - change - 31 Jul 2023
Title
[J4.4] API item->id
[J4.4] API Create Article item->id
avatar Razzo1987 Razzo1987 - edited - 31 Jul 2023
avatar Razzo1987
Razzo1987 - comment - 1 Aug 2023

NOTE
the code:
is used onContentAFTERsave and not in onContentBEFORESave

The different behavior remains, but in case of BEFORE Save the correct control is:

if (!is_array($data) || empty($data['com_fields']))

avatar Hackwar Hackwar - change - 28 Mar 2024
Labels Added: bug
avatar Hackwar Hackwar - labeled - 28 Mar 2024
avatar Hackwar
Hackwar - comment - 28 Mar 2024

To rephrase the issue: When creating an article via the browser, the default value for the ID of an article is 0. When doing the same via the API, no value is set, resulting in a null value being used in this place.

Add a Comment

Login with GitHub to post a comment