…logic of a unit, server-side and client-side, is contained within the unit itself. Nearly all ajax unit tests take advantage of the new 'framework'. Lots of files got deleted because they became redundant or weren't used anymore.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
$requestArray = "REQUEST"; | ||
|
||
if ( isset( $_REQUEST["requestArray"] ) ) { | ||
$requestArray = $_REQUEST["requestArray"]; | ||
} | ||
|
||
$requestArray =& ${"_$requestArray"}; | ||
This comment has been minimized.
Sorry, something went wrong.
Krinkle
Member
|
||
|
||
$response = array( | ||
"status" => "200", | ||
"statusText" => "", | ||
"contentType" => "text/plain", | ||
"content" => "", | ||
"callback" => "", | ||
"delay" => 0 | ||
); | ||
|
||
foreach( $response as $field => &$value ) { | ||
if ( isset( $requestArray[ $field ] ) ) { | ||
$value = $requestArray[ $field ]; | ||
} | ||
} | ||
|
||
if ( is_array( $response["content"] ) ) { | ||
$response["content"] = http_build_query( $response["content"] ); | ||
} | ||
|
||
if ( !$response["callback"] && preg_match( '/index.php\/([^\/\?&]+)/', $_SERVER["REQUEST_URI"], $match ) ) { | ||
$response["callback"] = $match[ 1 ]; | ||
} | ||
|
||
header("HTTP/1.1 $response[status] $response[statusText]"); | ||
This comment has been minimized.
Sorry, something went wrong.
Krinkle
Member
|
||
header("Content-Type: $response[contentType]"); | ||
|
||
if ( $response["delay"] ) { | ||
sleep( $response["delay"] ); | ||
} | ||
|
||
echo $response["callback"] | ||
? "$response[callback](" . json_encode("$response[content]") . ");" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jaubourg
Author
Member
|
||
: "$response[content]"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
$headers = array( | ||
|
||
"If-Modified-Since" => array( | ||
"request" => "HTTP_IF_MODIFIED_SINCE", | ||
"response" => "Last-Modified", | ||
), | ||
"If-None-Match" => array( | ||
"request" => "HTTP_IF_NONE_MATCH", | ||
"response" => "Etag", | ||
), | ||
|
||
); | ||
|
||
$header = $_REQUEST["header"]; | ||
$value = $_REQUEST["value"]; | ||
|
||
if ( $header === "If-None-Match" ) { | ||
$value = md5( $value ); | ||
} | ||
|
||
$headers = $headers[ $header ]; | ||
|
||
$requestHeader = isset( $_SERVER[ $headers["request"] ] ) ? stripslashes($_SERVER[ $headers["request"] ]) : false; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if ( $requestHeader === $value ) { | ||
header("HTTP/1.0 304 Not Modified"); | ||
} else { | ||
header("$headers[response]: $value"); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
echo $requestHeader ? "OK: $value": "FAIL"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
$headers = array(); | ||
|
||
foreach( $_SERVER as $key => $value ) { | ||
$key = str_replace( "_" , "-" , substr($key,0,5) == "HTTP_" ? substr($key,5) : $key ); | ||
$headers[ $key ] = $value; | ||
} | ||
|
||
foreach( explode( "," , $_GET["headers"] ) as $key ) { | ||
echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
foreach( $_REQUEST as $header => $value ) { | ||
@header("$header: $value"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
7 comments
on commit 228ab3d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Krinkle seems like we have 12 failures on all browsers in ajax units... thing is I ran those test locally against all browsers so there must be some config discrepancy. Gotta get some sleep right now, but if you have manage to guess what's going on, I'd be happy to adapt the tests to testswarm's configuration if needs be later today ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please some consistency. echo
, echo/
, echo/index.php
. What's it gonna be?
I'd recommend either being completely explicit everywhere (echo/index.php
) or abstracting it (calling service()
only with a symbolic name and mapping those to a file by appending .php
). For example, rename echo/index.php
to echo.php
. And call service("echo")
, which then appends .php
.
Depending on which web server (Apache, Nginx, Nodejs, ..) and configuration therefor, various of these may fail (12 fail on jQuery servers).
There various random factors being relied on:
- accepting directory lookups without trailing slash
- assuming that even if that is supported, that it does not use a redirect (in which case the AJAX request would get a 301 response)
- using index.php as the (or one of) default directory index files
etc.
In case of TestSwarm servers, it does support directory lookups without trailing slash but 301 redirects, causing some of the requests to fail when they get 301 instead of whatever response is expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is various other issues with the PHP code that are imho unacceptable (we do execute this, server side, on production servers!). Please do this from a PR next time instead of pushing straight into master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
228ab3d (by @gibson042) fixes a few of the path errors but from running it locally and by actually looking at the errors on TestSwarm I see that that was only a small part of the problem. I can reproduce the majority of the issues locally regardless of any path format.
There seem to be some invalid XML responses and stuff. Not something I can imagine would make any difference on whatever web server or browser.
And there are the style/security issues with PHP code mentioned earlier (though those don't affect the tests). I don't have time for this right now, as in, we can't have this in master taking over other people's priority all of a sudden.
I recommend reverting these 2 commits out of master ASAP. Then re-submit it as a pull request to go through further review and iteration until it passes the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Krinkle, there are only 12 tests not passing. I'd prefer we fix the issue on master and be done with it rather than revert/PR/commit... We can fix all the issues here with a simple commit.
If you prefer it consistent, then we can make sure the paths are always correctly formatted. I just assumed that 301 were followed and that data just weren't rePOSTed again after the redirection (hence the differences between echo
, echo/
, ...). I can as easily switch to a pure file.php
approach, that like 2 minutes of work.
I see the request array switching as a security risk, is there any other security issue I didn't see? Also, where is the style guide for the php code? Is there any? I tried to stay consistent with the Core style guide as I didn't know of any specific to PHP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, where is the style guide for the php code? Is there any? I tried to stay consistent with the Core style guide as I didn't know of any specific to PHP.
We should write one (or at least write the differences between PHP and JS). Basically, just follow the core style guide but use single quotes instead of double quotes unless you need string interpolation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1058 as per discussion on IRC.
Mixed tabs and spaces..