Problem/Motivation
Batch Update failed with the the following error:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=13811&op=do_nojs&op=do
StatusText: OK
ResponseText: Error: Call to a member function getType() on null in Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker() (line 137 of /docroot/modules/contrib/entity_usage/src/EntityUsageBatchManager.php).
Steps to reproduce
I'm not sure if this was due to a misconfiguration that I did in the setting tab, but I've followed the instruction per the provided "Installation and basic usage" and modified the following default setting
- Enabled Media and Content under the "ENABLED LOCAL TASKS" section
- Enabled File and Media under the "ENABLED SOURCE ENTITY TYPES" section in addition to the default enabled entities
- Enabled Content and Media under the "ENABLED TARGET ENTITY TYPES" section in addition to the default enabled entities
- Disabled HTML links under "ENABLED TRACKING PLUGINS" section
- Enabled Content and Media under "WARNING MESSAGE ON DELETE FORM" section
- Enabled Track referencing basefields under "GENERIC" section
- Saved the configuration and executed the Batch Update
Update:
I tried running the Batch Update from my terminal using the drush command $ drush eu-r -y and the process failed to complete with this error:
Unable to decode output into JSON: Syntax error
Error: Call to a member function getType() on null in Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker() (line 137 of /home/ffattal/mndor/docroot/modules/contrib/entity_usage/src/EntityUsageBatchManager.php).
Error trace:
[warning] Undefined array key 0 EntityUsageBatchManager.php:131
> [error] Error: Call to a member function getType() on null in Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker() (line 137 of /home/ffattal/mndor/docroot/modules/contrib/entity_usage/src/EntityUsageBatchManager.php) #0 /home/ffattal/mndor/vendor/drush/drush/includes/batch.inc(256): Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker()
> #1 /home/ffattal/mndor/vendor/drush/drush/includes/batch.inc(201): _drush_batch_worker()
> #2 /home/ffattal/mndor/vendor/drush/drush/includes/batch.inc(95): _drush_batch_command()
> #3 /home/ffattal/mndor/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(20): drush_batch_command()
> #4 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process()
> #5 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
> #6 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
> #7 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
> #8 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process()
> #9 /home/ffattal/mndor/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
> #10 /home/ffattal/mndor/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
> #11 /home/ffattal/mndor/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
> #12 /home/ffattal/mndor/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
> #13 /home/ffattal/mndor/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run()
> #14 /home/ffattal/mndor/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun()
> #15 /home/ffattal/mndor/vendor/drush/drush/drush.php(77): Drush\Runtime\Runtime->run()
> #16 /home/ffattal/mndor/vendor/drush/drush/drush(4): require('...')
> #17 /home/ffattal/mndor/vendor/bin/drush(117): include('...')
> #18 {main}.
> Error: Call to a member function getType() on null in /home/ffattal/mndor/docroot/modules/contrib/entity_usage/src/EntityUsageBatchManager.php on line 137 #0 /home/ffattal/mndor/vendor/drush/drush/includes/batch.inc(256): Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker()
> #1 /home/ffattal/mndor/vendor/drush/drush/includes/batch.inc(201): _drush_batch_worker()
> #2 /home/ffattal/mndor/vendor/drush/drush/includes/batch.inc(95): _drush_batch_command()
> #3 /home/ffattal/mndor/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(20): drush_batch_command()
> #4 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process()
> #5 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
> #6 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
> #7 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
> #8 /home/ffattal/mndor/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process()
> #9 /home/ffattal/mndor/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
> #10 /home/ffattal/mndor/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
> #11 /home/ffattal/mndor/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
> #12 /home/ffattal/mndor/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
> #13 /home/ffattal/mndor/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run()
> #14 /home/ffattal/mndor/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun()
> #15 /home/ffattal/mndor/vendor/drush/drush/drush.php(77): Drush\Runtime\Runtime->run()
> #16 /home/ffattal/mndor/vendor/drush/drush/drush(4): require('...')
> #17 /home/ffattal/mndor/vendor/bin/drush(117): include('...')
> #18 {main}
> [warning] Drush command terminated abnormally.
Comments
Comment #2
alfattal commentedComment #3
imrodmartin commentedI’m adding this project to my “Ultimate Guide to the Media Manager” talk for DC Asheville and my course at OSTraining - but I’m seeing the same issue as described on a batch update.
I'm going to test on a few different environments/php versions to see if there's any difference.
Comment #5
jessehsAdding a null safe operator here fixed the issue for me. Note I did not investigate the root/underlying cause of the issue. This simple change fixed the blocking error, however, and allowed the module to be used.
https://git.drupalcode.org/issue/entity_usage-3347068/-/commit/e41520cfc...
Comment #7
marcoscanoThank you all for reporting and for the fix. The fix seems to be simple enough that I'm OK getting it in even if we don't know what's causing it. I did change it into a more old-style check since we still support sites on php7.4, if I remember well.
Can you all please test with latest -dev to see if this is really fixed for you? If that's the case then I'll tag a new release with the fix.
Thanks!
Comment #8
jessehsIt is working for me. Thanks!
Comment #9
marcoscanoThank you! Tagged https://www.drupal.org/project/entity_usage/releases/8.x-2.0-beta12 with this fix.