I'm not sure if this is a commit mistake or what but the views_update_nn() between D6 and D7 is out of sync making the upgrade path to look messy and apt to fail.

In 6.x.2.x-dev the file ends with this code:

/**
 * Correct the cache setting for exposed filter blocks.
 *
 * @see http://drupal.org/node/910864
 */
function views_update_6011() {
  $ret = array();

  // There is only one simple query to run.
  $ret[] = update_sql("UPDATE {blocks} SET cache = " . BLOCK_NO_CACHE . " WHERE module = 'views' AND delta LIKE '-exp-%'");
  
  return $ret;
}

function views_schema_6013() {
  $schema = views_schema(__FUNCTION__);
  $schema['views_view']['fields']['core'] = array(
    'type' => 'int',
    'default' => 0,
    'description' => 'Stores the drupal core version of the view.',
  );
  return $schema;
}

/**
 * Add a drupal core version field.
 */
function views_update_6013() {
  $ret = array();
  $new_field = array(
    'type' => 'int',
    'default' => 0,
    'description' => 'Stores the drupal core version of the view.',
  );

  db_add_field($ret, 'views_view', 'core', $new_field);

  return $ret;
}

Note the missing _6012

While in 7.x.3.x it is:

/**
 * Remove views_object_cache table and move the data to ctools_object_cache.
 */
function views_schema_6011() {
  $schema = views_schema(__FUNCTION__);
  unset($schema['views_object_cache']);
  return $schema;
}

/**
 * Remove views_object_cache table and move the data to ctools_object_cache.
 */
function views_update_6011() {
  $ret = array();

  $caches = db_query("SELECT * FROM {views_object_cache}")->fetch();
  foreach ($caches as $item) {
    drupal_write_record('ctools_object_cache', $item);
  }
  db_drop_table($ret, 'views_object_cache');

  return $ret;
}

/**
 * Correct the cache setting for exposed filter blocks.
 *
 * @see http://drupal.org/node/910864
 */
function views_update_6012() {
  $ret = array();

  // There is only one simple query to run.
  $update = db_update('blocks')
    ->condition('module', 'views')
    ->condition('delta', db_like('-exp-') . '%', 'LIKE')
    ->fields(array('cache' => DRUPAL_NO_CACHE));
  
  return $ret;
}


/**
 * Add a human readable name.
 */
function views_schema_6013() {
  $schema = views_schema(__FUNCTION__);
  $schema['views_view']['fields']['human_name'] = array(
    'type' => 'varchar',
    'length' => '255',
    'default' => '',
    'description' => 'A human readable name used to be displayed in the admin interface',
  );
  return $schema;
}

function views_update_6013() {
  $ret = array();

  $new_field = array(
    'type' => 'varchar',
    'length' => '255',
    'default' => '',
    'description' => 'A human readable name used to be displayed in the admin interface',
  );

  db_add_field('views_view', 'human_name', $new_field);

  return $ret;
}

function views_schema_6014() {
  $schema = views_schema(__FUNCTION__);
  $schema['views_view']['fields']['core'] = array(
    'type' => 'int',
    'default' => 0,
    'description' => 'Stores the drupal core version of the view.',
  );
  return $schema;
}

/**
 * Add a drupal core version field.
 */
function views_update_6014() {
  $ret = array();
  $new_field = array(
    'type' => 'int',
    'default' => 0,
    'description' => 'Stores the drupal core version of the view.',
  );

  db_add_field('views_view', 'core', $new_field);

  return $ret;
}

To summarize, ending _6013 in D6 do the same as ending _6014 in D7. The result of this is not only that update_6014() fails when upgrading, but also that D7 updates _6011, _6012 and _6013 never trigger and result in various errors are triggered after upgrade.

I wasn't sure if to file this as a D6 or D7 bug as it sort of affect both, and I became aware of this when I did a test upgrade to D7, but decided for D6 as views_update_6012() is missing and the new field 'core' created in _6013 never seem to be used, so I suspect this commit possibly have happened by mistake or we have a situation here were the left hand doesn't know what the right one does, so to speak.

The issue for both D6 and D7 still remains though with the inconsistency starting with 'function views_update_6011();' in both. Also, afaik D7 should start its numbered sequence with 7, but I assume there is a valid reason for not doing so yet, but still they need to be in sync.

Just for anyone else running in to this, I was able to successfully upgrade views-6.x-2.x-dev to 7.x-.3.x-dev by manually edit the database and change the value of schema_version field, from 6013 to 6010, to have all updates starting with 6011 applied. Not extensively tested yet though so I may have missed something, but so far seem to be ok.

Comments

dawehner’s picture

The update function is cool, when we change the function names now, the user will run the update functions again.

vikingew’s picture

I don't know if you talk about something that hasn't happened yet, but as it is now isn't cool at all, because when you update from D6 (2.x or 3.x) to D7 you get errors because views_update_6011/6012/6013 never run and 6014 fails because the core column is already there. That should be a recoverable error but because the other update functions never run stuff never completes and the schema_version number never gets updated to 6014 in db, so the same failure comes back every time you run update.php

Sure this is still dev versions but the fact that you use 6nnn numbered update functions and don't keep things in sync just make things more difficult down the road... just pointing out the obvious ;-)

jromine’s picture

StatusFileSize
new430 bytes
new1.3 KB

Just ran into this upgrading from 6.x-2.x-dev to 6.x-3.x-dev.

Please add views_update_6012 to the 6.x-2.x-dev source. This will fix upgrades from 6.x-2.12 to 6.x-2.x-dev to 6.x-3.x-dev. The views_view.human_name column is not used by 6.x-2.x-dev, but it won't break anything to add it to 6.x-2.x-dev.

Sites already on 6.x-2.x-dev at schema 6013 missed the 6012 update. One fix could be to add a 6014 update to 6.x-2.x-dev and 6.x-3.x-dev which re-runs the 6012 update if the human_name field is not already present.

dawehner’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new717 bytes

Oh. Please next time set the status to needs review, so we see the patch, attached is basically the same as your patch, but with a more detailed explanation.

Please add views_update_6012 to the 6.x-2.x-dev source. This will fix upgrades from 6.x-2.12 to 6.x-2.x-dev to 6.x-3.x-dev. The views_view.human_name column is not used by 6.x-2.x-dev, but it won't break anything to add it to 6.x-2.x-dev.

But only for sites with 6.x-3.x human_name is important, so just appying the patch from 6.x-3.x fixes the issue.

merlinofchaos’s picture

Just adding 6012 won't help anyone who is already at 6013, sadly.

dawehner’s picture

Tested this patch by

checkout 2.x, install views, checkout 6.x-3.x, run update.php, test views ui. This breaks the ui.
Then applied the patch and runned update.php again and tested the ui as well. This time it worked fine.

dawehner’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Commited to 6.x-3.x, let's see whether this is required for 7.x-3.x as well, but probably yes, because people upgrade from views2 to 7.x-3.x.

dawehner’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new772 bytes

Here is a patch for d7

dawehner’s picture

StatusFileSize
new729 bytes

A new patch based on an idea of drupol

pol’s picture

héhé Thanks @dereine :-) Testing it right now.

pol’s picture

This patch works if we rename db_column_exists in db_field_exists.
I did it in this patch and I've also corrected 2 typos.

pol’s picture

Finally I still got problems with previous patches.

Here is patches for 7.x-3.x and 7.x-3.0-rc1.

dawehner’s picture

Status: Needs review » Fixed

Commited to 7.x-3.x Thanks!

jherencia’s picture

Well, I don't know the schredule of releases, or the plan, but currently both recommended versions of views make impossible to upgrade from D6 to D7.

I think this patch is important enough to be commited to the stable branch and generate a new rc or whatever.

Otherwise, it should be documented that only upgrades can be done with dev versions.

dawehner’s picture

You can't commit a patch to a stable release, because well it changes then :)

If you need the change please use the dev release until the next release.
You know this bug exists since a LONG time and additional i think all bugs fixed since the last release and the current dev should be documented. You know you can apply this for many issues.

jherencia’s picture

Well I don't know if this is useful, I hope so.

I think this issue needs to generate a hotfix.

jherencia’s picture

@dereine maybe I'm noone to doubt about the branching model, sorry if you think so, but I think maybe the talk could led into something productive:

In my opinion there are some cases, and I think this is one of them, that need to be fixed as soon as possible.
One of the problems I see in Drupal contrib modules, and I'm not talking about Views in particular (see #1283426: Need release for: D6->D7 upgrade: Table webform_last_download already exists.), is that there is no release plan and users have to investigate themselves which version they need to download or which patches they need to apply to cover they needs.

dawehner’s picture

This would be great to get sub-releases out, but this could cause major overhead for the maintainers.
But you know there are so many issues which would have to be fixed as soon as possible. Why is this one special? The problem was in basically forever ... If they don't know that DEV releases have bugs fixed then an upgrade of a major drupal version might not be the best task for them.

My personal recommendation would be to help people out, that's possible the best way to get things forward.

So enough time used on this issue.

jherencia’s picture

@dereine I think this issue is special because without this patch, upgrade path between D6 and D7 is broken. If the current recommended versions of views had this patch commited the less problems would have users to upgrade their sites.

But I agree it would be more work for maintainers. I was just trying to offer a different point of view and propose a different branch model, that in my opinion will make Drupal a better product.

Thank for your great work, and for your time.

Status: Fixed » Closed (fixed)

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