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 the following notice when trying to use the webform as a block with display mode :
Notice: Undefined index: preview_excluded_components in webform_node_load() (line 1577 of /www/dev/drupal7/sites/all/modules/contrib/webform/webform.module).
Notice: Undefined property: stdClass::$content in webform_block_view() (line 2050 of /www/dev/drupal7/sites/all/modules/contrib/webform/webform.module).
Comment | File | Size | Author |
---|---|---|---|
#4 | webform-2119309-unset_preview_values.patch | 3.07 KB | xurizaemon |
#1 | webform.patch | 1.42 KB | 谢艳 |
webform_error.jpg | 35.84 KB | 谢艳 |
Comments
Comment #1
谢艳 CreditAttribution: 谢艳 commentedhi:
there is a patch in the attachment.
I write the code above with this, it worked for me!!
Comment #2
woop_light CreditAttribution: woop_light commentedThanks @xieyanxy9, I tried your code and no longer received an error for line 1577 and 2050, but I am still getting the following errors:
Comment #3
谢艳 CreditAttribution: 谢艳 commentedhi:
I'm sorry, there is nothing I can do……
Webform 4.x has several API changes that may make add-on modules incompatible with the new version until they are updated. You can try other versions! it says "Which version should I choose" Notice……
Comment #4
xurizaemonAdded checks for $node->webform['preview'] also.
I'm seeing this in Webforms with AJAX submission, which is perhaps why the preview phase isn't getting fired?
Testing alongside Webform CiviCRM
which may also be a factor.Note to self: Still some remaining.
* Notice: Undefined index: preview_excluded_components in webform_node_update() (line 1384 of /path/to/site/sites/all/modules/webform/webform.module).
* Warning: implode(): Invalid arguments passed in webform_node_update() (line 1384 of /path/to/site/sites/all/modules/webform/webform.module).
Status message
Comment #5
xurizaemon(Disabling Webform CiviCRM didn't make the notices go away.)
Comment #6
quicksketchHi guys, this patch shouldn't be necessary because Webform ensures that defaults are populated for all these values as part of hook_node_load(). If these values are missing, we need to find why the defaults aren't getting populated, rather than adding isset() and empty() checks all over the place.
This error could occur if update.php needs to be run (to add the "preview_excluded_components" column to the "webform" database table).
Using Webform by itself, I can't reproduce these notices. I would check which module is causing the notices and then file an issue with that module if it's loading/creating Webform nodes in a way that doesn't populate the defaults.
Comment #7
quicksketchClosing after lack of activity.
Comment #8
DigitalFrontiersMediaRe-opening this as I've just experienced what I think is the same root problem but may have more information to help diagnose.
The exact message displayed:
We have a site that was built with a template from MoreThanThemes.com. The version of Webform used in the template's database was 7.x-3.x and we needed 7.x-4.x. The code was updated and the database was updated. Everything worked without errors at that point. The site's database was blown away to start fresh with the original template database (that was expecting 7.x-3.x to be the code base used). A new drush site-install was run followed by the enabling of a Feature that requires Webform. According to the system table, schema_version is 7430. However, if you look at the webform table, it's missing the preview_excluded_components column (and it appears others) that seem (according to webform.install) should be a part of a 7.x-4.x build.
So somehow webform enabled, added the webforms that came with the template and updated the schema_version but somehow missed actually installing the required schema?
Could a Feature or something report the wrong starting schema_version to begin with causing some required updates to be skipped?
Any ideas/pointers on the best way to figure out what updates have been applied and which haven't and how to apply the missing ones?
It just seems to me that something like this shouldn't really happen, but that's what it appears is the case. Thoughts?
Comment #9
Liam MorlandIt doesn't make sense. A new install should use hook_install() and shouldn't need any updates to run. I suggest trying again, but install Webform manually first, then install the Feature.
Comment #10
DigitalFrontiersMediaI can't say what the issue was and maybe it was just a fluke, but I ended up just manually adding the missing columns to the table. :-(
Thanks for the help anyway.
Going to go ahead and restore previous closed status since we weren't able to determine what the true issue was here in my case.
Comment #11
DigitalFrontiersMediaI figured out what my problem was and just documenting the exact fix here in case it is useful for others. I was getting confused between existing subsites and new subsites. New subsites ran _install just fine, but for some reason existing sites weren't applying updates correctly in some cases for me. I manually fixed those subsites via the following SQL query: