Skip to content

Commit d144332

Browse files
committed
Remove dead code from runserver
1 parent f97eeac commit d144332

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

misc/d8-rs-router.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
<?php
22

3-
// Get a $_SERVER key, or equivalent environment variable
4-
// if it is not set in $_SERVER.
5-
function runserver_env($key) {
6-
if (isset($_SERVER[$key])) {
7-
return $_SERVER[$key];
8-
}
9-
else {
10-
return getenv($key);
11-
}
12-
}
13-
143
$url = parse_url($_SERVER["REQUEST_URI"]);
154
if (file_exists('.' . urldecode($url['path']))) {
165
// Serve the requested resource as-is.
176
return FALSE;
187
}
198

20-
// We set the base_url so that Drupal generates correct URLs for runserver
21-
// (e.g. http://127.0.0.1:8888/...), but can still select and serve a specific
22-
// site in a multisite configuration (e.g. http://mysite.com/...).
23-
$base_url = runserver_env('RUNSERVER_BASE_URL');
24-
259
// The built in webserver incorrectly sets $_SERVER['SCRIPT_NAME'] when URLs
2610
// contain multiple dots (such as config entity IDs) in the path. Since this is
2711
// a virtual resource, served by index.php set the script name explicitly.

src/Commands/core/RunserverCommands.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class RunserverCommands extends DrushCommands
4242
* Use a default (would be specified in your drushrc) that starts runserver on port 8080, and opens a browser to the front page. Set path to a single hyphen path in argument to prevent opening browser for this session.
4343
* @usage drush rs :9000/admin
4444
* Start runserver on 127.0.0.1, port 9000, and open /admin in browser. Note that you need a colon when you specify port and path, but no IP.
45+
* @usage drush --quiet rs
46+
* Silence logging the printing of web requests to the console.
4547
*/
4648
public function runserver($uri = null, $options = ['default-server' => self::REQ, 'browser' => true, 'dns' => false])
4749
{
48-
global $base_url;
49-
5050
// Determine active configuration.
5151
$uri = $this->uri($uri, $options);
5252
if (!$uri) {
@@ -65,15 +65,6 @@ public function runserver($uri = null, $options = ['default-server' => self::REQ
6565
// We delete any registered files here, since they are not caught by Ctrl-C.
6666
_drush_delete_registered_files();
6767

68-
// We set the effective base_url, since we have now detected the current site,
69-
// and need to ensure generated URLs point to our runserver host.
70-
// We also pass in the effective base_url to our auto_prepend_script via the
71-
// CGI environment. This allows Drupal to generate working URLs to this http
72-
// server, whilst finding the correct multisite from the HTTP_HOST header.
73-
$base_url = 'http://' . $addr . ':' . $uri['port'];
74-
$env['RUNSERVER_BASE_URL'] = $base_url;
75-
76-
7768
$link = Url::fromUserInput('/' . $path, ['absolute' => true])->toString();
7869
$this->logger()->notice(dt('HTTP server listening on !addr, port !port (see http://!hostname:!port/!path), serving site, !site', ['!addr' => $addr, '!hostname' => $hostname, '!port' => $uri['port'], '!path' => $path, '!site' => Drush::bootstrap()->confPath()]));
7970
// Start php built-in server.

0 commit comments

Comments
 (0)