error message "Field moderation_state is unknown"

Created on 6 October 2023, 9 months ago
Updated 14 October 2023, 9 months ago

installed 2.0.3-beta2 (on Drupal 9.5.10) and tried the "find" menu item /admin/text

enter any text to search for, and it returns immediately to the page, due to a php error on the AJAX call:

InvalidArgumentException: Field moderation_state is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 587 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

according to Field List /admin/reports/fields there is no field called moderation_state in my site, couldn't find it in the database either.

๐Ÿ› Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada earthangelconsulting

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @earthangelconsulting
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada earthangelconsulting

    also, the first time i tried this did not occur, but the second time, the log file also had multiple occurrences (about 20?) of this error:

    Message Warning: Undefined property: stdClass::$revision_id in search_fields() (line 240 of xxx/web/modules/contrib/find_text/find_text.module)

  • Assigned to abhishek_virasat
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States duckydan

    I ran into this exact thing. I think it is assuming the site uses a Workflow for content.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States duckydan

    If I change that area to this:

              //Check the published status.
              if ($node->isPublished()) {
                $status = 'Published';
              } else {
                $status = 'Not Published';
              }
    

    This it works great for me. I realize that messes things up for people who want to see the Workflow Moderation state, so it's not a real fix.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada earthangelconsulting

    thanks @duckydan, i will try that later today, if it works, you are my hero! :-)

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada earthangelconsulting

    i tried what @duckydan suggested and it did not work for me, unfortunately.

    i get a different error, in the same piece of code


    Error: Call to a member function isPublished() on null in Drupal\find_text\Form\SearchForm->buildResultsTable() (line 247 of /var/www/html/web/modules/contrib/find_text/src/Form/SearchForm.php)

    it seems that $node in the following line

    if ($node->isPublished()) {

    is null

    i looked at the immediately surrounding code, to see if we could just add a conditional for that, but from what i could see it made no sense for $node to be null in any "normal" situation.

    i am admitting defeat for now, hope someone else can figure this out!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States themarkahrens

    mytungsten โ†’ made their first commit to this issueโ€™s fork.

  • @mytungsten opened merge request.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States themarkahrens

    I think I have a fix for both the Field moderation_state is unknown and Undefined property: stdClass::$revision_id errors. I just pushed an update to the dev version if folks want to test that out.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States duckydan

    It works perfectly! Thank you!

  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States themarkahrens
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada earthangelconsulting

    well, it's interesting that duckydan and i keep getting different results, there must be something about their data that is different?

    i am using the latest dev version, (i upgraded by doing this: composer require 'drupal/find_text:1.x-dev@dev' ) ... and now i get this error:

    Message Error: Call to a member function hasField() on null in Drupal\find_text\Form\SearchForm->buildResultsTable() (line 247 of /var/www/html/web/modules/contrib/find_text/src/Form/SearchForm.php)

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada earthangelconsulting

    still, we are making progress here :-) thanks all!

Production build 0.69.0 2024