I get the error "Warning: end(): Passed variable is not an array or object i file_managed_file_validate() (linje 536 af /home/www/demosite.oldrup.dk/modules/file/file.module)."

Steps to reproduce:

- fresh install of drupal 7 rc1
- import of danish language
- create article
- during creation of the node, i select "create new book"

Please see the attached screenshot.

Comments

juxelle’s picture

Version: 7.0-rc1 » 7.0-rc4

I get the same error with a fresh install of drupal 7rc4.

- fresh install
- create article
- select "create new book"

gives the error message

droplet’s picture

Title: New Article > Create new book gives "Passed variable is not an array..." error. » create a new book from non-book content type gives "Passed variable is not an array..." error.
droplet’s picture

Version: 7.0-rc4 » 7.x-dev
timhilliard’s picture

Component: node system » file.module
Status: Active » Needs review
StatusFileSize
new1.47 KB

Hi guys I've tracked down this problem. it was with file.module and in the file_managed_file_validate validate hook it was still using the legacy 'clicked_button' array key in the $form_state variable. For legacy drupal does set the 'clicked_button' variable but in this instance it did not as the ajax event was not triggered by a click. This conversely meant that the 'clicked_button' variable in the array was not there and triggering the error. To fix this I have created a patch that replaces the 'clicked_button' array key to 'triggered_element' instead and also changes the $clicked_button variable to $triggered_element to better represent the variable.

Status: Needs review » Needs work

The last submitted patch, file_module-legacy-clicked-button-990260.patch, failed testing.

droplet’s picture

StatusFileSize
new1.38 KB

above patch worked. try follow patch for testbots

timhilliard’s picture

Assigned: Unassigned » timhilliard
Status: Needs work » Needs review
StatusFileSize
new1.51 KB

Re-rolled patch as I hadn't created the patch from the root drupal directory. Submitting for retesting.

droplet’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Let's get a test for this.

rfay’s picture

Status: Needs work » Closed (duplicate)
timhilliard’s picture

Makes sense to me. Looks like this problem occurs in more than just the place we have found here.

Wappie08’s picture

Priority: Normal » Critical
Status: Closed (duplicate) » Active
Issue tags: -Needs tests +book, +book module

Actually the thread rfay mentioned is now 8.x related, so I think it is ok to reopen this thread to fix this in 7.x asap.

Actually I'm not able to make a new book at all (the content type is in the books allowed list) so I think this is actually critical then!

Warning: end() [function.end]: Passed variable is not an array or object in file_managed_file_validate() (line 536

will try the above patch later on.

Wappie08’s picture

Issue tags: -book, -book module +Needs tests

sorry, screwed up the tags..

arlinsandbulte’s picture

Status: Active » Closed (duplicate)

still considered a duplicate of #1049462: Usage of deprecated $form_state['clicked_button'] causes bugs during AJAX submissions by non-buttons
Policy is that all D7 bugs need to be first fixed in D8 and then back ported to D7 (if applicable).
The eliminates regressions in D8.

I have tagged #1049462 with 'needs backport to D7'

kisugiai’s picture

Version: 7.x-dev » 7.2

its still in 7.2
why?

-.-

Anonymous’s picture

same issue

libre fan’s picture

same issue since D 7.2.

elgandoz’s picture

still exist

arlinsandbulte’s picture

Hey people (#15-18), if you would pay attention here you would notice that this issue was marked a duplicate of another issue where this is being addressed:
#1049462: Usage of deprecated $form_state['clicked_button'] causes bugs during AJAX submissions by non-buttons

That issue was fixed, but may not yet be part of the most recent Drupal release. Commits were made to both Drupal 7 & 8. Here are the commit details:
D7.x: http://drupalcode.org/project/drupal.git/commit/2c01d05
D8.x: http://drupalcode.org/project/drupal.git/commit/c0bfd27

Furthermore, if you would have paid attention to the correct issue (#1049462) instead of this duplicate, you would have noticed that webchick said this fix is not available in the 7.4 release, but you will need to either wait for the 7.5 release or use the current -dev:
http://drupal.org/node/1049462#comment-4702154

I encourage you to test the -dev to verify that #1049462 did indeed fix this issue.