Elgg  Version master
RewriteTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Router\Middleware;
4 
6 use Elgg\Request;
8 
12 class RewriteTest {
13 
21  public function __invoke(Request $request) {
22 
23  $rewriteTester = new RewriteTester();
24  $url = elgg_get_site_url() . '__testing_rewrite?__testing_rewrite=1';
25  if (!$rewriteTester->runRewriteTest($url)) {
26  // see if there is a problem accessing the site at all
27  // due to ip restrictions for example
28  if (!$rewriteTester->runLocalhostAccessTest()) {
29  // note: translation may not be available until after upgrade
30  $msg = elgg_echo('installation:htaccess:localhost:connectionfailed');
31  if ($msg === 'installation:htaccess:localhost:connectionfailed') {
32  $msg = 'Elgg cannot connect to itself to test rewrite rules properly. Check ';
33  $msg .= 'that curl is working and there are no IP restrictions preventing ';
34  $msg .= 'localhost connections.';
35  }
36 
38  }
39 
40  // note: translation may not be available until after upgrade
41  $msg = elgg_echo('installation:htaccess:needs_upgrade');
42  if ($msg === 'installation:htaccess:needs_upgrade') {
43  $msg = 'You must update your .htaccess file (use install/config/htaccess.dist as a guide).';
44  }
45 
47  }
48  }
49 }
$request
Definition: livesearch.php:12
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
Ensure that mod_rewrite is enabled and working.
Definition: RewriteTest.php:12
Test if URL rewriting is working.
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:21
Generic HTTP exception.
const ELGG_HTTP_INTERNAL_SERVER_ERROR
Definition: constants.php:91
Request container.
Definition: Request.php:12
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
Definition: deactivate.php:39