I have created a couple of simple entityqueues to control the order of my content in views, but when I export and then later import the entityqueues the subqueues are not created in the db which causes an error on the entityqueue admin page (admin/structure/entityqueue). Do you have any advise on how to fix this? Maybe create the subqueues after a queue has been imported?

CommentFileSizeAuthor
#12 2782535-12.patch485 bytesamateescu
#8 2782535.patch6.17 KBamateescu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jesperjb created an issue. See original summary.

jespermb’s picture

Issue summary: View changes
amateescu’s picture

Status: Active » Postponed (maintainer needs more info)

Subqueues for simple queues are created automatically in the postSave() method of the queue, see \Drupal\entityqueue\Entity\EntityQueue::postSave() and \Drupal\entityqueue\Plugin\EntityQueueHandler\Simple::onQueuePostSave() so maybe something went wrong when you imported the configuration?

vlledo’s picture

Hi, we have the same problem. When you create an entityqueue from admin interface it works fine, but when you export the configuration and later import in a clean drupal installation, the entity queue doesn't persist the elements in the queue on save.

amateescu’s picture

That's a different problem. By elements you mean the entities referenced by the subqueue? If so, those are usually content items that are not synchronized by the configuration system.

vlledo’s picture

Obviously referenced entities are content, not configuration and it couldn't be exported/imported, probably I didn't explain well enough. I'll explain again:

  • First, I created two entityqueues and later I exported it as yml config files. Here, I can add elements into my queues without problems.
  • Later (after installed a new Drupal 8 site) I imported the entityqueues (previously exported in first step).
  • Aparently everything works fine, I have my entityqueues in admin panel, but when I add a new element into the queue and I click on save button, nothing is added. The problem seems to be that the subqueues does not exists.

I hope I explained better this time. Thanks.

vdanielpop’s picture

Hi,

I'm having the same issue. The Entity Queue is created and exported successfully, but when I'm trying to import the configuration on a different Drupal installation, only the queue is created and not the subqueue.

Edit: I managed to fix the issue by creating an EventSubscriber that triggers on config import and creates subqueues where needed. Do you think that's a good approach, should I make a patch for that?

amateescu’s picture

Version: 8.x-1.0-alpha4 » 8.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs review
FileSize
6.17 KB

That does sound like a good solution indeed. Can you try out this patch?

vlledo’s picture

Hi,

For me the problem persists after apply the patch.

amateescu’s picture

@vlledo, can you try to debug with the patch applied and check if EntityQueueConfigSubscriber::onConfigSave() is reached when you import the queues?

vlledo’s picture

Hi @amateescu, after apply the patch, the items were added to the subqueue but the showed number of queue items was 0 and the editor couldn't be able to order or view the current queue elements.

The problem was subqueues langcode. After a few hours of debugging we've found that the register of subqueue in database (when the queue was imported from config files during site installation) had a different langcode than the queues created by the Drupal UI. We have our sites in spanish and the imported queues was generated with langcode 'en' and uid '0', while the others subqueues (created by Drupal UI) had langcode 'en' and uid 1.

We solved it adding a new line into function onQueueConfigSave(Config $config) into your patch to set the langcode value. After set the langcode value all works fine. We finally have the following code:

  public function onQueueConfigSave(Config $config) {
    // Make sure that every simple queue has a subqueue.
    $queue_id = $config->get('id');
    if (!$subqueue = EntitySubqueue::load($config->get('id'))) {
      EntitySubqueue::create([
        'queue' => $queue_id,
        'name' => $queue_id,
        'title' => $config->get('label'),
        'langcode' => $config->get('langcode'),
      ])->save();
    }
  }

Hope it could be useful.

amateescu’s picture

FileSize
485 bytes

Ok.. that's an interesting observation :)

I investigated how configuration is imported and it seems that entity hooks *are* fired when default config is imported, so the patch from #8 should not really be necessary.

Can you try out this simpler version instead, which simply sets the langcode using the current config entity pre-save hook?

vlledo’s picture

It works perfectly :-)

  • amateescu committed adb542a on 8.x-1.x
    Issue #2782535 by amateescu, vlledo, vdanielpop: Subqueue missing after...
amateescu’s picture

Status: Needs review » Fixed

Great! That means the langcode was the problem after all, not the config entity hooks.

Committed the patch from #12 to 8.x.-1.x. Thanks @vlledo for testing!

@vdanielpop, can you also confirm that this fixes the problem for you as well?

vdanielpop’s picture

@amateescu yes, the problem is solved.
Thank you all for your time!

Status: Fixed » Closed (fixed)

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