Problem/Motivation

When you have the "Watch for content" options selected, when saving a node, the following error is displayed.

TypeError: Drupal\paragraphs_report\ParagraphsReport::getParasFromNid(): Argument #2 ($current) must be of type array, null given, called in /app/web/modules/contrib/paragraphs_report/src/ParagraphsReport.php on line 478 in Drupal\paragraphs_report\ParagraphsReport->getParasFromNid() (line 327 of modules/contrib/paragraphs_report/src/ParagraphsReport.php).
Drupal\paragraphs_report\ParagraphsReport->insertParagraphs(Object) (Line: 33)
paragraphs_report_node_insert(Object)
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'paragraphs_report') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('node_insert', Object) (Line: 416)
Drupal\Core\Extension\ModuleHandler->invokeAll('node_insert', Array) (Line: 215)
Drupal\Core\Entity\EntityStorageBase->invokeHook('insert', Object) (Line: 903)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('insert', Object) (Line: 564)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 784)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 489)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 270)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 595)
Drupal\Core\Form\FormBuilder->processForm('node_article_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 681)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

drush si
drush en paragraphs_report -y
Log in as administrator
Navigate to /admin/reports/paragraphs-report/settings
Select Articles content type
Select "Watch for content changes and update report data"
Save configuration
Create a paragrah type called "Text" with one Long Formatted Text field
Add a field to the article content type called field_paragraphs allowing the paragraph type
Create a new article with the required title Test and one paragraph.

This seems to only happen when You have never Clicked "Update Report Data" before.

Proposed resolution

CommentFileSizeAuthor
#2 3382078-1.patch897 bytesayush.pandey
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

generalredneck created an issue. See original summary.

ayush.pandey’s picture

StatusFileSize
new897 bytes

The issue is reproducible with module version 2.x-dev on Drupal 10.1. The patch fixes the issue.

abhishek_virasat made their first commit to this issue’s fork.

abhishek_gupta1’s picture

Status: Active » Needs review

@generalredneck, I have fixed this issue. please kindly review the MR

generalredneck’s picture

Assigned: Unassigned » generalredneck
Status: Needs review » Needs work

Hey, I appreciate both of yall taking a look at this. While identified areas where this would be a problem. I think the problem is bigger.

Specifically aisforaaron is storing the report state in the configuration entity. that does mean that any time you do a configuration export after content is updated (and you don't ignore this configuration entity) that it will be updated...

Example... after I run the report manually I get:

_core:
  default_config_hash: WDVVbTde1eXP94qMDbx4NqQy4uOAEHLdyGsAcQBcF4o
content_types:
  article: article
  page: 0
hide_paras:
  text: 0
import_rows_per_batch: '10'
watch_content: 0
report: '{"text":{"top":["1","2","3","4"]}}'

Prior to doing so, I get

_core:
  default_config_hash: WDVVbTde1eXP94qMDbx4NqQy4uOAEHLdyGsAcQBcF4o
content_types:
  article: article
  page: 0
hide_paras:
  text: 0
import_rows_per_batch: '10'
watch_content: 0

I propose that we use the State API to store the report state instead of the Configuration Entity... and then we use abstracted retrieval of the state so that we can handle this error for all 3 places in one area. It's currently being handled inf ParagraphsReport::fetchJson(), but just not being used everywhere.

  • generalredneck committed 256624f4 on 2.x
    Issue #3382078 by abhishek_gupta1, generalredneck, ayush.pandey: When...
generalredneck’s picture

Status: Needs work » Fixed

I pushed up the fix from ayush.pandey's patch because MR!12 did some reverts against some of the code changed in 2.x. Plus the patch works more completely.

Pushing the changes of MR!16 to #3423079: Why are entities saved in config ?

Status: Fixed » Closed (fixed)

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