Hello,

On a migrated D9 from D6, when I want to add items to a queue I get this:
Error: Call to a member function setTitle() on null in Drupal\entityqueue\Plugin\EntityQueueHandler\Simple->onQueuePostSave() (line 123 of modules/contrib/entityqueue/src/Plugin/EntityQueueHandler/Simple.php).

with:

 Entityqueue   Entityqueue (entityqueue)                           Enabled    8.x-1.2  
  Entityqueue   Entityqueue Smartqueue (entityqueue_smartqueue)     Disabled   8.x-1.2  
  Entityqueue   Entityqueue Form Widget (entityqueue_form_widget)   Disabled   2.0.2 

Do I need to enable others modules ?

Thanks

Comments

aiphes created an issue. See original summary.

amateescu’s picture

Category: Bug report » Support request
Status: Active » Fixed

That error means that you queue (config entity) doesn't have its corresponding subqueue (content entity) created. You can either create the subqueue manually or delete the queue and re-create it.

aiphes’s picture

Thanks but I get another issue when I want to go to admin/structure/entityqueue with WSOD. The website run on PHP8, instead of Dev thats run on PHP7.4.

TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 202 of modules/contrib/entityqueue/src/EntityQueueListBuilder.php).

amateescu’s picture

That's the same underlying problem, the missing subqueue entity.

Here's a snippet which creates it easily:

      $queue = EntityQueue::load('ID_OF_YOUR_QUEUE');
      $subqueue = EntitySubqueue::create([
        'queue' => $queue->id(),
        'name' => $queue->id(),
        'title' => $queue->label(),
        'langcode' => $queue->language()->getId(),
      ]);
     $subqueue->save();
aiphes’s picture

How do I use this snippet ?
Can I reset all queues and recreate them ( in DB or elsewhere) .
Why config import do this unusable queues ?

amateescu’s picture

How do I use this snippet ?

You can put it in a .php file and execute it with Drush: https://www.drush.org/latest/commands/php_script/#examples

Can I reset all queues and recreate them ( in DB or elsewhere) .

That's harder to do.

Why config import do this unusable queues ?

No idea.

aiphes’s picture

According to the drush example I made a file called entityqueue.php with this code in it:

<?php

//
// This example demonstrates how to write a drush
// script. These scripts are run with the php:script command.
//
use Drush\Drush;

      $queue = EntityQueue::load('File_test_php');
      $subqueue = EntitySubqueue::create([
        'queue' => $queue->id(),
        'name' => $queue->id(),
        'title' => $queue->label(),
        'langcode' => $queue->language()->getId(),
      ]);
     $subqueue->save();

and I get an error like:
Error: Class &#039;EntityQueue&#039; not found in include() (line 9 of /home/xx/www/xxx/config_d9pf/config_partager/scripts-php-drush/entityqueue/entityqueue.php).

The only difference between Dev and Prod website is PHP version..but putting PHP7 on Prod change nothing.

amateescu’s picture

You also need to add use statements for the classes that you are calling in the snippet:

use Drupal\entityqueue\Entity\EntityQueue;
use Drupal\entityqueue\Entity\EntitySubqueue;
aiphes’s picture

After done modifications on the file like:

<?php
//
// This example demonstrates how to write a drush
// script. These scripts are run with the php:script command.
//
use Drush\Drush;
use Drupal\entityqueue\Entity\EntityQueue;
use Drupal\entityqueue\Entity\EntitySubqueue;
      $queue = EntityQueue::load('File_test_php');
      $subqueue = EntitySubqueue::create([
        'queue' => $queue->id(),
        'name' => $queue->id(),
        'title' => $queue->label(),
        'langcode' => $queue->language()->getId(),
      ]);
     $subqueue->save();

I get:

 [error]  Error: Call to a member function id() on null in include() (line 13 of /home/provence-formation-php7/www/xx/config_d9pf/config_partager/scripts-php-drush/entityqueue/entityqueue.php) 
#0 /home/x-php7/www/xxx/sited9/vendor/drush/drush/src/Commands/core/PhpCommands.php(111): include()
#1 [internal function]: Drush\Commands\core\PhpCommands->script(Array, Array)
amateescu’s picture

$queue = EntityQueue::load('File_test_php');

Is File_test_php the ID of your queue?

aiphes’s picture

not, it's a test name, real is actualites_brulante, so I try with the real name and I get this:

 [error]  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'actualites_brulante' for column `xxx_xd9`.`linkchecker_index`.`entity_id` at row 1: INSERT INTO "linkchecker_index" ("entity_id", "entity_type", "last_extracted_time") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => actualites_brulante
    [:db_insert_placeholder_1] => entity_subqueue
    [:db_insert_placeholder_2] => 1652272517
)
 in Drupal\linkchecker\LinkExtractorService->updateEntityExtractIndex() (line 391 of /home/xxx/www/xxx/sited9/web/modules/contrib/linkchecker/src/LinkExtractorService.php).
amateescu’s picture

That's a problem in the linkchecker module: https://www.drupal.org/project/linkchecker/issues/3203329

aiphes’s picture

ok I've posted on the issue because patch doesn't work on beta. So I removed linkchecker module, and run the modified script, no error. :)
But I get an error on admin/structure/entityqueue like in #3 :(

TypeError: Argument 1 passed to Drupal\Core\Entity\EntityRepository::getTranslationFromContext() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /home/xxx/www/xxx/sited9/web/modules/contrib/entityqueue/src/Plugin/EntityQueueHandler/Simple.php on line 97 in Drupal\Core\Entity\EntityRepository->getTranslationFromContext() (line 93 of core/lib/Drupal/Core/Entity/EntityRepository.php).

amateescu’s picture

This means that either your subqueue was not created and saved properly, or you have multiple queues with this problem.

aiphes’s picture

So if I uninstall the module and reinstall it, and re import config it would work, now linkchecker is disabled ?

amateescu’s picture

I guess it should, but be careful with what other config is deleted (for example: views) when the queue is deleted when uninstalling the module.

aiphes’s picture

I done the uninstall/reinstall process for entityqueue + import entityqueue config + import view config and all is back as designed. I will see if linkchecker will be updated to avoid the issue mentionned here. Thanks for your help.

amateescu’s picture

No problem, glad you got it working :)

Status: Fixed » Closed (fixed)

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

gbisht’s picture

For reference purposes. added a patch in #3124403 to create a subqueue on the queue update operation.
After this patch just re-save the queue to create a subqueue.