Upon upgrading from Drupal 8.6.16 to 8.7.1, any attempt to run a feed downloading from a URL on cron runs results in the following errors:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "field_item:feeds_serialized" plugin does not exist.
Drupal\Core\Entity\EntityStorageException: The "field_item:feeds_serialized" plugin does not exist. 

The actual new feed item itself is not created and the error continues to throw on each cron run. Reverting the site back to 8.6.16 allows the feed to begin working properly again. We are running the alpha5 branch of Feeds. Tried drush updb, as well as drush entup when back on 8.6.16 to make sure there weren't entity updates gumming up the system. Errors still throw when upgrading to 8.7.1 for core.

This is preventing us from updating a site to the 8.7 branch of core, so we are struggling with how to resolve this error / bug. Any help would be greatly appreciated!

Comments

kferencz91 created an issue. See original summary.

MegaChriz’s picture

Category: Bug report » Support request

This is a field type deleted almost three years ago. See https://git.drupalcode.org/project/feeds/commit/b73b5702f7280f7763669335... and #2728621: Adding modules that hook into the feed config is not working.

Since Drupal 8.7, Drupal no longer supports automatic entity updates, so that's probably why you see this error since that version: https://www.drupal.org/node/3034742.

Hopefully one of the methods described on that page would help you further. Perhaps "Updating an existing field storage definition"?

function example_update_8701() {
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('hostname', 'comment');
  $field_storage_definition->setDefaultValueCallback(Comment::class . '::getDefaultHostname');
  $entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
}

Instead of changing the default value as above, the field type should be changed for the field 'config' on the feed entity type, so I assume you need to start with the following:

$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('config', 'feeds_feed');
kferencz91’s picture

@MegaChriz, thank you for the reply. I won’t be able to test this out until a little later in the week as I am traveling, but I appreciate the suggestions!

When we have the site on 8.6 that does support entup, it comes back saying there’s no entity configuration to update. Should it not register this need when on the core branch that supports it? Or did something strange get missed when we upgraded the Feeds module itself?

I’ll report back when I’m able to test further. Again, appreciate the assistance!

MegaChriz’s picture

When we have the site on 8.6 that does support entup, it comes back saying there’s no entity configuration to update. Should it not register this need when on the core branch that supports it?

I don't know. Maybe entup doesn't support field type changes.

awm’s picture

I am running into the same issue can you elaborate on what

$field_storage_definition->setDefaultValueCallback(Comment::class . '::getDefaultHostname'); 

should be in the example for feeds_feed?
note that the structure of $field_storage_definition from

$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('config', 'feeds_feed');

is :

Drupal\Core\Field\BaseFieldDefinition Object
(
    [type:protected] => feeds_serialized // I believe this should be 'map' instead of 'feeds_serialized' . It is probably possible to update this. 
    [propertyDefinitions:protected] => 
    [schema:protected] => Array
        (
            [columns] => Array
                (
                    [value] => Array
                        (
                            [type] => blob
                            [size] => big
                            [serialize] => 1
                        )

                )

            [unique keys] => Array
                (
                )

            [indexes] => Array
                (
                )

            [foreign keys] => Array
                (
                )

        )

    [indexes:protected] => Array
        (
        )

    [itemDefinition:protected] => Drupal\Core\Field\TypedData\FieldItemDataDefinition Object
        (
            [fieldDefinition:protected] => Drupal\Core\Field\BaseFieldDefinition Object
 *RECURSION*
            [definition:protected] => Array
                (
                    [type] => field_item:feeds_serialized
                    [settings] => Array
                        (
                        )

                )

            [typedDataManager:protected] => 
        )

    [definition:protected] => Array
        (
            [label] => Drupal\Core\StringTranslation\TranslatableMarkup Object
                (
                    [translatedMarkup:protected] => 
                    [options:protected] => Array
                        (
                        )

                    [stringTranslation:protected] => 
                    [string:protected] => Config
                    [arguments:protected] => Array
                        (
                        )

                )

            [description] => Drupal\Core\StringTranslation\TranslatableMarkup Object
                (
                    [translatedMarkup:protected] => 
                    [options:protected] => Array
                        (
                        )

                    [stringTranslation:protected] => 
                    [string:protected] => The config of the feed.
                    [arguments:protected] => Array
                        (
                        )

                )

            [provider] => feeds
            [field_name] => config
            [entity_type] => feeds_feed
            [bundle] => 
        )

    [typedDataManager:protected] => 
)

This exist in the key_value table in the database.

awm’s picture

so to fix this issue, the best way to do it is to uninstall and reinstall the feeds module. However this is sometimes difficult without deleting all feeds entities. I was able to mock the process by doing to following in a hook update:

  // Read the configuration.
  $module_data = \Drupal::config('core.extension')->get('module');
  // Unset the modules you do not need.
  unset($module_data['feeds']);

  
  \Drupal::configFactory()
    ->getEditable('core.extension')
    ->set('module', $module_data)
    ->save();
  // Delete a configuration object in order to reinstall
  $config = Drupal::configFactory()
    ->getEditable('system.action.feeds_feed_delete_action');
  if ($config) {
    $config->delete();
  }
  // Reinstall the schema
  \Drupal::service('module_installer')->install(['feeds']);

this worked without any obvious repercussions.
@MegaChriz do you have any thoughts on this?

MegaChriz’s picture

@awm
Your code seems like a hack, but if it works, then that's great! Looks weird that specifically the action plugin instance needs to be deleted. But feed types, feeds and feeds_item fields can thus all stay in place without the need to deleting these?

So 'feeds_serialized' cannot be changed to 'map' with the entity definition update manager?

awm’s picture

@MegaChriz uninstalling the module and re-installing is what I determined was the best way. However, upon uninstalling the module the action remained, which I reckon is a feeds bug. This prevented me from re-installing the module and thus I needed to delete it.

Do you agree uninstalling and re-installing the cleanest way to address such a problem?

It is possible to update but I have not tried, can you post sample code how how to update it using the manager?

Finally I opted for re-installing the module because I was not sure if that's the only issue that will be encountered.

MegaChriz’s picture

@awm
Finding out how to update is what I hope you or @kferencz91 would find out ;). I don't know the answer, at least not without diving into it myself.

If the action remains upon uninstalling, then that sounds like a bug. Perhaps you want to create a new issue for that? Perhaps you also want to write a test for reinstalling Feeds? It can be added to the existing \Drupal\Tests\feeds\Functional\FeedsUninstallTest.

kferencz91’s picture

What worked best for us was what @awm mentioned - uninstalling the module completely, then reinstalling it. We had to delete all existing feeds before doing this, ran field_purge_batch a few times via drush to clean out the old feeds references in the DB (this usually happens in small batches via cron, but running field_purge_batch was faster for us), then re-installed and setup the feeds as they previously were. Wish there had been an easier way, but it was the only thing that stopped the constant errors on import!

RmrJmrGrl’s picture

I am having this same error with feeds. I am trying to delete the feeds in order to uninstall/re-install the module but it keeps erroring out when I try to delete the feeds. This is the first part of a mile-long error log entry: Error: Maximum function nesting level of '256' reached, aborting! in Drupal\Core\Entity\EntityType->isSubclassOf() (line 450 of /app/web/core/lib/Drupal/Core/Entity/EntityType.php).