diff --git a/includes/cache.inc b/includes/cache.inc index 871d65e46766b9910a84b058b6ef9bead14afccd..92d5864e26719ec123dfe4b85b8bdea158680c26 100644 --- a/includes/cache.inc +++ b/includes/cache.inc @@ -44,17 +44,6 @@ function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { } } if (isset($cache[$table])) { - if (isset($cache[$table]['moved to']) && $move) { - $moved_table = $cache[$table]['moved to']; - if (!empty($recursion_protection[$table])) { - // recursion detected! - return NULL; - } - $recursion_protection[$table] = TRUE; - $data = _views_fetch_data($moved_table); - $recursion_protection = array(); - return $data; - } return $cache[$table]; } } diff --git a/lib/Drupal/views/Tests/ModuleTest.php b/lib/Drupal/views/Tests/ModuleTest.php index 9998cbde2399ed06cd14b25489f17070b3769f52..070a6293005fbeeecef83e382a8fa8b1146724f3 100644 --- a/lib/Drupal/views/Tests/ModuleTest.php +++ b/lib/Drupal/views/Tests/ModuleTest.php @@ -27,19 +27,6 @@ public function setUp() { drupal_theme_rebuild(); } - public function viewsData() { - $data = parent::viewsData(); - $data['views_test_data_previous'] = array(); - $data['views_test_data_previous']['id']['field']['moved to'] = array('views_test_data', 'id'); - $data['views_test_data_previous']['id']['filter']['moved to'] = array('views_test_data', 'id'); - $data['views_test_data']['age_previous']['field']['moved to'] = array('views_test_data', 'age'); - $data['views_test_data']['age_previous']['sort']['moved to'] = array('views_test_data', 'age'); - $data['views_test_data_previous']['name_previous']['field']['moved to'] = array('views_test_data', 'name'); - $data['views_test_data_previous']['name_previous']['argument']['moved to'] = array('views_test_data', 'name'); - - return $data; - } - public function test_views_trim_text() { // Test unicode, @see http://drupal.org/node/513396#comment-2839416 $text = array( @@ -115,29 +102,9 @@ function testviews_get_handler() { } } - // Test the automatic conversion feature. - - // Test the automatic table renaming. - $handler = views_get_handler('views_test_data_previous', 'id', 'field'); - $this->assertInstanceHandler($handler, 'views_test_data', 'id', 'field'); - $handler = views_get_handler('views_test_data_previous', 'id', 'filter'); - $this->assertInstanceHandler($handler, 'views_test_data', 'id', 'filter'); - - // Test the automatic field renaming. - $handler = views_get_handler('views_test_data', 'age_previous', 'field'); - $this->assertInstanceHandler($handler, 'views_test_data', 'age', 'field'); - $handler = views_get_handler('views_test_data', 'age_previous', 'sort'); - $this->assertInstanceHandler($handler, 'views_test_data', 'age', 'sort'); - - // Test the automatic table and field renaming. - $handler = views_get_handler('views_test_data_previous', 'name_previous', 'field'); - $this->assertInstanceHandler($handler, 'views_test_data', 'name', 'field'); - $handler = views_get_handler('views_test_data_previous', 'name_previous', 'argument'); - $this->assertInstanceHandler($handler, 'views_test_data', 'name', 'argument'); - // Test the override handler feature. - $handler = views_get_handler('views_test_data', 'job', 'filter', 'string'); - $this->assertEqual('Drupal\\views\\Plugin\\views\\filter\\String', get_class($handler)); + $handler = views_get_handler('views_test_data', 'job', 'filter', 'standard'); + $this->assertEqual('Drupal\\views\\Plugin\\views\\filter\\Standard', get_class($handler)); } /** diff --git a/lib/Drupal/views/Tests/UpgradeTestCase.php b/lib/Drupal/views/Tests/UpgradeTestCase.php deleted file mode 100644 index 2ee7fd235b14c82a0cd1c217928df7896e0fb233..0000000000000000000000000000000000000000 --- a/lib/Drupal/views/Tests/UpgradeTestCase.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views\Tests\UpgradeTestCase. - */ - -namespace Drupal\views\Tests; - -/** - * Tests the upgrade path of all conversions. - * - * You can find all conversions by searching for "moved to". - */ -class UpgradeTestCase extends ViewTestBase { - - /** - * Modules to enable. - * - * To import a view the user needs use PHP for settings rights, so enable php - * module. - * - * @var array - */ - public static $modules = array('views_ui', 'block', 'php'); - - public static function getInfo() { - return array( - 'name' => 'Upgrade path', - 'description' => 'Tests the upgrade path of modules which were changed.', - 'group' => 'Views', - ); - } - - protected function setUp() { - parent::setUp(); - - $this->enableViewsTestModule(); - } - - function viewsData() { - $data = parent::viewsData(); - $data['views_test_data']['old_field_1']['moved to'] = array('views_test_data', 'id'); - $data['views_test_data']['old_field_2']['field']['moved to'] = array('views_test_data', 'name'); - $data['views_test_data']['old_field_3']['filter']['moved to'] = array('views_test_data', 'age'); - - // @todo Test this scenario, too. - $data['views_old_table_2']['old_field']['moved to'] = array('views_test_data', 'job'); - - $data['views_old_table']['moved to'] = 'views_test_data'; - - return $data; - } - - function debugField($field) { - $keys = array('id', 'table', 'field', 'actualField', 'original_field', 'realField'); - $info = array(); - foreach ($keys as $key) { - $info[$key] = $field->{$key}; - } - debug($info, NULL, TRUE); - } - - /** - * Tests the moved to parameter in general. - */ - public function testMovedTo() { - // Test moving on field lavel. - $view = $this->createViewFromConfig('test_views_move_to_field'); - $view->storage->update(); - $view->build(); - -// $this->assertEqual('old_field_1', $view->field['old_field_1']->options['id'], "Id shouldn't change during conversion"); -// $this->assertEqual('id', $view->field['old_field_1']->field, 'The field should change during conversion'); - $this->assertEqual('id', $view->field['old_field_1']->realField); - $this->assertEqual('views_test_data', $view->field['old_field_1']->table); - $this->assertEqual('old_field_1', $view->field['old_field_1']->original_field, 'The field should have stored the original_field'); - - // Test moving on handler lavel. - $view = $this->createViewFromConfig('test_views_move_to_handler'); - $view->storage->update(); - $view->build(); - -// $this->assertEqual('old_field_2', $view->field['old_field_2']->options['id']); - $this->assertEqual('name', $view->field['old_field_2']->realField); - $this->assertEqual('views_test_data', $view->field['old_field_2']->table); - -// $this->assertEqual('old_field_3', $view->filter['old_field_3']->options['id']); - $this->assertEqual('age', $view->filter['old_field_3']->realField); - $this->assertEqual('views_test_data', $view->filter['old_field_3']->table); - - // Test moving on table level. - $view = $this->createViewFromConfig('test_views_move_to_table'); - $view->storage->update(); - $view->build(); - - $this->assertEqual('views_test_data', $view->storage->base_table, 'Make sure that view->base_table gets automatically converted.'); -// $this->assertEqual('id', $view->field['id']->field, 'If we move a whole table fields of this table should work, too.'); - $this->assertEqual('id', $view->field['id']->realField, 'To run the query right the realField has to be set right.'); - $this->assertEqual('views_test_data', $view->field['id']->table); - } - -} diff --git a/lib/Drupal/views/ViewStorage.php b/lib/Drupal/views/ViewStorage.php index df6a8d7b7f73c60831e02f74f3339cfe87cf26af..d4ae36c765e74a8d1727f2d0eb7b592831b50b4e 100644 --- a/lib/Drupal/views/ViewStorage.php +++ b/lib/Drupal/views/ViewStorage.php @@ -222,19 +222,6 @@ public function getHumanName() { return $human_name; } - /** - * Perform automatic updates when loading or importing a view. - * - * Over time, some things about Views or Drupal data has changed. - * this attempts to do some automatic updates that must happen - * to ensure older views will at least try to work. - */ - public function update() { - // When views are converted automatically the base_table should be renamed - // to have a working query. - $this->base_table = views_move_table($this->base_table); - } - /** * Adds a new display handler to the view, automatically creating an ID. * diff --git a/modules/comment.views.inc b/modules/comment.views.inc index acf1d6335726ff2583fad7fb8560c2e959aa4096..6e1293be030ee7915f64ebebc6b7669ca2775d34 100644 --- a/modules/comment.views.inc +++ b/modules/comment.views.inc @@ -157,7 +157,6 @@ function comment_views_data() { // Langcode field if (module_exists('language')) { - $data['comment']['language']['moved to'] = array('comment', 'langcode'); $data['comment']['langcode'] = array( 'title' => t('Language'), 'help' => t('The language the comment is in.'), diff --git a/modules/node.views.inc b/modules/node.views.inc index 8ac6fd608ccfa2fffe418b3e797d2c6d6f65d60a..7efd63011101954b71a854966dac03d7bea25fee 100644 --- a/modules/node.views.inc +++ b/modules/node.views.inc @@ -215,7 +215,6 @@ function node_views_data() { // Language field if (module_exists('language')) { - $data['node']['language']['moved to'] = array('node', 'langcode'); $data['node']['langcode'] = array( 'title' => t('Language'), 'help' => t('The language the content is in.'), @@ -464,6 +463,7 @@ function node_views_data() { 'help' => t('The revision NID of the content revision.'), // Information for displaying the nid. 'field' => array( + 'id' => 'standard', 'click sortable' => TRUE, ), // Information for accepting a nid as an argument. @@ -495,6 +495,7 @@ function node_views_data() { 'help' => t('The revision ID of the content revision.'), // Information for displaying the vid 'field' => array( + 'id' => 'standard', 'click sortable' => TRUE, ), // Information for accepting a vid as an argument diff --git a/modules/user.views.inc b/modules/user.views.inc index 68793706183b6a66343f57268929f3a26dcb516f..ad6d9ffd1ceb4d7181927f6b2665cfc4d3caea4f 100644 --- a/modules/user.views.inc +++ b/modules/user.views.inc @@ -135,7 +135,6 @@ function user_views_data() { ); // language - $data['users']['language']['moved to'] = array('users', 'langcode'); $data['users']['langcode'] = array( 'title' => t('Language'), // The item it appears as on the UI, 'help' => t('Language of the user'), diff --git a/views.module b/views.module index 4ead28bd9bb1a7fc837dd41e4201a9623543c49c..e20d3f8a20deb7b2c9b967db96acf9d6f0441ec4 100644 --- a/views.module +++ b/views.module @@ -1288,57 +1288,11 @@ function views_include_handlers($reset = FALSE) { * An instance of a handler object. May be views_handler_broken. */ function views_get_handler($table, $field, $type, $override = NULL) { - static $recursion_protection = array(); + // Get the plugin manager for this type. + $manager = drupal_container()->get("plugin.manager.views.$type"); $data = views_fetch_data($table, FALSE); - $handler = NULL; - - // Support conversion on table level. - if (isset($data['moved to'])) { - $moved = array($data['moved to'], $field); - } - // Support conversion on datafield level. - if (isset($data[$field]['moved to'])) { - $moved = $data[$field]['moved to']; - } - // Support conversion on handler level. - if (isset($data[$field][$type]['moved to'])) { - $moved = $data[$field][$type]['moved to']; - } - - if (isset($data[$field][$type]) || !empty($moved)) { - if (!empty($moved)) { - list($moved_table, $moved_field) = $moved; - if (!empty($recursion_protection[$moved_table][$moved_field])) { - // recursion detected! - return NULL; - } - - $recursion_protection[$moved_table][$moved_field] = TRUE; - $handler = views_get_handler($moved_table, $moved_field, $type, $override); - $recursion_protection = array(); - if ($handler) { - // store these values so we know what we were originally called. - $handler->original_table = $table; - $handler->original_field = $field; - if (empty($handler->actualTable)) { - $handler->actualTable = $moved_table; - $handler->actualField = $moved_field; - } - } - return $handler; - } - - // @fixme: temporary. - // Set up a default handler, if both handler and id is not specified. - if (empty($data[$field][$type]['handler']) && empty($data[$field][$type]['id'])) { - $data[$field][$type]['id'] = 'standard'; - } - - if ($override) { - $data[$field][$type]['override handler'] = $override; - } - + if (isset($data[$field][$type])) { $definition = $data[$field][$type]; foreach (array('group', 'title', 'title short', 'help', 'real field', 'real table') as $key) { if (!isset($definition[$key])) { @@ -1354,8 +1308,7 @@ function views_get_handler($table, $field, $type, $override = NULL) { } // @todo This is crazy. Find a way to remove the override functionality. - $manager = drupal_container()->get("plugin.manager.views.$type"); - $plugin_id = !empty($definition['override handler']) ? $definition['override handler'] : $definition['id']; + $plugin_id = $override ?: $definition['id']; // Try to use the overridden handler. try { return $manager->createInstance($plugin_id, $definition); @@ -1373,7 +1326,7 @@ function views_get_handler($table, $field, $type, $override = NULL) { // Finally, use the 'broken' handler. debug(t("Missing handler: @table @field @type", array('@table' => $table, '@field' => $field, '@type' => $type))); - return views_get_plugin($type, 'broken'); + return $manager->createInstance('broken'); } /** @@ -1715,28 +1668,10 @@ function views_view_is_disabled($view) { function views_get_view($name) { $view = entity_load('view', $name); if ($view) { - $view->update(); - $view = $view->getExecutable(); - // @figure out whether it makes sense to clone this here. - return $view->cloneView(); + return $view->getExecutable(); } } -/** - * Find the real location of a table. - * - * If a table has moved, find the new name of the table so that we can - * change its name directly in options where necessary. - */ -function views_move_table($table) { - $data = views_fetch_data($table, FALSE); - if (isset($data['moved to'])) { - $table = $data['moved to']; - } - - return $table; -} - // ------------------------------------------------------------------ // Views form (View with form elements) diff --git a/views_ui/admin.inc b/views_ui/admin.inc index ddbacfeb7e0493a557d9e7d25785b13398b662ae..08126925cff6465861b2a30ecf1b4c958cafed0b 100644 --- a/views_ui/admin.inc +++ b/views_ui/admin.inc @@ -2600,10 +2600,6 @@ function views_fetch_fields($base, $type, $grouping = FALSE) { $skip_bases[$field][$key][$base_name] = TRUE; } } - // Don't show old fields. The real field will be added right. - if (isset($info[$key]['moved to'])) { - continue; - } foreach (array('title', 'group', 'help', 'base', 'aliases') as $string) { // First, try the lowest possible level if (!empty($info[$key][$string])) {