Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
poll.module
Priority:
Critical
Category:
Task
Assigned:
Reporter:
Created:
8 Nov 2008 at 03:26 UTC
Updated:
1 Jan 2009 at 15:50 UTC
Jump to comment: Most recent file
The patch makes poll.module 13 LoC shorter. That's already something in itself. But also, there is much more to that: the current code is ugly. The new code is nice and absolutely good example. We do not carry $_POST to a new element -- that's Drupal 5 thinking. This code violated the "all form start equal" principle.
Edit: The D6 version is tested, the D7 is not but we have unit tests for that.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | poll_choice_js-331708-d6.patch | 3.19 KB | chx |
| #10 | poll_ahah_test.patch | 6.4 KB | catch |
| #9 | poll_ahah_test.patch | 6.06 KB | chx |
| #2 | poll_choice_js-331708-d6.patch | 2.72 KB | katbailey |
| #2 | poll_choice_js-331708.patch | 3.46 KB | katbailey |
Comments
Comment #1
gábor hojtsyHm, interesting. Chx tells me in chat that drupal_rebuild_form() does throw away _POST so that it does not affect the current form building (via validation or submission), so that is why it needs to be added back in.
Comment #2
katbailey commentedThere was one redundant line left in in the last patch. I have removed it and re-rolled the patch for the two versions. The line in questions was
in D6, and
in D7.
The $key/$delta variable does not exist in the new code. There is no difference between the new ahah content and the previous content because all the choices are being re-rendered and they are all coming from $form_state, nothing from $_POST.
Comment #3
robloachPutting on my list of patches to have a look at.... I love patches that have less net code.
Comment #4
dries commentedLooks like a nice clean-up -- are the changes in this patch covered by tests?
Comment #5
catchWe don't have coverage for poll_choice_js() according to http://acquia.com/files/test-results/modules_poll_poll.module.html and applying the patch then doing stupid things in there confirmed this.
Comment #7
chx commentedAnd yes tests are coming in http://drupal.org/node/295992
Comment #8
dries commentedPlease add some code comments to the form API related code. It would be good to explain why we do things this way, and what happens in the background. Thanks!
I would also recommend (but not mandate) that we merge #295992: TestingParty08: poll_choice_js() into this patch.
Comment #9
chx commentedThere we go: this is just the Drupal 7 version, with a very very through test. We need a followup issue, changing the testing framework to better support AHAH callback tests. But, even without that, this is quite ready.
Comment #10
catchThe class and test function itself needs phpdoc, setUp() and getInfo() don't. Didn't have the heart to mark CNW since poll module gets enough abuse from me as it is, so re-rolled with this, and a couple extra line breaks between comments. Otherwise the new tests pass and it looks like a big improvement.
Comment #11
dries commentedCommitted to CVS HEAD. Thanks.
Comment #12
chx commentedD6.
Comment #13
dries commentedCommitted to CVS HEAD. Thanks.