Posted by xjm on July 5, 2012 at 4:20pm
10 followers
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | documentation |
| Category: | task |
| Priority: | normal |
| Assigned: | iflista |
| Status: | closed (fixed) |
| Issue tags: | needs backport to D7 |
Issue Summary
Problem/Motivation
- Misuse of the method
DrupalTestBase::randomString()is frequently responsible for random, hard-to-debug test failures, because it generates a list of random characters that includes special characters like#, *, /, \, ?, etc. - Developers often do not consider the implications of using this for values that are not user input or that have already been sanitized, nor do they necessarily know to look for
DrupalTestBase::randomName()(which is the "safe" variant).
Proposed resolution
- Improve the documentation to clarify when each method should be used.
Remaining tasks
- Patch needs review.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| randomstring-docs.patch | 1.81 KB | Idle | PASSED: [[SimpleTest]]: [MySQL] 37,057 pass(es). | View details |
Comments
#1
This looks reasonable to me, and the documentation is clear.... Maybe I'll wait for a second opinion (or a few days at RTBC) to commit though, in case the policy suggestion here needs tweaking?
#2
RTBC++
#3
Thanks! I also just left messages for the two simpletest maintainers in IRC about this issue to see if they want to comment.
#4
Looks good. Do we want namespace anchors already? Or fix 'em later?
#5
Committed to 8.x. Moving to 7.x.
#6
#7
See attached.
#8
#9
@sun's remarks in #1659682: Consider renaming randomString() and/or adding additional, context-appropriate helpers for random string generation made me realize my wording might inappropriately dissuade developers from using
randomString()when they should. The attached is better, I think. Apologies for the extra work.#10
Seems like a good improvement.
#11
Seems like good clarification to docs.
#12
Committed to 8.x. Thanks.
#13
Moving back
#14
Looks good, committed to 8.x, ready to port original + follow-up to 7.x.
Note: the 7.x patch should probably wait on this "avoid commit conflicts" patch for committing:
#1541958: Split setUp() into specific sub-methods
#15
Hm. I wonder who committed the fix? :)
#16
@jhodgdon you did, guess Dries didn't push?
http://drupalcode.org/project/drupal.git/commit/586d48e
#17
Note that #1541958: Split setUp() into specific sub-methods is against 8.x again now.
#18
Changed comments according to previous patches.
Needs review.
#19
Thanks! I think the text in the patch looks good, but this line needs to be wrapped to 80 character maximum:
+ * machine or file names that have already been validated); instead, use DrupalWebTestCase::randomName().Should be a quick re-roll... I still think we need to wait for #1541958: Split setUp() into specific sub-methods before this is committed also.
#20
Fixed few more comments longer than 80 character.
#21
Please limit the patch on this issue to fixing just this one issue in 7.x that was already fixed in 8.x.
Other documentation cleanups are being addressed on:
#1310084: [meta] API documentation cleanup sprint
If you'd like to help with that other issue, that would be great! Instructions are at the top of that issue. Thanks!
#22
Done.
#23
The last submitted patch, simpletest-1672764-22.patch, failed testing.
#24
Second try.
#25
Ups. Needs review! :)
#26
Looks good! I'll get this committed shortly.
#27
Oh, I can't commit this until
#1541958: Split setUp() into specific sub-methods
is done.
#28
That patch is now in, and it looks like it didn't wind up conflicting (but thanks for waiting anyway).
So, I went ahead and committed this one to 7.x. Thanks! http://drupalcode.org/project/drupal.git/commit/1c2301b
#29
Automatically closed -- issue fixed for 2 weeks with no activity.