Closed (fixed)
Project:
Drupal core
Version:
9.5.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Jul 2018 at 05:40 UTC
Updated:
24 Nov 2023 at 09:46 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dpiComment #4
extexan commented+1
Comment #6
rosk0Real issue, proposed solutions seams reasonable, would love to see this implemented.
Comment #7
idebr commentedClosed #3002803: Unable to reset to alphabetical without administer content permission as a duplicate issue.
Comment #8
idebr commentedAttached patch implements a 'reset all weights' operation on the
\Drupal\taxonomy\VocabularyAccessControlHandler::checkAccess()method and applies it to the Term overview form.Comment #11
idebr commentedFixed Drupal code style.
Comment #13
tim-dielsThis works for me. Good job!
Comment #15
craigperks commentedThis works for me also. Thank you!
Comment #17
intrafusionPatch applied without issue to 8.9.x and fixes the issue, do 3 reviews over 9 months count as reviewed?
Also as I believe this is a non-disruptive bug fix, this can be applied to all active versions.
Comment #18
dpi9.1 is the target version, with optional backports.
Comment #19
jeroentComment #20
ayushmishra206 commentedRerolled the patch for 9.1. Please review.
Comment #22
sarvjeetsingh commentedupdated patch with fixed undefined variable error and coding standard errors.
please review.
Comment #23
meghasharma commentedI have reviewed the attached #22patch, Here are the results:
* Patch applied cleanly without any issues.
* After applying the patch,
saw some more coding standard errors in updated files
updated patch with fixed above coding standard errors.
please review.
Comment #24
kapilv commentedComment #25
jeroentPatch #23 is working for me.
Comment #26
quietone commented@meghasharma, Welcome to Drupal! Thank you for running phpcs and checking the coding standards. However, this issue isn't about fixing coding standards in the modified files and having those changes in the patch become noise and make it harder to review the patch.
Out of scope.
Also out of scope
Out of scope
Out of scope
So here the the the list gets reset to alphabetical. That proves the button is there but how do we know that the data has actually been reordered? Where is the test for that?
Comment #27
jeroentThe actual reordering is tested here: https://git.drupalcode.org/project/drupal/-/blob/9.1.x/core/modules/taxo...
Comment #28
anmolgoyal74 commentedRemoved the out of scope changes mentioned in #26
Comment #31
kim.pepperComment #32
darvanenThe rerolls since #11 have muddled up the logic somewhat, likely because of underlying changes to the form that git/patch couldn't sort out by itself. Here's what I can see at the moment:
This is the wrong check to replace with this logic. It's determining whether the "add term" link should be shown so it should be checking create access.
This is the second place this logic exists (it's functionally the same as line 316). Turn this into a variable if the need to use it mutliple times remains.
This will need to be reinstated because of point 1.
Comment #33
darvanenComment #35
mohit_aghera commentedUpdating the comments based on feedback in #32
Test cases are passing on local as well.
Comment #37
idebr commentedAttached patch replaces the call to the deprecation
drupalPostForm()withsubmitForm()Comment #39
jeroentPatch looks good to me.
Comment #40
darvanenIt is looking good :) however:
Why has this been moved? This looks like an unrelated change.
Error message needs to reflect the reason for failure.
Comment #41
idebr commented#40.1 Returned the line to its original location. Having the cache dependencies added on subsequent lines was helping readability for me, but there is a merit to the smallest change possible I suppose
#40.2 Copied the message from \Drupal\taxonomy\Form\OverviewTerms::buildForm() so it accurately reflects the reason for failure.
Comment #43
darvanenLooks good, thank you.
Re #40.1, the idea is to give core committers less to figure out when reading the patch. I've seen so many issues knocked back with "unrelated change" :)
I wonder if they'll insist on tests for the error messages? That's a grey area for me, so as far as I'm concerned this can go back to RTBC.
Comment #44
catchI don't think it's reasonable to load the entire taxonomy tree, which can contain potentially hundreds of thousands of terms, to check access here. Why not make the button access rely on the administer taxonomy permission instead?
Comment #45
dpi@catch
Not to nitpick, but
\Drupal\taxonomy\Form\OverviewTerms's buildForm and submitForm already do this. They make the same call of$this->storageController->loadTree($taxonomy_vocabulary->id(), 0, NULL, TRUE);Regardless, I think we shouldnt need to do this in the access check either. Checking for the administer permission is enough. If contrib wants to do something fancy this new operation; access check will allow modules to hook in.
The patch moved the 'reset all weights'' permission check to the operation in
VocabularyAccessControlHandler. So we dont lose this behavior.So, lets lets remove this hunk.
I also dont fully understand why this is in access control. We dont need to determine whether *it is possible* to reorder. We only need to check whether the user should have *permission* to reorder. This responsibility should remain with
\Drupal\taxonomy\Form\OverviewTermsComment #46
andregp commented@dpi here is a patch as per your comment.
I removed the hunk of code related to
$tree = $storage_controller->loadTree($entity->id(), 0, NULL, TRUE);and added a simple permission check.I also removed these checks as \Drupal\taxonomy\Form\OverviewTerms already takes care of them. (line 308).
Comment #48
andregp commentedRandom test fail.
Comment #49
Johnny Santos commentedI'm going to reproduce in my enviroment and check if it's working as planned to be
Comment #50
Johnny Santos commentedTested as Admin and another created user(without administer taxonomy), and it worked as intented ,reseting to alphabetical order.
Comment #51
xjmThanks @Johnny Santos for manually testing this!
In addition to manual testing, the patch also needs code review to be marked "Reviewed and tested by the community". It looks like the test hit a known random fail, so I am requeuing it.
Comment #52
lpeidro commentedI check the tests about this case. I don't find any cause about the random fail, but I have added new checks about different context.
Please confirm that I correctly understood that;
The user only can "Reset to alphabetical" WHEN
- The user has the permission "administer taxonomy", OR
- The user has the permission "edit terms in ..."
I have generated new patch with the new checks in the test.
Comment #53
lpeidro commentedThe files uploaded in my last comment (#52) are wrong. I did not properly generated the patches, for this reason they did not pass the test.
I have regenerated them again. Sorry for the confusion, this is one of my first contributions to the community.
Comment #54
lpeidro commentedThis time, I had problems with a blank line during static analysis. Sorry again.
Comment #55
lpeidro commentedI think this is the final version of the patch files.
Comment #57
andregp commented@Ipeidro, welcome to the Drupal Community! We're happy to have you helping.
It's perfectly normal to make mistakes sometimes, none of us is free from sending a wrong patch from time to time.
Just some tips for you:
You can easily install yarn on your environment and run
./core/scripts/dev/commit-code-check.shto run the custom commands check before sending the patch (more info).You can also use the phpcs commands (see here) to check for coding standards on your code.
This way you know beforehand if your patch will pass the initial checks, and save time of having to wait the test results here.
Another good practice to follow is to always provide an interdiff file when sending a patch based on a previous one, so that way other developers can more easily see what you changed on the code between the patches. (see here).
Comment #59
prasanth_kp commentedThanks for the patch,
I have applied it cleanly and it worked perfectly according to the condition.
Now the user can Reset to alphabetical if they have "administer taxonomy " or edit term permissions.
Comment #60
darvanenNot convinced this is the correct permission to be applying here. Access to the taxonomy overview doesn't automatically imply the right to edit the arrangement of terms.
I think it should be if they have either "edit terms in [vocabulary-name]" or "administer taxonomy" (which is handled in the lines prior to these ones).
Comment #61
ravi.shankar commentedMade changes as per comment #60, please review.
Comment #63
darvanenThanks Ravi, the "edit terms in" line is correct in #55. It's the 'access taxonomy overview' I was questioning, though I was tired so I didn't really see that it was tempered by the presence of the next line already.
Having had more time to think about it I think #55 can be called RTBC. The code looks good, test coverage is good and it's passing, I don't see any outstanding feedback, and it does what the IS says it should.
Comment #64
darvanenReuploading #55 because of the 2 day test cycle.
Comment #66
darvanenRandom fail, back to RTBC
Comment #67
larowlanQueued a 10.0.x test-run
We could simplify this to
But I don't feel strongly about it.
Let's see what the 10.0.x result comes back (although HEAD is broken atm due to container/ci changes)
Comment #68
quietone commentedstarting a retest on D10.
Comment #70
darvanenI agree with #67. Applied.
Comment #71
jeroentComment #72
darvanenOops. I ran the auto-formatter in PhpStorm but I must have had it badly highlighted.
Comment #73
berdirI'm not sure the check for access overview is needed at all? What's the reason for limiting it to that?
We could just an OR check for admin or edit all permission as a single check?
Comment #75
jsricardo commentedI will review this
Comment #76
jsricardo commentedI think the question in question is valid.
I believe it should be analyzed better!
Comment #77
darvanen#73 fair point, I agree. New patch attached.
Comment #79
darvanenComment #80
Manibharathi E R commentedPatch #77 Tested and Applied successfully on Drupal 9.5.x.
Comment #81
gaurav-mathur commentedApplied patch #77 successfully on Drupal 9.5.x. and work fine .Refer to the screenshot.
Thank you
Comment #82
wellsPatch in #77 applies and addresses point raised in #73. Moving back to RTBC.
Comment #83
Martin Markov commentedApplied patch #77 successfully on Drupal 9.4.3. and work fine.
Thank you!
Comment #85
wellsTest fail looks unrelated... moving back to NR for new tests.
Comment #86
acbramley commentedTests passed so back to RTBC
Comment #88
penyaskitoTest failures are unrelated. Couldn't find if tracked elsewhere, asked on https://drupal.slack.com/archives/C1BMUQ9U6/p1676468080110019.
Comment #90
catchDid my best with issue credit, but this is a long issue with lots of participants so apologies for any oversights.
This looks good now - since it's adding a new entity access case, going to commit to 10.1.x only.
Comment #92
boromino commentedAs described in https://www.drupal.org/project/drupal/issues/3403785, the committed solution does not hide the drag'n'drop icons nor the Show row weights link if there is a term with multiple parents. Therefore, I'm attaching a patch that fixes this for 9.5.x.
Comment #93
boromino commentedOverlooked one line to revert.