I'm getting an error every time I try to change settings on the performance page:
FormAPI Bug Encountered; Try Again

Also, strange text on all buttons in settings pages. See attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

I added in that text, as a way to detect when Drupal wasn't firing the right function behind the button. I mainly encountered the error when the crawler was running; in short I would press the stop crawler button and there was a random chance the "Clear all Boost cached data" button would be pressed. If the number on the button doesn't match the number in the function, then it aborts. I have yet to file a bug with this because its kinda hard to reproduce.

What setting are you trying to change?

gregarios’s picture

It doesn't seem to matter what settings I try to change. I get the error every time I push any button on that page.

Wait... now they all are working except the "Clear Boost's Database & File Cache" button. Sorry.

mikeytown2’s picture

does it happen when you press the save button?

gregarios’s picture

Save works fine. It seems to be just the "Clear Boost's Database & File Cache" button that does it every time.

mikeytown2’s picture

I'm currently looking into the drupal.org issue queue for answers for the bug. If you downgrade core to 6.13 the bug seems to go away (according to these threads).
#302240: button broken due to fix various problems when using form storage
#591696: Problem with various AHAH forms and validation
#206955: image_button: clicked_button value is wrong

In the mean time, I might be able to work around the bug; I'll keep you updated.

mikeytown2’s picture

Status: Active » Needs review
FileSize
5.16 KB
mikeytown2’s picture

Status: Needs review » Fixed

committed above patch

Status: Fixed » Closed (fixed)

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

AlexisWilke’s picture

Priority: Critical » Minor
Status: Closed (fixed) » Active

I got this message today with the newest version (installed a few hours ago):

FormAPI Bug Encountered; trying to work around the bug. Given: 0 Wanted: 4.

I did apply the upgrade, and as mentioned by the previous person who reported the problem, I got the error when clicked "Clear Cache". I did not do a "Save" yet... Okay, I did a "Save" and tried the "Clear Cache" again and same error. So something's going on.

Is there something I can test to find out the problem/reason for that FormAPI bug?

Thank you.
Alexis

mikeytown2’s picture

@AlexisWilke
What version of Drupal are you using?

The operation did what you wanted correct?

AlexisWilke’s picture

Status: Closed (fixed) » Active

Mikey,

I have the latest: Drupal 6.14. Just in case, I updated the Version of this issue since it "breaks" in the 1.x-dev. (it was set to 1.15)

It looks like all the files were deleted, yes. So the operation did what I was expecting. Testing the site, I got the pages refreshed since it started showing the right things.

Thank you.
Alexis

mikeytown2’s picture

Version: 6.x-1.15 » 6.x-1.x-dev
Status: Active » Closed (fixed)

Try Drupal 6.16. It's a bug with core; With boost I bypass the core bug. But when I do that, I throw an error message up letting you know what happened. So in your case, you selected button #4 but Drupal said you selected button #0. Boost sees the mismatch and fixes it.

sinasalek’s picture

Still exists in Drupal 6.16

mikeytown2’s picture

hmmm, well at least the correct action is happening.

jimcaruso’s picture

Still exists in 6.17

sinasalek’s picture

Still exists in 6.17 confirmed

AlexisWilke’s picture

Status: Active » Closed (fixed)

I've not gotten that error in ages, but i don't have a 1 to 1 Drupal Core version... Yet I had that error before so I would think it is gone (for me).

hedac’s picture

in dev... it seems all working ok but I get the error displayed... what the error means? Should I worry?

mikeytown2’s picture

means there is still a bug in formAPI in core. don't worry, I don't have the time to track in down in core so I worked around it.

aiphes’s picture

idem for me on 6.19 : FormAPI Bug Encountered; trying to work around the bug. Given: 0 Wanted: 4.
could be the source of my issue on displaying a empty page instead of a table whith images in ?

http://www.lycee-le-rocher.com/les-formations-du-lycee

lizac’s picture

I think this issue is still present on Drupal 6.19. I received this error -
FormAPI Bug Encountered; trying to work around the bug. Given: 0 Wanted: 4.

and these when trying to add more options on poll - an Http 403 error occured in /poll/js so I checked the dlog and it gave me this error

{ "status": true, "data": "\x3cdiv class=\"messages error\"\x3e\n \x3cul\x3e\n \x3cli\x3ewarning: array_shift() [\x3ca href=\'function.array-shift\'\x3efunction.array-shift\x3c/a\x3e]: The argument should be an array in /modules/poll/poll.module on line 332.\x3c/li\x3e\n \x3cli\x3ewarning: call_user_func_array() [\x3ca href=\'function.call-user-func-array\'\x3efunction.call-user-func-array\x3c/a\x3e]: First argument is expected to be a valid callback, \'\' was given in /opt/va/www/cms/includes/form.inc on line 376.\x3c/li\x3e\n \x3c/ul\x3e\n\x3c/div\x3e\n" }

can anyone help? Thanks!

osalcedo’s picture

Version: 6.x-1.x-dev » 6.x-1.18

I'm using Drupal 6.19 and Boost 6.x-1.18
I disabled the Performance Logging module under Development and the "FormAPI Bug Encountered" error disappeared.
Just an FYI... I tried to enable the Performance Logging module without first having APC installed on my server. So I'm not sure if that was a contributing factor. Either way the error went away when I disabled the module.

lizac’s picture

Hi! resq935.

I actually don't have the Performance Logging module under Development. Can you elaborate more?

Thanks!

MattFielding’s picture

subscribing

osalcedo’s picture

@lizac I truly do wish I had more to offer other than disabling that one module.

lizac’s picture

@resq935. No problem. Your comment here is truly appreciated.

Unfortunately, I'm still dealing with the issue and just leave it for a while. Hopefully, we could get more info when I'm ready to face it again. =(

TheoRichel’s picture

I do not have the performance module enabled, but I do receive this error.

superflyman’s picture

Title: "FormAPI Bug Encountered" error on attempts to change settings » "FormAPI Bug Encountered" error on Clear Boost's Database & File Cache
Priority: Minor » Major
Status: Closed (fixed) » Active

When running Clear Boost's Database & File Cache, the system hangs for a while and then comes back with 'FormAPI Bug Encountered; trying to work around the bug. Given: 0 Wanted: 4.' I am using 6.19. Is there any way around this? Does the Dev version solve this problem? I see this was closed but I'm still having this problem with 6.x 1.18. We desperately need to clear out all of the database records and CSS and would like to keep using this module. Any help appreciated. Thanks!

naero’s picture

+1 Re:#28 .. me too.

mikeytown2’s picture

For CSS/JS issues I've been working on a new project.
http://drupal.org/project/advagg

The button should still work... It works around a core bug.

SchwebDesign’s picture

subscribing, getting the same "FormAPI Bug Encountered; trying to work around the bug. Given: 0 Wanted: 4." message, but the system doesn't necessarily "hang" for me, not that i can tell. subscribing.

AlexisWilke’s picture

FYI, I got that error today. It was when I ran a full Cache Clear of the entire server (which I did not mean to, btw, and an intermediate window that tells people exactly what will happen and confirmation would be nice.)

Anyway, this being said, I do not see a problem in the output, just that unusual message at the top.

Thank you.
Alexis

alexbk66-’s picture

I get it too, Drpal 6.20

subscribing

HobbyBlob.com

Shawn DeArmond’s picture

I get it with Drupal 6.20

Cosmy’s picture

I'm getting it too and I'm using pressflow.. never happende before today, and i've not installed any more module..

deomurari’s picture

I get it with Drupal 6.20 with pressflow

aliensun’s picture

Drupal 6.22

subscribing

jvieille’s picture

Drupal 6.22

tran_tien’s picture

+1 sub. I meet this notice too, on this site : Xem bong da truc tuyen

gregaltuna’s picture

Bump. I'm getting this bug, too. Subscribing.

Drupal 6.25

jami3z’s picture

so a 3 year issue still exists with no solution yet?

thats awesome.

gregarios’s picture

Version: 6.x-1.18 » 6.x-1.20
tangent’s picture

I respectfully suggest that if boost is able to reliably work around this core issue then there is no reason to display an alarming warning to the user.

I haven't examined the work-around code but if it detects both the expected form post and the current buggy form post and it is expected that boost will "do the right thing" even if the core bug is fixed then there is no reason to needlessly alarm users about the core bug and the warning can be removed. If that isn't the case then perhaps the work-around logic can be improved to handle both scenarios so that the warning message can be removed.

bgm’s picture

I have to admit that I have a hard time understanding the issue, and as it happens often, an issue kind of drifts into something else.

Can someone write a short summary of:

- the problem,
- steps to reproduce it, and how systematic it is to reproduce,
- the proposed solution,
- if there are any side effects to the proposed solution ?

Thanks

tangent’s picture

Status: Active » Needs review
FileSize
4.17 KB

@bgm, it seems that this issue has morphed from a core bug to a complaint with the "FormAPI Bug Encountered; trying to work around the bug. Given: %given Wanted: %wanted." warning message generated by Boost. I am partly to blame here, with my previous comment. Perhaps this ticket should remain closed and a new ticket about the warning should be opened.

Nevertheless, I'm going to comment on the warning complaint here until I hear otherwise. I do not believe that the core FormAPI bug exists any more. I'm not sure what it was but I've removed the button router logic which was added to work around the bug and the form works flawlessly, without the offending message.

Attached is a patch which works great for me.

bgm’s picture

@tangent: thanks for the update and patch, much clearer now.

Seems a bit risky to remove all the error checking code. If people are still running into the warning, doesn't it mean that the bug still exists? (or are they running an old version of core?)

In the mean time, I would rather only transform the drupal_set_message() complaining about the error into a watchdog message. See commit f74a90bd5508b346bc9fbf54810f34141c57d620.

People who run into the message should post what button they pressed, and what was the error message. From the only post that does mention it, it seems like the code did what it should (catch a FormAPI bug) and re-routed the action correctly, i.e. flush cache.

EDIT: to be more specific, I removed the first "trying to work around.." message, but left the "try again" if it failed. From the latest comments, it seems that people are not running into that issue.

gregarios’s picture

FileSize
128.07 KB

The bug is indeed still there using Drupal 6.26 and Boost 6.x-1.20 (unpatched), with all caches completely cleared or not.

If you push the "_4 Reset Button - Database Records: XXX, Files: XXX" button, it gives the error message for me.

See attached screenshot.

tangent’s picture

@gregarios, it is not an error you are seeing but a warning message. It is not in question that the warning is present.

@bgm, like I said, I'm not sure what the core FormAPI bug was. The issues linked to in comment #5 seem to be fixed or for future Drupal versions. Each submit button has a different callback and in my testing each button calls the correct associated callback and only that callback. Each submit callback executes that global button router function though and button router merely checks if there is a value (button text), which will always be true so the warning is displayed.

Removing all that code, per my patch, each callback is executed when the associated button is clicked. There is no FormAPI bug as far as I can tell with Drupal 6.26.

gregarios’s picture

No problem. I just was reaffirming that the Boost page does report that "a bug was encountered," which to me is a warning about an error, if not an "error message" per se.

IE: A bug is an error or it wouldn't be a bug. If it isn't an error-bug, then it is a purposeful-bug, which is an "Easter Egg." ;-)

tangent’s picture

@bgm, sorry, I missed the part about your new commit. If the warning messaging must remain perhaps we could do a version check so it doesn't need to display for the current Drupal version where the bug does not exist?

bgm’s picture

As much as I'd like to remove this code, gregarios mentions running into this issue with Drupal 6.26, so I tend to disagree with the patch in #50, although I can't reproduce the bug.

In the screenshot posted in #47, boost caught the bug and correctly executed the correct action, so seems to me like the code is working OK, and removing the first warning is sufficient.

@tangent: do you see any inconvenience in leaving the code as is? (e.g. without the first drupal_set_message for when boost correctly handles the bug)

mikeytown2’s picture

Remove the warning. Bug is with core and I don't see that getting fixed. Message is mainly a debugging thing.

Another way to not have this bug happen is to only have one button in each field group. If you have more than 1 button in a field group the bug appears sporadically. Its a bug with core from what I've seen.

bgm’s picture

Status: Needs review » Fixed

Thanks Mike. So the latest commits should be good enough.

I'd rather not make big changes to 6.x-1.x if not really necessary, and focus on 7.x-1.x.
Marking issue as fixed.

Status: Fixed » Closed (fixed)

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

ataliba’s picture

Here I had the same error on Drupal 6.23

FormAPI Bug Encountered; trying to work around the bug.

Katharine_Gates’s picture

Issue summary: View changes

Getting this message on "Clear Boost's Database & File Cache" on Drupal 6.33 and Boost 6.x-1.21

"FormAPI Bug Encountered; trying to work around the bug. Given: 0 Wanted: 4. Are you running an old version of Drupal core? For more information, see: http://drupal.org/node/630000. Please describe which button was clicked and the complete error message."

Anonymous’s picture

I believe the error message request "which button was clicked" ?

Katharine_Gates’s picture

The button I clicked was "Clear Boost's Database and File Cache" (not obvious? that's the name of this issue, right?)
at the bottom of this page: admin/settings/performance/boost