Navigate to admin/content/aggregator/settings and submit the form. See the errors:

  • Notice: Undefined index: aggregator_processors in aggregator_admin_form_submit() (line 484 of /Users/akahn/drupal-7/modules/aggregator/aggregator.admin.inc).
  • Warning: array_filter(): The first argument should be an array in aggregator_admin_form_submit() (line 484 of /Users/akahn/drupal-7/modules/aggregator/aggregator.admin.inc).

Looks like this has to do with aggregator_admin_form_submit():

 function aggregator_admin_form_submit($form, &$form_state) {
  $form_state['values']['aggregator_processors'] = array_filter($form_state['values']['aggregator_processors']);
  system_settings_form_submit($form, $form_state);
} 

The issue seems to be that while aggregator_admin_form() checks whether any modules add processors for aggregator, and only displays settings pertaining to these add-ons if they are present, aggregator_admin_form_submit() performs no check and attempts to work with form data that may not be there. (See #303930: Pluggable architecture for aggregator.module for more info.) All that should be needed is adding a similar check to the latter function. Only do the array_filter() if that form element is actually there.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akahn’s picture

Here's a patch that checks module_implements('aggregator_process'). If the return is an array with a length greater than 1, then the array_filter line gets run. Otherwise, there is only 1 implementation of hook_aggregator_process, which is aggregator_aggregator process, meaning the array_filter line isn't necessary and doesn't get called.

This is the same check that's done for the settings form.

akahn’s picture

Status: Active » Needs review

(anyone know what's up with the comment form eating my comment text when uploading a file?)

dixon_’s picture

Status: Needs review » Reviewed & tested by the community

The patch works fine and fixes the problem on a fresh D7 install.

Nothing to comment about code style.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

I think the aggreggator settings should live under 'Site configuration' instead of 'Content management - Aggregator' but that is another issue.

More importantly, can you provide a test with this patch? Either we don't have tests for the settings page yet, or they are not adequate. It would be great if we could look into that.

akahn’s picture

Dries, would the test just make sure that this form submits without errors? Are there other tests that would be good to follow as a model for this? I haven't written tests before.

And I can make a new issue to move aggregator settings to where they should be: Site configuration.

alex_b’s picture

Subscribing

alex_b’s picture

Title: Errors on submitting aggregator settings form » Notice/warnings on submitting aggregator settings form

#4: #293318: Convert Aggregator feeds into entities adds tests to the settings form (see testFeedContentType()) - could we fix the notice/warnings with a patch as suggested in #1 and add the tests with #293318?

If we really do want to have the tests with this patch, we should take them from #293318 - starting with testFeedContentType().

alex_b’s picture

Status: Needs work » Needs review
Issue tags: +Quick fix
FileSize
881 bytes

I've simplified the fix as it's really just a check for the presence of a value (that *is* an array if it is present) before running an array_filter() on it (see patch).

alex_b’s picture

BTW, disregard #7 as #293318 is stalled.

twistor’s picture

Status: Needs review » Reviewed & tested by the community

Solves the problem, works for me.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

We could write a test for this, but it seems like a pretty simple logic fix that we're unlikely to break in the future.

Committed to HEAD. Thanks!

alex_b’s picture

Cool, yes - this is really a simple fix. Thanks for commit.

Status: Fixed » Closed (fixed)
Issue tags: -Quick fix

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