Check if file_metadata table exists before query on prepareMediaEntityRow

Created on 29 July 2022, over 2 years ago
Updated 9 March 2024, 10 months ago

Problem/Motivation

Really minor issue and I'm not very sure why but the project I'm migrating images from doesn't have a file_metadata table, and because of that I'm getting errors trying to query for image's width and height on line 100 of src/Plugin/media_migration/file_entity/Image.php on prepareMediaEntityRow.

   $width_and_height_statement = $connection->select('file_metadata', 'fmd')
       ->fields('fmd', ['name', 'value'])
       ->condition('fmd.fid', $file_id)
       ->condition('fmd.name', ['width', 'height'], 'IN')
       ->execute()->fetchAll(\PDO::FETCH_ASSOC);

Proposed resolution

Wrap the query on an if statement that checks if the table exists.

if ($connection->schema()->tableExists('file_metadata')) {
....
}
πŸ› Bug report
Status

Needs review

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada bbombachini London, ON

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States dane powell

    I also encountered this bug using Media 7.x-1.10 and File Entity 7.x-1.10, which don't have any such file_metadata table, and can confirm the patch fixes it. However, I'm not sure if it might leave unresolved issues (i.e., whatever data exists in that table not getting migrated).

    Does the media_migration module intend to support Media 7.x-1.x?

Production build 0.71.5 2024