? Success

User tests: Successful: Unsuccessful:

avatar nhusung
nhusung
10 Mar 2019

Summary of Changes

Since the introduction of the categoryedit form field in the edit models/views of com_content, com_contact, com_newsfeeds and com_banners (d6673d7), there is no action attribute on the catid form field and thus no need to set it anymore.

Furthermore cleanups concerning the $id in ContentModelArticle::getForm() are performed. As the
getState('article.id') method returns the correct article id, no matter whether in frontend or backend, and seems to be the standard way of retrieving the article id, there is no need to fetch it from the CMSApplication's input.

Testing Instructions

As the changes are pretty small, a code review should be enough. However you can have a look at the category field inside the edit forms of com_content, com_contact, com_newsfeeds and com_banners with users associated to different groups and access levels and privileges.

Expected results

Same as before this pull

avatar nhusung nhusung - open - 10 Mar 2019
avatar nhusung nhusung - change - 10 Mar 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 Mar 2019
Category Administration com_banners com_contact com_content com_newsfeeds
avatar nhusung nhusung - change - 11 Mar 2019
The description was changed
avatar nhusung nhusung - edited - 11 Mar 2019
avatar nhusung nhusung - change - 11 Mar 2019
Labels Added: ?
avatar nhusung nhusung - change - 23 Mar 2019
The description was changed
avatar nhusung nhusung - edited - 23 Mar 2019
avatar nhusung nhusung - change - 23 Mar 2019
The description was changed
avatar nhusung nhusung - edited - 23 Mar 2019
avatar nhusung
nhusung - comment - 23 Mar 2019

As far as I know, many extensions developers use com_content as a template for their components. In order to stop developers from copying the unnecessary lines as fast as possible I decided to create a pull request on the staging branch. However, I started to wonder whether this is the correct place to put code cleanups (anyway it would not be merged into the 4.0-dev branch, would it?). That is why I created another pull request #24329.

avatar nhusung nhusung - change - 5 Apr 2019
Title
Remove setFieldAttribute `action` on `catid` in com_content, …
Code cleanup: remove setFieldAttribute('catid', 'action', …)
avatar nhusung nhusung - edited - 5 Apr 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 24 Apr 2019

@HLeithner any Comment as Release Lead?

avatar HLeithner
HLeithner - comment - 24 Apr 2019

We need at least 2 tests and better testing instructions, also the merge conflict must be solved.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 24 Apr 2019

@nhusung please give clear test instructions and resolve the conflicting files, thanks.

avatar nhusung nhusung - change - 25 Apr 2019
Labels Removed: J3 Issue
avatar nhusung
nhusung - comment - 25 Apr 2019

While I resolved the conflicts I tried hard to remove big parts the following code (as $form->setFieldAttribute('catid', 'action', '…') is not needed):

// Determine correct permissions to check.
if ($this->getState('article.id'))
{
$id = $this->getState('article.id');
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
// Existing record. Can only edit own articles in selected categories.
if ($app->isClient('administrator'))
{
$form->setFieldAttribute('catid', 'action', 'core.edit.own');
}
else
// Existing record. We can't edit the category in frontend if not edit.state.
{
if ($id != 0 && (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id))
|| ($id == 0 && !$user->authorise('core.edit.state', 'com_content')))
{
$form->setFieldAttribute('catid', 'readonly', 'true');
$form->setFieldAttribute('catid', 'filter', 'unset');
}
}
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}

However, I’m not a hundred percent sure what @infograf768 intended in his last two commits (#24216 and #24640). To me it seems like issue #23991 occurs when a user with no edit.state permission on an already published article tries to change the article’s category. So why do we check for $id == 0 && !$user->authorise('core.edit.state', 'com_content')? If I’m not mistaking, this check is not relevant anyway. We already tested that $this->getState('article.id') is not 0 above. Furthermore, I’d like to question the $app->isClient('…') check. Couldn’t someone theoretically have permissions to view the article in backend but not to edit its state?

avatar nhusung
nhusung - comment - 26 Apr 2019

I could confirm my second concern (#24150 (comment)) so I just corrected it.

avatar HLeithner
HLeithner - comment - 26 Apr 2019

@nhusung I tought about this pr again, we shouldn't do PRs in J3 that could delay the work in j4. So please check if this code is still in j4 and if so please rebase on j4-dev branch.

avatar nhusung
nhusung - comment - 26 Apr 2019

@HLeithner yes, the setFieldAttribute('catid', 'action', '…') lines are still present in J4. I already created #24329 which simply removes them. Sorry for the bad testing instructions but this is my first pull request ever and I was not quite sure what instructions to give when it can be verified from reviewing the code that the it does not do anything at all. Should I close this PR now?

avatar HLeithner
HLeithner - comment - 26 Apr 2019

thx and don't worry.

avatar HLeithner HLeithner - change - 26 Apr 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-04-26 10:19:59
Closed_By HLeithner
avatar HLeithner HLeithner - close - 26 Apr 2019

Add a Comment

Login with GitHub to post a comment