Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#12 | 2782535-12.patch | 485 bytes | amateescu |
#8 | 2782535.patch | 6.17 KB | amateescu |
Comments
Comment #2
jespermb CreditAttribution: jespermb at Adapt commentedComment #3
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedSubqueues 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?Comment #4
vlledo CreditAttribution: vlledo commentedHi, 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.
Comment #5
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThat'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.
Comment #6
vlledo CreditAttribution: vlledo commentedObviously referenced entities are content, not configuration and it couldn't be exported/imported, probably I didn't explain well enough. I'll explain again:
I hope I explained better this time. Thanks.
Comment #7
vdanielpop CreditAttribution: vdanielpop at PitechPlus commentedHi,
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?
Comment #8
amateescu CreditAttribution: amateescu as a volunteer commentedThat does sound like a good solution indeed. Can you try out this patch?
Comment #9
vlledo CreditAttribution: vlledo commentedHi,
For me the problem persists after apply the patch.
Comment #10
amateescu CreditAttribution: amateescu as a volunteer commented@vlledo, can you try to debug with the patch applied and check if
EntityQueueConfigSubscriber::onConfigSave()
is reached when you import the queues?Comment #11
vlledo CreditAttribution: vlledo commentedHi @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:Hope it could be useful.
Comment #12
amateescu CreditAttribution: amateescu as a volunteer commentedOk.. 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?
Comment #13
vlledo CreditAttribution: vlledo commentedIt works perfectly :-)
Comment #15
amateescu CreditAttribution: amateescu as a volunteer commentedGreat! 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?
Comment #16
vdanielpop CreditAttribution: vdanielpop at PitechPlus commented@amateescu yes, the problem is solved.
Thank you all for your time!