Currently, there are a couple update hooks in core that begin to migrate Drupal 7 contrib Views data to Drupal 8 Views. Core should not be providing a contrib upgrade path.

Instead, D7->D8 migrations of Views data should be done with the views_d8_upgrade module. This migration tool will be developed later in the release cycle.

We are fine to just delete the incorrect update hooks now since we aren't rolling unstables yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm’s picture

This also blocks #1806334: Replace the node listing at /node with a view, because they were written such that the update hooks assume the D7 tables exist, and so the upgrade path chokes when enabling Views. At a minimum, we'd need to check db_table_exists(), but removing the misplaced upgrade path entirely is preferable.

xjm’s picture

This issue also made me realize that we should not drop the {variable} table from old installations, even after we remove variable_set() and so forth, because contrib will need to update its variables too.

chx’s picture

Status: Needs review » Reviewed & tested by the community

Yummy! Less the upgrade code, less to worry about...

sun’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/views/views.install
@@ -28,51 +28,43 @@ function views_schema() {
-function views_update_last_removed() {
...
+function views_update_last_removed() {

Can we move this back up? — usually comes after hook_schema(), but before individual update functions.

+++ b/core/modules/views/views.install
@@ -28,51 +28,43 @@ function views_schema() {
+function views_schema_8000() {
...
 function views_update_8000() {
...
+  $schema = views_schema_8000();
+  _drupal_schema_initialize($schema, 'views', FALSE);
...
+  foreach ($schema as $name => $table) {
+    if (!db_table_exists($name)) {
+      db_create_table($name, $table);
+    };
+  }

update_module_enable() implements a hook_schema_0() facility for basically the same... although it lacks the db_table_exists() condition. Perhaps it would make sense to inject that logic through an optional flag into update_module_enable()?

xjm’s picture

FileSize
3.01 KB

update_module_enable() implements a hook_schema_0() facility for basically the same... although it lacks the db_table_exists() condition. Perhaps it would make sense to inject that logic through an optional flag into update_module_enable()?

Hm? This code is covering the case where update_module_enable() does not get called because contrib Views was already enabled on the D7 site.

Attached just moves the hook_last_removed() back up; that was an accident.

Also, forgot to mention -- chx had also suggested re-setting the module weight per the hook_install() since hook_install() won't be invoked for those sites, but I checked and Views 7.x-3.x had the same install weight, and we should avoid changing the weight on existing sites if possible since the user may have overridden it for compatibility with something else.

xjm’s picture

FileSize
2.96 KB
+++ b/core/modules/views/views.installundefined
@@ -1,4 +1,4 @@
-<?php
+><?php

Whoops.

xjm’s picture

FileSize
2.54 KB
4.64 KB
+++ b/core/modules/views/views.installundefined
@@ -35,44 +35,36 @@ function views_update_last_removed() {
+function views_schema_8000() {
+  $schema['cache_views_info'] = drupal_get_schema_unprocessed('system', 'cache');

catch pointed out that this needs to be defined with a fixed schema (rather than system_schema(), which may change) since it's used in an update hook.

xjm’s picture

FileSize
641 bytes
4.64 KB

With fewer syntax errors.

Status: Needs review » Needs work

The last submitted patch, views-1850418-8.patch, failed testing.

xjm’s picture

So @dawehner and I talked a bit about our strategy for http://drupal.org/project/views_d8_upgrade today. We're going to have a 7.x version of that module as well as an 8.x version, and have the 7.x version copy the user's Views data to some upgrade tables and then uninstall the module.

xjm’s picture

Status: Needs work » Needs review

Drupal\system\Tests\Entity\EntityTranslationTest->testMultilingualProperties()? That looks random.

#8: views-1850418-8.patch queued for re-testing.

xjm’s picture

Whoops, didn't finish what I was saying. So if the helper module uninstalls D7 Views, then maybe we don't need any of this? And if they try to upgrade with Views installed... should we display a warning somehow?

sun’s picture

That plan sounds more reasonable to me.

We also did not provide any kind of upgrade path for all the field type modules that we've added to core for D8 — even though there are direct clashes with the field type names (and supplying an upgrade path for that in contrib will be quite a pain).

But yeah, that would at least be consistent, so +1 for removing this altogether.

xjm’s picture

FileSize
3.2 KB

I can't actually test this patch yet because of #1848998: Problems with update_module_enable(), but something along these lines.

sun’s picture

+++ b/core/modules/views/views.install
@@ -35,44 +35,40 @@ function views_update_last_removed() {
+ * Set the Views schema version.
  */
 function views_update_8000() {
...
+  // No update, just set the schema version to 8000.
 }

That looks like the exact job of hook_update_last_removed() to me ;)

So we should just swap out the schema version, I think.

I'm not sure whether it makes sense to specify any removed version number though. As soon as the D7 contrib Views module will see a new module update, the logic will no longer work.

+++ b/core/modules/views/views.install
@@ -35,44 +35,40 @@ function views_update_last_removed() {
+  // Display a warning if the user attempts to update with a Drupal 7 version
+  // of Views. An upgrade path is provided by the views_d8_upgrade contributed
+  // module, which uninstalls Views before beginning the Drupal 8 upgrade.
...
+          'Your installed version of Views is too old. To migrade Views data from Drupal 7, install and run the <a href="@url">Views Drupal 7 to Drupal 8 upgrade</a> module before installing Drupal 8.',

Hm. I'd prefer to leave this out entirely. As said, we did not introduce any special care for the new field type modules in D8, and we also did not do so for the entire CCK thing in D7.

--

All things combined, I think we should remove the hook_update_last_removed(), existing schema updates, and also don't introduce any hook_requirements(). All of this can be handled by the contrib migration module.

xjm’s picture

FileSize
0 bytes

Actually, let's split that off into its own issue since the bad update hooks are blockers for other issues. Filed #1851386: Add a hook_requirements() to Views disallowing unsupported upgrade from D7 Views.

xjm’s picture

FileSize
1.99 KB
xjm’s picture

FileSize
507 bytes

Hm. I'd prefer to leave this out entirely. As said, we did not introduce any special care for the new field type modules in D8, and we also did not do so for the entire CCK thing in D7.

Well, trying to upgrade from D7 to D8 with Views installed is something we don't want to support, so I think it makes sense to simply inform the user and explicitly not support it. A lot of people will break their sites otherwise. (I'd also point out that the CCK upgrade issues caused many, many sites to languish on D6... including sites I maintain for work, even.) I don't think it does any harm to stop users from shooting themselves in the foot. We can do that in the other issue, though.

I guess it does make sense to take out the _last_removed() as well.

Status: Needs review » Needs work

The last submitted patch, views-1850418-18.patch, failed testing.

xjm’s picture

Status: Needs work » Needs review
FileSize
2.03 KB

For some reason I'm git-idiotic this evening; sorry for all the useless noise.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Nice diffstat ;)
After all of the conversation around this, I think this makes the most sense.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Well then. :) Less code FTW, I guess. :)

At some point tonight I must've committed this because patch -p1 asks me if I meant -R. Woot. ;) Thanks!

sun’s picture

Btw, is there any particular reason for why you plan to use a separate project instead of the views project directly for the D8 migration module?

Normally and technically, project != module. AFAIK, all tools that we have are able to properly differentiate between the two notions. IIRC, the CCK project was also continued for D7, but contained a content_upgrade.module or similar instead of the former module(s).

xjm’s picture

Because then there would be two different views.module in the user's codebase.

tim.plunkett’s picture

Not if we emptied out the 8.x branch to only have the upgrade path module...

xjm’s picture

Status: Fixed » Reviewed & tested by the community

This doesn't actually seem to be committed to 8.x yet.

xjm’s picture

FileSize
1.98 KB

No idea why this needs a reroll, but here it is.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

There we go!

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.