Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * Install, update and uninstall functions for the system module.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@0
|
8 use Drupal\Component\Utility\Crypt;
|
Chris@0
|
9 use Drupal\Component\Utility\Environment;
|
Chris@0
|
10 use Drupal\Component\FileSystem\FileSystem;
|
Chris@0
|
11 use Drupal\Component\Utility\OpCodeCache;
|
Chris@0
|
12 use Drupal\Component\Utility\Unicode;
|
Chris@0
|
13 use Drupal\Core\Cache\Cache;
|
Chris@0
|
14 use Drupal\Core\Path\AliasStorage;
|
Chris@0
|
15 use Drupal\Core\Url;
|
Chris@0
|
16 use Drupal\Core\Database\Database;
|
Chris@0
|
17 use Drupal\Core\Entity\ContentEntityTypeInterface;
|
Chris@0
|
18 use Drupal\Core\Entity\EntityTypeInterface;
|
Chris@0
|
19 use Drupal\Core\Entity\FieldableEntityInterface;
|
Chris@0
|
20 use Drupal\Core\DrupalKernel;
|
Chris@4
|
21 use Drupal\Core\Extension\Extension;
|
Chris@0
|
22 use Drupal\Core\Field\BaseFieldDefinition;
|
Chris@0
|
23 use Drupal\Core\Site\Settings;
|
Chris@0
|
24 use Drupal\Core\StreamWrapper\PrivateStream;
|
Chris@0
|
25 use Drupal\Core\StreamWrapper\PublicStream;
|
Chris@0
|
26 use Drupal\system\SystemRequirements;
|
Chris@0
|
27 use Symfony\Component\HttpFoundation\Request;
|
Chris@0
|
28
|
Chris@0
|
29 /**
|
Chris@0
|
30 * Implements hook_requirements().
|
Chris@0
|
31 */
|
Chris@0
|
32 function system_requirements($phase) {
|
Chris@0
|
33 global $install_state;
|
Chris@0
|
34 $requirements = [];
|
Chris@0
|
35
|
Chris@0
|
36 // Report Drupal version
|
Chris@0
|
37 if ($phase == 'runtime') {
|
Chris@0
|
38 $requirements['drupal'] = [
|
Chris@0
|
39 'title' => t('Drupal'),
|
Chris@0
|
40 'value' => \Drupal::VERSION,
|
Chris@0
|
41 'severity' => REQUIREMENT_INFO,
|
Chris@0
|
42 'weight' => -10,
|
Chris@0
|
43 ];
|
Chris@0
|
44
|
Chris@0
|
45 // Display the currently active installation profile, if the site
|
Chris@0
|
46 // is not running the default installation profile.
|
Chris@0
|
47 $profile = drupal_get_profile();
|
Chris@0
|
48 if ($profile != 'standard') {
|
Chris@0
|
49 $info = system_get_info('module', $profile);
|
Chris@0
|
50 $requirements['install_profile'] = [
|
Chris@0
|
51 'title' => t('Installation profile'),
|
Chris@0
|
52 'value' => t('%profile_name (%profile-%version)', [
|
Chris@0
|
53 '%profile_name' => $info['name'],
|
Chris@0
|
54 '%profile' => $profile,
|
Chris@4
|
55 '%version' => $info['version'],
|
Chris@0
|
56 ]),
|
Chris@0
|
57 'severity' => REQUIREMENT_INFO,
|
Chris@4
|
58 'weight' => -9,
|
Chris@0
|
59 ];
|
Chris@0
|
60 }
|
Chris@0
|
61
|
Chris@0
|
62 // Warn if any experimental modules are installed.
|
Chris@0
|
63 $experimental = [];
|
Chris@0
|
64 $enabled_modules = \Drupal::moduleHandler()->getModuleList();
|
Chris@0
|
65 foreach ($enabled_modules as $module => $data) {
|
Chris@0
|
66 $info = system_get_info('module', $module);
|
Chris@0
|
67 if (isset($info['package']) && $info['package'] === 'Core (Experimental)') {
|
Chris@0
|
68 $experimental[$module] = $info['name'];
|
Chris@0
|
69 }
|
Chris@0
|
70 }
|
Chris@0
|
71 if (!empty($experimental)) {
|
Chris@0
|
72 $requirements['experimental'] = [
|
Chris@0
|
73 'title' => t('Experimental modules enabled'),
|
Chris@0
|
74 'value' => t('Experimental modules found: %module_list. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', ['%module_list' => implode(', ', $experimental), ':url' => 'https://www.drupal.org/core/experimental']),
|
Chris@0
|
75 'severity' => REQUIREMENT_WARNING,
|
Chris@0
|
76 ];
|
Chris@0
|
77 }
|
Chris@0
|
78 }
|
Chris@0
|
79
|
Chris@0
|
80 // Web server information.
|
Chris@4
|
81 $request_object = \Drupal::request();
|
Chris@4
|
82 $software = $request_object->server->get('SERVER_SOFTWARE');
|
Chris@0
|
83 $requirements['webserver'] = [
|
Chris@0
|
84 'title' => t('Web server'),
|
Chris@0
|
85 'value' => $software,
|
Chris@0
|
86 ];
|
Chris@0
|
87
|
Chris@0
|
88 // Tests clean URL support.
|
Chris@4
|
89 if ($phase == 'install' && $install_state['interactive'] && !$request_object->query->has('rewrite') && strpos($software, 'Apache') !== FALSE) {
|
Chris@0
|
90 // If the Apache rewrite module is not enabled, Apache version must be >=
|
Chris@0
|
91 // 2.2.16 because of the FallbackResource directive in the root .htaccess
|
Chris@0
|
92 // file. Since the Apache version reported by the server is dependent on the
|
Chris@0
|
93 // ServerTokens setting in httpd.conf, we may not be able to determine if a
|
Chris@0
|
94 // given config is valid. Thus we are unable to use version_compare() as we
|
Chris@0
|
95 // need have three possible outcomes: the version of Apache is greater than
|
Chris@0
|
96 // 2.2.16, is less than 2.2.16, or cannot be determined accurately. In the
|
Chris@0
|
97 // first case, we encourage the use of mod_rewrite; in the second case, we
|
Chris@0
|
98 // raise an error regarding the minimum Apache version; in the third case,
|
Chris@0
|
99 // we raise a warning that the current version of Apache may not be
|
Chris@0
|
100 // supported.
|
Chris@0
|
101 $rewrite_warning = FALSE;
|
Chris@0
|
102 $rewrite_error = FALSE;
|
Chris@0
|
103 $apache_version_string = 'Apache';
|
Chris@0
|
104
|
Chris@0
|
105 // Determine the Apache version number: major, minor and revision.
|
Chris@0
|
106 if (preg_match('/Apache\/(\d+)\.?(\d+)?\.?(\d+)?/', $software, $matches)) {
|
Chris@0
|
107 $apache_version_string = $matches[0];
|
Chris@0
|
108
|
Chris@0
|
109 // Major version number
|
Chris@0
|
110 if ($matches[1] < 2) {
|
Chris@0
|
111 $rewrite_error = TRUE;
|
Chris@0
|
112 }
|
Chris@0
|
113 elseif ($matches[1] == 2) {
|
Chris@0
|
114 if (!isset($matches[2])) {
|
Chris@0
|
115 $rewrite_warning = TRUE;
|
Chris@0
|
116 }
|
Chris@0
|
117 elseif ($matches[2] < 2) {
|
Chris@0
|
118 $rewrite_error = TRUE;
|
Chris@0
|
119 }
|
Chris@0
|
120 elseif ($matches[2] == 2) {
|
Chris@0
|
121 if (!isset($matches[3])) {
|
Chris@0
|
122 $rewrite_warning = TRUE;
|
Chris@0
|
123 }
|
Chris@0
|
124 elseif ($matches[3] < 16) {
|
Chris@0
|
125 $rewrite_error = TRUE;
|
Chris@0
|
126 }
|
Chris@0
|
127 }
|
Chris@0
|
128 }
|
Chris@0
|
129 }
|
Chris@0
|
130 else {
|
Chris@0
|
131 $rewrite_warning = TRUE;
|
Chris@0
|
132 }
|
Chris@0
|
133
|
Chris@0
|
134 if ($rewrite_warning) {
|
Chris@0
|
135 $requirements['apache_version'] = [
|
Chris@0
|
136 'title' => t('Apache version'),
|
Chris@0
|
137 'value' => $apache_version_string,
|
Chris@0
|
138 'severity' => REQUIREMENT_WARNING,
|
Chris@0
|
139 'description' => t('Due to the settings for ServerTokens in httpd.conf, it is impossible to accurately determine the version of Apache running on this server. The reported value is @reported, to run Drupal without mod_rewrite, a minimum version of 2.2.16 is needed.', ['@reported' => $apache_version_string]),
|
Chris@0
|
140 ];
|
Chris@0
|
141 }
|
Chris@0
|
142
|
Chris@0
|
143 if ($rewrite_error) {
|
Chris@0
|
144 $requirements['Apache version'] = [
|
Chris@0
|
145 'title' => t('Apache version'),
|
Chris@0
|
146 'value' => $apache_version_string,
|
Chris@0
|
147 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
148 'description' => t('The minimum version of Apache needed to run Drupal without mod_rewrite enabled is 2.2.16. See the <a href=":link">enabling clean URLs</a> page for more information on mod_rewrite.', [':link' => 'http://drupal.org/node/15365']),
|
Chris@0
|
149 ];
|
Chris@0
|
150 }
|
Chris@0
|
151
|
Chris@0
|
152 if (!$rewrite_error && !$rewrite_warning) {
|
Chris@0
|
153 $requirements['rewrite_module'] = [
|
Chris@0
|
154 'title' => t('Clean URLs'),
|
Chris@0
|
155 'value' => t('Disabled'),
|
Chris@0
|
156 'severity' => REQUIREMENT_WARNING,
|
Chris@0
|
157 'description' => t('Your server is capable of using clean URLs, but it is not enabled. Using clean URLs gives an improved user experience and is recommended. <a href=":link">Enable clean URLs</a>', [':link' => 'http://drupal.org/node/15365']),
|
Chris@0
|
158 ];
|
Chris@0
|
159 }
|
Chris@0
|
160 }
|
Chris@0
|
161
|
Chris@0
|
162 // Verify the user is running a supported PHP version.
|
Chris@0
|
163 // If the site is running a recommended version of PHP, just display it
|
Chris@0
|
164 // as an informational message on the status report. This will be overridden
|
Chris@0
|
165 // with an error or warning if the site is running older PHP versions for
|
Chris@0
|
166 // which Drupal has already or will soon drop support.
|
Chris@0
|
167 $phpversion = $phpversion_label = phpversion();
|
Chris@0
|
168 if (function_exists('phpinfo')) {
|
Chris@0
|
169 if ($phase === 'runtime') {
|
Chris@0
|
170 $phpversion_label = t('@phpversion (<a href=":url">more information</a>)', ['@phpversion' => $phpversion, ':url' => (new Url('system.php'))->toString()]);
|
Chris@0
|
171 }
|
Chris@0
|
172 $requirements['php'] = [
|
Chris@0
|
173 'title' => t('PHP'),
|
Chris@0
|
174 'value' => $phpversion_label,
|
Chris@0
|
175 ];
|
Chris@0
|
176 }
|
Chris@0
|
177 else {
|
Chris@0
|
178 // @todo Revisit whether this description makes sense in
|
Chris@0
|
179 // https://www.drupal.org/project/drupal/issues/2927318.
|
Chris@0
|
180 $requirements['php'] = [
|
Chris@0
|
181 'title' => t('PHP'),
|
Chris@0
|
182 'value' => $phpversion_label,
|
Chris@0
|
183 'description' => t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']),
|
Chris@0
|
184 'severity' => REQUIREMENT_INFO,
|
Chris@0
|
185 ];
|
Chris@0
|
186 }
|
Chris@0
|
187
|
Chris@0
|
188 if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
|
Chris@0
|
189 $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
|
Chris@0
|
190 $requirements['php']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
191 // If PHP is old, it's not safe to continue with the requirements check.
|
Chris@0
|
192 return $requirements;
|
Chris@0
|
193 }
|
Chris@0
|
194 if ((version_compare($phpversion, DRUPAL_RECOMMENDED_PHP) < 0) && ($phase === 'install' || $phase === 'runtime')) {
|
Chris@0
|
195 // Warn if still on PHP 5. If at least PHP 7.0, relax from "warning" to
|
Chris@0
|
196 // "info", and show it at runtime only, to not scare users while installing.
|
Chris@0
|
197 if (version_compare($phpversion, '7.0') < 0) {
|
Chris@0
|
198 $requirements['php']['description'] = t('Drupal will drop support for this version on March 6, 2019. Upgrade to PHP version %recommended or higher to ensure your site can receive updates and remain secure. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']);
|
Chris@0
|
199 $requirements['php']['severity'] = REQUIREMENT_WARNING;
|
Chris@0
|
200 }
|
Chris@0
|
201 else {
|
Chris@0
|
202 if ($phase === 'runtime') {
|
Chris@0
|
203 $requirements['php']['description'] = t('It is recommended to upgrade to PHP version %recommended or higher for the best ongoing support. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']);
|
Chris@0
|
204 $requirements['php']['severity'] = REQUIREMENT_INFO;
|
Chris@0
|
205 }
|
Chris@0
|
206 }
|
Chris@0
|
207 }
|
Chris@0
|
208
|
Chris@0
|
209 // Suggest to update to at least 5.5.21 or 5.6.5 for disabling multiple
|
Chris@0
|
210 // statements.
|
Chris@0
|
211 if (($phase === 'install' || \Drupal::database()->driver() === 'mysql') && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
|
Chris@0
|
212 $requirements['php_multiple_statement'] = [
|
Chris@0
|
213 'title' => t('PHP (multiple statement disabling)'),
|
Chris@0
|
214 'value' => $phpversion_label,
|
Chris@0
|
215 'description' => t('PHP versions higher than 5.6.5 or 5.5.21 provide built-in SQL injection protection for mysql databases. It is recommended to update.'),
|
Chris@0
|
216 'severity' => REQUIREMENT_INFO,
|
Chris@0
|
217 ];
|
Chris@0
|
218 }
|
Chris@0
|
219
|
Chris@0
|
220 // Test for PHP extensions.
|
Chris@0
|
221 $requirements['php_extensions'] = [
|
Chris@0
|
222 'title' => t('PHP extensions'),
|
Chris@0
|
223 ];
|
Chris@0
|
224
|
Chris@0
|
225 $missing_extensions = [];
|
Chris@0
|
226 $required_extensions = [
|
Chris@0
|
227 'date',
|
Chris@0
|
228 'dom',
|
Chris@0
|
229 'filter',
|
Chris@0
|
230 'gd',
|
Chris@0
|
231 'hash',
|
Chris@0
|
232 'json',
|
Chris@0
|
233 'pcre',
|
Chris@0
|
234 'pdo',
|
Chris@0
|
235 'session',
|
Chris@0
|
236 'SimpleXML',
|
Chris@0
|
237 'SPL',
|
Chris@0
|
238 'tokenizer',
|
Chris@0
|
239 'xml',
|
Chris@0
|
240 ];
|
Chris@0
|
241 foreach ($required_extensions as $extension) {
|
Chris@0
|
242 if (!extension_loaded($extension)) {
|
Chris@0
|
243 $missing_extensions[] = $extension;
|
Chris@0
|
244 }
|
Chris@0
|
245 }
|
Chris@0
|
246
|
Chris@0
|
247 if (!empty($missing_extensions)) {
|
Chris@0
|
248 $description = t('Drupal requires you to enable the PHP extensions in the following list (see the <a href=":system_requirements">system requirements page</a> for more information):', [
|
Chris@0
|
249 ':system_requirements' => 'https://www.drupal.org/requirements',
|
Chris@0
|
250 ]);
|
Chris@0
|
251
|
Chris@0
|
252 // We use twig inline_template to avoid twig's autoescape.
|
Chris@0
|
253 $description = [
|
Chris@0
|
254 '#type' => 'inline_template',
|
Chris@0
|
255 '#template' => '{{ description }}{{ missing_extensions }}',
|
Chris@0
|
256 '#context' => [
|
Chris@0
|
257 'description' => $description,
|
Chris@0
|
258 'missing_extensions' => [
|
Chris@0
|
259 '#theme' => 'item_list',
|
Chris@0
|
260 '#items' => $missing_extensions,
|
Chris@0
|
261 ],
|
Chris@0
|
262 ],
|
Chris@0
|
263 ];
|
Chris@0
|
264
|
Chris@0
|
265 $requirements['php_extensions']['value'] = t('Disabled');
|
Chris@0
|
266 $requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
267 $requirements['php_extensions']['description'] = $description;
|
Chris@0
|
268 }
|
Chris@0
|
269 else {
|
Chris@0
|
270 $requirements['php_extensions']['value'] = t('Enabled');
|
Chris@0
|
271 }
|
Chris@0
|
272
|
Chris@0
|
273 if ($phase == 'install' || $phase == 'runtime') {
|
Chris@0
|
274 // Check to see if OPcache is installed.
|
Chris@0
|
275 if (!OpCodeCache::isEnabled()) {
|
Chris@0
|
276 $requirements['php_opcache'] = [
|
Chris@0
|
277 'value' => t('Not enabled'),
|
Chris@0
|
278 'severity' => REQUIREMENT_WARNING,
|
Chris@0
|
279 'description' => t('PHP OPcode caching can improve your site\'s performance considerably. It is <strong>highly recommended</strong> to have <a href="http://php.net/manual/opcache.installation.php" target="_blank">OPcache</a> installed on your server.'),
|
Chris@0
|
280 ];
|
Chris@0
|
281 }
|
Chris@0
|
282 else {
|
Chris@0
|
283 $requirements['php_opcache']['value'] = t('Enabled');
|
Chris@0
|
284 }
|
Chris@0
|
285 $requirements['php_opcache']['title'] = t('PHP OPcode caching');
|
Chris@0
|
286 }
|
Chris@0
|
287
|
Chris@0
|
288 if ($phase != 'update') {
|
Chris@0
|
289 // Test whether we have a good source of random bytes.
|
Chris@0
|
290 $requirements['php_random_bytes'] = [
|
Chris@0
|
291 'title' => t('Random number generation'),
|
Chris@0
|
292 ];
|
Chris@0
|
293 try {
|
Chris@0
|
294 $bytes = random_bytes(10);
|
Chris@0
|
295 if (strlen($bytes) != 10) {
|
Chris@0
|
296 throw new \Exception(t('Tried to generate 10 random bytes, generated @count', ['@count' => strlen($bytes)]));
|
Chris@0
|
297 }
|
Chris@0
|
298 $requirements['php_random_bytes']['value'] = t('Successful');
|
Chris@0
|
299 }
|
Chris@0
|
300 catch (\Exception $e) {
|
Chris@0
|
301 // If /dev/urandom is not available on a UNIX-like system, check whether
|
Chris@0
|
302 // open_basedir restrictions are the cause.
|
Chris@0
|
303 $open_basedir_blocks_urandom = FALSE;
|
Chris@0
|
304 if (DIRECTORY_SEPARATOR === '/' && !@is_readable('/dev/urandom')) {
|
Chris@0
|
305 $open_basedir = ini_get('open_basedir');
|
Chris@0
|
306 if ($open_basedir) {
|
Chris@0
|
307 $open_basedir_paths = explode(PATH_SEPARATOR, $open_basedir);
|
Chris@0
|
308 $open_basedir_blocks_urandom = !array_intersect(['/dev', '/dev/', '/dev/urandom'], $open_basedir_paths);
|
Chris@0
|
309 }
|
Chris@0
|
310 }
|
Chris@0
|
311 $args = [
|
Chris@0
|
312 ':drupal-php' => 'https://www.drupal.org/docs/7/system-requirements/php#csprng',
|
Chris@0
|
313 '%exception_message' => $e->getMessage(),
|
Chris@0
|
314 ];
|
Chris@0
|
315 if ($open_basedir_blocks_urandom) {
|
Chris@0
|
316 $requirements['php_random_bytes']['description'] = t('Drupal is unable to generate highly randomized numbers, which means certain security features like password reset URLs are not as secure as they should be. Instead, only a slow, less-secure fallback generator is available. The most likely cause is that open_basedir restrictions are in effect and /dev/urandom is not on the whitelist. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args);
|
Chris@0
|
317 }
|
Chris@0
|
318 else {
|
Chris@0
|
319 $requirements['php_random_bytes']['description'] = t('Drupal is unable to generate highly randomized numbers, which means certain security features like password reset URLs are not as secure as they should be. Instead, only a slow, less-secure fallback generator is available. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args);
|
Chris@0
|
320 }
|
Chris@0
|
321 $requirements['php_random_bytes']['value'] = t('Less secure');
|
Chris@0
|
322 $requirements['php_random_bytes']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
323 }
|
Chris@0
|
324 }
|
Chris@0
|
325
|
Chris@0
|
326 if ($phase == 'install' || $phase == 'update') {
|
Chris@0
|
327 // Test for PDO (database).
|
Chris@0
|
328 $requirements['database_extensions'] = [
|
Chris@0
|
329 'title' => t('Database support'),
|
Chris@0
|
330 ];
|
Chris@0
|
331
|
Chris@0
|
332 // Make sure PDO is available.
|
Chris@0
|
333 $database_ok = extension_loaded('pdo');
|
Chris@0
|
334 if (!$database_ok) {
|
Chris@0
|
335 $pdo_message = t('Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension. See the <a href=":link">system requirements</a> page for more information.', [
|
Chris@0
|
336 ':link' => 'https://www.drupal.org/requirements/pdo',
|
Chris@0
|
337 ]);
|
Chris@0
|
338 }
|
Chris@0
|
339 else {
|
Chris@0
|
340 // Make sure at least one supported database driver exists.
|
Chris@0
|
341 $drivers = drupal_detect_database_types();
|
Chris@0
|
342 if (empty($drivers)) {
|
Chris@0
|
343 $database_ok = FALSE;
|
Chris@0
|
344 $pdo_message = t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href=":drupal-databases">Drupal supports</a>.', [
|
Chris@0
|
345 ':drupal-databases' => 'https://www.drupal.org/requirements/database',
|
Chris@0
|
346 ]);
|
Chris@0
|
347 }
|
Chris@0
|
348 // Make sure the native PDO extension is available, not the older PEAR
|
Chris@0
|
349 // version. (See install_verify_pdo() for details.)
|
Chris@0
|
350 if (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
|
Chris@0
|
351 $database_ok = FALSE;
|
Chris@0
|
352 $pdo_message = t('Your web server seems to have the wrong version of PDO installed. Drupal requires the PDO extension from PHP core. This system has the older PECL version. See the <a href=":link">system requirements</a> page for more information.', [
|
Chris@0
|
353 ':link' => 'https://www.drupal.org/requirements/pdo#pecl',
|
Chris@0
|
354 ]);
|
Chris@0
|
355 }
|
Chris@0
|
356 }
|
Chris@0
|
357
|
Chris@0
|
358 if (!$database_ok) {
|
Chris@0
|
359 $requirements['database_extensions']['value'] = t('Disabled');
|
Chris@0
|
360 $requirements['database_extensions']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
361 $requirements['database_extensions']['description'] = $pdo_message;
|
Chris@0
|
362 }
|
Chris@0
|
363 else {
|
Chris@0
|
364 $requirements['database_extensions']['value'] = t('Enabled');
|
Chris@0
|
365 }
|
Chris@0
|
366 }
|
Chris@0
|
367 else {
|
Chris@0
|
368 // Database information.
|
Chris@0
|
369 $class = Database::getConnection()->getDriverClass('Install\\Tasks');
|
Chris@0
|
370 $tasks = new $class();
|
Chris@0
|
371 $requirements['database_system'] = [
|
Chris@0
|
372 'title' => t('Database system'),
|
Chris@0
|
373 'value' => $tasks->name(),
|
Chris@0
|
374 ];
|
Chris@0
|
375 $requirements['database_system_version'] = [
|
Chris@0
|
376 'title' => t('Database system version'),
|
Chris@0
|
377 'value' => Database::getConnection()->version(),
|
Chris@0
|
378 ];
|
Chris@0
|
379 }
|
Chris@0
|
380
|
Chris@0
|
381 // Test PHP memory_limit
|
Chris@0
|
382 $memory_limit = ini_get('memory_limit');
|
Chris@0
|
383 $requirements['php_memory_limit'] = [
|
Chris@0
|
384 'title' => t('PHP memory limit'),
|
Chris@0
|
385 'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
|
Chris@0
|
386 ];
|
Chris@0
|
387
|
Chris@0
|
388 if (!Environment::checkMemoryLimit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
|
Chris@0
|
389 $description = [];
|
Chris@0
|
390 if ($phase == 'install') {
|
Chris@0
|
391 $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', ['%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]);
|
Chris@0
|
392 }
|
Chris@0
|
393 elseif ($phase == 'update') {
|
Chris@0
|
394 $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', ['%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]);
|
Chris@0
|
395 }
|
Chris@0
|
396 elseif ($phase == 'runtime') {
|
Chris@0
|
397 $description['phase'] = t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', ['%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]);
|
Chris@0
|
398 }
|
Chris@0
|
399
|
Chris@0
|
400 if (!empty($description['phase'])) {
|
Chris@0
|
401 if ($php_ini_path = get_cfg_var('cfg_file_path')) {
|
Chris@0
|
402 $description['memory'] = t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', ['%configuration-file' => $php_ini_path]);
|
Chris@0
|
403 }
|
Chris@0
|
404 else {
|
Chris@0
|
405 $description['memory'] = t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
|
Chris@0
|
406 }
|
Chris@0
|
407
|
Chris@0
|
408 $handbook_link = t('For more information, see the online handbook entry for <a href=":memory-limit">increasing the PHP memory limit</a>.', [':memory-limit' => 'https://www.drupal.org/node/207036']);
|
Chris@0
|
409
|
Chris@0
|
410 $description = [
|
Chris@0
|
411 '#type' => 'inline_template',
|
Chris@0
|
412 '#template' => '{{ description_phase }} {{ description_memory }} {{ handbook }}',
|
Chris@0
|
413 '#context' => [
|
Chris@0
|
414 'description_phase' => $description['phase'],
|
Chris@0
|
415 'description_memory' => $description['memory'],
|
Chris@0
|
416 'handbook' => $handbook_link,
|
Chris@0
|
417 ],
|
Chris@0
|
418 ];
|
Chris@0
|
419
|
Chris@0
|
420 $requirements['php_memory_limit']['description'] = $description;
|
Chris@0
|
421 $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
|
Chris@0
|
422 }
|
Chris@0
|
423 }
|
Chris@0
|
424
|
Chris@0
|
425 // Test configuration files and directory for writability.
|
Chris@0
|
426 if ($phase == 'runtime') {
|
Chris@0
|
427 $conf_errors = [];
|
Chris@0
|
428 // Find the site path. Kernel service is not always available at this point,
|
Chris@0
|
429 // but is preferred, when available.
|
Chris@0
|
430 if (\Drupal::hasService('kernel')) {
|
Chris@0
|
431 $site_path = \Drupal::service('site.path');
|
Chris@0
|
432 }
|
Chris@0
|
433 else {
|
Chris@0
|
434 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
|
Chris@0
|
435 }
|
Chris@0
|
436 // Allow system administrators to disable permissions hardening for the site
|
Chris@0
|
437 // directory. This allows additional files in the site directory to be
|
Chris@0
|
438 // updated when they are managed in a version control system.
|
Chris@0
|
439 if (Settings::get('skip_permissions_hardening')) {
|
Chris@4
|
440 $error_value = t('Protection disabled');
|
Chris@0
|
441 // If permissions hardening is disabled, then only show a warning for a
|
Chris@0
|
442 // writable file, as a reminder, rather than an error.
|
Chris@0
|
443 $file_protection_severity = REQUIREMENT_WARNING;
|
Chris@0
|
444 }
|
Chris@0
|
445 else {
|
Chris@4
|
446 $error_value = t('Not protected');
|
Chris@0
|
447 // In normal operation, writable files or directories are an error.
|
Chris@0
|
448 $file_protection_severity = REQUIREMENT_ERROR;
|
Chris@0
|
449 if (!drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')) {
|
Chris@0
|
450 $conf_errors[] = t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", ['%file' => $site_path]);
|
Chris@0
|
451 }
|
Chris@0
|
452 }
|
Chris@0
|
453 foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
|
Chris@0
|
454 $full_path = $site_path . '/' . $conf_file;
|
Chris@4
|
455 if (file_exists($full_path) && !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE, 'file', !Settings::get('skip_permissions_hardening'))) {
|
Chris@0
|
456 $conf_errors[] = t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", ['%file' => $full_path]);
|
Chris@0
|
457 }
|
Chris@0
|
458 }
|
Chris@0
|
459 if (!empty($conf_errors)) {
|
Chris@0
|
460 if (count($conf_errors) == 1) {
|
Chris@0
|
461 $description = $conf_errors[0];
|
Chris@0
|
462 }
|
Chris@0
|
463 else {
|
Chris@0
|
464 // We use twig inline_template to avoid double escaping.
|
Chris@0
|
465 $description = [
|
Chris@0
|
466 '#type' => 'inline_template',
|
Chris@0
|
467 '#template' => '{{ configuration_error_list }}',
|
Chris@0
|
468 '#context' => [
|
Chris@0
|
469 'configuration_error_list' => [
|
Chris@0
|
470 '#theme' => 'item_list',
|
Chris@0
|
471 '#items' => $conf_errors,
|
Chris@0
|
472 ],
|
Chris@0
|
473 ],
|
Chris@0
|
474 ];
|
Chris@0
|
475 }
|
Chris@0
|
476 $requirements['configuration_files'] = [
|
Chris@4
|
477 'value' => $error_value,
|
Chris@0
|
478 'severity' => $file_protection_severity,
|
Chris@0
|
479 'description' => $description,
|
Chris@0
|
480 ];
|
Chris@0
|
481 }
|
Chris@0
|
482 else {
|
Chris@0
|
483 $requirements['configuration_files'] = [
|
Chris@0
|
484 'value' => t('Protected'),
|
Chris@0
|
485 ];
|
Chris@0
|
486 }
|
Chris@0
|
487 $requirements['configuration_files']['title'] = t('Configuration files');
|
Chris@0
|
488 }
|
Chris@0
|
489
|
Chris@0
|
490 // Test the contents of the .htaccess files.
|
Chris@0
|
491 if ($phase == 'runtime') {
|
Chris@0
|
492 // Try to write the .htaccess files first, to prevent false alarms in case
|
Chris@0
|
493 // (for example) the /tmp directory was wiped.
|
Chris@0
|
494 file_ensure_htaccess();
|
Chris@0
|
495 $file_system = \Drupal::service('file_system');
|
Chris@0
|
496 $htaccess_files['public://.htaccess'] = [
|
Chris@0
|
497 'title' => t('Public files directory'),
|
Chris@0
|
498 'directory' => $file_system->realpath('public://'),
|
Chris@0
|
499 ];
|
Chris@0
|
500 if (PrivateStream::basePath()) {
|
Chris@0
|
501 $htaccess_files['private://.htaccess'] = [
|
Chris@0
|
502 'title' => t('Private files directory'),
|
Chris@0
|
503 'directory' => $file_system->realpath('private://'),
|
Chris@0
|
504 ];
|
Chris@0
|
505 }
|
Chris@0
|
506 $htaccess_files['temporary://.htaccess'] = [
|
Chris@0
|
507 'title' => t('Temporary files directory'),
|
Chris@0
|
508 'directory' => $file_system->realpath('temporary://'),
|
Chris@0
|
509 ];
|
Chris@0
|
510 foreach ($htaccess_files as $htaccess_file => $info) {
|
Chris@0
|
511 // Check for the string which was added to the recommended .htaccess file
|
Chris@0
|
512 // in the latest security update.
|
Chris@0
|
513 if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
|
Chris@0
|
514 $url = 'https://www.drupal.org/SA-CORE-2013-003';
|
Chris@0
|
515 $requirements[$htaccess_file] = [
|
Chris@0
|
516 'title' => $info['title'],
|
Chris@0
|
517 'value' => t('Not fully protected'),
|
Chris@0
|
518 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
519 'description' => t('See <a href=":url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', [':url' => $url, '@url' => $url, '%directory' => $info['directory']]),
|
Chris@0
|
520 ];
|
Chris@0
|
521 }
|
Chris@0
|
522 }
|
Chris@0
|
523 }
|
Chris@0
|
524
|
Chris@0
|
525 // Report cron status.
|
Chris@0
|
526 if ($phase == 'runtime') {
|
Chris@0
|
527 $cron_config = \Drupal::config('system.cron');
|
Chris@0
|
528 // Cron warning threshold defaults to two days.
|
Chris@0
|
529 $threshold_warning = $cron_config->get('threshold.requirements_warning');
|
Chris@0
|
530 // Cron error threshold defaults to two weeks.
|
Chris@0
|
531 $threshold_error = $cron_config->get('threshold.requirements_error');
|
Chris@0
|
532
|
Chris@0
|
533 // Determine when cron last ran.
|
Chris@0
|
534 $cron_last = \Drupal::state()->get('system.cron_last');
|
Chris@0
|
535 if (!is_numeric($cron_last)) {
|
Chris@0
|
536 $cron_last = \Drupal::state()->get('install_time', 0);
|
Chris@0
|
537 }
|
Chris@0
|
538
|
Chris@0
|
539 // Determine severity based on time since cron last ran.
|
Chris@0
|
540 $severity = REQUIREMENT_INFO;
|
Chris@0
|
541 if (REQUEST_TIME - $cron_last > $threshold_error) {
|
Chris@0
|
542 $severity = REQUIREMENT_ERROR;
|
Chris@0
|
543 }
|
Chris@0
|
544 elseif (REQUEST_TIME - $cron_last > $threshold_warning) {
|
Chris@0
|
545 $severity = REQUIREMENT_WARNING;
|
Chris@0
|
546 }
|
Chris@0
|
547
|
Chris@0
|
548 // Set summary and description based on values determined above.
|
Chris@0
|
549 $summary = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
|
Chris@0
|
550
|
Chris@0
|
551 $requirements['cron'] = [
|
Chris@0
|
552 'title' => t('Cron maintenance tasks'),
|
Chris@0
|
553 'severity' => $severity,
|
Chris@0
|
554 'value' => $summary,
|
Chris@0
|
555 ];
|
Chris@0
|
556 if ($severity != REQUIREMENT_INFO) {
|
Chris@0
|
557 $requirements['cron']['description'][] = [
|
Chris@0
|
558 [
|
Chris@0
|
559 '#markup' => t('Cron has not run recently.'),
|
Chris@0
|
560 '#suffix' => ' ',
|
Chris@0
|
561 ],
|
Chris@0
|
562 [
|
Chris@0
|
563 '#markup' => t('For more information, see the online handbook entry for <a href=":cron-handbook">configuring cron jobs</a>.', [':cron-handbook' => 'https://www.drupal.org/cron']),
|
Chris@0
|
564 '#suffix' => ' ',
|
Chris@0
|
565 ],
|
Chris@0
|
566 ];
|
Chris@0
|
567 }
|
Chris@0
|
568 $requirements['cron']['description'][] = [
|
Chris@0
|
569 [
|
Chris@0
|
570 '#type' => 'link',
|
Chris@0
|
571 '#prefix' => '(',
|
Chris@0
|
572 '#title' => t('more information'),
|
Chris@0
|
573 '#suffix' => ')',
|
Chris@0
|
574 '#url' => Url::fromRoute('system.cron_settings'),
|
Chris@0
|
575 ],
|
Chris@0
|
576 [
|
Chris@0
|
577 '#prefix' => '<span class="cron-description__run-cron">',
|
Chris@0
|
578 '#suffix' => '</span>',
|
Chris@0
|
579 '#type' => 'link',
|
Chris@0
|
580 '#title' => t('Run cron'),
|
Chris@0
|
581 '#url' => Url::fromRoute('system.run_cron'),
|
Chris@0
|
582 ],
|
Chris@0
|
583 ];
|
Chris@0
|
584 }
|
Chris@0
|
585 if ($phase != 'install') {
|
Chris@0
|
586 $filesystem_config = \Drupal::config('system.file');
|
Chris@0
|
587 $directories = [
|
Chris@0
|
588 PublicStream::basePath(),
|
Chris@0
|
589 // By default no private files directory is configured. For private files
|
Chris@0
|
590 // to be secure the admin needs to provide a path outside the webroot.
|
Chris@0
|
591 PrivateStream::basePath(),
|
Chris@0
|
592 file_directory_temp(),
|
Chris@0
|
593 ];
|
Chris@0
|
594 }
|
Chris@0
|
595
|
Chris@0
|
596 // During an install we need to make assumptions about the file system
|
Chris@0
|
597 // unless overrides are provided in settings.php.
|
Chris@0
|
598 if ($phase == 'install') {
|
Chris@0
|
599 $directories = [];
|
Chris@0
|
600 if ($file_public_path = Settings::get('file_public_path')) {
|
Chris@0
|
601 $directories[] = $file_public_path;
|
Chris@0
|
602 }
|
Chris@0
|
603 else {
|
Chris@0
|
604 // If we are installing Drupal, the settings.php file might not exist yet
|
Chris@0
|
605 // in the intended site directory, so don't require it.
|
Chris@0
|
606 $request = Request::createFromGlobals();
|
Chris@0
|
607 $site_path = DrupalKernel::findSitePath($request);
|
Chris@0
|
608 $directories[] = $site_path . '/files';
|
Chris@0
|
609 }
|
Chris@0
|
610 if ($file_private_path = Settings::get('file_private_path')) {
|
Chris@0
|
611 $directories[] = $file_private_path;
|
Chris@0
|
612 }
|
Chris@0
|
613 if (!empty($GLOBALS['config']['system.file']['path']['temporary'])) {
|
Chris@0
|
614 $directories[] = $GLOBALS['config']['system.file']['path']['temporary'];
|
Chris@0
|
615 }
|
Chris@0
|
616 else {
|
Chris@0
|
617 // If the temporary directory is not overridden use an appropriate
|
Chris@0
|
618 // temporary path for the system.
|
Chris@0
|
619 $directories[] = FileSystem::getOsTemporaryDirectory();
|
Chris@0
|
620 }
|
Chris@0
|
621 }
|
Chris@0
|
622
|
Chris@0
|
623 // Check the config directory if it is defined in settings.php. If it isn't
|
Chris@0
|
624 // defined, the installer will create a valid config directory later, but
|
Chris@0
|
625 // during runtime we must always display an error.
|
Chris@0
|
626 if (!empty($GLOBALS['config_directories'])) {
|
Chris@0
|
627 foreach (array_keys(array_filter($GLOBALS['config_directories'])) as $type) {
|
Chris@0
|
628 $directory = config_get_config_directory($type);
|
Chris@0
|
629 // If we're installing Drupal try and create the config sync directory.
|
Chris@0
|
630 if (!is_dir($directory) && $phase == 'install') {
|
Chris@0
|
631 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
|
Chris@0
|
632 }
|
Chris@0
|
633 if (!is_dir($directory)) {
|
Chris@0
|
634 if ($phase == 'install') {
|
Chris@0
|
635 $description = t('An automated attempt to create the directory %directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', ['%directory' => $directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']);
|
Chris@0
|
636 }
|
Chris@0
|
637 else {
|
Chris@0
|
638 $description = t('The directory %directory does not exist.', ['%directory' => $directory]);
|
Chris@0
|
639 }
|
Chris@0
|
640 $requirements['config directory ' . $type] = [
|
Chris@0
|
641 'title' => t('Configuration directory: %type', ['%type' => $type]),
|
Chris@0
|
642 'description' => $description,
|
Chris@0
|
643 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
644 ];
|
Chris@0
|
645 }
|
Chris@0
|
646 }
|
Chris@0
|
647 }
|
Chris@0
|
648 if ($phase != 'install' && (empty($GLOBALS['config_directories']) || empty($GLOBALS['config_directories'][CONFIG_SYNC_DIRECTORY]))) {
|
Chris@0
|
649 $requirements['config directories'] = [
|
Chris@0
|
650 'title' => t('Configuration directories'),
|
Chris@0
|
651 'value' => t('Not present'),
|
Chris@0
|
652 'description' => t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', ['%file' => $site_path . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY]),
|
Chris@0
|
653 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
654 ];
|
Chris@0
|
655 }
|
Chris@0
|
656
|
Chris@0
|
657 $requirements['file system'] = [
|
Chris@0
|
658 'title' => t('File system'),
|
Chris@0
|
659 ];
|
Chris@0
|
660
|
Chris@0
|
661 $error = '';
|
Chris@0
|
662 // For installer, create the directories if possible.
|
Chris@0
|
663 foreach ($directories as $directory) {
|
Chris@0
|
664 if (!$directory) {
|
Chris@0
|
665 continue;
|
Chris@0
|
666 }
|
Chris@0
|
667 if ($phase == 'install') {
|
Chris@0
|
668 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
|
Chris@0
|
669 }
|
Chris@0
|
670 $is_writable = is_writable($directory);
|
Chris@0
|
671 $is_directory = is_dir($directory);
|
Chris@0
|
672 if (!$is_writable || !$is_directory) {
|
Chris@0
|
673 $description = '';
|
Chris@0
|
674 $requirements['file system']['value'] = t('Not writable');
|
Chris@0
|
675 if (!$is_directory) {
|
Chris@0
|
676 $error = t('The directory %directory does not exist.', ['%directory' => $directory]);
|
Chris@0
|
677 }
|
Chris@0
|
678 else {
|
Chris@0
|
679 $error = t('The directory %directory is not writable.', ['%directory' => $directory]);
|
Chris@0
|
680 }
|
Chris@0
|
681 // The files directory requirement check is done only during install and runtime.
|
Chris@0
|
682 if ($phase == 'runtime') {
|
Chris@0
|
683 $description = t('You may need to set the correct directory at the <a href=":admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', [':admin-file-system' => \Drupal::url('system.file_system_settings')]);
|
Chris@0
|
684 }
|
Chris@0
|
685 elseif ($phase == 'install') {
|
Chris@0
|
686 // For the installer UI, we need different wording. 'value' will
|
Chris@0
|
687 // be treated as version, so provide none there.
|
Chris@0
|
688 $description = t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', [':handbook_url' => 'https://www.drupal.org/server-permissions']);
|
Chris@0
|
689 $requirements['file system']['value'] = '';
|
Chris@0
|
690 }
|
Chris@0
|
691 if (!empty($description)) {
|
Chris@0
|
692 $description = [
|
Chris@0
|
693 '#type' => 'inline_template',
|
Chris@0
|
694 '#template' => '{{ error }} {{ description }}',
|
Chris@0
|
695 '#context' => [
|
Chris@0
|
696 'error' => $error,
|
Chris@0
|
697 'description' => $description,
|
Chris@0
|
698 ],
|
Chris@0
|
699 ];
|
Chris@0
|
700 $requirements['file system']['description'] = $description;
|
Chris@0
|
701 $requirements['file system']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
702 }
|
Chris@0
|
703 }
|
Chris@0
|
704 else {
|
Chris@0
|
705 // This function can be called before the config_cache table has been
|
Chris@0
|
706 // created.
|
Chris@0
|
707 if ($phase == 'install' || file_default_scheme() == 'public') {
|
Chris@0
|
708 $requirements['file system']['value'] = t('Writable (<em>public</em> download method)');
|
Chris@0
|
709 }
|
Chris@0
|
710 else {
|
Chris@0
|
711 $requirements['file system']['value'] = t('Writable (<em>private</em> download method)');
|
Chris@0
|
712 }
|
Chris@0
|
713 }
|
Chris@0
|
714 }
|
Chris@0
|
715
|
Chris@0
|
716 // See if updates are available in update.php.
|
Chris@0
|
717 if ($phase == 'runtime') {
|
Chris@0
|
718 $requirements['update'] = [
|
Chris@0
|
719 'title' => t('Database updates'),
|
Chris@0
|
720 'value' => t('Up to date'),
|
Chris@0
|
721 ];
|
Chris@0
|
722
|
Chris@0
|
723 // Check installed modules.
|
Chris@0
|
724 $has_pending_updates = FALSE;
|
Chris@0
|
725 foreach (\Drupal::moduleHandler()->getModuleList() as $module => $filename) {
|
Chris@0
|
726 $updates = drupal_get_schema_versions($module);
|
Chris@0
|
727 if ($updates !== FALSE) {
|
Chris@0
|
728 $default = drupal_get_installed_schema_version($module);
|
Chris@0
|
729 if (max($updates) > $default) {
|
Chris@0
|
730 $has_pending_updates = TRUE;
|
Chris@0
|
731 break;
|
Chris@0
|
732 }
|
Chris@0
|
733 }
|
Chris@0
|
734 }
|
Chris@0
|
735 if (!$has_pending_updates) {
|
Chris@0
|
736 /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
|
Chris@0
|
737 $post_update_registry = \Drupal::service('update.post_update_registry');
|
Chris@0
|
738 $missing_post_update_functions = $post_update_registry->getPendingUpdateFunctions();
|
Chris@0
|
739 if (!empty($missing_post_update_functions)) {
|
Chris@0
|
740 $has_pending_updates = TRUE;
|
Chris@0
|
741 }
|
Chris@0
|
742 }
|
Chris@0
|
743
|
Chris@0
|
744 if ($has_pending_updates) {
|
Chris@0
|
745 $requirements['update']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
746 $requirements['update']['value'] = t('Out of date');
|
Chris@0
|
747 $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => \Drupal::url('system.db_update')]);
|
Chris@0
|
748 }
|
Chris@0
|
749
|
Chris@0
|
750 $requirements['entity_update'] = [
|
Chris@0
|
751 'title' => t('Entity/field definitions'),
|
Chris@0
|
752 'value' => t('Up to date'),
|
Chris@0
|
753 ];
|
Chris@0
|
754 // Verify that no entity updates are pending.
|
Chris@0
|
755 if ($change_list = \Drupal::entityDefinitionUpdateManager()->getChangeSummary()) {
|
Chris@0
|
756 $build = [];
|
Chris@0
|
757 foreach ($change_list as $entity_type_id => $changes) {
|
Chris@0
|
758 $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
|
Chris@0
|
759 $build[] = [
|
Chris@0
|
760 '#theme' => 'item_list',
|
Chris@0
|
761 '#title' => $entity_type->getLabel(),
|
Chris@0
|
762 '#items' => $changes,
|
Chris@0
|
763 ];
|
Chris@0
|
764 }
|
Chris@0
|
765
|
Chris@0
|
766 $entity_update_issues = \Drupal::service('renderer')->renderPlain($build);
|
Chris@0
|
767 $requirements['entity_update']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
768 $requirements['entity_update']['value'] = t('Mismatched entity and/or field definitions');
|
Chris@0
|
769 $requirements['entity_update']['description'] = t('The following changes were detected in the entity type and field definitions. @updates', ['@updates' => $entity_update_issues]);
|
Chris@0
|
770 }
|
Chris@0
|
771 }
|
Chris@0
|
772
|
Chris@0
|
773 // Verify the update.php access setting
|
Chris@0
|
774 if ($phase == 'runtime') {
|
Chris@0
|
775 if (Settings::get('update_free_access')) {
|
Chris@0
|
776 $requirements['update access'] = [
|
Chris@0
|
777 'value' => t('Not protected'),
|
Chris@0
|
778 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
779 'description' => t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the @settings_name value in your settings.php back to FALSE.', ['@settings_name' => '$settings[\'update_free_access\']']),
|
Chris@0
|
780 ];
|
Chris@0
|
781 }
|
Chris@0
|
782 else {
|
Chris@0
|
783 $requirements['update access'] = [
|
Chris@0
|
784 'value' => t('Protected'),
|
Chris@0
|
785 ];
|
Chris@0
|
786 }
|
Chris@0
|
787 $requirements['update access']['title'] = t('Access to update.php');
|
Chris@0
|
788 }
|
Chris@0
|
789
|
Chris@0
|
790 // Display an error if a newly introduced dependency in a module is not resolved.
|
Chris@0
|
791 if ($phase == 'update') {
|
Chris@0
|
792 $profile = drupal_get_profile();
|
Chris@0
|
793 $files = system_rebuild_module_data();
|
Chris@0
|
794 foreach ($files as $module => $file) {
|
Chris@0
|
795 // Ignore disabled modules and installation profiles.
|
Chris@0
|
796 if (!$file->status || $module == $profile) {
|
Chris@0
|
797 continue;
|
Chris@0
|
798 }
|
Chris@0
|
799 // Check the module's PHP version.
|
Chris@0
|
800 $name = $file->info['name'];
|
Chris@0
|
801 $php = $file->info['php'];
|
Chris@0
|
802 if (version_compare($php, PHP_VERSION, '>')) {
|
Chris@0
|
803 $requirements['php']['description'] .= t('@name requires at least PHP @version.', ['@name' => $name, '@version' => $php]);
|
Chris@0
|
804 $requirements['php']['severity'] = REQUIREMENT_ERROR;
|
Chris@0
|
805 }
|
Chris@0
|
806 // Check the module's required modules.
|
Chris@0
|
807 foreach ($file->requires as $requirement) {
|
Chris@0
|
808 $required_module = $requirement['name'];
|
Chris@0
|
809 // Check if the module exists.
|
Chris@0
|
810 if (!isset($files[$required_module])) {
|
Chris@0
|
811 $requirements["$module-$required_module"] = [
|
Chris@0
|
812 'title' => t('Unresolved dependency'),
|
Chris@0
|
813 'description' => t('@name requires this module.', ['@name' => $name]),
|
Chris@0
|
814 'value' => t('@required_name (Missing)', ['@required_name' => $required_module]),
|
Chris@0
|
815 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
816 ];
|
Chris@0
|
817 continue;
|
Chris@0
|
818 }
|
Chris@0
|
819 // Check for an incompatible version.
|
Chris@0
|
820 $required_file = $files[$required_module];
|
Chris@0
|
821 $required_name = $required_file->info['name'];
|
Chris@0
|
822 $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version']);
|
Chris@0
|
823 $compatibility = drupal_check_incompatibility($requirement, $version);
|
Chris@0
|
824 if ($compatibility) {
|
Chris@0
|
825 $compatibility = rtrim(substr($compatibility, 2), ')');
|
Chris@0
|
826 $requirements["$module-$required_module"] = [
|
Chris@0
|
827 'title' => t('Unresolved dependency'),
|
Chris@0
|
828 'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]),
|
Chris@0
|
829 'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $compatibility]),
|
Chris@0
|
830 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
831 ];
|
Chris@0
|
832 continue;
|
Chris@0
|
833 }
|
Chris@0
|
834 }
|
Chris@0
|
835 }
|
Chris@0
|
836 }
|
Chris@0
|
837
|
Chris@0
|
838 // Returns Unicode library status and errors.
|
Chris@0
|
839 $libraries = [
|
Chris@0
|
840 Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
|
Chris@0
|
841 Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
|
Chris@0
|
842 Unicode::STATUS_ERROR => t('Error'),
|
Chris@0
|
843 ];
|
Chris@0
|
844 $severities = [
|
Chris@0
|
845 Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
|
Chris@0
|
846 Unicode::STATUS_MULTIBYTE => NULL,
|
Chris@0
|
847 Unicode::STATUS_ERROR => REQUIREMENT_ERROR,
|
Chris@0
|
848 ];
|
Chris@0
|
849 $failed_check = Unicode::check();
|
Chris@0
|
850 $library = Unicode::getStatus();
|
Chris@0
|
851
|
Chris@0
|
852 $requirements['unicode'] = [
|
Chris@0
|
853 'title' => t('Unicode library'),
|
Chris@0
|
854 'value' => $libraries[$library],
|
Chris@0
|
855 'severity' => $severities[$library],
|
Chris@0
|
856 ];
|
Chris@0
|
857 switch ($failed_check) {
|
Chris@0
|
858 case 'mb_strlen':
|
Chris@0
|
859 $requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="http://php.net/mbstring">PHP mbstring extension</a> for improved Unicode support.');
|
Chris@0
|
860 break;
|
Chris@0
|
861
|
Chris@0
|
862 case 'mbstring.func_overload':
|
Chris@0
|
863 $requirements['unicode']['description'] = t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
Chris@0
|
864 break;
|
Chris@0
|
865
|
Chris@0
|
866 case 'mbstring.encoding_translation':
|
Chris@0
|
867 $requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
Chris@0
|
868 break;
|
Chris@0
|
869
|
Chris@0
|
870 case 'mbstring.http_input':
|
Chris@0
|
871 $requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
Chris@0
|
872 break;
|
Chris@0
|
873
|
Chris@0
|
874 case 'mbstring.http_output':
|
Chris@0
|
875 $requirements['unicode']['description'] = t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
Chris@0
|
876 break;
|
Chris@0
|
877 }
|
Chris@0
|
878
|
Chris@0
|
879 if ($phase == 'runtime') {
|
Chris@0
|
880 // Check for update status module.
|
Chris@0
|
881 if (!\Drupal::moduleHandler()->moduleExists('update')) {
|
Chris@0
|
882 $requirements['update status'] = [
|
Chris@0
|
883 'value' => t('Not enabled'),
|
Chris@0
|
884 'severity' => REQUIREMENT_WARNING,
|
Chris@0
|
885 'description' => t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the Update Manager module from the <a href=":module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href=":update">Update status handbook page</a>.', [
|
Chris@0
|
886 ':update' => 'https://www.drupal.org/documentation/modules/update',
|
Chris@0
|
887 ':module' => \Drupal::url('system.modules_list'),
|
Chris@0
|
888 ]),
|
Chris@0
|
889 ];
|
Chris@0
|
890 }
|
Chris@0
|
891 else {
|
Chris@0
|
892 $requirements['update status'] = [
|
Chris@0
|
893 'value' => t('Enabled'),
|
Chris@0
|
894 ];
|
Chris@0
|
895 }
|
Chris@0
|
896 $requirements['update status']['title'] = t('Update notifications');
|
Chris@0
|
897
|
Chris@0
|
898 if (Settings::get('rebuild_access')) {
|
Chris@0
|
899 $requirements['rebuild access'] = [
|
Chris@0
|
900 'title' => t('Rebuild access'),
|
Chris@0
|
901 'value' => t('Enabled'),
|
Chris@0
|
902 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
903 'description' => t('The rebuild_access setting is enabled in settings.php. It is recommended to have this setting disabled unless you are performing a rebuild.'),
|
Chris@0
|
904 ];
|
Chris@0
|
905 }
|
Chris@0
|
906 }
|
Chris@0
|
907
|
Chris@0
|
908 // See if trusted hostnames have been configured, and warn the user if they
|
Chris@0
|
909 // are not set.
|
Chris@0
|
910 if ($phase == 'runtime') {
|
Chris@0
|
911 $trusted_host_patterns = Settings::get('trusted_host_patterns');
|
Chris@0
|
912 if (empty($trusted_host_patterns)) {
|
Chris@0
|
913 $requirements['trusted_host_patterns'] = [
|
Chris@0
|
914 'title' => t('Trusted Host Settings'),
|
Chris@0
|
915 'value' => t('Not enabled'),
|
Chris@0
|
916 'description' => t('The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is <strong>highly recommended</strong> that you configure this. See <a href=":url">Protecting against HTTP HOST Header attacks</a> for more information.', [':url' => 'https://www.drupal.org/node/1992030']),
|
Chris@0
|
917 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
918 ];
|
Chris@0
|
919 }
|
Chris@0
|
920 else {
|
Chris@0
|
921 $requirements['trusted_host_patterns'] = [
|
Chris@0
|
922 'title' => t('Trusted Host Settings'),
|
Chris@0
|
923 'value' => t('Enabled'),
|
Chris@0
|
924 'description' => t('The trusted_host_patterns setting is set to allow %trusted_host_patterns', ['%trusted_host_patterns' => implode(', ', $trusted_host_patterns)]),
|
Chris@0
|
925 ];
|
Chris@0
|
926 }
|
Chris@0
|
927 }
|
Chris@0
|
928
|
Chris@0
|
929 // Check xdebug.max_nesting_level, as some pages will not work if it is too
|
Chris@0
|
930 // low.
|
Chris@0
|
931 if (extension_loaded('xdebug')) {
|
Chris@0
|
932 // Setting this value to 256 was considered adequate on Xdebug 2.3
|
Chris@0
|
933 // (see http://bugs.xdebug.org/bug_view_page.php?bug_id=00001100)
|
Chris@0
|
934 $minimum_nesting_level = 256;
|
Chris@0
|
935 $current_nesting_level = ini_get('xdebug.max_nesting_level');
|
Chris@0
|
936
|
Chris@0
|
937 if ($current_nesting_level < $minimum_nesting_level) {
|
Chris@0
|
938 $requirements['xdebug_max_nesting_level'] = [
|
Chris@0
|
939 'title' => t('Xdebug settings'),
|
Chris@0
|
940 'value' => t('xdebug.max_nesting_level is set to %value.', ['%value' => $current_nesting_level]),
|
Chris@0
|
941 'description' => t('Set <code>xdebug.max_nesting_level=@level</code> in your PHP configuration as some pages in your Drupal site will not work when this setting is too low.', ['@level' => $minimum_nesting_level]),
|
Chris@0
|
942 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
943 ];
|
Chris@0
|
944 }
|
Chris@0
|
945 }
|
Chris@0
|
946
|
Chris@0
|
947 // Warning for httpoxy on IIS with affected PHP versions
|
Chris@0
|
948 // @see https://www.drupal.org/node/2783079
|
Chris@0
|
949 if (strpos($software, 'Microsoft-IIS') !== FALSE
|
Chris@0
|
950 && (
|
Chris@0
|
951 version_compare(PHP_VERSION, '5.5.38', '<')
|
Chris@0
|
952 || (version_compare(PHP_VERSION, '5.6.0', '>=') && version_compare(PHP_VERSION, '5.6.24', '<'))
|
Chris@0
|
953 || (version_compare(PHP_VERSION, '7.0.0', '>=') && version_compare(PHP_VERSION, '7.0.9', '<'))
|
Chris@0
|
954 )) {
|
Chris@0
|
955 $dom = new \DOMDocument('1.0', 'UTF-8');
|
Chris@0
|
956 $webconfig = file_get_contents('web.config');
|
Chris@0
|
957 // If you are here the web.config file must - of course - be well formed.
|
Chris@0
|
958 // But the PHP DOM component will throw warnings on some XML compliant
|
Chris@0
|
959 // stuff, so silently parse the configuration file.
|
Chris@0
|
960 @$dom->loadHTML($webconfig);
|
Chris@0
|
961 $httpoxy_rewrite = FALSE;
|
Chris@0
|
962 foreach ($dom->getElementsByTagName('rule') as $rule) {
|
Chris@0
|
963 foreach ($rule->attributes as $attr) {
|
Chris@0
|
964 if (@$attr->name == 'name' && @$attr->nodeValue == 'Erase HTTP_PROXY') {
|
Chris@0
|
965 $httpoxy_rewrite = TRUE;
|
Chris@0
|
966 break 2;
|
Chris@0
|
967 }
|
Chris@0
|
968 }
|
Chris@0
|
969 }
|
Chris@0
|
970 if (!$httpoxy_rewrite) {
|
Chris@0
|
971 $requirements['iis_httpoxy_protection'] = [
|
Chris@0
|
972 'title' => t('IIS httpoxy protection'),
|
Chris@0
|
973 'value' => t('Your PHP runtime version is affected by the httpoxy vulnerability.'),
|
Chris@0
|
974 'description' => t('Either update your PHP runtime version or uncomment the "Erase HTTP_PROXY" rule in your web.config file and add HTTP_PROXY to the allowed headers list. See more details in the <a href=":link">security advisory</a>.', [':link' => 'https://www.drupal.org/SA-CORE-2016-003']),
|
Chris@0
|
975 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
976 ];
|
Chris@0
|
977 }
|
Chris@0
|
978 }
|
Chris@0
|
979
|
Chris@0
|
980 // Installations on Windows can run into limitations with MAX_PATH if the
|
Chris@0
|
981 // Drupal root directory is too deep in the filesystem. Generally this shows
|
Chris@0
|
982 // up in cached Twig templates and other public files with long directory or
|
Chris@0
|
983 // file names. There is no definite root directory depth below which Drupal is
|
Chris@0
|
984 // guaranteed to function correctly on Windows. Since problems are likely
|
Chris@0
|
985 // with more than 100 characters in the Drupal root path, show an error.
|
Chris@0
|
986 if (substr(PHP_OS, 0, 3) == 'WIN') {
|
Chris@0
|
987 $depth = strlen(realpath(DRUPAL_ROOT . '/' . PublicStream::basePath()));
|
Chris@0
|
988 if ($depth > 120) {
|
Chris@0
|
989 $requirements['max_path_on_windows'] = [
|
Chris@0
|
990 'title' => t('Windows installation depth'),
|
Chris@0
|
991 'description' => t('The public files directory path is %depth characters. Paths longer than 120 characters will cause problems on Windows.', ['%depth' => $depth]),
|
Chris@0
|
992 'severity' => REQUIREMENT_ERROR,
|
Chris@0
|
993 ];
|
Chris@0
|
994 }
|
Chris@0
|
995 }
|
Chris@0
|
996 // Check to see if dates will be limited to 1901-2038.
|
Chris@0
|
997 if (PHP_INT_SIZE <= 4) {
|
Chris@0
|
998 $requirements['limited_date_range'] = [
|
Chris@0
|
999 'title' => t('Limited date range'),
|
Chris@0
|
1000 'value' => t('Your PHP installation has a limited date range.'),
|
Chris@0
|
1001 'description' => t('You are running on a system where PHP is compiled or limited to using 32-bit integers. This will limit the range of dates and timestamps to the years 1901-2038. Read about the <a href=":url">limitations of 32-bit PHP</a>.', [':url' => 'https://www.drupal.org/docs/8/system-requirements/limitations-of-32-bit-php']),
|
Chris@0
|
1002 'severity' => REQUIREMENT_WARNING,
|
Chris@0
|
1003 ];
|
Chris@0
|
1004 }
|
Chris@0
|
1005
|
Chris@4
|
1006 // During installs from configuration don't support install profiles that
|
Chris@4
|
1007 // implement hook_install.
|
Chris@4
|
1008 if ($phase == 'install' && !empty($install_state['config_install_path'])) {
|
Chris@4
|
1009 $install_hook = $install_state['parameters']['profile'] . '_install';
|
Chris@4
|
1010 if (function_exists($install_hook)) {
|
Chris@4
|
1011 $requirements['config_install'] = [
|
Chris@4
|
1012 'title' => t('Configuration install'),
|
Chris@4
|
1013 'value' => $install_state['parameters']['profile'],
|
Chris@4
|
1014 'description' => t('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.'),
|
Chris@4
|
1015 'severity' => REQUIREMENT_ERROR,
|
Chris@4
|
1016 ];
|
Chris@4
|
1017 }
|
Chris@4
|
1018 }
|
Chris@4
|
1019
|
Chris@4
|
1020 if ($phase === 'runtime') {
|
Chris@4
|
1021 $settings = Settings::getAll();
|
Chris@4
|
1022 if (array_key_exists('install_profile', $settings)) {
|
Chris@4
|
1023 // The following message is only informational because not all site owners
|
Chris@4
|
1024 // have access to edit their settings.php as it may be controlled by their
|
Chris@4
|
1025 // hosting provider.
|
Chris@4
|
1026 $requirements['install_profile_in_settings'] = [
|
Chris@4
|
1027 'title' => t('Install profile in settings'),
|
Chris@4
|
1028 'value' => t("Drupal 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed."),
|
Chris@4
|
1029 'severity' => REQUIREMENT_INFO,
|
Chris@4
|
1030 ];
|
Chris@4
|
1031 }
|
Chris@4
|
1032 }
|
Chris@4
|
1033
|
Chris@0
|
1034 return $requirements;
|
Chris@0
|
1035 }
|
Chris@0
|
1036
|
Chris@0
|
1037 /**
|
Chris@0
|
1038 * Implements hook_install().
|
Chris@0
|
1039 */
|
Chris@0
|
1040 function system_install() {
|
Chris@0
|
1041 // Populate the cron key state variable.
|
Chris@0
|
1042 $cron_key = Crypt::randomBytesBase64(55);
|
Chris@0
|
1043 \Drupal::state()->set('system.cron_key', $cron_key);
|
Chris@0
|
1044
|
Chris@0
|
1045 // Populate the site UUID and default name (if not set).
|
Chris@0
|
1046 $site = \Drupal::configFactory()->getEditable('system.site');
|
Chris@0
|
1047 $site->set('uuid', \Drupal::service('uuid')->generate());
|
Chris@0
|
1048 if (!$site->get('name')) {
|
Chris@0
|
1049 $site->set('name', 'Drupal');
|
Chris@0
|
1050 }
|
Chris@0
|
1051 $site->save(TRUE);
|
Chris@0
|
1052 }
|
Chris@0
|
1053
|
Chris@0
|
1054 /**
|
Chris@0
|
1055 * Implements hook_schema().
|
Chris@0
|
1056 */
|
Chris@0
|
1057 function system_schema() {
|
Chris@0
|
1058 $schema['key_value'] = [
|
Chris@0
|
1059 'description' => 'Generic key-value storage table. See the state system for an example.',
|
Chris@0
|
1060 'fields' => [
|
Chris@0
|
1061 'collection' => [
|
Chris@0
|
1062 'description' => 'A named collection of key and value pairs.',
|
Chris@0
|
1063 'type' => 'varchar_ascii',
|
Chris@0
|
1064 'length' => 128,
|
Chris@0
|
1065 'not null' => TRUE,
|
Chris@0
|
1066 'default' => '',
|
Chris@0
|
1067 ],
|
Chris@0
|
1068 'name' => [
|
Chris@0
|
1069 'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
|
Chris@0
|
1070 'type' => 'varchar_ascii',
|
Chris@0
|
1071 'length' => 128,
|
Chris@0
|
1072 'not null' => TRUE,
|
Chris@0
|
1073 'default' => '',
|
Chris@0
|
1074 ],
|
Chris@0
|
1075 'value' => [
|
Chris@0
|
1076 'description' => 'The value.',
|
Chris@0
|
1077 'type' => 'blob',
|
Chris@0
|
1078 'not null' => TRUE,
|
Chris@0
|
1079 'size' => 'big',
|
Chris@0
|
1080 ],
|
Chris@0
|
1081 ],
|
Chris@0
|
1082 'primary key' => ['collection', 'name'],
|
Chris@0
|
1083 ];
|
Chris@0
|
1084
|
Chris@0
|
1085 $schema['key_value_expire'] = [
|
Chris@0
|
1086 'description' => 'Generic key/value storage table with an expiration.',
|
Chris@0
|
1087 'fields' => [
|
Chris@0
|
1088 'collection' => [
|
Chris@0
|
1089 'description' => 'A named collection of key and value pairs.',
|
Chris@0
|
1090 'type' => 'varchar_ascii',
|
Chris@0
|
1091 'length' => 128,
|
Chris@0
|
1092 'not null' => TRUE,
|
Chris@0
|
1093 'default' => '',
|
Chris@0
|
1094 ],
|
Chris@0
|
1095 'name' => [
|
Chris@0
|
1096 // KEY is an SQL reserved word, so use 'name' as the key's field name.
|
Chris@0
|
1097 'description' => 'The key of the key/value pair.',
|
Chris@0
|
1098 'type' => 'varchar_ascii',
|
Chris@0
|
1099 'length' => 128,
|
Chris@0
|
1100 'not null' => TRUE,
|
Chris@0
|
1101 'default' => '',
|
Chris@0
|
1102 ],
|
Chris@0
|
1103 'value' => [
|
Chris@0
|
1104 'description' => 'The value of the key/value pair.',
|
Chris@0
|
1105 'type' => 'blob',
|
Chris@0
|
1106 'not null' => TRUE,
|
Chris@0
|
1107 'size' => 'big',
|
Chris@0
|
1108 ],
|
Chris@0
|
1109 'expire' => [
|
Chris@0
|
1110 'description' => 'The time since Unix epoch in seconds when this item expires. Defaults to the maximum possible time.',
|
Chris@0
|
1111 'type' => 'int',
|
Chris@0
|
1112 'not null' => TRUE,
|
Chris@0
|
1113 'default' => 2147483647,
|
Chris@0
|
1114 ],
|
Chris@0
|
1115 ],
|
Chris@0
|
1116 'primary key' => ['collection', 'name'],
|
Chris@0
|
1117 'indexes' => [
|
Chris@0
|
1118 'all' => ['name', 'collection', 'expire'],
|
Chris@0
|
1119 'expire' => ['expire'],
|
Chris@0
|
1120 ],
|
Chris@0
|
1121 ];
|
Chris@0
|
1122
|
Chris@0
|
1123 $schema['sequences'] = [
|
Chris@0
|
1124 'description' => 'Stores IDs.',
|
Chris@0
|
1125 'fields' => [
|
Chris@0
|
1126 'value' => [
|
Chris@0
|
1127 'description' => 'The value of the sequence.',
|
Chris@0
|
1128 'type' => 'serial',
|
Chris@0
|
1129 'unsigned' => TRUE,
|
Chris@0
|
1130 'not null' => TRUE,
|
Chris@0
|
1131 ],
|
Chris@0
|
1132 ],
|
Chris@0
|
1133 'primary key' => ['value'],
|
Chris@0
|
1134 ];
|
Chris@0
|
1135
|
Chris@0
|
1136 $schema['sessions'] = [
|
Chris@0
|
1137 'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
|
Chris@0
|
1138 'fields' => [
|
Chris@0
|
1139 'uid' => [
|
Chris@0
|
1140 'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
|
Chris@0
|
1141 'type' => 'int',
|
Chris@0
|
1142 'unsigned' => TRUE,
|
Chris@0
|
1143 'not null' => TRUE,
|
Chris@0
|
1144 ],
|
Chris@0
|
1145 'sid' => [
|
Chris@0
|
1146 'description' => "A session ID (hashed). The value is generated by Drupal's session handlers.",
|
Chris@0
|
1147 'type' => 'varchar_ascii',
|
Chris@0
|
1148 'length' => 128,
|
Chris@0
|
1149 'not null' => TRUE,
|
Chris@0
|
1150 ],
|
Chris@0
|
1151 'hostname' => [
|
Chris@0
|
1152 'description' => 'The IP address that last used this session ID (sid).',
|
Chris@0
|
1153 'type' => 'varchar_ascii',
|
Chris@0
|
1154 'length' => 128,
|
Chris@0
|
1155 'not null' => TRUE,
|
Chris@0
|
1156 'default' => '',
|
Chris@0
|
1157 ],
|
Chris@0
|
1158 'timestamp' => [
|
Chris@0
|
1159 'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.',
|
Chris@0
|
1160 'type' => 'int',
|
Chris@0
|
1161 'not null' => TRUE,
|
Chris@0
|
1162 'default' => 0,
|
Chris@0
|
1163 ],
|
Chris@0
|
1164 'session' => [
|
Chris@0
|
1165 'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.',
|
Chris@0
|
1166 'type' => 'blob',
|
Chris@0
|
1167 'not null' => FALSE,
|
Chris@0
|
1168 'size' => 'big',
|
Chris@0
|
1169 ],
|
Chris@0
|
1170 ],
|
Chris@0
|
1171 'primary key' => [
|
Chris@0
|
1172 'sid',
|
Chris@0
|
1173 ],
|
Chris@0
|
1174 'indexes' => [
|
Chris@0
|
1175 'timestamp' => ['timestamp'],
|
Chris@0
|
1176 'uid' => ['uid'],
|
Chris@0
|
1177 ],
|
Chris@0
|
1178 'foreign keys' => [
|
Chris@0
|
1179 'session_user' => [
|
Chris@0
|
1180 'table' => 'users',
|
Chris@0
|
1181 'columns' => ['uid' => 'uid'],
|
Chris@0
|
1182 ],
|
Chris@0
|
1183 ],
|
Chris@0
|
1184 ];
|
Chris@0
|
1185
|
Chris@0
|
1186 // Create the url_alias table. The alias_storage service can auto-create its
|
Chris@0
|
1187 // table, but this relies on exceptions being thrown. These exceptions will be
|
Chris@0
|
1188 // thrown every request until an alias is created.
|
Chris@0
|
1189 $schema['url_alias'] = AliasStorage::schemaDefinition();
|
Chris@0
|
1190
|
Chris@0
|
1191 return $schema;
|
Chris@0
|
1192 }
|
Chris@0
|
1193
|
Chris@0
|
1194 /**
|
Chris@0
|
1195 * Change two fields on the default menu link storage to be serialized data.
|
Chris@0
|
1196 */
|
Chris@0
|
1197 function system_update_8001(&$sandbox = NULL) {
|
Chris@0
|
1198 $database = \Drupal::database();
|
Chris@0
|
1199 $schema = $database->schema();
|
Chris@0
|
1200 if ($schema->tableExists('menu_tree')) {
|
Chris@0
|
1201
|
Chris@0
|
1202 if (!isset($sandbox['current'])) {
|
Chris@0
|
1203 // Converting directly to blob can cause problems with reading out and
|
Chris@0
|
1204 // serializing the string data later on postgres, so rename the existing
|
Chris@0
|
1205 // columns and create replacement ones to hold the serialized objects.
|
Chris@0
|
1206 $old_fields = [
|
Chris@0
|
1207 'title' => [
|
Chris@0
|
1208 'description' => 'The text displayed for the link.',
|
Chris@0
|
1209 'type' => 'varchar',
|
Chris@0
|
1210 'length' => 255,
|
Chris@0
|
1211 'not null' => TRUE,
|
Chris@0
|
1212 'default' => '',
|
Chris@0
|
1213 ],
|
Chris@0
|
1214 'description' => [
|
Chris@0
|
1215 'description' => 'The description of this link - used for admin pages and title attribute.',
|
Chris@0
|
1216 'type' => 'text',
|
Chris@0
|
1217 'not null' => FALSE,
|
Chris@0
|
1218 ],
|
Chris@0
|
1219 ];
|
Chris@0
|
1220 foreach ($old_fields as $name => $spec) {
|
Chris@0
|
1221 $schema->changeField('menu_tree', $name, 'system_update_8001_' . $name, $spec);
|
Chris@0
|
1222 }
|
Chris@0
|
1223 $spec = [
|
Chris@0
|
1224 'description' => 'The title for the link. May be a serialized TranslatableMarkup.',
|
Chris@0
|
1225 'type' => 'blob',
|
Chris@0
|
1226 'size' => 'big',
|
Chris@0
|
1227 'not null' => FALSE,
|
Chris@0
|
1228 'serialize' => TRUE,
|
Chris@0
|
1229 ];
|
Chris@0
|
1230 $schema->addField('menu_tree', 'title', $spec);
|
Chris@0
|
1231 $spec = [
|
Chris@0
|
1232 'description' => 'The description of this link - used for admin pages and title attribute.',
|
Chris@0
|
1233 'type' => 'blob',
|
Chris@0
|
1234 'size' => 'big',
|
Chris@0
|
1235 'not null' => FALSE,
|
Chris@0
|
1236 'serialize' => TRUE,
|
Chris@0
|
1237 ];
|
Chris@0
|
1238 $schema->addField('menu_tree', 'description', $spec);
|
Chris@0
|
1239
|
Chris@0
|
1240 $sandbox['current'] = 0;
|
Chris@0
|
1241 $sandbox['max'] = $database->query('SELECT COUNT(mlid) FROM {menu_tree}')
|
Chris@0
|
1242 ->fetchField();
|
Chris@0
|
1243 }
|
Chris@0
|
1244
|
Chris@0
|
1245 $menu_links = $database->queryRange('SELECT mlid, system_update_8001_title AS title, system_update_8001_description AS description FROM {menu_tree} ORDER BY mlid ASC', $sandbox['current'], $sandbox['current'] + 50)
|
Chris@0
|
1246 ->fetchAllAssoc('mlid');
|
Chris@0
|
1247
|
Chris@0
|
1248 foreach ($menu_links as $menu_link) {
|
Chris@0
|
1249 $menu_link = (array) $menu_link;
|
Chris@0
|
1250 // Convert title and description to serialized strings.
|
Chris@0
|
1251 $menu_link['title'] = serialize($menu_link['title']);
|
Chris@0
|
1252 $menu_link['description'] = serialize($menu_link['description']);
|
Chris@0
|
1253
|
Chris@0
|
1254 $database->update('menu_tree')
|
Chris@0
|
1255 ->fields($menu_link)
|
Chris@0
|
1256 ->condition('mlid', $menu_link['mlid'])
|
Chris@0
|
1257 ->execute();
|
Chris@0
|
1258
|
Chris@0
|
1259 $sandbox['current']++;
|
Chris@0
|
1260 }
|
Chris@0
|
1261
|
Chris@0
|
1262 $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']);
|
Chris@0
|
1263
|
Chris@0
|
1264 if ($sandbox['#finished'] >= 1) {
|
Chris@0
|
1265 // Drop unnecessary fields from {menu_tree}.
|
Chris@0
|
1266 $schema->dropField('menu_tree', 'system_update_8001_title');
|
Chris@0
|
1267 $schema->dropField('menu_tree', 'title_arguments');
|
Chris@0
|
1268 $schema->dropField('menu_tree', 'title_context');
|
Chris@0
|
1269 $schema->dropField('menu_tree', 'system_update_8001_description');
|
Chris@0
|
1270 }
|
Chris@0
|
1271 return t('Menu links converted');
|
Chris@0
|
1272 }
|
Chris@0
|
1273 else {
|
Chris@0
|
1274 return t('Menu link conversion skipped, because the {menu_tree} table did not exist yet.');
|
Chris@0
|
1275 }
|
Chris@0
|
1276 }
|
Chris@0
|
1277
|
Chris@0
|
1278 /**
|
Chris@0
|
1279 * Removes the system.filter configuration.
|
Chris@0
|
1280 */
|
Chris@0
|
1281 function system_update_8002() {
|
Chris@0
|
1282 \Drupal::configFactory()->getEditable('system.filter')->delete();
|
Chris@0
|
1283 return t('The system.filter configuration has been moved to a container parameter, see default.services.yml for more information.');
|
Chris@0
|
1284 }
|
Chris@0
|
1285
|
Chris@0
|
1286 /**
|
Chris@0
|
1287 * Change the index on the {router} table.
|
Chris@0
|
1288 */
|
Chris@0
|
1289 function system_update_8003() {
|
Chris@0
|
1290 $database = \Drupal::database();
|
Chris@0
|
1291 $database->schema()->dropIndex('router', 'pattern_outline_fit');
|
Chris@0
|
1292 $database->schema()->addIndex(
|
Chris@0
|
1293 'router',
|
Chris@0
|
1294 'pattern_outline_parts',
|
Chris@0
|
1295 ['pattern_outline', 'number_parts'],
|
Chris@0
|
1296 [
|
Chris@0
|
1297 'fields' => [
|
Chris@0
|
1298 'pattern_outline' => [
|
Chris@0
|
1299 'description' => 'The pattern',
|
Chris@0
|
1300 'type' => 'varchar',
|
Chris@0
|
1301 'length' => 255,
|
Chris@0
|
1302 'not null' => TRUE,
|
Chris@0
|
1303 'default' => '',
|
Chris@0
|
1304 ],
|
Chris@0
|
1305 'number_parts' => [
|
Chris@0
|
1306 'description' => 'Number of parts in this router path.',
|
Chris@0
|
1307 'type' => 'int',
|
Chris@0
|
1308 'not null' => TRUE,
|
Chris@0
|
1309 'default' => 0,
|
Chris@0
|
1310 'size' => 'small',
|
Chris@0
|
1311 ],
|
Chris@0
|
1312 ],
|
Chris@0
|
1313 ]
|
Chris@0
|
1314 );
|
Chris@0
|
1315 }
|
Chris@0
|
1316
|
Chris@0
|
1317 /**
|
Chris@0
|
1318 * Add a (id, default_langcode, langcode) composite index to entities.
|
Chris@0
|
1319 */
|
Chris@0
|
1320 function system_update_8004() {
|
Chris@0
|
1321 // \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema was changed in
|
Chris@0
|
1322 // https://www.drupal.org/node/2261669 to include a (id, default_langcode,
|
Chris@0
|
1323 // langcode) compound index, but this update function wasn't added until
|
Chris@0
|
1324 // https://www.drupal.org/node/2542748. Regenerate the related schemas to
|
Chris@0
|
1325 // ensure they match the currently expected status.
|
Chris@0
|
1326 $manager = \Drupal::entityDefinitionUpdateManager();
|
Chris@0
|
1327 foreach (array_keys(\Drupal::entityManager()
|
Chris@0
|
1328 ->getDefinitions()) as $entity_type_id) {
|
Chris@0
|
1329 // Only update the entity type if it already exists. This condition is
|
Chris@0
|
1330 // needed in case new entity types are introduced after this update.
|
Chris@0
|
1331 if ($entity_type = $manager->getEntityType($entity_type_id)) {
|
Chris@0
|
1332 $manager->updateEntityType($entity_type);
|
Chris@0
|
1333 }
|
Chris@0
|
1334 }
|
Chris@0
|
1335 }
|
Chris@0
|
1336
|
Chris@0
|
1337 /**
|
Chris@0
|
1338 * Place local actions and tasks blocks in every theme.
|
Chris@0
|
1339 */
|
Chris@0
|
1340 function system_update_8005() {
|
Chris@0
|
1341 // When block module is not installed, there is nothing that could be done
|
Chris@0
|
1342 // except showing a warning.
|
Chris@0
|
1343 if (!\Drupal::moduleHandler()->moduleExists('block')) {
|
Chris@0
|
1344 return t('Block module is not enabled so local actions and tasks which have been converted to blocks, are not visible anymore.');
|
Chris@0
|
1345 }
|
Chris@0
|
1346 $config_factory = \Drupal::configFactory();
|
Chris@0
|
1347 /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
|
Chris@0
|
1348 $theme_handler = \Drupal::service('theme_handler');
|
Chris@0
|
1349 $custom_themes_installed = FALSE;
|
Chris@0
|
1350 $message = NULL;
|
Chris@0
|
1351 $langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
|
Chris@0
|
1352
|
Chris@0
|
1353 $local_actions_default_settings = [
|
Chris@0
|
1354 'plugin' => 'local_actions_block',
|
Chris@0
|
1355 'region' => 'content',
|
Chris@0
|
1356 'settings.label' => 'Primary admin actions',
|
Chris@0
|
1357 'settings.label_display' => 0,
|
Chris@0
|
1358 'settings.cache.max_age' => 0,
|
Chris@0
|
1359 'visibility' => [],
|
Chris@0
|
1360 'weight' => 0,
|
Chris@0
|
1361 'langcode' => $langcode,
|
Chris@0
|
1362 ];
|
Chris@0
|
1363 $tabs_default_settings = [
|
Chris@0
|
1364 'plugin' => 'local_tasks_block',
|
Chris@0
|
1365 'region' => 'content',
|
Chris@0
|
1366 'settings.label' => 'Tabs',
|
Chris@0
|
1367 'settings.label_display' => 0,
|
Chris@0
|
1368 'settings.cache.max_age' => 0,
|
Chris@0
|
1369 'visibility' => [],
|
Chris@0
|
1370 'weight' => 0,
|
Chris@0
|
1371 'langcode' => $langcode,
|
Chris@0
|
1372 ];
|
Chris@0
|
1373 foreach ($theme_handler->listInfo() as $theme) {
|
Chris@0
|
1374 $theme_name = $theme->getName();
|
Chris@0
|
1375 switch ($theme_name) {
|
Chris@0
|
1376 case 'bartik':
|
Chris@0
|
1377 $name = 'block.block.bartik_local_actions';
|
Chris@0
|
1378 $values = [
|
Chris@0
|
1379 'id' => 'bartik_local_actions',
|
Chris@0
|
1380 'weight' => -1,
|
Chris@0
|
1381 ] + $local_actions_default_settings;
|
Chris@0
|
1382 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1383
|
Chris@0
|
1384 $name = 'block.block.bartik_local_tasks';
|
Chris@0
|
1385 $values = [
|
Chris@0
|
1386 'id' => 'bartik_local_tasks',
|
Chris@0
|
1387 'weight' => -7,
|
Chris@0
|
1388 ] + $tabs_default_settings;
|
Chris@0
|
1389 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1390
|
Chris@0
|
1391 // Help region has been removed so all the blocks inside has to be moved
|
Chris@0
|
1392 // to content region.
|
Chris@0
|
1393 $weight = -6;
|
Chris@0
|
1394 $blocks = [];
|
Chris@0
|
1395 foreach ($config_factory->listAll('block.block.') as $block_config) {
|
Chris@0
|
1396 $block = $config_factory->getEditable($block_config);
|
Chris@0
|
1397 if ($block->get('theme') == 'bartik' && $block->get('region') == 'help') {
|
Chris@0
|
1398 $blocks[] = $block;
|
Chris@0
|
1399 }
|
Chris@0
|
1400 }
|
Chris@0
|
1401 // Sort blocks by block weight.
|
Chris@0
|
1402 uasort($blocks, function ($a, $b) {
|
Chris@0
|
1403 return $a->get('weight') - $b->get('weight');
|
Chris@0
|
1404 });
|
Chris@0
|
1405 // Move blocks to content region and set them in right order by their
|
Chris@0
|
1406 // weight.
|
Chris@0
|
1407 foreach ($blocks as $block) {
|
Chris@0
|
1408 $block->set('region', 'content');
|
Chris@0
|
1409 $block->set('weight', $weight++);
|
Chris@0
|
1410 $block->save();
|
Chris@0
|
1411 }
|
Chris@0
|
1412 break;
|
Chris@0
|
1413
|
Chris@0
|
1414 case 'seven':
|
Chris@0
|
1415 $name = 'block.block.seven_local_actions';
|
Chris@0
|
1416 $values = [
|
Chris@0
|
1417 'id' => 'seven_local_actions',
|
Chris@0
|
1418 'weight' => -10,
|
Chris@0
|
1419 ] + $local_actions_default_settings;
|
Chris@0
|
1420 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1421
|
Chris@0
|
1422 $name = 'block.block.seven_primary_local_tasks';
|
Chris@0
|
1423 $values = [
|
Chris@0
|
1424 'region' => 'header',
|
Chris@0
|
1425 'id' => 'seven_primary_local_tasks',
|
Chris@0
|
1426 'settings.label' => 'Primary tabs',
|
Chris@0
|
1427 'settings.primary' => TRUE,
|
Chris@0
|
1428 'settings.secondary' => FALSE,
|
Chris@0
|
1429 ] + $tabs_default_settings;
|
Chris@0
|
1430 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1431
|
Chris@0
|
1432 $name = 'block.block.seven_secondary_local_tasks';
|
Chris@0
|
1433 $values = [
|
Chris@0
|
1434 'region' => 'pre_content',
|
Chris@0
|
1435 'id' => 'seven_secondary_local_tasks',
|
Chris@0
|
1436 'settings.label' => 'Secondary tabs',
|
Chris@0
|
1437 'settings.primary' => FALSE,
|
Chris@0
|
1438 'settings.secondary' => TRUE,
|
Chris@0
|
1439 ] + $tabs_default_settings;
|
Chris@0
|
1440 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1441 break;
|
Chris@0
|
1442
|
Chris@0
|
1443 case 'stark':
|
Chris@0
|
1444 $name = 'block.block.stark_local_actions';
|
Chris@0
|
1445 $values = [
|
Chris@0
|
1446 'id' => 'stark_local_actions',
|
Chris@0
|
1447 ] + $local_actions_default_settings;
|
Chris@0
|
1448 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1449
|
Chris@0
|
1450 $name = 'block.block.stark_local_tasks';
|
Chris@0
|
1451 $values = [
|
Chris@0
|
1452 'id' => 'stark_local_tasks',
|
Chris@0
|
1453 ] + $tabs_default_settings;
|
Chris@0
|
1454 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1455 break;
|
Chris@0
|
1456
|
Chris@0
|
1457 case 'classy':
|
Chris@0
|
1458 case 'stable':
|
Chris@0
|
1459 // Don't place any blocks or trigger custom themes installed warning.
|
Chris@0
|
1460 break;
|
Chris@0
|
1461
|
Chris@0
|
1462 default:
|
Chris@0
|
1463 $custom_themes_installed = TRUE;
|
Chris@0
|
1464 $name = 'block.block.' . $theme_name . '_local_actions';
|
Chris@0
|
1465 $values = [
|
Chris@0
|
1466 'id' => $theme_name . '_local_actions',
|
Chris@0
|
1467 'weight' => -10,
|
Chris@0
|
1468 ] + $local_actions_default_settings;
|
Chris@0
|
1469 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1470
|
Chris@0
|
1471 $name = sprintf('block.block.%s_local_tasks', $theme_name);
|
Chris@0
|
1472 $values = [
|
Chris@0
|
1473 'id' => $theme_name . '_local_tasks',
|
Chris@0
|
1474 'weight' => -20,
|
Chris@0
|
1475 ] + $tabs_default_settings;
|
Chris@0
|
1476 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1477 break;
|
Chris@0
|
1478 }
|
Chris@0
|
1479 }
|
Chris@0
|
1480
|
Chris@0
|
1481 if ($custom_themes_installed) {
|
Chris@0
|
1482 $message = t('Because your site has custom theme(s) installed, we had to set local actions and tasks blocks into the content region. Please manually review the block configurations and remove the removed variables from your templates.');
|
Chris@0
|
1483 }
|
Chris@0
|
1484
|
Chris@0
|
1485 return $message;
|
Chris@0
|
1486 }
|
Chris@0
|
1487
|
Chris@0
|
1488 /**
|
Chris@0
|
1489 * Place branding blocks in every theme.
|
Chris@0
|
1490 */
|
Chris@0
|
1491 function system_update_8006() {
|
Chris@0
|
1492 // When block module is not installed, there is nothing that could be done
|
Chris@0
|
1493 // except showing a warning.
|
Chris@0
|
1494 if (!\Drupal::moduleHandler()->moduleExists('block')) {
|
Chris@0
|
1495 return t('Block module is not enabled so site branding elements, which have been converted to a block, are not visible anymore.');
|
Chris@0
|
1496 }
|
Chris@0
|
1497
|
Chris@0
|
1498 /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
|
Chris@0
|
1499 $theme_handler = \Drupal::service('theme_handler');
|
Chris@0
|
1500 $custom_themes_installed = FALSE;
|
Chris@0
|
1501 $message = NULL;
|
Chris@0
|
1502 $langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
|
Chris@0
|
1503
|
Chris@0
|
1504 $site_branding_default_settings = [
|
Chris@0
|
1505 'plugin' => 'system_branding_block',
|
Chris@0
|
1506 'region' => 'content',
|
Chris@0
|
1507 'settings.label' => 'Site branding',
|
Chris@0
|
1508 'settings.label_display' => 0,
|
Chris@0
|
1509 'visibility' => [],
|
Chris@0
|
1510 'weight' => 0,
|
Chris@0
|
1511 'langcode' => $langcode,
|
Chris@0
|
1512 ];
|
Chris@0
|
1513 foreach ($theme_handler->listInfo() as $theme) {
|
Chris@0
|
1514 $theme_name = $theme->getName();
|
Chris@0
|
1515 switch ($theme_name) {
|
Chris@0
|
1516 case 'bartik':
|
Chris@0
|
1517 $name = 'block.block.bartik_branding';
|
Chris@0
|
1518 $values = [
|
Chris@0
|
1519 'id' => 'bartik_branding',
|
Chris@0
|
1520 'region' => 'header',
|
Chris@0
|
1521 ] + $site_branding_default_settings;
|
Chris@0
|
1522 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1523 break;
|
Chris@0
|
1524
|
Chris@0
|
1525 case 'stark':
|
Chris@0
|
1526 $name = 'block.block.stark_branding';
|
Chris@0
|
1527 $values = [
|
Chris@0
|
1528 'id' => 'stark_branding',
|
Chris@0
|
1529 'region' => 'header',
|
Chris@0
|
1530 ] + $site_branding_default_settings;
|
Chris@0
|
1531 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1532 break;
|
Chris@0
|
1533
|
Chris@0
|
1534 case 'seven':
|
Chris@0
|
1535 case 'classy':
|
Chris@0
|
1536 case 'stable':
|
Chris@0
|
1537 // Don't place any blocks or trigger custom themes installed warning.
|
Chris@0
|
1538 break;
|
Chris@0
|
1539 default:
|
Chris@0
|
1540 $custom_themes_installed = TRUE;
|
Chris@0
|
1541 $name = sprintf('block.block.%s_branding', $theme_name);
|
Chris@0
|
1542 $values = [
|
Chris@0
|
1543 'id' => sprintf('%s_branding', $theme_name),
|
Chris@0
|
1544 'region' => 'content',
|
Chris@0
|
1545 'weight' => '-50',
|
Chris@0
|
1546 ] + $site_branding_default_settings;
|
Chris@0
|
1547 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1548 break;
|
Chris@0
|
1549 }
|
Chris@0
|
1550 }
|
Chris@0
|
1551
|
Chris@0
|
1552 if ($custom_themes_installed) {
|
Chris@0
|
1553 $message = t('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.');
|
Chris@0
|
1554 }
|
Chris@0
|
1555
|
Chris@0
|
1556 return $message;
|
Chris@0
|
1557 }
|
Chris@0
|
1558
|
Chris@0
|
1559 /**
|
Chris@0
|
1560 * Helper function to create block configuration objects for an update.
|
Chris@0
|
1561 *
|
Chris@0
|
1562 * @param string $name
|
Chris@0
|
1563 * The name of the config object.
|
Chris@0
|
1564 * @param string $theme_name
|
Chris@0
|
1565 * The name of the theme the block is associated with.
|
Chris@0
|
1566 * @param array $values
|
Chris@0
|
1567 * The block config values.
|
Chris@0
|
1568 */
|
Chris@0
|
1569 function _system_update_create_block($name, $theme_name, array $values) {
|
Chris@0
|
1570 if (!\Drupal::service('config.storage')->exists($name)) {
|
Chris@0
|
1571 $block = \Drupal::configFactory()->getEditable($name);
|
Chris@0
|
1572 $values['uuid'] = \Drupal::service('uuid')->generate();
|
Chris@0
|
1573 $values['theme'] = $theme_name;
|
Chris@0
|
1574 $values['dependencies.theme'] = [$theme_name];
|
Chris@0
|
1575 foreach ($values as $key => $value) {
|
Chris@0
|
1576 $block->set($key, $value);
|
Chris@0
|
1577 }
|
Chris@0
|
1578 $block->save();
|
Chris@0
|
1579 }
|
Chris@0
|
1580 }
|
Chris@0
|
1581
|
Chris@0
|
1582 /**
|
Chris@0
|
1583 * Set langcode fields to be ASCII-only.
|
Chris@0
|
1584 */
|
Chris@0
|
1585 function system_update_8007() {
|
Chris@0
|
1586 $database = \Drupal::database();
|
Chris@0
|
1587 $database_schema = $database->schema();
|
Chris@0
|
1588 $entity_types = \Drupal::entityManager()->getDefinitions();
|
Chris@0
|
1589
|
Chris@0
|
1590 $schema = \Drupal::keyValue('entity.storage_schema.sql')->getAll();
|
Chris@0
|
1591 $schema_copy = $schema;
|
Chris@0
|
1592 foreach ($schema as $item_name => $item) {
|
Chris@0
|
1593 list($entity_type_id, ,) = explode('.', $item_name);
|
Chris@0
|
1594 if (!isset($entity_types[$entity_type_id])) {
|
Chris@0
|
1595 continue;
|
Chris@0
|
1596 }
|
Chris@0
|
1597 foreach ($item as $table_name => $table_schema) {
|
Chris@0
|
1598 foreach ($table_schema as $schema_key => $schema_data) {
|
Chris@0
|
1599 if ($schema_key == 'fields') {
|
Chris@0
|
1600 foreach ($schema_data as $field_name => $field_data) {
|
Chris@0
|
1601 foreach ($field_data as $field_data_property => $field_data_value) {
|
Chris@0
|
1602 // Langcode fields have the property 'is_ascii' set, instead
|
Chris@0
|
1603 // they should have set the type to 'varchar_ascii'.
|
Chris@0
|
1604 if ($field_data_property == 'is_ascii') {
|
Chris@0
|
1605 unset($schema_copy[$item_name][$table_name]['fields'][$field_name]['is_ascii']);
|
Chris@0
|
1606 $schema_copy[$item_name][$table_name]['fields'][$field_name]['type'] = 'varchar_ascii';
|
Chris@0
|
1607 if ($database->driver() == 'mysql') {
|
Chris@0
|
1608 $database_schema->changeField($table_name, $field_name, $field_name, $schema_copy[$item_name][$table_name]['fields'][$field_name]);
|
Chris@0
|
1609 }
|
Chris@0
|
1610 }
|
Chris@0
|
1611 }
|
Chris@0
|
1612 }
|
Chris@0
|
1613 }
|
Chris@0
|
1614 }
|
Chris@0
|
1615 }
|
Chris@0
|
1616 }
|
Chris@0
|
1617 \Drupal::keyValue('entity.storage_schema.sql')->setMultiple($schema_copy);
|
Chris@0
|
1618
|
Chris@0
|
1619 $definitions = \Drupal::keyValue('entity.definitions.installed')->getAll();
|
Chris@0
|
1620 $definitions_copy = $definitions;
|
Chris@0
|
1621 foreach ($definitions as $item_name => $item_value) {
|
Chris@0
|
1622 $suffix = '.field_storage_definitions';
|
Chris@0
|
1623 if (substr($item_name, -strlen($suffix)) == $suffix) {
|
Chris@0
|
1624 foreach ($item_value as $field_name => $field_definition) {
|
Chris@0
|
1625 $reflection = new \ReflectionObject($field_definition);
|
Chris@0
|
1626 $schema_property = $reflection->getProperty('schema');
|
Chris@0
|
1627 $schema_property->setAccessible(TRUE);
|
Chris@0
|
1628 $schema = $schema_property->getValue($field_definition);
|
Chris@0
|
1629 if (isset($schema['columns']['value']['is_ascii'])) {
|
Chris@0
|
1630 $schema['columns']['value']['type'] = 'varchar_ascii';
|
Chris@0
|
1631 unset($schema['columns']['value']['is_ascii']);
|
Chris@0
|
1632 }
|
Chris@0
|
1633 $schema_property->setValue($field_definition, $schema);
|
Chris@0
|
1634 $schema_property->setAccessible(FALSE);
|
Chris@0
|
1635 $definitions_copy[$item_name][$field_name] = $field_definition;
|
Chris@0
|
1636 }
|
Chris@0
|
1637 }
|
Chris@0
|
1638 }
|
Chris@0
|
1639 \Drupal::keyValue('entity.definitions.installed')->setMultiple($definitions_copy);
|
Chris@0
|
1640 }
|
Chris@0
|
1641
|
Chris@0
|
1642 /**
|
Chris@0
|
1643 * Purge field schema data for uninstalled entity types.
|
Chris@0
|
1644 */
|
Chris@0
|
1645 function system_update_8008() {
|
Chris@0
|
1646 $entity_types = \Drupal::entityManager()->getDefinitions();
|
Chris@0
|
1647 /** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $schema */
|
Chris@0
|
1648 $schema = \Drupal::keyValue('entity.storage_schema.sql');
|
Chris@0
|
1649 foreach ($schema->getAll() as $key => $item) {
|
Chris@0
|
1650 list($entity_type_id, ,) = explode('.', $key);
|
Chris@0
|
1651 if (!isset($entity_types[$entity_type_id])) {
|
Chris@0
|
1652 $schema->delete($key);
|
Chris@0
|
1653 }
|
Chris@0
|
1654 }
|
Chris@0
|
1655 }
|
Chris@0
|
1656
|
Chris@0
|
1657 /**
|
Chris@0
|
1658 * Add allowed attributes to existing html filters.
|
Chris@0
|
1659 */
|
Chris@0
|
1660 function system_update_8009() {
|
Chris@0
|
1661 $default_mapping = [
|
Chris@0
|
1662 '<a>' => '<a href hreflang>',
|
Chris@0
|
1663 '<blockquote>' => '<blockquote cite>',
|
Chris@0
|
1664 '<ol>' => '<ol start type>',
|
Chris@0
|
1665 '<ul>' => '<ul type>',
|
Chris@0
|
1666 '<img>' => '<img src alt height width>',
|
Chris@0
|
1667 '<h2>' => '<h2 id>',
|
Chris@0
|
1668 '<h3>' => '<h3 id>',
|
Chris@0
|
1669 '<h4>' => '<h4 id>',
|
Chris@0
|
1670 '<h5>' => '<h5 id>',
|
Chris@0
|
1671 '<h6>' => '<h6 id>',
|
Chris@0
|
1672 ];
|
Chris@0
|
1673 $config_factory = \Drupal::configFactory();
|
Chris@0
|
1674 foreach ($config_factory->listAll('filter.format') as $name) {
|
Chris@0
|
1675 $allowed_html_mapping = $default_mapping;
|
Chris@0
|
1676 $config = $config_factory->getEditable($name);
|
Chris@0
|
1677 // The image alignment filter needs the data-align attribute.
|
Chris@0
|
1678 $align_enabled = $config->get('filters.filter_align.status');
|
Chris@0
|
1679 if ($align_enabled) {
|
Chris@0
|
1680 $allowed_html_mapping['<img>'] = str_replace('>', ' data-align>', $allowed_html_mapping['<img>']);
|
Chris@0
|
1681 }
|
Chris@0
|
1682 // The image caption filter needs the data-caption attribute.
|
Chris@0
|
1683 $caption_enabled = $config->get('filters.filter_caption.status');
|
Chris@0
|
1684 if ($caption_enabled) {
|
Chris@0
|
1685 $allowed_html_mapping['<img>'] = str_replace('>', ' data-caption>', $allowed_html_mapping['<img>']);
|
Chris@0
|
1686 }
|
Chris@0
|
1687 $allowed_html = $config->get('filters.filter_html.settings.allowed_html');
|
Chris@0
|
1688 if (!empty($allowed_html)) {
|
Chris@0
|
1689 $allowed_html = strtr($allowed_html, $allowed_html_mapping);
|
Chris@0
|
1690 $config->set('filters.filter_html.settings.allowed_html', $allowed_html);
|
Chris@0
|
1691 $config->save();
|
Chris@0
|
1692 }
|
Chris@0
|
1693 }
|
Chris@0
|
1694 }
|
Chris@0
|
1695
|
Chris@0
|
1696 /**
|
Chris@0
|
1697 * Place page title blocks in every theme.
|
Chris@0
|
1698 */
|
Chris@0
|
1699 function system_update_8010() {
|
Chris@0
|
1700 // When block module is not installed, there is nothing that could be done
|
Chris@0
|
1701 // except showing a warning.
|
Chris@0
|
1702 if (!\Drupal::moduleHandler()->moduleExists('block')) {
|
Chris@0
|
1703 return t('Block module is not enabled. The page title has been converted to a block, but default page title markup will still display at the top of the main content area.');
|
Chris@0
|
1704 }
|
Chris@0
|
1705
|
Chris@0
|
1706 /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
|
Chris@0
|
1707 $theme_handler = \Drupal::service('theme_handler');
|
Chris@0
|
1708 $custom_themes_installed = FALSE;
|
Chris@0
|
1709 $message = NULL;
|
Chris@0
|
1710 $langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
|
Chris@0
|
1711
|
Chris@0
|
1712 $page_title_default_settings = [
|
Chris@0
|
1713 'plugin' => 'page_title_block',
|
Chris@0
|
1714 'region' => 'content',
|
Chris@0
|
1715 'settings.label' => 'Page title',
|
Chris@0
|
1716 'settings.label_display' => 0,
|
Chris@0
|
1717 'visibility' => [],
|
Chris@0
|
1718 'weight' => -50,
|
Chris@0
|
1719 'langcode' => $langcode,
|
Chris@0
|
1720 ];
|
Chris@0
|
1721 foreach ($theme_handler->listInfo() as $theme) {
|
Chris@0
|
1722 $theme_name = $theme->getName();
|
Chris@0
|
1723 switch ($theme_name) {
|
Chris@0
|
1724 case 'bartik':
|
Chris@0
|
1725 $name = 'block.block.bartik_page_title';
|
Chris@0
|
1726 $values = [
|
Chris@0
|
1727 'id' => 'bartik_page_title',
|
Chris@0
|
1728 ] + $page_title_default_settings;
|
Chris@0
|
1729 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1730 break;
|
Chris@0
|
1731
|
Chris@0
|
1732 case 'stark':
|
Chris@0
|
1733 $name = 'block.block.stark_page_title';
|
Chris@0
|
1734 $values = [
|
Chris@0
|
1735 'id' => 'stark_page_title',
|
Chris@0
|
1736 'region' => 'content',
|
Chris@0
|
1737 ] + $page_title_default_settings;
|
Chris@0
|
1738 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1739 break;
|
Chris@0
|
1740
|
Chris@0
|
1741 case 'seven':
|
Chris@0
|
1742 $name = 'block.block.seven_page_title';
|
Chris@0
|
1743 $values = [
|
Chris@0
|
1744 'id' => 'seven_page_title',
|
Chris@0
|
1745 'region' => 'header',
|
Chris@0
|
1746 ] + $page_title_default_settings;
|
Chris@0
|
1747 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1748 break;
|
Chris@0
|
1749
|
Chris@0
|
1750 case 'classy':
|
Chris@0
|
1751 $name = 'block.block.classy_page_title';
|
Chris@0
|
1752 $values = [
|
Chris@0
|
1753 'id' => 'classy_page_title',
|
Chris@0
|
1754 'region' => 'content',
|
Chris@0
|
1755 ] + $page_title_default_settings;
|
Chris@0
|
1756 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1757 break;
|
Chris@0
|
1758
|
Chris@0
|
1759 default:
|
Chris@0
|
1760 $custom_themes_installed = TRUE;
|
Chris@0
|
1761 $name = sprintf('block.block.%s_page_title', $theme_name);
|
Chris@0
|
1762 $values = [
|
Chris@0
|
1763 'id' => sprintf('%s_page_title', $theme_name),
|
Chris@0
|
1764 'region' => 'content',
|
Chris@0
|
1765 'weight' => '-50',
|
Chris@0
|
1766 ] + $page_title_default_settings;
|
Chris@0
|
1767 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1768 break;
|
Chris@0
|
1769 }
|
Chris@0
|
1770 }
|
Chris@0
|
1771
|
Chris@0
|
1772 if ($custom_themes_installed) {
|
Chris@0
|
1773 $message = t('Because your site has custom theme(s) installed, we have placed the page title block in the content region. Please manually review the block configuration and remove the page title variables from your page templates.');
|
Chris@0
|
1774 }
|
Chris@0
|
1775
|
Chris@0
|
1776 return $message;
|
Chris@0
|
1777 }
|
Chris@0
|
1778
|
Chris@0
|
1779 /**
|
Chris@0
|
1780 * Add secondary local tasks block to Seven (fixes system_update_8005).
|
Chris@0
|
1781 */
|
Chris@0
|
1782 function system_update_8011() {
|
Chris@0
|
1783 $langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
|
Chris@0
|
1784 $theme_name = 'seven';
|
Chris@0
|
1785 $name = 'block.block.seven_secondary_local_tasks';
|
Chris@0
|
1786 $values = [
|
Chris@0
|
1787 'plugin' => 'local_tasks_block',
|
Chris@0
|
1788 'region' => 'pre_content',
|
Chris@0
|
1789 'id' => 'seven_secondary_local_tasks',
|
Chris@0
|
1790 'settings.label' => 'Secondary tabs',
|
Chris@0
|
1791 'settings.label_display' => 0,
|
Chris@0
|
1792 'settings.primary' => FALSE,
|
Chris@0
|
1793 'settings.secondary' => TRUE,
|
Chris@0
|
1794 'visibility' => [],
|
Chris@0
|
1795 'weight' => 0,
|
Chris@0
|
1796 'langcode' => $langcode,
|
Chris@0
|
1797 ];
|
Chris@0
|
1798 _system_update_create_block($name, $theme_name, $values);
|
Chris@0
|
1799 }
|
Chris@0
|
1800
|
Chris@0
|
1801 /**
|
Chris@0
|
1802 * Enable automated cron module and move the config into it.
|
Chris@0
|
1803 */
|
Chris@0
|
1804 function system_update_8013() {
|
Chris@0
|
1805 $config_factory = \Drupal::configFactory();
|
Chris@0
|
1806 $system_cron_config = $config_factory->getEditable('system.cron');
|
Chris@0
|
1807 if ($autorun = $system_cron_config->get('threshold.autorun')) {
|
Chris@0
|
1808 // Install 'automated_cron' module.
|
Chris@0
|
1809 \Drupal::service('module_installer')->install(['automated_cron'], FALSE);
|
Chris@0
|
1810
|
Chris@0
|
1811 // Copy 'autorun' value into the new module's 'interval' setting.
|
Chris@0
|
1812 $config_factory->getEditable('automated_cron.settings')
|
Chris@0
|
1813 ->set('interval', $autorun)
|
Chris@0
|
1814 ->save(TRUE);
|
Chris@0
|
1815 }
|
Chris@0
|
1816
|
Chris@0
|
1817 // Remove the 'autorun' key in system module config.
|
Chris@0
|
1818 $system_cron_config
|
Chris@0
|
1819 ->clear('threshold.autorun')
|
Chris@0
|
1820 ->save(TRUE);
|
Chris@0
|
1821 }
|
Chris@0
|
1822
|
Chris@0
|
1823 /**
|
Chris@0
|
1824 * Install the Stable base theme if needed.
|
Chris@0
|
1825 */
|
Chris@0
|
1826 function system_update_8014() {
|
Chris@0
|
1827 $theme_handler = \Drupal::service('theme_handler');
|
Chris@0
|
1828 if ($theme_handler->themeExists('stable')) {
|
Chris@0
|
1829 return;
|
Chris@0
|
1830 }
|
Chris@0
|
1831 $theme_handler->refreshInfo();
|
Chris@0
|
1832 foreach ($theme_handler->listInfo() as $theme) {
|
Chris@0
|
1833 // We first check that a base theme is set because if it's set to false then
|
Chris@0
|
1834 // it's unset in \Drupal\Core\Extension\ThemeHandler::rebuildThemeData().
|
Chris@0
|
1835 if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') {
|
Chris@0
|
1836 $theme_handler->install(['stable']);
|
Chris@0
|
1837 return;
|
Chris@0
|
1838 }
|
Chris@0
|
1839 }
|
Chris@0
|
1840 }
|
Chris@0
|
1841
|
Chris@0
|
1842 /**
|
Chris@0
|
1843 * Fix configuration overrides to not override non existing keys.
|
Chris@0
|
1844 */
|
Chris@0
|
1845 function system_update_8200(&$sandbox) {
|
Chris@0
|
1846 $config_factory = \Drupal::configFactory();
|
Chris@0
|
1847 if (!array_key_exists('config_names', $sandbox)) {
|
Chris@0
|
1848 $sandbox['config_names'] = $config_factory->listAll();
|
Chris@0
|
1849 $sandbox['max'] = count($sandbox['config_names']);
|
Chris@0
|
1850 }
|
Chris@0
|
1851
|
Chris@0
|
1852 // Get a list of 50 to work on at a time.
|
Chris@0
|
1853 $config_names_to_process = array_slice($sandbox['config_names'], 0, 50);
|
Chris@0
|
1854 // Preload in a single query.
|
Chris@0
|
1855 $config_factory->loadMultiple($config_names_to_process);
|
Chris@0
|
1856 foreach ($config_names_to_process as $config_name) {
|
Chris@0
|
1857 $config_factory->getEditable($config_name)->save();
|
Chris@0
|
1858 }
|
Chris@0
|
1859
|
Chris@0
|
1860 // Update the list of names to process.
|
Chris@0
|
1861 $sandbox['config_names'] = array_diff($sandbox['config_names'], $config_names_to_process);
|
Chris@0
|
1862 $sandbox['#finished'] = empty($sandbox['config_names']) ? 1 : ($sandbox['max'] - count($sandbox['config_names'])) / $sandbox['max'];
|
Chris@0
|
1863 }
|
Chris@0
|
1864
|
Chris@0
|
1865 /**
|
Chris@0
|
1866 * Clear caches due to behavior change in DefaultPluginManager.
|
Chris@0
|
1867 */
|
Chris@0
|
1868 function system_update_8201() {
|
Chris@0
|
1869 // Empty update to cause a cache rebuild.
|
Chris@4
|
1870
|
Chris@4
|
1871 // Use hook_post_update_NAME() instead to clear the cache.
|
Chris@4
|
1872 // The use of hook_update_N() to clear the cache has been deprecated
|
Chris@4
|
1873 // see https://www.drupal.org/node/2960601 for more details.
|
Chris@0
|
1874 }
|
Chris@0
|
1875
|
Chris@0
|
1876 /**
|
Chris@0
|
1877 * Clear caches due to behavior change in MachineName element.
|
Chris@0
|
1878 */
|
Chris@0
|
1879 function system_update_8202() {
|
Chris@0
|
1880 // Empty update to cause a cache rebuild.
|
Chris@4
|
1881
|
Chris@4
|
1882 // Use hook_post_update_NAME() instead to clear the cache.The use
|
Chris@4
|
1883 // of hook_update_N to clear the cache has been deprecated see
|
Chris@4
|
1884 // https://www.drupal.org/node/2960601 for more details.
|
Chris@0
|
1885 }
|
Chris@0
|
1886
|
Chris@0
|
1887 /**
|
Chris@0
|
1888 * Add detailed cron logging configuration.
|
Chris@0
|
1889 */
|
Chris@0
|
1890 function system_update_8300() {
|
Chris@0
|
1891 \Drupal::configFactory()->getEditable('system.cron')
|
Chris@0
|
1892 ->set('logging', 1)
|
Chris@0
|
1893 ->save(TRUE);
|
Chris@0
|
1894 }
|
Chris@0
|
1895
|
Chris@0
|
1896 /**
|
Chris@0
|
1897 * Add install profile to core.extension configuration.
|
Chris@0
|
1898 */
|
Chris@0
|
1899 function system_update_8301() {
|
Chris@0
|
1900 \Drupal::configFactory()->getEditable('core.extension')
|
Chris@0
|
1901 ->set('profile', \Drupal::installProfile())
|
Chris@0
|
1902 ->save();
|
Chris@0
|
1903 }
|
Chris@0
|
1904
|
Chris@0
|
1905 /**
|
Chris@0
|
1906 * Move revision metadata fields to the revision table.
|
Chris@0
|
1907 */
|
Chris@0
|
1908 function system_update_8400(&$sandbox) {
|
Chris@0
|
1909 // Due to the fields from RevisionLogEntityTrait not being explicitly
|
Chris@0
|
1910 // mentioned in the storage they might have been installed wrongly in the base
|
Chris@0
|
1911 // table for revisionable untranslatable entities and in the data and revision
|
Chris@0
|
1912 // data tables for revisionable and translatable entities.
|
Chris@0
|
1913 $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
Chris@0
|
1914 $database = \Drupal::database();
|
Chris@0
|
1915 $database_schema = $database->schema();
|
Chris@0
|
1916
|
Chris@0
|
1917 if (!isset($sandbox['current'])) {
|
Chris@0
|
1918 // This must be the first run. Initialize the sandbox.
|
Chris@0
|
1919 $sandbox['current'] = 0;
|
Chris@0
|
1920
|
Chris@0
|
1921 $definitions = array_filter(\Drupal::entityTypeManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($entity_definition_update_manager) {
|
Chris@0
|
1922 if ($entity_type = $entity_definition_update_manager->getEntityType($entity_type->id())) {
|
Chris@0
|
1923 return is_subclass_of($entity_type->getClass(), FieldableEntityInterface::class) && ($entity_type instanceof ContentEntityTypeInterface) && $entity_type->isRevisionable();
|
Chris@0
|
1924 }
|
Chris@0
|
1925 return FALSE;
|
Chris@0
|
1926 });
|
Chris@0
|
1927 $sandbox['entity_type_ids'] = array_keys($definitions);
|
Chris@0
|
1928 $sandbox['max'] = count($sandbox['entity_type_ids']);
|
Chris@0
|
1929 }
|
Chris@0
|
1930
|
Chris@0
|
1931 $current_entity_type_key = $sandbox['current'];
|
Chris@0
|
1932 for ($i = $current_entity_type_key; ($i < $current_entity_type_key + 1) && ($i < $sandbox['max']); $i++) {
|
Chris@0
|
1933 $entity_type_id = $sandbox['entity_type_ids'][$i];
|
Chris@0
|
1934 /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
|
Chris@0
|
1935 $entity_type = $entity_definition_update_manager->getEntityType($entity_type_id);
|
Chris@0
|
1936
|
Chris@0
|
1937 $base_fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type_id);
|
Chris@0
|
1938 $revision_metadata_fields = $entity_type->getRevisionMetadataKeys();
|
Chris@0
|
1939 $fields_to_update = array_intersect_key($base_fields, array_flip($revision_metadata_fields));
|
Chris@0
|
1940
|
Chris@0
|
1941 if (!empty($fields_to_update)) {
|
Chris@0
|
1942 // Initialize the entity table names.
|
Chris@0
|
1943 // @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout()
|
Chris@0
|
1944 $base_table = $entity_type->getBaseTable() ?: $entity_type_id;
|
Chris@0
|
1945 $data_table = $entity_type->getDataTable() ?: $entity_type_id . '_field_data';
|
Chris@0
|
1946 $revision_table = $entity_type->getRevisionTable() ?: $entity_type_id . '_revision';
|
Chris@0
|
1947 $revision_data_table = $entity_type->getRevisionDataTable() ?: $entity_type_id . '_field_revision';
|
Chris@0
|
1948 $revision_field = $entity_type->getKey('revision');
|
Chris@0
|
1949
|
Chris@0
|
1950 // No data needs to be migrated if the entity type is not translatable.
|
Chris@0
|
1951 if ($entity_type->isTranslatable()) {
|
Chris@0
|
1952 if (!isset($sandbox[$entity_type_id])) {
|
Chris@0
|
1953 // This must be the first run for this entity type. Initialize the
|
Chris@0
|
1954 // sub-sandbox for it.
|
Chris@0
|
1955
|
Chris@0
|
1956 // Calculate the number of revisions to process.
|
Chris@0
|
1957 $count = \Drupal::entityQuery($entity_type_id)
|
Chris@0
|
1958 ->allRevisions()
|
Chris@0
|
1959 ->count()
|
Chris@0
|
1960 ->accessCheck(FALSE)
|
Chris@0
|
1961 ->execute();
|
Chris@0
|
1962
|
Chris@0
|
1963 $sandbox[$entity_type_id]['current'] = 0;
|
Chris@0
|
1964 $sandbox[$entity_type_id]['max'] = $count;
|
Chris@0
|
1965 }
|
Chris@0
|
1966 // Define the step size.
|
Chris@0
|
1967 $steps = Settings::get('entity_update_batch_size', 50);
|
Chris@0
|
1968
|
Chris@0
|
1969 // Collect the revision IDs to process.
|
Chris@0
|
1970 $revisions = \Drupal::entityQuery($entity_type_id)
|
Chris@0
|
1971 ->allRevisions()
|
Chris@0
|
1972 ->range($sandbox[$entity_type_id]['current'], $sandbox[$entity_type_id]['current'] + $steps)
|
Chris@0
|
1973 ->sort($revision_field, 'ASC')
|
Chris@0
|
1974 ->accessCheck(FALSE)
|
Chris@0
|
1975 ->execute();
|
Chris@0
|
1976 $revisions = array_keys($revisions);
|
Chris@0
|
1977
|
Chris@0
|
1978 foreach ($fields_to_update as $revision_metadata_field_name => $definition) {
|
Chris@0
|
1979 // If the revision metadata field is present in the data and the
|
Chris@0
|
1980 // revision data table, install its definition again with the updated
|
Chris@0
|
1981 // storage code in order for the field to be installed in the
|
Chris@0
|
1982 // revision table. Afterwards, copy over the field values and remove
|
Chris@0
|
1983 // the field from the data and the revision data tables.
|
Chris@0
|
1984 if ($database_schema->fieldExists($data_table, $revision_metadata_field_name) && $database_schema->fieldExists($revision_data_table, $revision_metadata_field_name)) {
|
Chris@0
|
1985 // Install the field in the revision table.
|
Chris@0
|
1986 if (!isset($sandbox[$entity_type_id]['storage_definition_installed'][$revision_metadata_field_name])) {
|
Chris@0
|
1987 $entity_definition_update_manager->installFieldStorageDefinition($revision_metadata_field_name, $entity_type_id, $entity_type->getProvider(), $definition);
|
Chris@0
|
1988 $sandbox[$entity_type_id]['storage_definition_installed'][$revision_metadata_field_name] = TRUE;
|
Chris@0
|
1989 }
|
Chris@0
|
1990
|
Chris@0
|
1991 // Apply the field value from the revision data table to the
|
Chris@0
|
1992 // revision table.
|
Chris@0
|
1993 foreach ($revisions as $rev_id) {
|
Chris@0
|
1994 $field_value = $database->select($revision_data_table, 't')
|
Chris@0
|
1995 ->fields('t', [$revision_metadata_field_name])
|
Chris@0
|
1996 ->condition($revision_field, $rev_id)
|
Chris@0
|
1997 ->execute()
|
Chris@0
|
1998 ->fetchField();
|
Chris@0
|
1999 $database->update($revision_table)
|
Chris@0
|
2000 ->condition($revision_field, $rev_id)
|
Chris@0
|
2001 ->fields([$revision_metadata_field_name => $field_value])
|
Chris@0
|
2002 ->execute();
|
Chris@0
|
2003 }
|
Chris@0
|
2004 }
|
Chris@0
|
2005 }
|
Chris@0
|
2006
|
Chris@0
|
2007 $sandbox[$entity_type_id]['current'] += count($revisions);
|
Chris@0
|
2008 $sandbox[$entity_type_id]['finished'] = ($sandbox[$entity_type_id]['current'] == $sandbox[$entity_type_id]['max']) || empty($revisions);
|
Chris@0
|
2009
|
Chris@0
|
2010 if ($sandbox[$entity_type_id]['finished']) {
|
Chris@0
|
2011 foreach ($fields_to_update as $revision_metadata_field_name => $definition) {
|
Chris@0
|
2012 // Drop the field from the data and revision data tables.
|
Chris@0
|
2013 $database_schema->dropField($data_table, $revision_metadata_field_name);
|
Chris@0
|
2014 $database_schema->dropField($revision_data_table, $revision_metadata_field_name);
|
Chris@0
|
2015 }
|
Chris@0
|
2016 $sandbox['current']++;
|
Chris@0
|
2017 }
|
Chris@0
|
2018 }
|
Chris@0
|
2019 else {
|
Chris@0
|
2020 foreach ($fields_to_update as $revision_metadata_field_name => $definition) {
|
Chris@0
|
2021 if ($database_schema->fieldExists($base_table, $revision_metadata_field_name)) {
|
Chris@0
|
2022 // Install the field in the revision table.
|
Chris@0
|
2023 $entity_definition_update_manager->installFieldStorageDefinition($revision_metadata_field_name, $entity_type_id, $entity_type->getProvider(), $definition);
|
Chris@0
|
2024 // Drop the field from the base table.
|
Chris@0
|
2025 $database_schema->dropField($base_table, $revision_metadata_field_name);
|
Chris@0
|
2026 }
|
Chris@0
|
2027 }
|
Chris@0
|
2028 $sandbox['current']++;
|
Chris@0
|
2029 }
|
Chris@0
|
2030 }
|
Chris@0
|
2031 else {
|
Chris@0
|
2032 $sandbox['current']++;
|
Chris@0
|
2033 }
|
Chris@0
|
2034
|
Chris@0
|
2035 }
|
Chris@0
|
2036
|
Chris@0
|
2037 $sandbox['#finished'] = $sandbox['current'] == $sandbox['max'];
|
Chris@0
|
2038 }
|
Chris@0
|
2039
|
Chris@0
|
2040 /**
|
Chris@0
|
2041 * Remove response.gzip (and response) from system module configuration.
|
Chris@0
|
2042 */
|
Chris@0
|
2043 function system_update_8401() {
|
Chris@0
|
2044 \Drupal::configFactory()->getEditable('system.performance')
|
Chris@0
|
2045 ->clear('response.gzip')
|
Chris@0
|
2046 ->clear('response')
|
Chris@0
|
2047 ->save();
|
Chris@0
|
2048 }
|
Chris@0
|
2049
|
Chris@0
|
2050 /**
|
Chris@0
|
2051 * Add the 'revision_translation_affected' field to all entity types.
|
Chris@0
|
2052 */
|
Chris@0
|
2053 function system_update_8402() {
|
Chris@0
|
2054 $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
Chris@0
|
2055
|
Chris@0
|
2056 // Clear the cached entity type definitions so we get the new
|
Chris@0
|
2057 // 'revision_translation_affected' entity key.
|
Chris@0
|
2058 \Drupal::entityTypeManager()->clearCachedDefinitions();
|
Chris@0
|
2059
|
Chris@0
|
2060 // Get a list of revisionable and translatable entity types.
|
Chris@0
|
2061 /** @var \Drupal\Core\Entity\ContentEntityTypeInterface[] $definitions */
|
Chris@0
|
2062 $definitions = array_filter(\Drupal::entityTypeManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($definition_update_manager) {
|
Chris@0
|
2063 if ($entity_type = $definition_update_manager->getEntityType($entity_type->id())) {
|
Chris@0
|
2064 return $entity_type->isRevisionable() && $entity_type->isTranslatable();
|
Chris@0
|
2065 }
|
Chris@0
|
2066 return FALSE;
|
Chris@0
|
2067 });
|
Chris@0
|
2068
|
Chris@0
|
2069 foreach ($definitions as $entity_type_id => $entity_type) {
|
Chris@0
|
2070 $field_name = $entity_type->getKey('revision_translation_affected');
|
Chris@0
|
2071 // Install the 'revision_translation_affected' field if needed.
|
Chris@0
|
2072 if (!$definition_update_manager->getFieldStorageDefinition($field_name, $entity_type_id)) {
|
Chris@0
|
2073 $storage_definition = BaseFieldDefinition::create('boolean')
|
Chris@0
|
2074 ->setLabel(t('Revision translation affected'))
|
Chris@0
|
2075 ->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
|
Chris@0
|
2076 ->setReadOnly(TRUE)
|
Chris@0
|
2077 ->setRevisionable(TRUE)
|
Chris@0
|
2078 ->setTranslatable(TRUE)
|
Chris@0
|
2079 // Mark all pre-existing revisions as affected in order to be consistent
|
Chris@0
|
2080 // with the previous API return value: if the field was not defined the
|
Chris@0
|
2081 // value returned was always TRUE.
|
Chris@0
|
2082 ->setInitialValue(TRUE);
|
Chris@0
|
2083
|
Chris@0
|
2084 $definition_update_manager
|
Chris@0
|
2085 ->installFieldStorageDefinition($field_name, $entity_type_id, $entity_type_id, $storage_definition);
|
Chris@0
|
2086 }
|
Chris@0
|
2087 }
|
Chris@0
|
2088 }
|
Chris@0
|
2089
|
Chris@0
|
2090 /**
|
Chris@0
|
2091 * Delete all cache_* tables. They are recreated on demand with the new schema.
|
Chris@0
|
2092 */
|
Chris@0
|
2093 function system_update_8403() {
|
Chris@0
|
2094 foreach (Cache::getBins() as $bin => $cache_backend) {
|
Chris@0
|
2095 // Try to delete the table regardless of which cache backend is handling it.
|
Chris@0
|
2096 // This is to ensure the new schema is used if the configuration for the
|
Chris@0
|
2097 // backend class is changed after the update hook runs.
|
Chris@0
|
2098 $table_name = "cache_$bin";
|
Chris@0
|
2099 $schema = Database::getConnection()->schema();
|
Chris@0
|
2100 if ($schema->tableExists($table_name)) {
|
Chris@0
|
2101 $schema->dropTable($table_name);
|
Chris@0
|
2102 }
|
Chris@0
|
2103 }
|
Chris@0
|
2104 }
|
Chris@0
|
2105
|
Chris@0
|
2106 /**
|
Chris@0
|
2107 * Add the 'revision_default' field to all relevant entity types.
|
Chris@0
|
2108 */
|
Chris@0
|
2109 function system_update_8501() {
|
Chris@0
|
2110 $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
Chris@0
|
2111
|
Chris@0
|
2112 // Clear the cached entity type definitions so we get the new
|
Chris@0
|
2113 // 'revision_default' revision metadata key.
|
Chris@0
|
2114 \Drupal::entityTypeManager()->clearCachedDefinitions();
|
Chris@0
|
2115
|
Chris@0
|
2116 // Get a list of revisionable entity types.
|
Chris@0
|
2117 /** @var \Drupal\Core\Entity\ContentEntityTypeInterface[] $definitions */
|
Chris@0
|
2118 $definitions = array_filter(\Drupal::entityTypeManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($definition_update_manager) {
|
Chris@0
|
2119 if ($entity_type = $definition_update_manager->getEntityType($entity_type->id())) {
|
Chris@0
|
2120 return $entity_type->isRevisionable();
|
Chris@0
|
2121 }
|
Chris@0
|
2122 return FALSE;
|
Chris@0
|
2123 });
|
Chris@0
|
2124
|
Chris@0
|
2125 // Install the 'revision_default' field.
|
Chris@0
|
2126 foreach ($definitions as $entity_type_id => $entity_type) {
|
Chris@0
|
2127 $field_name = $entity_type->getRevisionMetadataKey('revision_default');
|
Chris@0
|
2128 // Install the 'revision_default' field if needed.
|
Chris@0
|
2129 if (!$definition_update_manager->getFieldStorageDefinition($field_name, $entity_type_id)) {
|
Chris@0
|
2130 // Make sure the new "revision_default" revision metadata key is available
|
Chris@0
|
2131 // also to code using the latest installed definition.
|
Chris@0
|
2132 $installed_entity_type = $definition_update_manager->getEntityType($entity_type_id);
|
Chris@0
|
2133 $revision_metadata_keys = $installed_entity_type->get('revision_metadata_keys');
|
Chris@0
|
2134
|
Chris@0
|
2135 if (!isset($revision_metadata_keys['revision_default'])) {
|
Chris@0
|
2136 // Update the property holding the required revision metadata keys,
|
Chris@0
|
2137 // which is used by the BC layer for retrieving the revision metadata
|
Chris@0
|
2138 // keys.
|
Chris@0
|
2139 // @see \Drupal\Core\Entity\ContentEntityType::getRevisionMetadataKeys().
|
Chris@0
|
2140 $required_revision_metadata_keys = $installed_entity_type->get('requiredRevisionMetadataKeys');
|
Chris@0
|
2141 $required_revision_metadata_keys['revision_default'] = $field_name;
|
Chris@0
|
2142 $installed_entity_type->set('requiredRevisionMetadataKeys', $required_revision_metadata_keys);
|
Chris@0
|
2143
|
Chris@0
|
2144 // Update the revision metadata keys to add the new required revision
|
Chris@0
|
2145 // metadata key "revision_default".
|
Chris@0
|
2146 $revision_metadata_keys['revision_default'] = $required_revision_metadata_keys['revision_default'];
|
Chris@0
|
2147 $installed_entity_type->set('revision_metadata_keys', $revision_metadata_keys);
|
Chris@0
|
2148
|
Chris@0
|
2149 $definition_update_manager->updateEntityType($installed_entity_type);
|
Chris@0
|
2150 }
|
Chris@0
|
2151
|
Chris@0
|
2152 $storage_definition = BaseFieldDefinition::create('boolean')
|
Chris@0
|
2153 ->setLabel(t('Default revision'))
|
Chris@0
|
2154 ->setDescription(t('A flag indicating whether this was a default revision when it was saved.'))
|
Chris@0
|
2155 ->setStorageRequired(TRUE)
|
Chris@0
|
2156 ->setTranslatable(FALSE)
|
Chris@0
|
2157 ->setRevisionable(TRUE)
|
Chris@0
|
2158 // We cannot tell whether existing revisions were default or not when
|
Chris@0
|
2159 // they were created, but since we did not support creating non-default
|
Chris@0
|
2160 // revisions in any core stable UI so far, we default to TRUE.
|
Chris@0
|
2161 ->setInitialValue(TRUE);
|
Chris@0
|
2162
|
Chris@0
|
2163 $definition_update_manager
|
Chris@0
|
2164 ->installFieldStorageDefinition($field_name, $entity_type_id, $entity_type_id, $storage_definition);
|
Chris@0
|
2165 }
|
Chris@0
|
2166 else {
|
Chris@0
|
2167 $variables = ['@entity_type_label' => $entity_type->getLabel()];
|
Chris@0
|
2168 if ($field_name === 'revision_default') {
|
Chris@0
|
2169 \Drupal::logger('system')->error('An existing "Default revision" field was found for the @entity_type_label entity type, but no "revision_default" revision metadata key was found in its definition.', $variables);
|
Chris@0
|
2170 }
|
Chris@0
|
2171 else {
|
Chris@0
|
2172 \Drupal::logger('system')->error('An existing "Default revision" field was found for the @entity_type_label entity type.', $variables);
|
Chris@0
|
2173 }
|
Chris@0
|
2174 }
|
Chris@0
|
2175 }
|
Chris@0
|
2176 }
|
Chris@4
|
2177
|
Chris@4
|
2178 /**
|
Chris@4
|
2179 * Fix missing install profile after updating to Drupal 8.6.9 with Drush 8.
|
Chris@4
|
2180 */
|
Chris@4
|
2181 function system_update_8601() {
|
Chris@4
|
2182 $extension_config = \Drupal::configFactory()->getEditable('core.extension');
|
Chris@4
|
2183 $install_profile = $extension_config->get('profile');
|
Chris@4
|
2184 if (!$install_profile) {
|
Chris@4
|
2185 // There's no install profile configured.
|
Chris@4
|
2186 return;
|
Chris@4
|
2187 }
|
Chris@4
|
2188 $modules = $extension_config->get('module');
|
Chris@4
|
2189 if (isset($modules[$install_profile])) {
|
Chris@4
|
2190 // The install profile is already in the installed module list.
|
Chris@4
|
2191 return;
|
Chris@4
|
2192 }
|
Chris@4
|
2193
|
Chris@4
|
2194 // Ensure the install profile is available.
|
Chris@4
|
2195 if (!\Drupal::service('extension.list.module')->exists($install_profile)) {
|
Chris@4
|
2196 return t('The %install_profile install profile configured in core.extension is not available.', ['%install_profile' => $install_profile]);
|
Chris@4
|
2197 }
|
Chris@4
|
2198
|
Chris@4
|
2199 // Add the install profile to the list of enabled modules.
|
Chris@4
|
2200 $modules[$install_profile] = 1000;
|
Chris@4
|
2201 $modules = module_config_sort($modules);
|
Chris@4
|
2202 $extension_config
|
Chris@4
|
2203 ->set('module', $modules)
|
Chris@4
|
2204 ->save(TRUE);
|
Chris@4
|
2205
|
Chris@4
|
2206 // Build a module list from the updated extension configuration.
|
Chris@4
|
2207 $current_module_filenames = \Drupal::moduleHandler()->getModuleList();
|
Chris@4
|
2208 $current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
|
Chris@4
|
2209 $current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
|
Chris@4
|
2210 $module_filenames = [];
|
Chris@4
|
2211 foreach ($current_modules as $name => $weight) {
|
Chris@4
|
2212 if (isset($current_module_filenames[$name])) {
|
Chris@4
|
2213 $module_filenames[$name] = $current_module_filenames[$name];
|
Chris@4
|
2214 }
|
Chris@4
|
2215 else {
|
Chris@4
|
2216 $module_path = \Drupal::service('extension.list.module')->getPath($name);
|
Chris@4
|
2217 $pathname = "$module_path/$name.info.yml";
|
Chris@4
|
2218 $filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL;
|
Chris@4
|
2219 $module_filenames[$name] = new Extension(\Drupal::root(), 'module', $pathname, $filename);
|
Chris@4
|
2220 }
|
Chris@4
|
2221 }
|
Chris@4
|
2222
|
Chris@4
|
2223 // Update the module handler list to contain the missing install profile.
|
Chris@4
|
2224 \Drupal::moduleHandler()->setModuleList($module_filenames);
|
Chris@4
|
2225 \Drupal::moduleHandler()->load($install_profile);
|
Chris@4
|
2226
|
Chris@4
|
2227 // Clear the static cache of the "extension.list.module" service to pick
|
Chris@4
|
2228 // up the new install profile correctly.
|
Chris@4
|
2229 \Drupal::service('extension.list.profile')->reset();
|
Chris@4
|
2230
|
Chris@4
|
2231 // Clear the static cache of the "extension.list.module" service to pick
|
Chris@4
|
2232 // up the new module, since it merges the installation status of modules
|
Chris@4
|
2233 // into its statically cached list.
|
Chris@4
|
2234 \Drupal::service('extension.list.module')->reset();
|
Chris@4
|
2235
|
Chris@4
|
2236 // Update the kernel to include the missing profile.
|
Chris@4
|
2237 \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames);
|
Chris@4
|
2238
|
Chris@4
|
2239 return t('The %install_profile install profile has been added to the installed module list.', ['%install_profile' => $install_profile]);
|
Chris@4
|
2240 }
|