Insufficient suffix size

Created on 6 June 2025, 2 days ago

Problem/Motivation

When trying to migrate one of the field, the module indicates there is no content to be migrated , when there actually is.

Steps to reproduce

Create a file image field with 32 machine name length , upload a media and try to migrate it

Proposed resolution

Remove more characters from the suffixing in the module files.
from 29 to 32

from line 34 to 44 in the module file :


   // Media field name.
   $field_name_length = strlen($field_name);
   $new_field = $field_name;
 
   if ($field_name_length.'_media' >  26) {
     $new_field = substr($field_name, 0, 26);
   }
   $media_field_name = $new_field . '_media';
   $count = 0;
 
   foreach ($entity_id as $entity_obj) {
     $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_obj->entity_id);
     $field_type = $entity->get($field_name)->getFieldDefinition()->getType();
 
     try {
       $image_has_field = $entity->hasField($field_name) ;
       $image_field_has_no_value =  $entity->get($field_name)->isEmpty() ;
       $entity_has_media =  $entity->hasField($media_field_name); 
       $media_has_no_value=  empty($entity->get($media_field_name)->getValue());
 
     }
     catch (\Exception $e) {
       \Drupal::logger('file_to_media')->error('Error resolving image field , field value and media field, media value :'. $e->getMessage() );
       return;
     }


    if ($entity->hasField($field_name) && $entity->get($field_name)->isEmpty() === FALSE && $entity->hasField($media_field_name) && empty($entity->get($media_field_name)->getValue())) {

please see the attached file

Remaining tasks

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024