Issue #2408613 by kpv: ViewExecutable::getHandlers() should restore display_id before return

8.0.x
Alex Pott 2015-02-03 15:54:00 +00:00
parent ebea5b839d
commit 079b250084
2 changed files with 23 additions and 1 deletions

View File

@ -401,6 +401,19 @@ class ViewExecutableTest extends ViewUnitTestBase {
}
}
/**
* Tests ViewExecutable::getHandlers().
*/
public function testGetHandlers() {
$view = Views::getView('test_executable_displays');
$view->setDisplay('page_1');
$view->getHandlers('field', 'page_2');
// getHandlers() shouldn't change the active display.
$this->assertEqual('page_1', $view->current_display, "The display shouldn't change after getHandlers()");
}
/**
* Tests the validation of display handlers.
*/

View File

@ -2001,6 +2001,8 @@ class ViewExecutable {
* An array of handler instances of a given type for this display.
*/
public function getHandlers($type, $display_id = NULL) {
$old_display_id = !empty($this->current_display) ? $this->current_display : 'default';
$this->setDisplay($display_id);
if (!isset($display_id)) {
@ -2009,7 +2011,14 @@ class ViewExecutable {
// Get info about the types so we can get the right data.
$types = static::getHandlerTypes();
return $this->displayHandlers->get($display_id)->getOption($types[$type]['plural']);
$handlers = $this->displayHandlers->get($display_id)->getOption($types[$type]['plural']);
// Restore initial display id (if any) or set to 'default'.
if ($display_id != $old_display_id) {
$this->setDisplay($old_display_id);
}
return $handlers;
}
/**