- ๐บ๐ธUnited States jnicola
I'm having the same issue creating a group entity in Behat from simple array values and a content moderation state.
- ๐บ๐ธUnited States jnicola
Also, just tested the patch locally. Resolved my issues.
Issue was programmatically creating a pretty simple group from array values. No idea where the array flip complaint came from.
This is likely an issue worth getting some review on. A simple start would be to create a bare bones drupal install with just content moderation and programatically create an entity to see if it can be reproduced, and increase complexity until the warning shows up.
- ๐บ๐ธUnited States jnicola
Alright, another update.
After experimenting with this, I was able to ascertain that $revision_ids is an array of a single NULL value when programmatically creating content with content moderation on it. In our case it is a group content type. We're experiencing this in 9.5.x, creating a simple group entity with very simple values.
I tried using the foreach patch above, which worked... but when standing the site up for automated testing it would error out on config imports due to memory limitation issues. Not sure how the two relate?
I was able to resolve the issue by instead of using a foreach, adding a few sanity checks prior to the array_flip causing the warning:
if ($revision_ids && !is_null(reset($revision_ids))) {
Attached is the patch, which does not follow the correct issue queue naming conventions, but eh whatever take it out of my bonus that I don't get ;)
Hope this helps somebody, and perhaps with some simpler steps to reproduce and a test we could get this onwards to core.
- Status changed to Needs review
7 months ago 11:59pm 29 May 2024 - ๐จ๐ฆCanada franceslui
The current implementation of ContentEntityStorageBase::loadRevision() and ContentEntityStorageBase::loadMultipleRevisions() does not adequately handle invalid or empty revision IDs. This can lead to potential errors or unexpected behavior when these methods are called with invalid parameters.
Solution:
1. Added validation in ContentEntityStorageBase::loadRevision($revision_id) to check if $revision_id is either an integer or a string. If not, the method exits early and returns NULL.
2. Added a check in ContentEntityStorageBase::loadMultipleRevisions(array $revision_ids) to exit early and return the revisions array if no revisions can be loaded, ensuring the method does not proceed with empty data. - Status changed to Needs work
7 months ago 12:04am 30 May 2024 The Needs Review Queue Bot โ tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request โ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
- ๐ฎ๐ณIndia prashant.c Dharamshala
Prashant.c โ made their first commit to this issueโs fork.
- Merge request !8230Check for int and string Revision Id and early returns โ (Open) created by prashant.c
- Status changed to Needs review
7 months ago 12:01pm 30 May 2024 - ๐ฎ๐ณIndia prashant.c Dharamshala
Raised a PR by taking the changes from #19 ๐ฌ Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\ContentEntityStorageBase->loadMultipleRevisions() Needs work .
Changing the status to NR.
Thanks
- Status changed to Needs work
7 months ago 1:21pm 30 May 2024 - ๐บ๐ธUnited States smustgrave
Support requests typically don't have patches or MRs.
Has anyone determined where the issue is happening? Instead of just putting a check that may be masking a larger issue.
- Status changed to Postponed: needs info
6 months ago 1:29am 21 June 2024 - ๐จ๐ฆCanada franceslui
I concur with @smustgraveโs comment #24 that the check I implemented in my patch might obscure a deeper issue. Therefore, I have removed my patch from this issue. Upon further investigation, I discovered that the problem stems from the static_page module rather than Drupal core. The detailed information can be found in the related issue at https://www.drupal.org/project/static_page/issues/3386719 ๐ Revision object is returned instead of revision id due to core type upcasting change. Needs review . You can also find my new patch in my comment at https://www.drupal.org/project/static_page/issues/3386719#comment-15649482 ๐ Revision object is returned instead of revision id due to core type upcasting change. Needs review .