Elgg  Version 3.0
RewriteTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Router\Middleware;
4 
6 use Elgg\Request;
7 
11 class RewriteTest {
12 
20  public function __invoke(Request $request) {
21 
22  $rewriteTester = new \ElggRewriteTester();
23  $url = elgg_get_site_url() . "__testing_rewrite?__testing_rewrite=1";
24  if (!$rewriteTester->runRewriteTest($url)) {
25  // see if there is a problem accessing the site at all
26  // due to ip restrictions for example
27  if (!$rewriteTester->runLocalhostAccessTest()) {
28  // note: translation may not be available until after upgrade
29  $msg = elgg_echo("installation:htaccess:localhost:connectionfailed");
30  if ($msg === "installation:htaccess:localhost:connectionfailed") {
31  $msg = "Elgg cannot connect to itself to test rewrite rules properly. Check "
32  . "that curl is working and there are no IP restrictions preventing "
33  . "localhost connections.";
34  }
35 
37  }
38 
39  // note: translation may not be available until after upgrade
40  $msg = elgg_echo("installation:htaccess:needs_upgrade");
41  if ($msg === "installation:htaccess:needs_upgrade") {
42  $msg = "You must update your .htaccess file (use install/config/htaccess.dist as a guide).";
43  }
44 
46  }
47  }
48 }
Generic HTTP exception.
$request
Page handler for autocomplete endpoint.
Definition: livesearch.php:9
Ensure that mod_rewrite is enabled and working.
Definition: RewriteTest.php:11
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$url
Definition: default.php:33
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
__invoke(Request $request)
Execute a rewrite test.
Definition: RewriteTest.php:20
const ELGG_HTTP_INTERNAL_SERVER_ERROR
Definition: constants.php:106
Request container.
Definition: Request.php:13