Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
modules/user/upload.test
modules/upload/upload.test
Slight differences, attached a diff.
I found this when trying to figure out what was going on with UploadPictureTestCase - which I expected to find in userinstead of upload, and when I grepped for 'picture' I found it there too!
Comment | File | Size | Author |
---|---|---|---|
#41 | contact-test.patch | 2.3 KB | catch |
#34 | simpletest-fix-contact-test-253506-31.patch | 2.16 KB | Damien Tournoud |
#30 | simpletest-fix-contact-test-253506-30.patch | 2.14 KB | webchick |
#27 | upload_fix_and_doc.patch | 2.18 KB | floretan |
#24 | drupalpost.patch | 1.72 KB | catch |
Comments
Comment #1
floretan CreditAttribution: floretan commentedI agree that the user picture test belongs in user.test (none of the functionality tested depends on upload.module). I started working on this issue, and there's a good amount of work/clean-up that needs to be done. Here's my plan:
1) move the test class UploadPictureTestCase found in modules/user/upload.test to user.test and rename it UserPictureTestCase.
2) remove modules/user/upload.test (this file is slightly different from modules/upload/upload.test as pointed out in the original issue. I looked at the differences, and we do want to delete this version).
3) remove the class UploadPictureTestCase from modules/upload/upload.test, as this class is now in user.test.
4) There is a lot of duplicate code in various places, and a lot of code clean-up. The goal is to have a patch with clean code that passes the tests with no failures.
Comment #2
floretan CreditAttribution: floretan commentedHere's a patch for steps 1-4 from my last comment, and some code clean-up in the UserPictureTestCase class.
The tests still fail whenever a test tries to simulate a file upload (upload.test and user.test are the only core tests that use the simpletest upload feature). The simpletest handbook page is outdated and wasn't helpful, it just shows that the upload feature was working at some point.
The debugging I've done so far shows that everything is ok until the call to curl_exec(), at which point the file doesn't get uploaded.
Comment #3
Senpai CreditAttribution: Senpai commentedI ran this upload test on an up-to-date copy of D7 HEAD. True enough, the upload test fails at the
It appears that the test is failing at the point in which the form's file field is populated with a path. Or, supposedly, it's being given a valid path.
Comment #4
boombatower CreditAttribution: boombatower commentedChanging 'component' in relation to http://drupal.org/node/253744.
Comment #5
catchhttp://drupal.org/node/253506 was duplicate.
Comment #6
boombatower CreditAttribution: boombatower commentedAs a note you linked to this issue as a duplicate. :)
Comment #7
catchThanks. http://drupal.org/node/260504 was duplicate ;)
Comment #8
webchickOops. Sorry! :) Subscribing.
Comment #9
Damien Tournoud CreditAttribution: Damien Tournoud commentedWell, it turns out that
CURLOPT_POST => TRUE
must be set beforeCURLOPT_POSTFIELDS => $post
if $post is an array, as documented (in a comment!) on the curl_setop() manual page [1].This patch does that, and remove code that is not needed anymore thanks to that change. Preliminary testing seems to show the change doesn't break anything (but more testing is definitely required).
Damien
[1] http://php.net/manual/en/function.curl-setopt.php
Comment #10
floretan CreditAttribution: floretan commented@Damien: thank you, thank you, thank you!
The ordering of the cURL parameters was indeed what caused the problem, and if you hadn't found this comment on the php manual this issue would stay open for a much longer time.
The only problem that I see with the patch is the line:
I don't see why we would reset the $post array at this point (it's already initialized earlier in the code, and then processed by handleForm()). With this line removed, both the upload test and the user picture test (with the patch from #2) pass without failure!
Here's an updated patch combining #2, #9.
Comment #11
floretan CreditAttribution: floretan commentedNote that the user picture upload test fails when GD is not enabled. That is because the value of image_get_toolkit() is evaluated to TRUE even when GD is not enabled, so image_gd_check_settings() should be used to check for the presence of the gd library instead. That should probably be fixed after the main issue from duplicate tests and inability to upload files with simpletest.
Comment #12
Damien Tournoud CreditAttribution: Damien Tournoud commented@flobruit, oh sorry. I messed up with my merging, the $post initialization was lying there by mistake.
Comment #13
catchTested, works, RTBC.
Comment #14
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. We're down to 56 failures now. Woot, woot.
Comment #15
floretan CreditAttribution: floretan commentedRemoving the duplicate upload.test inside of the user module's folder was part of the patch but hasn't been committed.
Comment #16
catchSame thing with the already committed stuff removed.
Comment #18
catchand again...
edit: nope. No upload for me. Anyway, you just need to delete everything except for the user/upload.test hunk.
Comment #19
floretan CreditAttribution: floretan commentedSorry, the additional changes to user.test shouldn't have been included in the patch (they're for the non-GD part of the user upload test, which is a different issue).
Comment #20
catchPretty sure this broke contact tests, whoops. http://drupal.org/node/267558
Comment #21
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #22
catchDouble checked, and this definitely broke contact.test I only ran the upload and user tests, not everything, so completely missed it.
Marking #267558 as duplicate.
Comment #23
catchThis fixes the contact.test issue. Just put that bit back in.
However, on ubuntu (gutsy), upload.test fails in HEAD. On debian (etch) - upload.test passes.
Comment #24
catchComment #25
catchComment #26
catchOK. That patch fixes contact.test for me, I've opened a new issue for the weird upload.test failures on ubuntu gutsy, might just be my system: http://drupal.org/node/267683
Comment #27
floretan CreditAttribution: floretan commentedYes, this code allows field values to start with the '@' character when there are no file uploads on a form. It's a messy piece of code, but I agree that it shouldn't have been removed. This does fix the issue with contact.test (where the test used a value starting with '@' for the e-mail field).
This behavior regarding values starting with '@' is only "documented" by the code itself. We need to mention this in the documentation of drupalPost().
Comment #28
catchExtra documentation makes sense - then we hopefully won't rip it out again next time we look at it. Since this was reviewed by a couple of people on irc as well, going to mark RTBC.
Comment #29
webchickNo longer applies. :(
Comment #30
webchickOh. Well that was the easiest re-roll ever. Just the documentation fix hunk. Re-rolled.
Confirmed that this still fixes the problem.
Comment #31
Damien Tournoud CreditAttribution: Damien Tournoud commentedWe really need to step back and think on this one.
I did a very fast review of libcurl code that convinced me that when CURLOPT_POSTFIELDS is an array, cURL does not urlencode the fields. So we need to answer these questions first:
Could someone dig up the relevant part of the HTTP RFC and answer these questions? I would really like to see a simplified version of that ugly code that work on both cases (with an upload file and without one).
Comment #32
catchDamien, IMO this is a regression that needs to be reverted.
It'd be great to tidy that code up, but at the moment we really need to get to zero test failures to avoid more regressions like this - since no-one knows what's supposed to pass or fail at the moment.
So back to RTBC, but please post a tidy up patch either in a followup issue, or this one once there's something to replace it.
Comment #33
Damien Tournoud CreditAttribution: Damien Tournoud commentedI investigated this, and the bad news is that there is no real solution for that problem. We will have to handle file upload ourselves, because the PHP extension leave us no choice to escape the '@' prefix.
The good news is that I found where these form submission are defined. It turns out that they are only informally defined in the HTML specification (!), here: http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
This also clarifies that we really need urlencode() and not rawurlencode(). So I updated the comments in the patch. Keeping the RTBC because only comments where modified.
I guess we could, with some work, handle the file upload submission ourselves and definitely get rid of the 'if you have an upload you can't have a field starting with @' annoyance.
Comment #34
Damien Tournoud CreditAttribution: Damien Tournoud commentedAnd here is the patch.
Comment #35
catchStill applies, still fixes the tests.
Comment #36
R.Muilwijk CreditAttribution: R.Muilwijk commentedFixes the tests indeed. The patch looks valid looking at comment #33
Comment #37
Dries CreditAttribution: Dries commentedPersonally, I think the '@' issue is a bit ugly. Before I commit this patch, I'd like to discuss what alternative solution we could implement.
Comment #38
catchIt's ugly, but it was in simpletest for a long time before this patch took it out and broke tests.
Mea culpa for not running all of them before RTBC-ing - but having test failures means that currently every time someone does that, they have to ask me or chx which ones are known issues and which ones aren't, which means a lot of wasted time on everyone's part.
But we'll see if anyone's got a better idea I guess.
Comment #39
Damien Tournoud CreditAttribution: Damien Tournoud commented@Dries: as the author of the patch that broke things, I investigated possible solutions in #31 and #33. It turns out that php_curl implementation is really broken (I reviewed the source code) and does not allow us to do that.
The only alternative that I can see is rewriting the HTTP client ourselves in PHP and getting rid of cURL completely. This would not be such a very big work (implementations probably do exist in GPL already), but requires some careful review and thinking.
In the meantime, we need to fix the regression I introduced, so let's commit this fix, but keep that issue open. We will come up with something else at a latter time.
Comment #40
Dries CreditAttribution: Dries commentedDamien, if you extend the documentation a bit, I'll commit it. It's good to capture why we do it this way and how we could do it better if curl wasn't broken. In other words, it would be good to leave a TODO list in the code so we can revisit this later. Thanks.
Comment #41
catchI've updated the comments with a TODO pointing back to this issue after discussion with Damien in irc.
Comment #42
Dries CreditAttribution: Dries commentedOK, the documentation addition is good enough. Committed to CVS HEAD.
Comment #43
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.