Upgrading from rc10 to 2.0 causes text field handlers in views to reset

jhedstrom - November 5, 2008 - 23:11
Project:Content Construction Kit (CCK)
Version:6.x-2.0
Component:Views Integration
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

When upgrading, views that used existing text fields that had "allowed values" reset to the non-allowed version. For example, field_foo allows

a|A
b|B
c|C

The view (during rc10) filter was set to, for example, find A or B. After the upgrade, the existing view reset to the (new as of 2.0)

Content: foo (field_bar)

instead of

Content: foo (field_bar) - Allowed values

Any suggestions on updating a lot of these en-masse (instead of removing and re-adding the filters one by one) would be much appreciated.

#1

yched - November 5, 2008 - 23:32
Status:active» fixed

Yes, this is mentioned in the release notes.
Unfortunate, but we the change was needed and it was best doing now than post-release, where the number of affected sites would have been much larger.

And, sorry, no suggestion for en-masse updating :-(

#2

yched - November 5, 2008 - 23:37

Forgot to add : the previous 'is one of / is none of'-style filters are available as additional filters for fields with 'allowed values'

#3

jhedstrom - November 6, 2008 - 00:41

I assumed as much. Thanks for the reply.

For anybody stumbling across this issue, I resolved it by exporting the broken views to a file, then fixed one via the views ui. Exporting the fixed one, the changes needed were fairly obvious:

-    'field_is_event_value' => array(
+    'field_is_event_value_many_to_one' => array(
       'operator' => 'not',
       'value' => array(
         '1' => '1',
@@ -732,14 +732,14 @@
         'operator' => FALSE,
         'label' => '',
       ),
-      'id' => 'field_is_event_value',
+      'id' => 'field_is_event_value_many_to_one',
       'table' => 'node_data_field_is_event',
-      'field' => 'field_is_event_value',
+      'field' => 'field_is_event_value_many_to_one',
       'override' => array(
         'button' => 'Use default',
       ),
       'relationship' => 'none',
-      'reduce_duplicates' => 0,
+      'reduce_duplicates' => 1,
     ),
   ));

So I was then able to quickly make the changes in the file instead of stepping through the UI for each one.

#4

yched - November 6, 2008 - 21:41
Status:fixed» active

Thx for sharing, jhedstrom.
Although,

-      'reduce_duplicates' => 0,
+      'reduce_duplicates' => 1,

doesn't seem right. 'reduce_duplicates' should be left as is IMO.

Let's leave this open for a while, might help other people.

#5

ayoder - November 9, 2008 - 21:35

Thanks jhedstrom.... I ran into the same issue. Your fix of exporting the view and adding "_many_to_one" before re-importing worked out great.

#6

David_Rothstein - November 21, 2008 - 20:12

Here is the start of a script that could be used to automate things, for sites using CCK and Views. We included similar code in the latest release of Acquia Drupal yesterday (see the "modules/acquia/acquia_agent/acquia_agent.install" file for the exact code we included), which made sense for us since the distribution contains both CCK and Views, and earlier versions had a release candidate version of CCK, so people using Acquia Drupal could potentially experience this problem. Credit for a large part of this code actually belongs to @yched and @merlinofchaos.

To use the attached, just remove the "_.txt" extension, put it in your Drupal root, and make sure you are logged in as user #1 with both CCK and Views enabled, then visit 'detect_views.php' in a web browser.

Right now, the code just looks through and detects broken Views for you, but does not actually try to fix them (we did not think it was worth the risk to go down that route for the moment). However, it would probably not be that difficult for someone who was interested in that functionality to modify this script for that purpose.

Hope this might help someone out...

AttachmentSize
detect_views.php_.txt 5.88 KB
 
 

Drupal is a registered trademark of Dries Buytaert.