Skip to content

Conversation

@wilsonge
Copy link
Contributor

@wilsonge wilsonge commented Jan 7, 2017

This cleans up canDelete, canEdit and canEditState functions so they always return a boolean and are consistent in how they operate (they can return null in many cases instead of the documented boolean). There are no actual changes to functionality here so theoretically this is code review.

But feel free to test that the authorisation checks on ability to edit, publish/unpublish and delete are unaffected

$menuTypeId = $this->getMenuTypeId($record->menutype);
}

return $user->authorise('core.delete', 'com_menus.menu.' . (int) $menuTypeId);
Copy link
Contributor

@andrepereiradasilva andrepereiradasilva Jan 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the (int) $menuTypeId is 0?
This will make a ACL check to com_menus.menu.0 - which is an asset name that doesn't exist.
IIRC, will not really be an issue because ACL checks will make a second ACL check to fallback to component.

But still this is extra ACL processing that IMHO could and should be avoided. The asset name to check when 0 should be the component itself, ie, in this case com_menus.

It seems the same issue applies to several of the ACL checks in this PR. maybe that should be reviewed too.

Anyway this one in particular already existed before this PR.

Copy link
Contributor

@andrepereiradasilva andrepereiradasilva Jan 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: In reality, thinking this better, there shouldn't even exist menu items without associated menutype, so ... don't even know why the if (!empty($record->menutype)) check exists here.

Update 2: Maybe the check is for when the menu item is not created yet, if that's the case, and in that case, the ACL check should be to com_menus when the menutype is 0 as commented above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be no items without id's in the record. I think it's just a basic sanity check to try and ensure that we have something that seems record like. At this point if someone's managed to inject dodgy details then we have a massive problem anyhow!

@joomla-cms-bot joomla-cms-bot changed the title Can delete [com_fields] Can delete Apr 7, 2017
@brianteeman
Copy link
Contributor

@wilsonge please can you look at resolving the conflicts here

@wilsonge wilsonge changed the title [com_fields] Can delete Cleanup of canDelete, canEdit and canEditState in Component Models May 21, 2017
@wilsonge
Copy link
Contributor Author

Done :)

else
{
return parent::canEditState('com_modules');
return parent::canEditState($record);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the else statement and this line can be on its own.

@Harmageddon
Copy link
Contributor

It seems to me that the if (!empty($record->id)... is the wrong way around in almost every file of this PR. The first one looks correct with if (empty($record->id).

Try to delete a client from the banners component or any other item in an affected component. It fails with this PR.

@brianteeman
Copy link
Contributor

@wilsonge can you look at the comments from @Harmageddon please

@wilsonge
Copy link
Contributor Author

wilsonge commented Aug 3, 2018

Fixed :) - nice spot @Harmageddon

return $user->authorise('core.delete', 'com_banners');
if (!empty($record->catid))
{
return $user->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete line 43 and change to:
return JFactory::getUser()->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice spot!

@ghost ghost added the J3 Issue label Apr 5, 2019
@ghost ghost removed the J3 Issue label Apr 19, 2019
@Hackwar
Copy link
Member

Hackwar commented Jun 30, 2019

I have tested this item ✅ successfully on b702f80

Done a code review and found this to be okay.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13500.

@Quy
Copy link
Contributor

Quy commented Jul 1, 2019

I have tested this item ✅ successfully on f29ab48


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13500.

@Quy
Copy link
Contributor

Quy commented Jul 1, 2019

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13500.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 1, 2019
@HLeithner HLeithner merged commit 4dbd480 into joomla:staging Jul 1, 2019
@HLeithner
Copy link
Member

thx

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jul 1, 2019
@HLeithner HLeithner added this to the Joomla 3.9.9 milestone Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants