Closed (fixed)
Project:
Drupal core
Version:
8.2.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Oct 2014 at 12:50 UTC
Updated:
24 Nov 2016 at 22:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerI do agree that this is not critical but its major and we really should fix it, in case possible before the release.
Comment #2
Jaesin commentedA temporary workaround in the theme layer for views blocks:
Comment #3
jhedstromUpdating the IS as it took me a bit to figure out this was about setting block titles. I tested and it works for page titles.
Comment #5
xjm@alexpott, @dawehner, @timplunkett, and I discussed this issue and agreed it does not need to be major priority. While this does indeed sound like a bug, its impact is limited to a specific usecase. (Also, it's technically not a regression for core.)
We did agree that this should be treated as a bug. Steps to reproduce:
/admin/structure/views/view/taxonomy_term/admin/structure/blockand place the block./admin/structure/views/view/taxonomy_termand add a title for the view overall (which should be overridden)./taxonomy/term/1and see that the page title overrides the overall title, but the block does not.I also checked whether there was test coverage for the page title case. It does not look like Views itself has test coverage for this functionality for arguments:
So, adding tests for the bug would be a good next step.
The main usecase in core is the taxonomy term view, which would merit its own test coverage. In TermTest, there is some related coverage, but it is not sufficient:
TaxonomyTermViewTest has similar assertions:
Since the term page has the rendered term in the header as well, that means we could get a false positive even if the page title were not overridden. So we should add test coverage for that. Test coverage for a specific view is out of scope in this issue, so it should be done in a separate issue. (The followup would check assertTitle() and also assertNoText() for the overridden one.) Tagging for a followup for that.
Comment #6
xjmI wonder if this bug has a similar cause as #2629566: Label is not shown for blocks with exposed forms.
Comment #7
dawehnerIt could be, but I would rather think the problem is here:
The
buildRenderable()doesn't necessarily fire any kind of code in views, but rather just returns a lazy render array, see\Drupal\views\Plugin\views\display\DisplayPluginBase::buildRenderableThis basically means that
getTitle()at that point cannot rely on anything dynamic, like arguments.I think one valid approach here would be to not use a lazy render array for views blocks, because we already have render level caching on the block level. When we would not execute things lazily anymore, we would then process the arguments all the times and have the title, as expected.
Comment #9
evanjenkins commentedUploading patch that worked for me!
Comment #10
zekvyrin commentedMarking it to needs review to trigger testbot
Comment #11
zekvyrin commentedpatch #9 by evanjenkins is working and seems very reasonable to me.
Filling view_build array (which build the view with filters etc) are done in preRenderViewElement (line 42 currently) where the "executedisplay" happens. This is where the view title is filled, so the block title fill should happen after this. That's why I think this addresses the issue very well.
The alternative dawehner said (execute & build more things to buildRenderable) would require to process the view display earlier (running view->executeDisplay in buildrenderable instead ?).
Also, this bug is from 8.0 so I think we need to backport it as well.
I'm marking it to RTBC (although I do not know if tests are needed for this issue or are needed generally in this area)
Also adding the Dublin2016 tag as I'm in the sprints :P
Comment #12
zekvyrin commentedNote:
We have to be careful though with the related issue #2629566: Label is not shown for blocks with exposed forms (mentioned by xjm) as it also contains a change in the same line (a wrapper function for these lines).
Comment #14
lendudeYeah, they are, so leaving at needs work for adding test coverage.
Comment #15
Frando commentedI can confirm that the patch in #9 works as expected (while debugging, I came up with the exact same solution).
What else is needed to get this in? Can someone write a test to make sure that this won't get lost again?
Comment #16
dawehner@Frando
Yes exactly, at this point, we need a test, that should be it. Maybe @Lendude would like to work on that?
Comment #17
lendude@dawehner Yeah I think I can work on that :)
Test only patch is the interdiff.
Comment #19
Frando commentedNice, thanks for the tests. I came up with the same solution and tested the patch manually as well. Setting to RTBC.
Comment #20
dawehnerI'm highly confused that the test don't have arguments
Comment #21
lendudeWell the fix has nothing to do with arguments either. I just looked at the fix and wrote a test for that, I didn't look to closely at the rest of the discussion here, my bad! But it seems that the bug here is more general then just argument validation not being able to set the block title.
Nothing that influences the view title in
preRenderViewElementis transferred to the block title. In this case, at the least tokens and overrides.But yeah, lets see if we can add some coverage for overrides too.
Comment #22
lendudeHere we go, setting an argument with a fixed value and a title override.
Comment #23
lendudeComment #24
dawehnerThank you a lot lendude! Its always nice to increase test coverage.
Comment #26
catchCommitted/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!
Comment #30
xjmThis introduced a test failure in HEAD on PHP7/Postgres:
https://www.drupal.org/pift-ci-job/527093
I've reverted that -- let's run tests on all environments for this one before commit once we've sorted the postgres fail. Thanks!
Comment #31
lendudeWonky sort order on Postgres. Setting a fixed sort order makes the test pass locally on Postgres.
Comment #32
catchThat looks great, back to RTBC.
Comment #35
xjmLooks good now. I also re-tested with my STR from #5 and confirmed it did at least resolve the issue. Committed 469d128 and pushed to 8.3.x and 8.2.x. Thanks!
Comment #36
catch