Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few improvements for assets #14319

Merged
merged 1 commit into from May 22, 2017
Merged

Conversation

csthomas
Copy link
Contributor

@csthomas csthomas commented Mar 3, 2017

Pull Request for a few fixes from my previous non B/C PR #14279

Summary of Changes

  • Do not force to set rules from com_content component to every new article.
    Use inheritance (simple '{}') as in other extensions.
  • Clean empty actions from rules: {'core.edit': {}, 'core.delete: {}'} to {}
  • Use faster JAccessRules::getData() instead of json_decode() and json_encode() in method JAccessRules::__toString()
  • Add missing column asset_id in tests/unit/schema/ddl.sql

Testing Instructions

  1. Install joomla (I have installed with sample - Test English)
  2. Go to backend Content -> Articles -> click on button Options -> select Tab Permissions
  3. Change permissions for Manager from 'Inherit' to 'Allowed' for Create, Edit, Delete:
    samplea1
  4. Save and Close.
  5. Create a new Article, in permission tab as above(for Manager) permission are set as 'Inherit' - it is OK.
  6. Save and check again - Now a few permissions has been changed from 'Inherit' to 'Allowed' - it is not OK.
  7. Apply patch
  8. Back to point 5 (create a new article)
  9. After save, permissions for Manager stay 'Inherit'. - that is now OK.
  10. Change permission for Manager for Edit action from 'Inherit' to 'Allowed' and Save.
  11. Change tab to user group 'Editor':
    samplea1
  12. Action Edit is as 'Allowed'. Change it to 'Inherit' and Save.
  13. Back to permissions for Manager and check if Edit action has not been reset and still has selected 'Allowed'.

Expected result

A new article by default inherit permissions from parent category (after stored).

Actual result

A new article after save always has copy of permissions from com_content asset.

Documentation Changes Required

None

@ghost
Copy link

ghost commented Mar 5, 2017

Questions about Test Instructions:

Go to backend and create a new article, go to permissions tab and check if permissions are sets as 'inherit'.

Check in each User Group for each Action?

After save it should stay as 'inherit'.

same as above.

If you set 'inherit' for group ex. Manager then it should not reset permissions for other groups.

sounds like this is the Problem but on testing i see no "reset permissions for other groups"

I don't understand the Issue and what to test.

@csthomas
Copy link
Contributor Author

csthomas commented Mar 5, 2017

@franz-wohlkoenig Some time ago I had a bug which reset permission to 'inherit' for other user groups if I only changed permission to 'inherit' for only one user group.

[Updated] Please take a look at the new test instruction.

@ghost
Copy link

ghost commented Mar 5, 2017

@csthomas will test today, thanks for Infos.

@ghost
Copy link

ghost commented Mar 5, 2017

Using default user groups:

bildschirmfoto 2017-03-05 um 14 17 18

and work your Example:

In article edit, permission tab, set permission for Edit to "Allowed" for Manager and Publisher.
After save article, change permission for Edit to "Inherit" for only Manager and save.
Now check if permission for Publisher is still Allowed and not 'Inherit'.

with and -out PR got in Manager: Inherited and in Publisher: Allowed (different Trees).

Creating an Article (before Save) all Groups are inherited.

@csthomas
Copy link
Contributor Author

csthomas commented Mar 6, 2017

@franz-wohlkoenig I have made a new better test instruction. Please test again.

@ghost
Copy link

ghost commented Mar 6, 2017

thanks @csthomas will test later.

@ghost
Copy link

ghost commented Mar 6, 2017

  1. Action Edit is as 'Allowed'. Change it to 'Inherit' and Save.

After Save Action Edit is set on Inherited. A Difference to Instructions the sad it is Allowed.

@csthomas
Copy link
Contributor Author

csthomas commented Mar 6, 2017

Allowed should be preserved/not changed on different user group permission 'Manager'.

@csthomas
Copy link
Contributor Author

csthomas commented Mar 6, 2017

Manager and Editor has the same value 'Allowed' for Edit action field.
Now you change for Editor this field to 'Inherit' and check if only this field has been changed and second one still is as 'Allowed' (I mean for Manager)

@ghost
Copy link

ghost commented Mar 6, 2017

Group Editor has Setting Inherited, not Allowed like wrote in Instructions (thanks for clear Instructions).

@csthomas
Copy link
Contributor Author

csthomas commented Mar 6, 2017

I suppose you do not understand me, May be I explained it in a wrong way:
Please test again points 10..13:

  • on patched joomla, on some existed article, only Edit action is important.
  • for Editor and Manager user group

On start, these two user groups has to be set as "Allowed".
As we have "Allowed" saved we can go to next step.

Change permission to "Inherit" for only one user group and save.
After that one (changed) user group should be as 'Inherit' and second should stay as 'Allowed'.

@ghost
Copy link

ghost commented Mar 6, 2017

Looks like misunderstanding, i try in another Words:

  1. Change tab to user group 'Editor': Action Edit is as 'Allowed'. Change it to 'Inherit' and Save.

I understand that opening Usergroup Editor Action Edit ist set on Allowed, but its set on Inherited:
bildschirmfoto 2017-03-06 um 16 35 14

  1. Action Edit is as 'Allowed'. Change it to 'Inherit' and Save.

So this is not possible cause Inherited set.

@csthomas
Copy link
Contributor Author

csthomas commented Mar 6, 2017

I understand that opening Usergroup Editor Action Edit ist set on Allowed, but its set on Inherited

But before you have to toggle to Manager tab to check that.

You have to do changes in Editor, but check Manager.
When you save setting for Editor group with 'Inherit' value then php code do some clean up for array, and should not erase too much. I means should not change settings for other user group like Manager.

@ghost
Copy link

ghost commented Mar 6, 2017

I have tested this item ✅ successfully on 08d10b2


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

@csthomas
Copy link
Contributor Author

csthomas commented Mar 6, 2017

Thanks for your patience :)

@ghost
Copy link

ghost commented Mar 6, 2017

Thanks for your patience too ;-)

@sanderpotjer
Copy link
Member

I have tested this item ✅ successfully on 08d10b2

Great PR, thanks!


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

@ghost
Copy link

ghost commented May 1, 2017

RTC after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 1, 2017
@rdeutz rdeutz modified the milestone: Joomla 3.7.2 May 4, 2017
@rdeutz rdeutz modified the milestones: Joomla 3.7.2, Joomla 3.7.3 May 18, 2017
@rdeutz rdeutz removed this from the Joomla 3.7.2 milestone May 18, 2017
@rdeutz rdeutz merged commit fed63a2 into joomla:staging May 22, 2017
@joomla-cms-bot joomla-cms-bot added PR-staging Unit/System Tests and removed RTC This Pull Request is Ready To Commit labels May 22, 2017
@csthomas csthomas deleted the some_assets_fix branch June 29, 2017 22:17
@olleharstedt
Copy link

After updating to 3.7.3, we got "Invalid parent ID" for our own JTable. Is this commit related?

@rdeutz
Copy link
Contributor

rdeutz commented Jul 6, 2017

@olleharstedt please open a new issue, comments on closed/merged PR get lost

@csthomas
Copy link
Contributor Author

csthomas commented Jul 6, 2017

Please open a new issue, but meantime:

You may try to revert libraries/joomla/table/asset.php for test or other files too to version from 3.7.2, but the reason is that in your db table #__assets does not exist parent row.

Check your table and find which assets rows has invalid parent_id, means parent_id points to not existed row id.

Example query:

SELECT a.* FROM `#__assets` a LEFT JOIN `#__assets` b ON a.parent_id = b.id WHERE b.id IS NULL 

The correct result is only one row with name = 'root.1'.

@olleharstedt
Copy link

Thank you.

@csthomas Query checks out, only returns root.1.

// JTableNested does not allow parent_id = 0, override this.
if ($this->parent_id > 0)
{
// Get the JDatabaseQuery object
$query = $this->_db->getQuery(true)
->select('COUNT(id)')
->select('1')

Choose a reason for hiding this comment

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

This does not work on our system, for some reason. Query returns null, but with COUNT(*) it returns 1, as should be.

Choose a reason for hiding this comment

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

Using 1 AS x also works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If only this change fix your problem then I do not understand it. What database do you have?

You said that:

SELECT count(*) FROM `#__assets` WHERE id = ?

return 1 and

SELECT 1 FROM `#__assets` WHERE id = ?

return null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using 1 AS x also works.

OK I can understand the reason.
But I thought that such error exists only in sub-queries generated in mssql.
Removing offset and limit also should fix that, ex:
replace $db->setQuery($query, 0, 1) to $db->setQuery($query)

Choose a reason for hiding this comment

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

Removing limit and offset did not fix the issue.

mysql Ver 14.14 Distrib 5.5.55, for debian-linux-gnu (x86_64) using readline 6.3

Choose a reason for hiding this comment

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

PHP 5.5.

Copy link

Choose a reason for hiding this comment

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

Strange thing is, when I run the exact same code in a script using CLI, it works!

Do you know which database driver is used in assets table?

Choose a reason for hiding this comment

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

Oh... _db = JFalangDatabase Object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you think this is a real joomla problem then you can create a PR and add alias to column as you mentioned. I will test it.

Choose a reason for hiding this comment

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

No, this is a Falang problem. They override the database driver and can't handle the query. But sure, if Falang won't fix it, it would be nice if the PR would be accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants