when execute "drush cron" in terminal;
this error occured:

#1 /docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(692): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\feeds\Entity\Feed))
#2 /docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(454): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object(Drupal\feeds\Entity\Feed))
#3 /docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(838): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\feeds\Entity\Feed))
#4 /docroot/core/lib/Drupal/Core/Entity/EntityBase.php(394): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\feeds\Entity\Feed))
#5 /docroot/modules/contrib/feeds/src/FeedImportHandler.php(305): Drupal\Core\Entity\EntityBase->save()
#6 /docroot/modules/contrib/feeds/src/Entity/Feed.php(260): Drupal\feeds\FeedImportHandler->startCronImport(Object(Drupal\feeds\Entity\Feed))
#7 /docroot/modules/contrib/feeds/feeds.module(90): Drupal\feeds\Entity\Feed->startCronImport()
#8 [internal function]: feeds_cron()
#9 /docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(392): call_user_func_array('feeds_cron', Array)
#10 /docroot/core/lib/Drupal/Core/Cron.php(236): Drupal\Core\Extension\ModuleHandler->invoke('feeds', 'cron')
#11 /docroot/core/lib/Drupal/Core/Cron.php(134): Drupal\Core\Cron->invokeCronHandlers()
#12 /docroot/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#13 /vendor/drush/drush/src/Drupal/Commands/core/DrupalCommands.php(59): Drupal\Core\ProxyClass\Cron->run()
#14 [internal function]: Drush\Drupal\Commands\core\DrupalCommands->cron(Array)
#15 /vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#16 /vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#17 /vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#18 /vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#19 /vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /vendor/symfony/console/Application.php(1000): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))#21 /vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#26 /vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/w...')
#27 phar:///usr/local/bin/drush/bin/drush.php(141): drush_main()
#28 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#29 {main}
Error: Call to a member function getPlugins() on null in Drupal\feeds\Entity\Feed->preSave() (line 512 of /docroot/modules/contrib/feeds/src/Entity/Feed.php).
[warning] Drush command terminated abnormally. Check for an exit() in your Drupal site.

Comments

jjwfcd created an issue. See original summary.

megachriz’s picture

Status: Active » Postponed (maintainer needs more info)

Can it be that you did the following?

  1. Started a feed import.
  2. Deleted the feed that was still in progress of importing.
  3. Deleted the feed type that the feed belonged to.

Because the line where the code failed was trying to call a method on the feed type. It looks like the feed type that the feed in question belonged to couldn't be loaded so it might have been deleted.

megachriz’s picture

Title: drush cron error » Cron import failed with error Call to a member function getPlugins() on null
prsnjtbarman’s picture

I got similar error, when 'drush pm-uninstall uc_product'

Error: Call to a member function getPlugins() on null in Drupal\feeds\Entity\Feed->preSave() (line 512 of /var/www/html/drbatrauae/modules/contrib/feeds/src/Entity/Feed.php)

developerweeks’s picture

StatusFileSize
new426 bytes

MegaChriz, your question in #2 looks like what happened on my local. Where should I go to purge this residue so the feed stops trying to process the ghost of feeds-past? Some context, I'm working in a docker environment and a teammate created some feeds. One of them became obsolete and was deleted. Deleting my containers and initializing the site again causes this error.
[error] Error: Call to a member function getPlugins() on null in Drupal\feeds\Entity\Feed->preSave() (line 517 of /app/wwwroot/modules/contrib/feeds/src/Entity/Feed.php)

I would prefer to clean my data instead of patching code to cover for it.

megachriz’s picture

@developerweeks
You can try to delete feeds tasks from the queue.

To do this in the UI:

  1. Install the Queue UI module.
  2. Go to Configuration > System > Queue manager (/admin/config/system/queue-ui)
  3. Select the Feed refresh queue for the feed type that was deleted (I hope it still gets listed).
  4. On the top of the page, select the action "Clear" and click "Apply to selected items".

Delete records from the database

You can also delete records from the database table "queue". Look for entries whose "name" starts with "feeds_feed_refresh:":

SELECT * FROM `queue` WHERE `name` LIKE 'feeds_feed_refresh:%'

Or if you know the exact name of the deleted feed type:

SELECT * FROM `queue` WHERE `name` = 'feeds_feed_refresh:my_feed_type'
megachriz’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.61 KB
new3.71 KB

@developerweeks
I've done some testing. It turns out that you need to delete (or deactivate) the feeds for which the feed type no longer exists.

The attached patch should prevent the PHP error noted in this issue and log a more useful error message instead:

The feed type "foo" for feed 1 no longer exists.

The last submitted patch, 7: feeds-deleted-feed-type-3104727-7-tests-only.patch, failed testing. View results

developerweeks’s picture

@MegaChriz Thank you. #6 had the information I needed to resolve the issue in my workspace, but it was a hectic day and I did not take the time to say it.

  • MegaChriz committed f1d4337 on 8.x-3.x
    Issue #3104727 by MegaChriz, developerweeks: Fixed cron import could...
megachriz’s picture

Status: Needs review » Fixed

Committed #7.

Status: Fixed » Closed (fixed)

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