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.

Comments

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?

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.

does it happen when you press the save button?

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

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.

Status:Active» Needs review
StatusFileSize
new5.16 KB

Status:Needs review» Fixed

committed above patch

Status:Fixed» Closed (fixed)

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

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

@AlexisWilke
What version of Drupal are you using?

The operation did what you wanted correct?

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

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.

Still exists in Drupal 6.16

hmmm, well at least the correct action is happening.

Still exists in 6.17

Still exists in 6.17 confirmed

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

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

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.

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

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!

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.

Hi! resq935.

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

Thanks!

subscribing

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

@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. =(

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

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!

+1 Re:#28 .. me too.

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.

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.

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

I get it too, Drpal 6.20

subscribing

HobbyBlob.com

I get it with Drupal 6.20

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

I get it with Drupal 6.20 with pressflow

Drupal 6.22

subscribing

Drupal 6.22

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

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

Drupal 6.25

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

thats awesome.

Version:6.x-1.18» 6.x-1.20

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.

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

Status:Active» Needs review
StatusFileSize
new4.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.

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

StatusFileSize
new128.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.

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

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." ;-)

StatusFileSize
new1.15 KB

@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?

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)

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.

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.

Here I had the same error on Drupal 6.23

FormAPI Bug Encountered; trying to work around the bug.