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.
Follow-up for #2204037: Views allows removal of required relationships and gives a fatal error on save.
Problem/Motivation
ViewExecutable::getHandlers($type, $display_id = NULL)
changes ViewExecutable::current_display
to $display_id
(or 'default'
if NULL) and doesn't set it back to the initial value.
Proposed resolution
To store initial value and restore it before return.
Comment | File | Size | Author |
---|---|---|---|
#11 | restore-display-id-2408613-11.patch | 1.99 KB | kpv |
#7 | restore-display-id-2408613-test_only-7.patch | 843 bytes | kpv |
Comments
Comment #1
kpv CreditAttribution: kpv commentedThe patch restores initial display id or sets it to
'default'
if it wasn't set earlier.Comment #2
dawehnerThe patch looks nice in general.
@kpv
It would be great if you could explain why we can't get just rid of the setDisplay() call. Sure, your fix is safer, just being curios here.
It would be great if you could add a beta evaluation as well as a test
Comment #3
kpv CreditAttribution: kpv commentedadded check for current and initial display _ids
Comment #4
kpv CreditAttribution: kpv commented@dawehner
setDisplay() is used to initialize
$this->displayHandlers
, if empty, (via initDisplay()) and to perform some checks likeif (!$this->displayHandlers->has($display_id)) debug(...)
.We could directly set
$this->displayHandlers = new DisplayPluginCollection($this, Views::pluginManager('display'))
in getHandlers() and copy required checks there.In this case we should also make some changes to
setDisplay()
not to instantiatedisplayHandlers
twice if it was set earlier.Comment #5
kpv CreditAttribution: kpv commentedthis one should fail
Comment #7
kpv CreditAttribution: kpv commentedminor test fix. also should fail
Comment #8
kpv CreditAttribution: kpv commentedComment #10
dawehner@kpv
Do you mind merging the two together?
Comment #11
kpv CreditAttribution: kpv commentedComment #12
dawehnerNice
Comment #13
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 079b250 and pushed to 8.0.x. Thanks!