Let built-in web server handle .php requests
authorAntoine Musso <hashar@free.fr>
Fri, 23 Mar 2018 10:38:26 +0000 (11:38 +0100)
committerAntoine Musso <hashar@free.fr>
Wed, 28 Mar 2018 13:36:02 +0000 (15:36 +0200)
When using the PHP built-in webserver with maintenance/dev/start.sh,
requests made to regular files do show in the console output but
requests to .php files do not log anything in the console. It is a bit
annoying since one is left wondering whether the requests are actually
honored.

The reason is the request router maintenance/dev/includes/router.php
does a require of the PHP file and abort the router (return true). That
causes the built-in php server to not produce the access log requests.

Based on the comment note, some earlier PHP version had POST data
stripped preventing login. The related upstream bug is
https://bugs.php.net/bug.php?id=60159:

  "Router returns false, but POST is not passed to requested resource"

750eac7e41d introduced the workaround on Nov 24th 2011. PHP 5.4.0 got
released in March 2012 and refers to that bug.  The development of our
router thus must have used a development/beta version of PHP 5.4.

Since the fix made it to the PHP final release, there is no need for
workaround anymore.

Bug: T190503
Change-Id: Ia8c4f1610ea0ef5b04ea30d6e91199b8e597065b

maintenance/dev/includes/router.php

index 77b0e61..9917a4f 100644 (file)
@@ -54,13 +54,7 @@ if ( !is_readable( $file ) ) {
 }
 $ext = pathinfo( $file, PATHINFO_EXTENSION );
 if ( $ext == 'php' || $ext == 'php5' ) {
-       # Execute php files
-       # We use require and return true here because when you return false
-       # the php webserver will discard post data and things like login
-       # will not function in the dev environment.
-       require $file;
-
-       return true;
+       return false;
 }
 $mime = false;
 // Borrow mime type file from MimeAnalyzer