Closed pjdevries closed 2 years ago
First of all I wonder why the back end id is checked in a front end model.
Because the model is used in frontend and backend. Therefore the line checks first for a frontend ID that normally uses a_id
not id
inside the edit URL. If a_id
not provided check for id
which 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
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.
@ReLater You are absolutely right and I feel ashamed for my inconsiderate response. I apologize and will correct the mistake.
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.
please test #36542
I tested and approved.
Steps to reproduce the issue
In a virgin J4.0.5 site:
Expected result
The new article being succesfully created and showing up in the Category List.
Actual result
A 404 with error message: Invalid field: Start Featured
System information (as much as possible)
Joomla! 4.0.5
Additional comments
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:First of all I wonder why the back end
id
is checked in a front end model. Secondly, theid
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 non0
value, whereas it should be0
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: