diff --git a/commands/runserver/d8-rs-router.php b/commands/runserver/rs-router.php similarity index 100% rename from commands/runserver/d8-rs-router.php rename to commands/runserver/rs-router.php diff --git a/commands/runserver/runserver-prepend.php b/commands/runserver/rs-router_6.php similarity index 96% rename from commands/runserver/runserver-prepend.php rename to commands/runserver/rs-router_6.php index 5bf753292d..f00e5e77c0 100644 --- a/commands/runserver/runserver-prepend.php +++ b/commands/runserver/rs-router_6.php @@ -66,3 +66,6 @@ function runserver_env($key) { return getenv($key); } } + +// Note that we are simply prepended to the PHP request, we fall through to the +// default PHP handling. diff --git a/commands/runserver/rs-router_7.php b/commands/runserver/rs-router_7.php new file mode 100644 index 0000000000..4475d7c83d --- /dev/null +++ b/commands/runserver/rs-router_7.php @@ -0,0 +1,44 @@ +uid; + } + else { + $uid = $log_entry['user']->id(); + } + $message = strtr('Watchdog: !message | severity: !severity | type: !type | uid: !uid | !ip | !request_uri | !referer | !link', array( + '!message' => strip_tags(!isset($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])), + '!severity' => $log_entry['severity'], + '!type' => $log_entry['type'], + '!ip' => $log_entry['ip'], + '!request_uri' => $log_entry['request_uri'], + '!referer' => $log_entry['referer'], + '!uid' => $uid, + '!link' => strip_tags($log_entry['link']), + )); + error_log($message); + } +} + +// Pass through to the default runserver router. +include __DIR__ . '/rs-router.php'; diff --git a/commands/runserver/runserver.drush.inc b/commands/runserver/runserver.drush.inc index b419486124..0edf7f4e76 100644 --- a/commands/runserver/runserver.drush.inc +++ b/commands/runserver/runserver.drush.inc @@ -131,11 +131,15 @@ function drush_core_runserver($uri = NULL) { drush_start_browser($browse, 2); } // Start the server using 'php -S'. - if (drush_drupal_major_version() >=8) { - $extra = ' "' . __DIR__ . '/d8-rs-router.php"'; + if (drush_drupal_major_version() >= 8) { + $extra = ' "' . __DIR__ . '/rs-router.php"'; + } + elseif (drush_drupal_major_version() == 7) { + $extra = ' "' . __DIR__ . '/rs-router_7.php"'; } else { - $extra = ' --define auto_prepend_file="' . __DIR__ . '/runserver-prepend.php"'; + // For Drupal 6 we prepend an include to what PHP was going invoke. + $extra = ' --define auto_prepend_file="' . __DIR__ . '/rs-router_6.php"'; } $root = \Drush::bootstrapManager()->getRoot(); drush_shell_exec_interactive('cd %s && %s -S ' . $addr . ':' . $uri['port']. $extra, $root, drush_get_option('php', 'php'));