2013-12-10 13:50:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Rebuilds all Drupal caches even when Drupal itself does not work.
|
|
|
|
*
|
|
|
|
* Needs a token query argument which can be calculated using the
|
|
|
|
* scripts/rebuild_token_calculator.sh script.
|
|
|
|
*
|
|
|
|
* @see drupal_rebuild()
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Drupal\Component\Utility\Crypt;
|
2014-06-26 10:47:01 +00:00
|
|
|
use Drupal\Core\DrupalKernel;
|
2014-04-25 19:13:44 +00:00
|
|
|
use Drupal\Core\Site\Settings;
|
2014-11-21 09:31:37 +00:00
|
|
|
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
2014-06-26 10:47:01 +00:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
2014-11-21 09:31:37 +00:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2013-12-10 13:50:21 +00:00
|
|
|
|
|
|
|
// Change the directory to the Drupal root.
|
|
|
|
chdir('..');
|
|
|
|
|
Issue #2380389 by webflo, Mile23, davidwbarratt, timmillwood, hussainweb, tstoeckler, bojanz, yched, MKorostoff, alexpott, webchick: Use a single vendor directory in the root
2015-09-30 19:58:08 +00:00
|
|
|
$autoloader = require_once __DIR__ . '/../autoload.php';
|
2014-01-25 01:48:29 +00:00
|
|
|
require_once __DIR__ . '/includes/utility.inc';
|
2013-12-10 13:50:21 +00:00
|
|
|
|
2014-06-26 10:47:01 +00:00
|
|
|
$request = Request::createFromGlobals();
|
|
|
|
// Manually resemble early bootstrap of DrupalKernel::boot().
|
|
|
|
DrupalKernel::bootEnvironment();
|
2014-11-21 09:31:37 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
Settings::initialize(dirname(__DIR__), DrupalKernel::findSitePath($request), $autoloader);
|
|
|
|
}
|
|
|
|
catch (HttpExceptionInterface $e) {
|
|
|
|
$response = new Response('', $e->getStatusCode());
|
|
|
|
$response->prepare($request)->send();
|
|
|
|
exit;
|
|
|
|
}
|
2013-12-10 13:50:21 +00:00
|
|
|
|
2014-03-24 08:51:28 +00:00
|
|
|
if (Settings::get('rebuild_access', FALSE) ||
|
2016-05-23 10:57:13 +00:00
|
|
|
($request->query->get('token') && $request->query->get('timestamp') &&
|
Issue #3112283 by ravi.shankar, mpdonadio, andregp, daffie, jhedstrom, alexpott, andypost, pifagor, vladbo, JeroenT, voleger, cliddell: Replace REQUEST_TIME in non-OO and non-module code
2022-05-16 16:27:01 +00:00
|
|
|
(($request->server->getInt('REQUEST_TIME') - $request->query->get('timestamp')) < 300) &&
|
2019-06-10 13:28:03 +00:00
|
|
|
hash_equals(Crypt::hmacBase64($request->query->get('timestamp'), Settings::get('hash_salt')), $request->query->get('token'))
|
2013-12-10 13:50:21 +00:00
|
|
|
)) {
|
2016-10-30 19:27:27 +00:00
|
|
|
// Clear user cache for all major platforms.
|
|
|
|
$user_caches = [
|
|
|
|
'apcu_clear_cache',
|
|
|
|
'wincache_ucache_clear',
|
|
|
|
];
|
2016-11-23 12:47:48 +00:00
|
|
|
array_map('call_user_func', array_filter($user_caches, 'is_callable'));
|
2016-10-30 19:27:27 +00:00
|
|
|
|
2014-06-26 10:47:01 +00:00
|
|
|
drupal_rebuild($autoloader, $request);
|
2018-01-22 15:28:16 +00:00
|
|
|
\Drupal::messenger()->addStatus('Cache rebuild complete.');
|
2013-12-10 13:50:21 +00:00
|
|
|
}
|
2020-04-23 16:15:14 +00:00
|
|
|
$base_path = dirname($request->getBaseUrl(), 2);
|
2018-09-19 18:07:53 +00:00
|
|
|
header('Location: ' . $request->getSchemeAndHttpHost() . $base_path);
|