Changeset 2663
- Timestamp:
- 06/30/08 22:52:33 (12 months ago)
- Files:
-
- 1 modified
-
branches/release-41/lib/MT/Upgrade.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-41/lib/MT/Upgrade.pm
r2661 r2663 935 935 code => \&core_upgrade_meta, 936 936 }, 937 'core_upgrade_category_meta' => { 938 version_limit => 4.0057, 939 priority => 3.2, 940 code => \&core_upgrade_category_meta, 941 }, 937 942 938 943 # Helper upgrade routines for core_upgrade_meta … … 945 950 code => \&core_upgrade_meta_for_table, 946 951 }, 952 'core_upgrade_plugindata_meta_for_table' => { 953 priority => 1.5, 954 code => \&core_upgrade_plugindata_meta_for_table, 955 }, 947 956 'core_drop_meta_for_table' => { 948 957 priority => 3.4, … … 1005 1014 my $types = MT->registry('object_types'); 1006 1015 my %added_step; 1007 TYPE: while (my ($ type, $reg_class) = each %$types) {1008 next TYPE if $ type eq 'plugin' && ref $reg_class; # plugin reference1009 1010 my $class = MT->model($ type);1016 TYPE: while (my ($registry_type, $reg_class) = each %$types) { 1017 next TYPE if $registry_type eq 'plugin' && ref $reg_class; # plugin reference 1018 1019 my $class = MT->model($registry_type); 1011 1020 next TYPE if !$class->has_meta(); # nothing to upgrade 1012 1021 1013 # TODO: what is this supposed to mean? 1014 my $t = $type; 1022 # If this is a class-based package, find its super-most superclass with the same table. 1015 1023 my $class_type = $class->properties->{class_type}; 1016 1024 if ($class_type && $class_type ne $class->datasource) { 1017 $t = $class_type;1018 1025 if (my $super_class = MT->model($class->datasource)) { 1019 1026 $class = $super_class … … 1022 1029 # If there's no appropriate superclass, go to update with the class 1023 1030 # we have, not the class we want. 1024 # TODO: if we're checking against the registry type without modifying it, why are we looking for a better object class first? 1025 next TYPE if $added_step{$type}; # already got that one 1026 } 1027 else { 1028 next TYPE if $added_step{$class->datasource}; # already got that one 1029 } 1030 1031 # TODO: why is this no longer the representative type for a table? that makes us upgrade tables multiple times 1032 my %step_param = ( type => $t ); 1033 # TODO: can't we just make this a different upgrade step? 1034 $step_param{plugindata} = 1 1035 if ( $class eq 'MT::Category' ) || ( $class eq 'MT::Folder' ); 1031 } 1032 1033 # Don't add another step for this table if we already made one. 1034 next TYPE if $added_step{$class->datasource}; 1035 1036 # Categories' and Folders' metadata are only custom fields, which are stored 1037 # in plugindata anyway. They're converted in their own upgrade step. So don't 1038 # handle them here. 1039 next TYPE if $class->isa('MT::Category'); 1040 1041 my %step_param = ( type => $registry_type ); 1036 1042 $step_param{meta_column} = $class->properties->{meta_column} 1037 1043 if $class->properties->{meta_column}; 1038 1044 $self->add_step('core_upgrade_meta_for_table', %step_param); 1039 # TODO: wait, then we set it based on the class? we're adding a step for every object_types entry then!! 1040 $added_step{$class} = 1; 1045 1046 # Yay, we added a step for this table. 1047 $added_step{$class->datasource} = 1; 1041 1048 } 1042 1049 return 0; … … 1078 1085 } 1079 1086 1080 sub core_upgrade_meta_for_table { 1087 sub core_upgrade_category_meta { 1088 my $self = shift; 1089 $self->add_step('core_upgrade_plugindata_meta_for_table', type => 'category'); 1090 $self->add_step('core_upgrade_plugindata_meta_for_table', type => 'folder'); 1091 return 0; 1092 } 1093 1094 sub core_upgrade_plugindata_meta_for_table { 1081 1095 my $self = shift; 1082 1096 return 0 if $Installing; … … 1086 1100 my $class = MT->model($type); 1087 1101 return 0 unless $class; 1102 1088 1103 my $cfclass = MT->model('field'); 1089 my $plugindata = $param{plugindata} || 0; 1090 1091 if ($cfclass) { 1092 # this looks weird, but it winds up invoking 1093 # the loading of custom field types and the 1094 # installation of their meta properties 1095 MT->registry('tags'); 1096 } 1104 return 0 if !$cfclass; 1105 1106 # this looks weird, but it winds up invoking 1107 # the loading of custom field types and the 1108 # installation of their meta properties 1109 MT->registry('tags'); 1097 1110 1098 1111 # special case for types that use CustomField plugindata 1099 1112 # for storing their custom field metadata instead of a 'meta' 1100 1113 # column. 1101 if ($cfclass && $plugindata) { 1102 require CustomFields::Upgrade; 1103 $self->progress($self->translate_escape('Moving metadata storage for categories...')); 1104 CustomFields::Upgrade::customfields_move_meta($self, $type); 1105 return 0; 1106 } 1107 if ($plugindata) { 1108 return 0; 1109 } 1114 require CustomFields::Upgrade; 1115 # TODO: really this should vary on $type but it's already translated for "categories" 1116 $self->progress($self->translate_escape('Moving metadata storage for categories...')); 1117 CustomFields::Upgrade::customfields_move_meta($self, $type); 1118 1119 return 0; 1120 } 1121 1122 sub core_upgrade_meta_for_table { 1123 my $self = shift; 1124 return 0 if $Installing; 1125 my (%param) = @_; 1126 my $type = $param{type}; 1127 return 0 unless $type; 1128 my $class = MT->model($type); 1129 return 0 unless $class; 1110 1130 1111 1131 my $offset = int($param{offset} || 0); … … 1187 1207 my $metavalue = $metadata->{$metaname}; 1188 1208 if ($metaname eq 'customfields') { 1209 my $cfclass = MT->model('field'); 1189 1210 next unless $cfclass; 1190 1211
