I'm performing a D5 -> D6 upgrade. At first I thought I had the same problem as #363668: CCK fields are not showing up in Views but this doesn't seem the case.
I am scripting this upgrade and (amongst other things) this:
- Disables all non-core modules.
- Put new D6 code base in.
- Re-enable all non-core modules.
I manually run upgrade.php
- Do further tweaks to complete upgrade.
This works well. I have numerous CCK fields that upgrade just fine. However, it seems only one of them is not being properly converted - a number with select widget with 3 defined values. I have another such number field in the system with 4 defined values that is being properly converted which is odd. I mean, it's odd one would work and the other not when they are basically identical.
Anyhow, I noticed this while upgrading the views that use these fields as the 3 value one was missing. At first thought this must be an integration issue but on further investigation do not think that is correct.
When I look in the content_node_field table I notice the db_columns field is blank for the CCK number field am having problems with. The other number field has something in there. Surely that is a big clue.
I don't recall any errors during upgrade but will re-run and see if I can glean any more information to help here.
Comments
Comment #1
raintonr commentedI just re-ran the upgrade and was wrong when I said, "The other number field has something in there. Surely that is a big clue."
Both the number fields have blank db_columns and neither appear in views content list.
Checking further I found that it's the
content_associate_fieldsfunction that fills this column. This should be called fromcontent_check_updatebut for some reason that hasn't happened.Forcing an update of the last number module install (
number_update_6000) fixes this, but it would still be nice not to have to do this.I guess the issue is more related to one of the above functions not properly executing during upgrade.
Comment #2
markus_petrux commentedI would say... a) make sure it works in the source site, then b) upgrade manually and see if there is any error reported. Just in case, review the upgrade instructions and follow the steps carefully.
Many sites have upgraded successfully, so this seems something odd in your environment. Switching to support request...
Comment #3
abhaga commentedI had exactly the same problem. As suggested by raintonr above , manually selecting number_update_6000 to run when running update.php solves the problem.
Thanks a ton for the tip raintonr. May be this is actually a bug after all.
Abhaya
Comment #4
jpl-2 commentedI also ran into the same problem during D5->D6 migration. I can provide a few more details that might help to reproduce it.
An example field that was not migrated properly (db_columns blank in D6 after migration) is an integer field with widget type checkbox and two values listed in the "Allowed values" field. Other (apparently - all) integer fields with select list widgets and "Allowed values" were similarly corrupted. Here is the SQL for the original field's definition in D5:
The D5 version of CCK used was 5.x-1.12. The target D6 version of CCK was 6.x-2.8. I followed the recommended migration steps, and in the end update.php did not offer any more automatic updates. As the original poster mentioned, forcing update 6000 from number.module manually fixed the problem. I conclude that there must be some state on the migration path in which executing this very update does not have the intended effect (ordering issue?), so you are left with an inconsistent database, which is rather tough to debug because the problem simply pops up in Views UI (for instance, I could not select the field as a filter). If this bug cannot be tracked down and fixed, I would suggest that an assertion is placed somewhere to shorten the bug hunt for anyone affected.
Comment #5
dwwFWIW, I just ran into exactly this bug. I was starting with a D5 site with 8 CCK number_integer fields, some using a textfield widget, others select lists. I've been scripting the upgrade, which looks something like this:
- Grab a clean copy of 6.x core
- drush updatedb -y (no errors)
- clone cck and checkout the end of the 6.x-2.x branch
- drush updatedb -y (no errors) -- it says number_update_6000() was run (although I don't see anything that would suggest that would impact this bug)
At this point, the number fields were all basically broken. I was getting a ton of PHP warnings when trying to view or edit nodes, and none of the values were there. After some debugging to figure out why, I discovered that {content_node_field}.db_columns was empty for most of them:
After a bit of experimentation, I discovered that creating a new dummy content type with some number fields was working fine. In that case, db_columns was set to:
'a:1:{s:5:"value";a:3:{s:4:"type";s:3:"int";s:8:"not null";b:0;s:8:"sortable";b:1;}}'. Makes sense, and from what I can tell, all number_integer fields, regardless of widget, share these values. Therefore, I ran this query:This seems to have repaired the site and things appear to be working fine again. All the old values for these number_integer fields are loading and working, etc.
I have no explanation for why these columns were empty, so I don't really know what the bug is, but it really does appear to be a bug. If I knew the internals of CCK better, I'd try to dig further and fix this, but I really don't have time for that now. Just wanted to update here about my experience and work-around.
@CCK maintainers: can there ever be a number_integer field that doesn't use the above value for db_columns? If not, perhaps a number_update_N() that just runs the above query would be safe, and could at least paper over this bug, even if we don't understand why it's needed? ;)
Cheers,
-Derek
Comment #6
karens commentedThis is something that didn't exist in D5, we added it in D6 because we found we had to have this information even if the field module that provided the field was no longer available. Somewhere in the original D5 -> D6 upgrade path that column gets populated. Since you are jumping straight from D5 to D7 you're missing it.
It requires that the D6 module be available to find out what values should be in those columns. I have no idea how you can do that if you're skipping D6.
Comment #7
karens commentedAnd it is needed for *all* field types, because the Content Migrate module uses those values to figure out where the data is.
Comment #8
dwwI am migrating from D5 to D6 first. I'm neither skipping nor jumping. ;) Look at my steps in comment #5...
My struggles with D7 content_migrate can be found in other issues, in particular:
#1092840: Allowed values for list_number and list_boolean not converted to arrays
#1066268: PHP Notice: undefined index when migrating decimal number (which I should rename, it's much more serious than a PHP notice in my case)
#1059214: Batch processing problem causes migration to fail with "1062 Duplicate entry" error
#1078804: 'longtext' columns converted to varchar(255) on migration
But this was just to get things working again in the D6 version... (which I might fall back to, this D7 upgrade has been hell so far).
It *did* work on most fields, just apparently not the number.module fields. I definitely had number.module enabled when I was trying any of the cck-related updates. I left this out of my steps in the issue (but it's there in my script):
drush en -y content fieldgroup filefield imageapi imagecache imagefield optionwidgets nodereference number text
(which comes just before the drush updatedb). Maybe I should run updatedb before trying to enable?
Any other suggestions I should investigate? I'm about to start another whole D5 -> D6 -> D7 data migration again this morning.
Thanks!
-Derek
Comment #9
dwwOkay, I'm running through from the original D5 site, and I hit this again. I couldn't run updatedb without enabling everything, since the updates fail in that case. So, my steps really are:
At this point, the following are enabled:
Note: Version is blank since I'm cloning from Git but haven't yet enabled git_deploy at this point. However, here's the relevant chunks of the drush make file I'm using:
Any ideas? I'm just going to manually repair again and keep going, but I wanted to document all this for clarity.
Thanks!
-Derek
Comment #10
karens commentedSorry, dww, I did read it but answered too quickly :)
Anyway I dug into where this got set originally and here's the scoop:
There is a very important function that gets run when you enable a field module in D6: content_associate_fields(); That function does things like populate the columns in that table and setting the name of the module that controls the field and widget (also needed for the D7 migration).
There are some cases where because of module weight it didn't run when it should, and in those cases we added it to the field .install file (i.e. text module has this).
In a normal update it seems to work fine to get all those fields populated. At least I have not seen any problems. But maybe when you do it the way you are doing it things are not triggering in the right order.
Try enabling the content module first, then doing back and enabling the individual field modules. That should ensure that the content module is ready and waiting to generate that function when the field module is enabled.
Comment #11
karens commentedAnd be sure to run updatedb *after* enabling the content module and *before* enabling the field modules. Then run it again after all the field modules are enabled.
Comment #12
karens commentedIf you still have trouble (that column is still empty) after doing all that, you can try running content_associate_fields('number') from drush and see if that helps.
Comment #13
dwwYeah, still not happening automatically. Even if I split step #5 above into these:
it still fails.
However, after the updatedb, this works fine:
Any objection/harm in adding a number_update_6001() that does that automatically? I'd be happy to roll such a patch if that was a good idea. ;)
Thanks!
-Derek
Comment #14
karens commentedGo ahead and roll a patch. We don't want to run that function on a site that has those tables populated already because we might change other values that should not be changed, so the update should only run if the table column is empty.
Comment #15
dwwOddly, adding that in number_update_6001() still doesn't work. :( Something funny must be going on with ordering and weights, although all the CCK-related modules in the D5 DB have weight 0 except for fieldgroup (which is at 9).
Note that there's no way to *just* run content's DB updates without number and the rest of CCK itself. Once I put CCK on the site, as soon as you run updates, all updates are run, even for modules that aren't yet enabled. I sort of understand why that behavior is necessary in some cases, but it sure makes things difficult for a lot of others. ;)
Anyway, for now, I'm just leaving that drush eval step in my migration and it's working. I wish I could figure out a way to fix this upstream in CCK itself so others could benefit, but I just don't have time to keep trying. Alas.
Comment #16
Mark Theunissen commentedI had the same issue, doing exactly the same thing (upgrading from Drupal 5 to 7). dww's drush command fixed it for me too, I just put it into my enormous bash script that doubles in length by the second. :O
Comment #17
karens commentedIf adding this to an update_6001 doesn't work, I'm out of ideas. I don't have the problem and can't relicate it, so the only thing I can do is apply a patch that works, and apparently there is no patch that works.