Follow-up from #2118245: [meta] Source classes for config entities.

Write a D6 source plugin + tests for CCK field instances.

Remaining tasks: hunt for variable_get calls in CCK 6.x with a name that contains the instance id. Such variables need to be added in prepareRow. See D6FilterFormats::prepareRow for variable get examples.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fastangel’s picture

Status: Active » Needs review
FileSize
5.04 KB

Created a first version and added a test with a field body (type field with multiple rows).

chx’s picture

This is an excellent issue to use the new Drupal6SqlBase because the table name changes with the module version.

chx’s picture

Status: Needs review » Needs work

fixing status.

fastangel’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
5.11 KB

Updated.

chx’s picture

Status: Needs review » Needs work

I am sorry, I have explained this poorly. If you check content.module, it uses content_field_tablename for retrieving the table name depending on the module schema version. Drupal6SqlBase has a method to check for the module schema and so you can query the proper table.

marvil07’s picture

Actually I guess that function exists only because it is used on install file.
Even if that is not the case, I will suggest to just simply require version >= 6001(reviewing cck git history, that change was introduced before 6.x-1.0-alpha1, so it's safe to assume it's in) on RequirementsInterface::checkRequirements(). See Drupal6SqlBase::getModuleSchemaVersion() for that check.

marvil07’s picture

fastangel’s picture

Status: Needs work » Needs review
FileSize
5.31 KB

Done the last changes commented.

By the way, what happen with version before 6.x-1.0-alpha1?. We exclude from migrate? Should we say in some comment?

chx’s picture

We were talking of a requirements interface that pre migrations every plugin (source, destination) can throw an exception in and the runner will skip that migration.

chx’s picture

So I'd guess we should put in a requirements function that checks and throws an exception and then later we can wire it in with the interface.

fastangel’s picture

ok. Then should I add a exception when the version is version < 6001. Right?

The code should be:

 public function checkRequirements() {
    //Code the check schema version if is < 6001 launch a exception.
    return $this->moduleExists('content');
  }
chx’s picture

Status: Needs review » Fixed
FileSize
4.8 KB

I have committed this but please see the attached interdiff to see how much I needed to change this. (I am not talking of the TestFieldInstance, that's somewhat new and you might've not heard of it.)

fastangel’s picture

Thanks. The code are changing so fast. I know that I need to stay into the weekly hangout to stay update.

chx’s picture

My problem is, as I mentioned in #12 is not the new code. The problem is you are submitting code that clearly never ever has been tried -- because it contains numerous syntax errors. You can not use any expression in the default value of a property to boot.

chx’s picture

Do you need assistance with running phpunit tests?

try

cd core
vendor/bin/phpunit --group migrate
chx’s picture

Issue summary: View changes
Priority: Normal » Critical
Status: Fixed » Active

I am reopening this to review any variables that might need to be added in prepareRow.

fastangel’s picture

Assigned: Unassigned » fastangel
Status: Active » Needs review

Any relevant variable to use. See grep in cck:

./content.install:  if (variable_get('content_update_1009', FALSE)) {
./content.module:  if (!defined('MAINTENANCE_MODE') && variable_get('content_schema_version', -1) >= 6007) {
./content.module:      if (variable_get('content_schema_version', -1) < 6007) {
./content.module:  if (variable_get('content_schema_version', -1) < 6007) {
./content.module:  if (variable_get('content_schema_version', -1) < 6007) {
./content.module:    if (variable_get('content_schema_version', -1) < 6007) {
./content.module:        foreach (variable_get('content_extra_weights_'. $type_name, array()) as $key => $value) {
./content.module:    $version = variable_get('content_schema_version', 0);
./content.module:    $version = variable_get('content_schema_version', 0);
./content.module:    $version = variable_get('content_schema_version', 0);
./content.module:  if (variable_get('content_schema_version', -1) < 6000) {
./content.module:  if (module_exists('locale') && variable_get("language_content_type_$type_name", 0)) {
./content.module:  if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
./includes/content.crud.inc:    if ($extra = variable_get('content_extra_weights_'. $info->old_type, array())) {
./modules/content_copy/content_copy.module:  if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
./modules/fieldgroup/fieldgroup.module:    $version = variable_get('fieldgroup_schema_version', 0);
./modules/fieldgroup/fieldgroup.module:    $version = variable_get('fieldgroup_schema_version', 0);
chx’s picture

> 'content_extra_weights_'. $info->old_type

Looks suspicious. What is this used for? D7 core allowed reordering of the fields and stored that in variables too. Is this the same?

chx’s picture

More on D7: field_ui_display_overview_form_submit calls field_bundle_settings which sets / gets the variable field_bundle_settings_' . $entity_type . '__' . $bundle and from field_ui_display_overview_form_submit it is plain the weight is stored in that variable:

    $bundle_settings['extra_fields']['display'][$name][$view_mode] = array(
      'weight' => $form_values['fields'][$name]['weight']

Under D8, I would recommend trying to install field ui play with it a little -- weights should be in the entity.display.$this->entity_type . '.' . $this->bundle . '.' . $mode file .

In short, if that weight is indeed the same as in D7 then it needs to be added to the instance and then we can deal with it later when we migrate instances into instances and display entities.

marvil07’s picture

Status: Needs review » Needs work

Reflecting issue status

fastangel’s picture

I was doing some test here. And yes the weight is the same. Then we need to check the variable with height and map. Let me work on this.

fastangel’s picture

Uhmm I was checking again in D6. http://api.drupalize.me/api/drupal/function/content_field_overview_form/6 overview in D6 isn't use variable. The only variable is used for extra _weight with custom fields implemented with extra weights instead field api. Then I think that this issue should be postponed to D7. What do you think?

Gábor Hojtsy’s picture

Is this to cover all of CCK migrations? Or just the fields that have been built in D6 (like node body mentioned above) and made optional in D7/8? Hard to grok the scope from the summary / discussion.

chx’s picture

Status: Needs work » Fixed

This is all written by now, even the test. And yes, it's CCK.

Status: Fixed » Closed (fixed)

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