Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Mar 2009 at 08:42 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damien tournoud commentedAll those should be @xx, not only !url. It's a really bad habit to use !xx, even when you believe that what you are passing "cannot be anything other then plaintext" (you are generally wrong :p).
Comment #2
mr.baileysLet's meet halfway: !status should probably become @status because curl::getInfo returns a string. Even though HTTP Status codes should always be numeric, it doesn't hurt to be suspicous in this case.
When it comes to !method though, I don't think we should convert this to @ because I dare say this cannot be anything other than plaintext since it's populated by the following code:
Same with !length: since the result of strlen is always numeric according to the docs (either 0 or number of characters), I think running this through check_plain is overkill.
<slightly off-topic>
I think "Always use @ unless you really really really know what you are doing" is a great rule, especially for newbies (and I still consider myself to be in that group). I do have two concerns with indiscriminently running check_plain though:
</slightly off-topic>
While working on this I also decided the wording can be improved:
instead of '!method to !url, status is !status, !length is length bytes' I shortened it to '!method !url returned !status (!length bytes).' (shorter and more to the point)
Attached is a new patch with an additional @ on status and re-worded message, let me know what you think...
Comment #3
damien tournoud commentedLooks ok. While we are at it, could we properly use format_size() for the length?
Comment #4
mr.baileysI debated whether or not format_size should be used. In this particular case I decided against it because I figured that the audience (testers, coders) of this type of messages (assertions) might want the exact byte count (12724 bytes instead of 12KB).
I wouldn't have a problem changing this if you still think this is better though.
Comment #5
damien tournoud commentedThe main use of this is to detect 0-byte page responses. I believe that it would be better with a format_size().
Comment #6
mr.baileysMakes sense, updated the patch to use format_size.
The assertion now looks like this:
Comment #7
dries commentedLooks like an improvement to me. Committed!