From 69fa3f1657c3d17814a00146fd53b46df156327f Mon Sep 17 00:00:00 2001 From: Tim Plunkett Date: Fri, 31 Aug 2012 13:37:21 -0400 Subject: [PATCH] Issue #1765704 by tim.plunkett: Fixed calls to getPlugin() bypass the static cache. --- includes/admin.inc | 3 +- .../views/display/DisplayPluginBase.php | 50 +++++++++++-------- .../views/Plugin/views/display/Feed.php | 3 +- .../Plugin/views/style/StylePluginBase.php | 3 +- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/includes/admin.inc b/includes/admin.inc index 71bd265cfce0..d7e770fdef84 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -2172,7 +2172,8 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { break; case 'field': // Fetch the style plugin info so we know whether to list fields or not. - $style_plugin = $display->handler->getPlugin(); + $name = $display->handler->getOption('style_plugin'); + $style_plugin = $display->handler->getPlugin('style', $name); $uses_fields = $style_plugin && $style_plugin->usesFields(); if (!$uses_fields) { $build['fields'][] = array( diff --git a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 2908635ae704..cd33bfe116e7 100644 --- a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -763,7 +763,8 @@ abstract class DisplayPluginBase extends PluginBase { * @return bool */ public function usesFields() { - $plugin = $this->getPlugin('style'); + $name = $this->getOption('style_plugin'); + $plugin = $this->getPlugin('style', $name); if ($plugin) { return $plugin->usesFields(); } @@ -1116,8 +1117,9 @@ abstract class DisplayPluginBase extends PluginBase { ); $manager = new ViewsPluginManager('style'); - $style_plugin = $manager->getDefinition($this->getOption('style_plugin')); - $style_plugin_instance = $this->getPlugin('style'); + $name = $this->getOption('style_plugin'); + $style_plugin = $manager->getDefinition($name); + $style_plugin_instance = $this->getPlugin('style', $name); $style_summary = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->summaryTitle(); $style_title = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->pluginTitle(); @@ -1138,8 +1140,9 @@ abstract class DisplayPluginBase extends PluginBase { if ($style_plugin_instance->usesRowPlugin()) { $manager = new ViewsPluginManager('row'); - $row_plugin = $manager->getDefinition($this->getOption('row_plugin')); - $row_plugin_instance = $this->getPlugin('row'); + $name = $this->getOption('row_plugin'); + $row_plugin = $manager->getDefinition($name); + $row_plugin_instance = $this->getPlugin('row', $name); $row_summary = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->summaryTitle(); $row_title = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->pluginTitle(); @@ -1645,7 +1648,8 @@ abstract class DisplayPluginBase extends PluginBase { '#description' => t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'), ); - $style_plugin = $this->getPlugin('style'); + $name = $this->getOption('style_plugin'); + $style_plugin = $this->getPlugin('style', $name); if ($style_plugin->usesOptions()) { $form['markup'] = array( '#markup' => '
' . t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->optionLink(t('settings'), 'style_options'))) . '
', @@ -1684,7 +1688,8 @@ abstract class DisplayPluginBase extends PluginBase { '#default_value' => $this->getOption('row_plugin'), ); - $row_plugin = $this->getPlugin('row'); + $name = $this->getOption('row_plugin'); + $row_plugin = $this->getPlugin('row', $name); if ($row_plugin->usesOptions()) { $form['markup'] = array( '#markup' => '
' . t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->optionLink(t('settings'), 'row_options'))) . '
', @@ -1832,7 +1837,8 @@ abstract class DisplayPluginBase extends PluginBase { } } - $plugin = $this->getPlugin(); + $name = $this->getOption('style_plugin'); + $plugin = $this->getPlugin('style', $name); if ($plugin) { $funcs[] = $this->optionLink(t('Style output'), 'analyze-theme-style') . ': ' . $this->formatThemes($plugin->themeFunctions(), $plugin->additionalThemeFunctions()); $themes = $plugin->additionalThemeFunctions(); @@ -1843,7 +1849,8 @@ abstract class DisplayPluginBase extends PluginBase { } if ($plugin->usesRowPlugin()) { - $row_plugin = $this->getPlugin('row'); + $name = $this->getOption('row_plugin'); + $row_plugin = $this->getPlugin('row', $name); if ($row_plugin) { $funcs[] = $this->optionLink(t('Row style output'), 'analyze-theme-row') . ': ' . $this->formatThemes($row_plugin->themeFunctions()); $themes = $row_plugin->additionalThemeFunctions(); @@ -1945,7 +1952,8 @@ abstract class DisplayPluginBase extends PluginBase { $form['#title'] .= t('Theming information (style)'); $output = '

' . t('Back to !info.', array('!info' => $this->optionLink(t('theming information'), 'analyze-theme'))) . '

'; - $plugin = $this->getPlugin(); + $name = $this->getOption('style_plugin'); + $plugin = $this->getPlugin('style', $name); if (empty($plugin->definition['theme'])) { $output .= t('This display has no style theming information'); @@ -1972,7 +1980,8 @@ abstract class DisplayPluginBase extends PluginBase { $form['#title'] .= t('Theming information (row style)'); $output = '

' . t('Back to !info.', array('!info' => $this->optionLink(t('theming information'), 'analyze-theme'))) . '

'; - $plugin = $this->getPlugin('row'); + $name = $this->getOption('row_plugin'); + $plugin = $this->getPlugin('row', $name); if (empty($plugin->definition['theme'])) { $output .= t('This display has no row style theming information'); @@ -2640,7 +2649,8 @@ abstract class DisplayPluginBase extends PluginBase { } // Validate style plugin - $style = $this->getPlugin(); + $name = $this->getOption('style_plugin'); + $style = $this->getPlugin('style', $name); if (empty($style)) { $errors[] = t('Display "@display" has an invalid style plugin.', array('@display' => $this->display->display_title)); } @@ -2832,7 +2842,8 @@ abstract class DisplayPluginBase extends PluginBase { */ public function exportStyle($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; - $style_plugin = $this->getPlugin(); + $name = $this->getOption('style_plugin'); + $style_plugin = $this->getPlugin('style', $name); if ($option == 'style_plugin') { $type = 'style'; $options_field = 'style_options'; @@ -2845,7 +2856,8 @@ abstract class DisplayPluginBase extends PluginBase { $type = 'row'; $options_field = 'row_options'; - $plugin = $this->getPlugin('row'); + $name = $this->getOption('row_plugin'); + $plugin = $this->getPlugin('row', $name); // If the style plugin doesn't use row plugins, don't even bother. } @@ -2893,10 +2905,9 @@ abstract class DisplayPluginBase extends PluginBase { public function unpackStyle($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; - $style_plugin = $this->getPlugin(); + $name = $this->getOption('style_plugin'); + $style_plugin = $this->getPlugin('style', $name); if ($option == 'style_plugin') { - $type = 'style'; - $options_field = 'style_options'; $plugin = $style_plugin; } else { @@ -2904,9 +2915,8 @@ abstract class DisplayPluginBase extends PluginBase { return; } - $type = 'row'; - $options_field = 'row_options'; - $plugin = $this->getPlugin('row'); + $name = $this->getOption('row_plugin'); + $plugin = $this->getPlugin('row', $name); // If the style plugin doesn't use row plugins, don't even bother. } diff --git a/lib/Drupal/views/Plugin/views/display/Feed.php b/lib/Drupal/views/Plugin/views/display/Feed.php index a73cf914207b..17568926509f 100644 --- a/lib/Drupal/views/Plugin/views/display/Feed.php +++ b/lib/Drupal/views/Plugin/views/display/Feed.php @@ -240,7 +240,8 @@ class Feed extends Page { // Defer to the feed style; it may put in meta information, and/or // attach a feed icon. - $plugin = $this->getPlugin('style'); + $name = $this->getOption('style_plugin'); + $plugin = $this->getPlugin('style', $name); if ($plugin) { $clone = $this->view->cloneView(); $clone->setDisplay($this->display->id); diff --git a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php index 8bb02b82e4d0..89e79cee9847 100644 --- a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php +++ b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php @@ -661,7 +661,8 @@ abstract class StylePluginBase extends PluginBase { $errors = parent::validate(); if ($this->usesRowPlugin()) { - $plugin = $this->display->handler->getPlugin('row'); + $name = $this->display->handler->getOption('row_plugin'); + $plugin = $this->display->handler->getPlugin('row', $name); if (empty($plugin)) { $errors[] = t('Style @style requires a row style but the row plugin is invalid.', array('@style' => $this->definition['title'])); }