Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
From \Drupal\views\Plugin\Block\ViewsBlock:
public function build() {
if ($output = $this->view->executeDisplay($this->displayID)) {
$output = $this->view->executeDisplay($this->displayID);
Comment | File | Size | Author |
---|---|---|---|
#10 | 2021829-10.patch | 2.5 KB | damiankloip |
#10 | interdiff-2021829-10.txt | 1.82 KB | damiankloip |
#4 | 2021829-5.patch | 2.22 KB | damiankloip |
redundant_execute_display.patch | 764 bytes | olli | |
Comments
Comment #2
dawehnerIn theory we could unit test that but I am not sure whether it is worth to do it.
Comment #3
olli CreditAttribution: olli commentedredundant_execute_display.patch queued for re-testing.
Comment #4
damiankloip CreditAttribution: damiankloip commentedWe could actually just not use the if at all, as currently it's a bit messed up. If $output returns it will be a string, otherwise it will be an empty array. The result of execute() from the Block display plugin should handle this for us instead, and return a render array, and NOT a string as it's currently doing. What do you think?
Comment #5
dawehnerI think the if for executeDisplay is important ... as things maybe fail.
This touches all the code which is fixed by #1957346: Add some settings on the block display to allow overrides on the block instance configuration already.
Comment #6
damiankloip CreditAttribution: damiankloip commentedOh yeah, that does touch the same build() method. However, look at the changes in Drupal\views\Plugin\views\display\Block here. that patch is wrong, we should be checking the output too I guess BUT the block display plugin should not be returning a string, we are trying to get away from this aren't we?
Comment #7
dawehnerThe point is that executeDisplay can return FALSE, if the display is missing for example. Yes an exception is thrown but maybe something else failed in the meantime.
Comment #8
damiankloip CreditAttribution: damiankloip commentedWe could still use the if (), and return our render array. I think we can have the best of both here..
Comment #9
dawehnerYeah I totally think we should do that!
Comment #10
damiankloip CreditAttribution: damiankloip commentedSo, how about something like this? If this is fixing the same parts of code in the other issue, do you think we should just move this there too?
Comment #11
dawehner+1
This change seems out of scope. FALSE or NULL is more or less the same meaning, but FALSE seems to indicate more then something went wrong.
Comment #12
dawehnerLet's get it in as it is now and improve later.
Comment #13
alexpottCommitted c66a78c and pushed to 8.x. Thanks!
Comment #15
longwave