In a virgin J4.0.5 site:
The new article being succesfully created and showing up in the Category List.
A 404 with error message: Invalid field: Start Featured
Joomla! 4.0.5
I traced the cause of the error to line 501 of the front end article model Joomla\Component\Content\Administrator\Model\ArticleModel (administrator/components/com_content/src/Model/ArticleModel.php). That line and preceeding comment read:
// Get ID of the article from input, for frontend, we use a_id while backend uses id
$articleIdFromInput = (int) $app->input->getInt('a_id') ?: $app->input->getInt('id', 0);
First of all I wonder why the back end id is checked in a front end model.
Secondly, the id obtained from $app->input can apparently contain a value other than the record id (didn't check but it looks like the category id). This sets the $articleIdFromInput to a non 0 value, whereas it should be 0 for new articles. The result is that permission, to edit certain attributes of the the record, are checked against a wrong or invalid record id, eventually resulting in the above mentioned error or unjustified acceptation or rejection of the record.
EDIT: I removed the proposed solution. Thanx to @ReLater who pointed out my stupid mistake.
Maybe this is a better approach:
$articleIdFromInput = $app->isClient('site')
? (int) $app->input->getInt('a_id', 0)
: $app->input->getInt('id', 0);
| Labels |
Added:
No Code Attached Yet
|
||
Like I mentioned, the problem appears in the front end ArticleModel. Why would that model be used in the back end? Anyhow, the problem exists, is reproducible and can be solved with the proposed modification.
Your pointing to
Joomla\Component\Content\ Administrator \Model\ArticleModel ( administrator /components/com_content/src/Model/ArticleModel.php).
in your opening post and I was just answering 1 question BTW.
I didn't want to discuss the main issue. Haven't tested.
Not an excuse, but I was completely wrong footed because I was creating a new article in the front end and did not notice it was actually the back end model in which the error occurred. Thanx to @ReLater for pointing that out.
The error is still real though. However, my suggested solution wasn't, so I removed it from the issue.
@pjdevries Your better approach is right (except (int) type casting is not needed). Could you please make a PR with your propose code?
@joomdonation Unfortunately I can not spare the time to create PR's. They always take unforeseen more time than anticipated and I'm not able to deal with that right now.
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-01-03 08:23:25 |
| Closed_By | ⇒ | alikon |
I tested and approved.
Because the model is used in frontend and backend. Therefore the line checks first for a frontend ID that normally uses
a_idnotidinside the edit URL. Ifa_idnot provided check foridwhich is normally the article id in backend inside the edit URL.Example for new article in frontend:
?view=form&a_id=0&layout=edit&catid=2&return=xyz