Commit 079b2500 authored by alexpott's avatar alexpott

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

parent ebea5b83
......@@ -401,6 +401,19 @@ public function testGetHandlerTypes() {
}
}
/**
* 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.
*/
......
......@@ -2001,6 +2001,8 @@ public static function generateHandlerId($requested_id, $existing_items) {
* 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 @@ public function getHandlers($type, $display_id = NULL) {
// 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;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment