Closed (duplicate)
Project:
Drupal core
Version:
8.3.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Apr 2015 at 10:43 UTC
Updated:
5 Feb 2018 at 20:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
willzyx commentedComment #2
xanoWe use a new approach for this in Drupal 8. All entity operations should be provided by the entity type's list builder (which primarily builds entity listings). The list builders allow entity types to provide their own operations, but also invoke the hooks that are necessary for other modules to provide additional operations. The prime example of that in core are probably the content and config translation modules.
Because term listings are more complex–they cannot be listed all at once, but only per vocabulary–we can only use the term list builder for providing operations. We've done this in core once before (I cannot remember where exactly right now).
Comment #3
willzyx commentedI cannot find another point in which the list builder is used in this way in core.. and doing so dont we lose the destination?
Comment #4
xanoIt's been done before somewhere in a core issue (I remember discussing it with @sun). The reason is that operations handlers could no longer be added to core after code freeze. This is why list builders have become responsible for providing operations links, even though they cannot always provide lists too.
This patch adds destinations.
Comment #5
willzyx commentedcall parent::__construct() instead of set manually the member variables and change
::getOperationsto::getDefaultOperations.Furthemore in
::render()\LogicExceptionis more appropriate, isn't it?Comment #6
xanoDuh... Thanks!
It's all potatoes potatoes to me. I looked it up and
\LogicExceptionmakes sense indeed.This change is actually a regression, as it would override any existing GET parameters and we don't want that.
Comment #7
willzyx commentedlooking at EntityListBuilder::getDefaultOperations() this should not be a problem. however..
Comment #8
xanoThanks!
It's unlikely, but the way your patch from #7 does it, is better practice. Basically: don't touch anything you don't have to.
Comment #9
xanoThanks!
It's unlikely, but the way your patch from #7 does it, is better practice. Basically: don't touch anything you don't have to.
Comment #10
willzyx commentedI think we should create, in a similar manner, a patch for shortcuts (links list page)
Comment #12
miro_dietikerWe tried to implement hook_entity_operation_alter() for all entity types in collect contrib and it was not possible to alter tag operations. See #2491307: Add "Capture" operation to all content entities
Works like a charm after applying this patch.
Comment #13
andypostAny reason to introduce non-usable list bulder?
Suppose proper fix is to convert OverviewTerms to list builder
incredible hack...
Comment #14
xanoSee #3 and #4 for why this is done in such a 'hacky' way. In 2014 the decision was made that because of code freeze we could no longer add new entity type handlers. The entire page cannot be converted to a list builder easily or at all, because the page only displays terms for a specific vocabulary, whereas list builders were designed to display all entities of a specified type.
Comment #16
miro_dietikerLooks much RTBC to me. (edited) Except: There is no documentation at all that explains why the TermListBuilder is limited to operations only.
Comment #18
xanoDoes this mean there is or is not enough documentation?
If there is, do you see any other objections to an RTBC?
Comment #23
miro_dietikerI'm not used to documentation verbosity in core.
There is zero explanation on why. I would have expected to see some comment similar to your words above:
Comment #24
xanoThe technical reason is that we crammed two separate features (list building and operations) in the same interface (
ListBuilderInterface) and we shouldn't have. There are numerous reasons why classes wouldn't want to provide lists, but do provide operations.In practice, the only reason I have seen so far (IIRC) is that we use alternative listing methods. I'm not sure we should explain this in the exception message, as the choice to use these alternative methods lies with the application (the entity type definition) and not with the list builder itself.
However, based on that reasoning, we should perhaps allow lists to be made using this list builder in case someone wants a list of terms across all vocabularies. It would also mean the class complies with the interface and there are no WTFs about application-level decisions.
Thanks for pointing out we can and should improve documentation!
Comment #25
arla commentedWhy is the destination param expected for term operations but not for operations of other entity types? Should we consider adding destination param to (some) operations in EntityListBuilder?
Comment #26
gappleRan into a similar issue with menu links, so created #2684577: Entity operations for menu links are hardcoded in edit menu form with some changes based on this issue.
Comment #27
miro_dietikerHm i guess it would be 8.x-2.x target meanwhile?
Comment #28
gappleRe-roll for 8.2.x
Comment #30
arla commentedDid a little bit of digging to answer #25, and found that both term and node operations have been including the destination for a long time. I guess there's no point in trying to change that in this issue.
Comment #32
effulgentsia commentedI queued a retest of #28 (on 8.3.x) to see if anything's changed in 6 months.
Comment #33
effulgentsia commentedCool. Same two failures. Anyone here able to debug them?
Comment #34
mohit_aghera commented@effulgentsia i am on it.
Comment #35
mohit_aghera commentedComment #36
andypostthis change is wrong! edit forum always have params!
Comment #37
mohit_aghera commented@andypost i tried to replicate it.
However exception is at the same line. [Notice] Line 64 of core/modules/forum/src/Form/Overview.php
Tried to reproduce by running test case locally as well.
Can there be anything that is internally calling `Overview.php` of forum module ?
Comment #38
berdir#2767857: Add destination to edit, delete, enable, disable links in entity list builders does this in a generic way, then we wouldn't need this anymore.
not sure why we need to do this.
Comment #39
berdirNot sure if/why that is needed with the forum operations but what about moving that to hook_entity_operations_alter() and out of the custom controller?
Comment #40
effulgentsia commentedBut that issue sets the destination to the 'collection' link template. Which wouldn't work for taxonomy terms, since they don't have such a template, and if we wanted to add such a template, it would need to have the
{taxonomy_vocabulary}parameter. I guess we could do that by adding aTerm::urlRouteParameters()override?Comment #41
berdirYeah, but as I commented there, I think that is wrong anyway and we should use the redirect destination API which defaults to the current page. See also #2838968: BlockContentListBuilder should use RedirectDestinationTrait instead of hardcoding the collection link template, any view that displays operation links would have the same problem as term.
Comment #42
effulgentsia commentedComment #43
claudiu.cristeaThis is a bug and should go to 8.2.x. I rerolled #7, that was the last good.
@Berdir,
That is a 8.3.x issue and that should account this fix if this will go first. Or we fix here if that goes first.
Removed
render()hack.Comment #46
andypostComment #47
farald commentedRe-roll against 8.3.x.
Tests are probably still failing though.
Comment #48
miro_dietikerComment #50
berdirI posted a detailed overview of all related issues that we have around this topic in #1848686-179: Add a dedicated permission to access the term overview page (without 'administer taxonomy' permission) (#179 if the link does not work).
As suggested there, I'm closing this issue as a duplicate of that issue as that also has to solve this problem.
I'll try to update that other issue and possibly incorporate the approach that this issue uses with the list builder.
Comment #51
josmera01 commentedAdd the patch for the version Drupal 8.3