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

  1. Enabled Media and Content under the "ENABLED LOCAL TASKS" section
  2. Enabled File and Media under the "ENABLED SOURCE ENTITY TYPES" section in addition to the default enabled entities
  3. Enabled Content and Media under the "ENABLED TARGET ENTITY TYPES" section in addition to the default enabled entities
  4. Disabled HTML links under "ENABLED TRACKING PLUGINS" section
  5. Enabled Content and Media under "WARNING MESSAGE ON DELETE FORM" section
  6. Enabled Track referencing basefields under "GENERIC" section
  7. 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.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alfattal created an issue. See original summary.

alfattal’s picture

Issue summary: View changes
imrodmartin’s picture

I’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.

jessehs made their first commit to this issue’s fork.

jessehs’s picture

Status: Active » Needs review

Adding 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...

  • marcoscano committed e69166f8 on 8.x-2.x authored by jessehs
    Issue #3347068 by jessehs, alfattal, imrodmartin: AJAX HTTP error when...
marcoscano’s picture

Thank 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!

jessehs’s picture

Status: Needs review » Reviewed & tested by the community

It is working for me. Thanks!

marcoscano’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Bug report

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.