Call to a member function getColumns() on bool in Drupal\Core\Entity\Query\Sql\Tables->addField() (line 245 of /core/lib/Drupal/C ore/Entity/Query/Sql/Tables.php)

Created on 9 January 2021, almost 4 years ago
Updated 17 June 2023, over 1 year ago

Steps to reproduce

D7 site with no module installed other than EU cookies and IMCE.
File module enabled.
Installed a fresh copy of D9.1
New D9 site has Image as configured media type.
Upgrade to D9.1 via migrate_tools and migrate_upgrade.
Everything goes smooth

Migrate does copy the files and make them available via /admin/content/files view.
MIME type is correct, "Used in" is correctly populated.
But /admin/content/media is empty.
When I try to add images from CKEditor "Insert from Media Library" nothing is available.

Installed migrate_file_to_media via composer and enabled via drush and then trying to "import" images for page, story or blog:

answers_module=$( tr '\n' ' ' <<EOF
{
  "name": "File2Image",
  "machine_name": "file2image",
  "module_path": "modules/contrib",
  "description": "file media migration",
  "package" : "Custom",
  "features-bundle": "no",
  "twigtemplate": "no"
}
EOF
)

answers_migrations=$( tr '\n' ' ' <<EOF
{
  "name": "File2Image",
  "machine_name": "file2image",
  "migration_group": "media",
  "entity_type": "node",
  "source_bundle": "page",
  "source_field_name": "field_image",
  "target_bundle": "image",
  "plugin_id": "media_basic_migration_page",
  "lang_code": "it",
  "translation_languages": "none"
}
EOF
)

drush generate module --answers "$answers_module"

 The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
 • modules/file2image/file2image.info.yml
 • modules/file2image/file2image.install
 • modules/file2image/file2image.libraries.yml
 • modules/file2image/file2image.links.menu.yml
 • modules/file2image/file2image.module
 • modules/file2image/file2image.permissions.yml
 • modules/file2image/file2image.routing.yml
 • modules/file2image/file2image.services.yml
 • modules/file2image/src/Controller/File2imageController.php
 • modules/file2image/src/EventSubscriber/File2imageSubscriber.php
 • modules/file2image/src/Form/SettingsForm.php
 • modules/file2image/src/Plugin/Block/ExampleBlock.php

drush cr

drush generate yml-migrate_file_to_media_migration_media --answers "$answers_migrations"

 Welcome to yml-migrate_file_to_media_migration_media generator!
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

 The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
 • modules/file2image/config/install/migrate_plus.migration.media_basic_migration_page_step1.yml
 • modules/file2image/config/install/migrate_plus.migration.media_basic_migration_page_step2.yml

drush en file2image

drush migrate:duplicate-file-detection media_basic_migration_page_step1

And then the full trace of the error...

[error]  Error: Call to a member function getColumns() on bool in Drupal\Core\Entity\Query\Sql\Tables->addField() (line 245 of /var/www/html/test/new/XXXXXXXXXXX_mysql/core/lib/Drupal/C
ore/Entity/Query/Sql/Tables.php) #0 /var/www/html/test/new/XXXXXXXXXXX_mysql/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(51): Drupal\Core\Entity\Query\Sql\Tables->addField()
#1 /var/www/html/test/new/XXXXXXXXXXX_mysql/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(172): Drupal\Core\Entity\Query\Sql\Condition->compile()
#2 /var/www/html/test/new/XXXXXXXXXXX_mysql/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(80): Drupal\Core\Entity\Query\Sql\Query->compile()
#3 /var/www/html/test/new/XXXXXXXXXXX_mysql/modules/contrib/migrate_file_to_media/src/Plugin/migrate/source/MediaEntityGenerator.php(174): Drupal\Core\Entity\Query\Sql\Query->execute()
#4 /var/www/html/test/new/XXXXXXXXXXX_mysql/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(287): Drupal\migrate_file_to_media\Plugin\migrate\source\MediaEntityGenera
tor->initializeIterator()
#5 /var/www/html/test/new/XXXXXXXXXXX_mysql/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(329): Drupal\migrate\Plugin\migrate\source\SourcePluginBase->getIterator()
#6 /var/www/html/test/new/XXXXXXXXXXX_mysql/modules/contrib/migrate_file_to_media/src/Commands/MediaMigrateCommands.php(255): Drupal\migrate\Plugin\migrate\source\SourcePluginBase->rewin
d()
#7 [internal function]: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands->duplicateImageDetection()
#8 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
#9 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#10 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#11 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(311): Consolidation\AnnotatedCommand\CommandProcessor->process()
#12 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#13 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run()
#14 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#15 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#16 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run()
#17 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun()
#18 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run()
#19 /var/www/html/test/new/XXXXXXXXXXX_mysql/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/t...')
#20 phar:///usr/local/bin/drush/bin/drush.php(141): drush_main()
#21 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#22 {main}.

At no time in the process I can see drush migrate:status reporting the migration I'd expect to see.

🐛 Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇮🇹Italy azaril Milano

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.

  • 🇺🇦Ukraine HitchShock Ukraine

    @chipway The main goal of the module is to migrate file entities to media entities on the same site (D9).
    For migration from D7 to D9, we provided plugins and examples of the configs in the migrate_file_to_media_d7_d8 module. It doesn't mean that these configs will work for your sites. They are just an example and you have to configure them by yourself, for example, configure the correct names of the fields.

    An error ```throws ERROR Call to a member function getColumns()``` means that the name of some column is wrong, it is probably you used a default name of the field in config but your D7 site uses another field.

    @azaril
    According to your description, you tried to migrate from D7 but at the same time, you used media_entity_generator source plugin instead of media_entity_generator_d7. This is the main reason for your issue. Also, please check my previous explanation for @chipway.

    The ticket is closed, as the main issue from the description is the expected result of incorrect use of the module

Production build 0.71.5 2024