The adventures of the infamous poll module continue. Since adding weighting to poll choices, two problems have cropped up regarding their display. First, if you enter a poll title, two choices, reorder the choices, then click "more choices", the order is lost. Second, if you reorder the choices and click preview, the order is both lost in the preview and in the form. Actually the form weights are still correct if you save the form, but they appear out of order because the form elements are not sorted.

We'll likely need a new sort function to sort the poll choices since this needs to be done in multiple places (in the preview and in the node form).

Related #371235: How many different ways can you sort elements by weight?, since this will add yet another sort function, though we can reuse the drupal_sort_weight() function at least in the uasort (but only after we add microweights to prevent reordering of elements with the same weight).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

sun’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
FileSize
4.84 KB

Extracted.

sun’s picture

Reviews, tests, anyone?

This patch may be a prerequisite for aforementioned issue.

sun’s picture

Extracting the actual bugs into required assertions:

  1. Enter a poll title, two choices, re-order the choices, and add "more choices". The original order of choices is lost.
  2. Re-order the choices and click "preview". The order is lost in the form and in the preview.
  3. A user without administrative permissions should not be able to enter/alter poll vote counts in the node form.
sun’s picture

Alright, technically this should fail.

sun’s picture

And, technically, this one should pass. ;)

sun’s picture

Interesting. The preview indeed seems to need some more work :)

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.7.patch, failed testing.

sun’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.7.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
20.23 KB

wow, we badly need to train people in PHP data types a bit more. :(

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.11.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
20.23 KB

Weird aggregator tests.

Now someone needs to make the weights in poll previews work.

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.13.patch, failed testing.

effulgentsia’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.13.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
19.77 KB

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.17.patch, failed testing.

sun’s picture

Assigned: quicksketch » sun
Status: Needs work » Needs review
FileSize
19.77 KB

Re-rolled against HEAD.

Status: Needs review » Needs work

The last submitted patch, drupal.poll-choice-weight-access.19.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
20.71 KB

This one should pass.

webchick’s picture

Wow, that is quite a patch for such a simpleish sounding issue title. :) Could we maybe get a summary of what's going on and how we got roped into Aggregator and other things?

sun’s picture

Heh, yarrr :)

A summary of bugs this patch fixes is in #4.

However, in order to write tests for this, I had to change the function/method signature of assertFieldByXPath() and the corresponding assertNoFieldByXPath() to accept a $value of NULL that really means NULL/nothing. Currently, the $value argument basically defaults to an empty string, but an empty string is a valid value of an input field; i.e.,

<input type="text" value="" />

Therefore, it's impossible to actually assert an empty string as value currently. Thus, I had to update a few test assertions throughout core to not pass totally weird values for $value (such as '', FALSE, and whatnot) when they really meant to pass NULL to completely skip the additional assertion of the field/input's value.

webchick’s picture

Issue tags: +API change

Ah, ok. Thanks for the context. That means this involves an API change for test authors. We might not have a choice, though. Hm.

sun’s picture

@quicksketch or anyone else: Could you review and possibly sign off this patch?

To summarize the bugs that this patch fixes once again:

1. Enter a poll title, two choices, re-order the choices, and add "more choices". The original order of choices is lost.
2. Re-order the choices and click "preview". The order is lost in the form and in the preview.
3. A user without administrative permissions should not be able to enter/alter poll vote counts in the node form. The corresponding "vote count" column should also not be visible.

as well as

4. assertFieldByXPath() and assertNoFieldByXPath() do not allow to assert a field with a value attribute of '' (empty string), which is required to make the added tests for Poll work.

sun’s picture

mmm, if anyone would use and install Poll module, we'd see much more traction on this issue. :(

sun’s picture

quicksketch, anyone, any feedback?

sun’s picture

Issue tags: +Release blocker

Actually, if you look at the current user interface, then you see that the very basic UI of Poll module's node form is completely b0rked. This must be fixed before release, so I think that the "Release blocker" tag is justified here. (At least we talked about the idea of solidly using this tag this way; feel free to revert, please.)

sun’s picture

Status: Needs review » Reviewed & tested by the community

I can't help. Asked several times and waited for reviews, even sent a tweet about this issue, but nothing.

Intensively and manually tested this patch myself, in addition to the automated tests that have been added.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for trying, sun. Poor, decrepit, neglected Poll module. :(

Committed to HEAD. It can't be worse than it already is. :P

webchick’s picture

Priority: Normal » Major
rfay’s picture

What's the API change here? Can you describe it? Does it need to be announced?

webchick’s picture

I don't think so, really. It's a change to assertFieldByXPath() and assertNoFieldByXPath() signature. Only affects test authors doing weird things.

Status: Fixed » Closed (fixed)
Issue tags: -Release blocker, -API change

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