comparison core/lib/Drupal/Core/Update/UpdateKernel.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
3 namespace Drupal\Core\Update; 3 namespace Drupal\Core\Update;
4 4
5 use Drupal\Core\DrupalKernel; 5 use Drupal\Core\DrupalKernel;
6 use Drupal\Core\Session\AnonymousUserSession; 6 use Drupal\Core\Session\AnonymousUserSession;
7 use Drupal\Core\Site\Settings; 7 use Drupal\Core\Site\Settings;
8 use Drupal\Core\StackMiddleware\ReverseProxyMiddleware;
8 use Symfony\Cmf\Component\Routing\RouteObjectInterface; 9 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
10 use Symfony\Component\DependencyInjection\ContainerInterface;
9 use Symfony\Component\HttpFoundation\ParameterBag; 11 use Symfony\Component\HttpFoundation\ParameterBag;
10 use Symfony\Component\HttpFoundation\Request; 12 use Symfony\Component\HttpFoundation\Request;
11 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; 13 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
12 14
13 /** 15 /**
57 try { 59 try {
58 static::bootEnvironment(); 60 static::bootEnvironment();
59 61
60 // First boot up basic things, like loading the include files. 62 // First boot up basic things, like loading the include files.
61 $this->initializeSettings($request); 63 $this->initializeSettings($request);
64 ReverseProxyMiddleware::setSettingsOnRequest($request, Settings::getInstance());
62 $this->boot(); 65 $this->boot();
63 $container = $this->getContainer(); 66 $container = $this->getContainer();
64 /** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */ 67 /** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */
65 $request_stack = $container->get('request_stack'); 68 $request_stack = $container->get('request_stack');
66 $request_stack->push($request); 69 $request_stack->push($request);
104 /** @var callable $db_update_controller */ 107 /** @var callable $db_update_controller */
105 $db_update_controller = $controller_resolver->getControllerFromDefinition('\Drupal\system\Controller\DbUpdateController::handle'); 108 $db_update_controller = $controller_resolver->getControllerFromDefinition('\Drupal\system\Controller\DbUpdateController::handle');
106 109
107 $this->setupRequestMatch($request); 110 $this->setupRequestMatch($request);
108 111
109 $arguments = $controller_resolver->getArguments($request, $db_update_controller); 112 /** @var \Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface $argument_resolver */
113 $argument_resolver = $container->get('http_kernel.controller.argument_resolver');
114 $arguments = $argument_resolver->getArguments($request, $db_update_controller);
110 return call_user_func_array($db_update_controller, $arguments); 115 return call_user_func_array($db_update_controller, $arguments);
111 } 116 }
112 117
113 /** 118 /**
114 * Boots up the session. 119 * Boots up the session.
115 * 120 *
116 * bootSession() + shutdownSession() basically simulates what 121 * This method + shutdownSession() basically simulates what
117 * \Drupal\Core\StackMiddleware\Session does. 122 * \Drupal\Core\StackMiddleware\Session does.
118 * 123 *
119 * @param \Symfony\Component\HttpFoundation\Request $request 124 * @param \Symfony\Component\HttpFoundation\Request $request
120 * The incoming request. 125 * The incoming request.
121 */ 126 */
184 if (!Settings::get('update_free_access', FALSE) && !$db_update_access->access($account)->isAllowed()) { 189 if (!Settings::get('update_free_access', FALSE) && !$db_update_access->access($account)->isAllowed()) {
185 throw new AccessDeniedHttpException('In order to run update.php you need to either have "Administer software updates" permission or have set $settings[\'update_free_access\'] in your settings.php.'); 190 throw new AccessDeniedHttpException('In order to run update.php you need to either have "Administer software updates" permission or have set $settings[\'update_free_access\'] in your settings.php.');
186 } 191 }
187 } 192 }
188 193
194 /**
195 * {@inheritdoc}
196 */
197 public function loadLegacyIncludes() {
198 parent::loadLegacyIncludes();
199 static::fixSerializedExtensionObjects($this->container);
200 }
201
202 /**
203 * Fixes caches and theme info if they contain old Extension objects.
204 *
205 * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
206 * The container.
207 *
208 * @internal
209 * This function is only to be called by the Drupal core update process.
210 * Additionally, this function will be removed in minor release of Drupal.
211 *
212 * @todo https://www.drupal.org/project/drupal/issues/3031322 Remove once
213 * Drupal 8.6.x is not supported.
214 */
215 public static function fixSerializedExtensionObjects(ContainerInterface $container) {
216 // Create a custom error handler that will clear caches if a warning occurs
217 // while getting 'system.theme.data' from state. If this state value was
218 // created by Drupal <= 8.6.7 then when it is read by Drupal >= 8.6.8 there
219 // will be PHP warnings. This silently fixes Drupal so that the update can
220 // continue.
221 $callable = function () use ($container) {
222 // Reset static caches in profile list so the module list is rebuilt
223 // correctly.
224 $container->get('extension.list.profile')->reset();
225 foreach ($container->getParameter('cache_bins') as $service_id => $bin) {
226 $container->get($service_id)->deleteAll();
227 }
228 // Also rebuild themes because it uses state as cache.
229 $container->get('theme_handler')->refreshInfo();
230 };
231
232 set_error_handler($callable, E_ERROR | E_WARNING);
233 $container->get('state')->get('system.theme.data', []);
234 restore_error_handler();
235 }
236
189 } 237 }