Error : Call to a member function getColumns()

Created on 22 February 2023, over 1 year ago
Updated 11 January 2024, 11 months ago

Problem/Motivation

Import fails with "Error : Call to a member function getColumns() on bool"

Steps to reproduce

In a Drupal 9 site where files have been added through means other than the Media Library or Entity Reference media fields :

  1. Enable the Media and Media Library modules
  2. Install Media Library Importer 2.0.0-beta1 in Drupal 9
  3. Navigate to /admin/config/media/media-library-importer/import and click the Import button
  4. Page loads blank screen with "The website encountered an unexpected error. Please try again later." error message

The next page that loads will display a success message with "Adding /path/to/site/web/sites/default/files/000001_8315.jpg to queue for new media entity creation" repeated a few hundred times (seems to only list files from first level of the files directory, doesn't list any files from sub directories)

In dblog, we have at least a few hundred entries from the media_library_importer module with the message "Checking existence of document: filename.pdf"

However the most recent message in dblog is Error : Call to a member function getColumns() (see full message below).

If I visit the Media Library ui it's empty, and the media database table is empty as well (except for the handful of items already uploaded manually).

More context:

  • current Drupal version = 9.5.2
  • migrated from D6 to D8 using Migrate API prior to media module in core, then eventually upgraded to D9
  • this site has a lot of files, probably a few thousand

Full journal message:

Error : Call to a member function getColumns() on bool in Drupal\Core\Entity\Query\Sql\Tables->addField() (/path/to/site/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php line 246)

#0 /path/to/site/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(58): Drupal\Core\Entity\Query\Sql\Tables->addField()
#1 /path/to/site/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile()
#2 /path/to/site/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(81): Drupal\Core\Entity\Query\Sql\Query->compile()
#3 /path/to/site/web/sites/default/modules/media_library_importer/src/Form/ImportForm.php(220): Drupal\Core\Entity\Query\Sql\Query->execute()
#4 /path/to/site/web/sites/default/modules/media_library_importer/src/Form/ImportForm.php(149): Drupal\media_library_importer\Form\ImportForm->mediaEntityExists()
#5 [internal function]: Drupal\media_library_importer\Form\ImportForm->submitForm()
#6 /path/to/site/web/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array()
#7 /path/to/site/web/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#8 /path/to/site/web/core/lib/Drupal/Core/Form/FormBuilder.php(595): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#9 /path/to/site/web/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\Core\Form\FormBuilder->processForm()
#10 /path/to/site/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#11 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#12 /path/to/site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#13 /path/to/site/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /path/to/site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#15 /path/to/site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#16 /path/to/site/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /path/to/site/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#18 /path/to/site/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#19 /path/to/site/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#20 /path/to/site/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#21 /path/to/site/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#22 /path/to/site/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#23 /path/to/site/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#24 /path/to/site/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#25 /path/to/site/web/core/lib/Drupal/Core/DrupalKernel.php(707): Stack\StackedHttpKernel->handle()
#26 /path/to/site/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#27 {main}

.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇨🇦Canada jmee Canada

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

Comments & Activities

  • Issue created by @jmee
  • 🇨🇦Canada jmee Canada

    I think that this is related to issues with the actual files on the server - corrupted files that cannot be read, extensions that are not allowed, etc. In my case, this is an old site and it's not surprising that there are issues with some files, and I'm running into issues when trying to look at unmanaged files with other modules (like unmanaged_files and fancy_file_delete).

    However, the media_library_importer behaviour is the same whether or not 'Import unmanaged files' is selected.

    I've also tried changing the path in the 'Import from folder' field to a directory that only contains valid files with a few different results. In one case, I pointed the import to a folder that contained a png and a pdf with the same result as above. There were journal entries for "Checking existence of" for both files, but only one success message for "Adding file.png to queue for new media entity creation" (for the png file).

    When I pointed it to a folder that contained only mp4 files, the imported worked! It seems like the import fails for pdfs, even though that is an allowed file type.

  • 🇺🇸United States joshuasosa

    I also get this error no matter what. Using Drupal 9.5.9, I tried it on one directory with a single jpg image and it failed with this error. IMO this is major if not critical since the module is completely unusable for its intended purpose.

  • Status changed to Closed: outdated 11 months ago
  • 🇮🇹Italy itamair

    please refer and move onto new 2.x-dev branch and 2.0.0 release

Production build 0.71.5 2024