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).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

谢艳’s picture

hi:
there is a patch in the attachment.
I write the code above with this, it worked for me!!

if (empty($result)) {
    return;
  }
  foreach ($result as $nid => $webform) {
    // Load the basic information for each node.
    $nodes[$nid]->webform = $webform;
    $nodes[$nid]->webform['record_exists'] = TRUE;

    // Expand the list of excluded preview components.
    if (isset($webform['preview_excluded_components'])) {
      $nodes[$nid]->webform['preview_excluded_components'] = array_filter(explode(',', $webform['preview_excluded_components']));
    }
  }
woop_light’s picture

Thanks @xieyanxy9, I tried your code and no longer received an error for line 1577 and 2050, but I am still getting the following errors:

Notice: Undefined index: preview in webform_client_form() (line 2226 of /home/content/71/7842571/html/aep/sites/all/modules/webform/webform.module).
Notice: Undefined index: preview in webform_page_labels() (line 3667 of /home/content/71/7842571/html/aep/sites/all/modules/webform/webform.module).
Notice: Undefined index: preview in webform_client_form() (line 2282 of /home/content/71/7842571/html/aep/sites/all/modules/webform/webform.module).
Notice: Undefined index: preview in webform_client_form() (line 2288 of /home/content/71/7842571/html/aep/sites/all/modules/webform/webform.module).
谢艳’s picture

hi:
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……

xurizaemon’s picture

Title: Undefined index: preview_excluded_components in webform_node_load() » Undefined index: preview_excluded_components, preview in webform_node_load()
Issue summary: View changes
FileSize
3.07 KB

Added 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

xurizaemon’s picture

(Disabling Webform CiviCRM didn't make the notices go away.)

quicksketch’s picture

Status: Needs review » Needs work

Hi 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.

quicksketch’s picture

Status: Needs work » Closed (cannot reproduce)

Closing after lack of activity.

DigitalFrontiersMedia’s picture

Version: 7.x-4.x-dev » 7.x-4.14
Category: Bug report » Support request
Status: Closed (cannot reproduce) » Active

Re-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:

Notice: Undefined index: preview_excluded_components in webform_node_load() (line 1725 of /path/to/sites/all/modules/contrib/webform/webform.module).

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?

Liam Morland’s picture

It 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.

DigitalFrontiersMedia’s picture

Status: Active » Closed (cannot reproduce)

I 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.

DigitalFrontiersMedia’s picture

I 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:

ALTER TABLE `webform`
ADD COLUMN `progressbar_bar` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value indicating if the bar should be shown as part of the progress bar.',
ADD COLUMN `progressbar_page_number` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value indicating if the page number should be shown as part of the progress bar.',
ADD COLUMN `progressbar_percent` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value indicating if the percentage complete should be shown as part of the progress bar.',
ADD COLUMN `progressbar_pagebreak_labels` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value indicating if the pagebreak labels should be included as part of the progress bar.',
ADD COLUMN `progressbar_include_confirmation` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value indicating if the confirmation page should count as a page in the progress bar.',
ADD COLUMN `progressbar_label_first` varchar(255) DEFAULT NULL COMMENT 'Label for the first page of the progress bar.',
ADD COLUMN `progressbar_label_confirmation` varchar(255) DEFAULT NULL COMMENT 'Label for the last page of the progress bar.',
ADD COLUMN `preview` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value indicating if this form includes a page for previewing the submission.',
ADD COLUMN `preview_next_button_label` varchar(255) DEFAULT NULL COMMENT 'The text for the button that will proceed to the preview page.',
ADD COLUMN `preview_prev_button_label` varchar(255) DEFAULT NULL COMMENT 'The text for the button to go backwards from the preview page.',
ADD COLUMN `preview_title` varchar(255) DEFAULT NULL COMMENT 'The title of the preview page, as used by the progress bar.',
ADD COLUMN `preview_message` text NOT NULL COMMENT 'Text shown on the preview page of the form.',
ADD COLUMN `preview_message_format` varchar(255) DEFAULT NULL COMMENT 'The filter_format.format of the preview page message.',
ADD COLUMN `preview_excluded_components` text NOT NULL COMMENT 'Comma-separated list of component IDs that should not be included in this form’s confirmation page.',
ADD COLUMN `next_serial` int(10) unsigned NOT NULL DEFAULT '1' COMMENT 'The serial number to give to the next submission to this webform.',
ADD COLUMN `confidential` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Boolean value for whether to anonymize submissions.'
;