Error: Call to undefined method Drupal\feeds\State::messenger()

Created on 14 November 2024, 5 months ago

Error: Call to undefined method Drupal\feeds\State::messenger() in Drupal\feeds\State->displayMessages() (line 196 of modules/contrib/feeds/src/State.php).

Getting this error in watchdog logs and on feed page after updating core to 10.3.6 and some other modules.

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Rudi Teschner

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

Merge Requests

Comments & Activities

  • Issue created by @Rudi Teschner
  • πŸ‡©πŸ‡ͺGermany Rudi Teschner

    Additional Stacktrace

    Drupal\feeds\FeedViewBuilder->getBuildDefaults() (Line: 157)
    Drupal\Core\Entity\EntityViewBuilder->viewMultiple() (Line: 123)
    Drupal\Core\Entity\EntityViewBuilder->view() (Line: 134)
    Drupal\Core\Entity\Controller\EntityViewController->view()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
  • πŸ‡³πŸ‡±Netherlands megachriz

    Thanks for reporting. I think that the error is related to incompleted imports at the time of the update.

    Only weird thing is that it says "undefined method". I would have expected the error to be something like "cannot call addMessage() on null" or something similar.

  • πŸ‡³πŸ‡±Netherlands megachriz

    You don't have patches applied to Feeds, by any chance?

  • πŸ‡©πŸ‡ͺGermany Rudi Teschner

    Thanks for the fast reply. No, I don't have any patches for the feeds module applied.

    I checked a different test system and there I actually get the error you mention (Error: Call to a member function addMessage() on null in Drupal\feeds\State->displayMessages()) during the cron runs. So it seems to actually be two different errors depending on whether the feed page is accessed or the cron jobs are executed.

    What I wondered though ... the messenger is addressed different ways in the feed module. No clue if that has to do something at all though.

    /src/Controller/CustomSourceListController.php:130: $this->messenger()->addError($e->getMessage());
    ./src/FeedTypeForm.php:355: $this->messenger()->addStatus($this->t('Your changes have been saved.'));
    ./src/Feeds/Processor/EntityProcessorBase.php:1292: $this->messenger()->addWarning($this->t('When mapping to the entity ID (@name), it is recommended to set it as unique.', [
    ./src/FeedForm.php:225: $this->messenger()->addMessage($this->t('%title has been created.', $t_args));
    ./src/FeedForm.php:229: $this->messenger()->addMessage($this->t('%title has been updated.', $t_args));
    ./src/FeedForm.php:235: $this->messenger()->addError($this->t('The feed could not be saved.'));
    ./src/Form/CustomSourceEditForm.php:137: $this->messenger()->addStatus($this->t('The source %label has been updated on the feed type %feed_type.', [
    ./src/Form/MappingForm.php:161: $this->messenger()->addWarning($this->t('Your changes will not be saved until you click the Save button at the bottom of the page.'));
    ./src/Form/MappingForm.php:392: $this->messenger()->addWarning($e->getMessage());
    ./src/Form/MappingForm.php:1076: !empty($message) ? $this->messenger()->addWarning(Markup::create(implode('
    ', $message))) : TRUE;
    ./src/Form/DeleteMultipleForm.php:53: $this->messenger()->addMessage($this->formatPlural($count, 'Deleted 1 feed.', 'Deleted @count feeds.'));
    ./src/Form/FeedUnlockForm.php:45: $this->messenger()->addMessage($this->t('%title has been unlocked.', $args));
    ./src/Form/FeedDeleteForm.php:73: $this->messenger()->addMessage($this->t('%title has been deleted.', $args));
    ./src/Form/ClearMultipleForm.php:52: $this->messenger()->addMessage($this->formatPlural($count, 'Deleted items of 1 feed.', 'Deleted items of @count feeds.'));
    ./src/Form/ImportMultipleForm.php:52: $this->messenger()->addMessage($this->formatPlural($count, 'Imported 1 feed.', 'Imported @count feeds.'));
    ./src/Form/FeedScheduleImportForm.php:61: $this->messenger()->addStatus($this->t('%title has been scheduled for import.', $args));
    ./src/Form/CustomSourceDeleteForm.php:100: $this->messenger()->addStatus($this->t('The source %label has been deleted from the feed type %feed_type.', [
    ./src/FeedExpireHandler.php:26: $this->messenger()->addWarning($this->t('The feed became locked before the expiring could begin.'));
    ./src/FeedExpireHandler.php:83: $this->messenger()->addError($e->getMessage());
    ./src/FeedExpireHandler.php:105: $this->messenger()->addStatus($this->t('Expired @count items.', ['@count' => $state->total]));
    ./src/Plugin/Type/Target/TargetBase.php:113: return $this->messenger();
    ./modules/log/src/Form/DeleteForm.php:44: $this->messenger()->addMessage($this->t('Log %id has been deleted.', [
    ./modules/log/src/Form/ClearLogConfirmForm.php:47: $this->messenger()->addStatus($this->t('Logs cleared for feed %label.', [

    against

    ./feeds.install:49: $messenger = \Drupal::messenger();
    ./tests/src/Kernel/FeedsEventsTest.php:63: $messages = \Drupal::messenger()->all();
    ./tests/src/Kernel/FeedsEventsTest.php:68: \Drupal::messenger()->deleteAll();
    ./tests/src/Kernel/FeedsEventsTest.php:92: $messages = \Drupal::messenger()->all();
    ./tests/src/Kernel/EntityIdTest.php:52: $messages = \Drupal::messenger()->all();
    ./tests/src/Kernel/EntityIdTest.php:165: $messages = \Drupal::messenger()->all();
    ./tests/src/Kernel/Feeds/Processor/GenericContentEntityProcessorTest.php:106: $messages = \Drupal::messenger()->all();
    ./tests/src/Kernel/Feeds/Target/LinkTest.php:83: $messages = \Drupal::messenger()->messagesByType('warning');
    ./tests/src/Kernel/Feeds/Target/TimestampTest.php:105: $messages = \Drupal::messenger()->messagesByType('warning');
    ./tests/src/Kernel/Feeds/Target/BookTest.php:297: $messages = \Drupal::messenger()->all();
    ./tests/src/Traits/FeedsCommonTrait.php:351: $messages = \Drupal::messenger()->all();

  • πŸ‡ΊπŸ‡ΈUnited States ajetiv1

    Same here, getting the following message:

    Error: Call to a member function addMessage() on null in Drupal\feeds\State->displayMessages() (line 196 of modules/contrib/feeds/src/State.php).

  • Merge request !205Possible fix. β†’ (Merged) created by megachriz
  • πŸ‡³πŸ‡±Netherlands megachriz

    I provided a possible fix in the MR. I did not test it yet though. I'm still working on the automated tests.

    If you want to apply the code to Feeds 8.x-3.0-rc2, you also need to apply the code from πŸ› Error: Serialization of 'CurlHandle' is not allowed in serialize() Active .

  • πŸ‡³πŸ‡±Netherlands megachriz

    The provided fix in the MR should be fixing this issue. πŸ™‚

    It would be great if you can test it, I plan to merge it this Thursday.

  • πŸ‡©πŸ‡ͺGermany Rudi Teschner

    I've added the changes in State.php to a system that had the messages appear every 5 minutes in watchdog - and the messages don't appear anymore

  • Pipeline finished with Skipped
    5 months ago
    #353075
  • πŸ‡³πŸ‡±Netherlands megachriz

    @rudi teschner
    Cool, thanks for testing. I merged the code!

  • πŸ‡¬πŸ‡§United Kingdom Rob230

    That patch doesn't apply. I tried applying https://www.drupal.org/project/feeds/issues/3479242 πŸ› Error: Serialization of 'CurlHandle' is not allowed in serialize() Active first. Are there specific commits or merge requests that need to be applied in a certain order?

  • πŸ‡¬πŸ‡§United Kingdom Rob230

    That is what I tried. I also tried applying every commit since October, and they all apply except for this ticket. There must be something weird about the diff with binary file added which means composer can't apply it.

    I've created a patch containing just the 2 required commits and no tests for anyone who wants to fix the WSOD on 8.x-3.0-rc2.

    It would be good to get a new release because currently anyone who updates gets a WSOD!

  • πŸ‡³πŸ‡±Netherlands megachriz

    @rob230
    I wasn't aware that this issue caused a WSOD, I thought it generated only some errors on the feed page.

    Thanks for creating the patch, I can see that applying the diff could be troublesome because of the binary file. I hadn't tried applying the diff with Composer, I only tried it like this:

    curl https://git.drupalcode.org/project/feeds/-/merge_requests/199.diff | git apply
    curl https://git.drupalcode.org/project/feeds/-/merge_requests/205.diff | git apply
    

    I didn't think about that for Composer it could cause trouble.

    While I think this issue doesn't affect everyone who updates Feeds (it only affects sites that have unfinished imports at the time of updating), good call on creating a new release. I can do that this Thursday.

  • πŸ‡³πŸ‡±Netherlands megachriz
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024