Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / user / user.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the user module.
6  */
7
8 /**
9  * Implements hook_schema().
10  */
11 function user_schema() {
12   $schema['users_data'] = [
13     'description' => 'Stores module data as key/value pairs per user.',
14     'fields' => [
15       'uid' => [
16         'description' => 'Primary key: {users}.uid for user.',
17         'type' => 'int',
18         'unsigned' => TRUE,
19         'not null' => TRUE,
20         'default' => 0,
21       ],
22       'module' => [
23         'description' => 'The name of the module declaring the variable.',
24         'type' => 'varchar_ascii',
25         'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
26         'not null' => TRUE,
27         'default' => '',
28       ],
29       'name' => [
30         'description' => 'The identifier of the data.',
31         'type' => 'varchar_ascii',
32         'length' => 128,
33         'not null' => TRUE,
34         'default' => '',
35       ],
36       'value' => [
37         'description' => 'The value.',
38         'type' => 'blob',
39         'not null' => FALSE,
40         'size' => 'big',
41       ],
42       'serialized' => [
43         'description' => 'Whether value is serialized.',
44         'type' => 'int',
45         'size' => 'tiny',
46         'unsigned' => TRUE,
47         'default' => 0,
48       ],
49     ],
50     'primary key' => ['uid', 'module', 'name'],
51     'indexes' => [
52       'module' => ['module'],
53       'name' => ['name'],
54     ],
55     'foreign keys' => [
56       'uid' => ['users' => 'uid'],
57     ],
58   ];
59
60   return $schema;
61 }
62
63 /**
64  * Implements hook_install().
65  */
66 function user_install() {
67   $storage = \Drupal::entityManager()->getStorage('user');
68   // Insert a row for the anonymous user.
69   $storage
70     ->create([
71       'uid' => 0,
72       'status' => 0,
73       'name' => '',
74     ])
75     ->save();
76
77   // We need some placeholders here as name and mail are unique.
78   // This will be changed by the settings form in the installer.
79   $storage
80     ->create([
81       'uid' => 1,
82       'name' => 'placeholder-for-uid-1',
83       'mail' => 'placeholder-for-uid-1',
84       'status' => TRUE,
85     ])
86     ->save();
87 }
88
89 /**
90  * Fix invalid token in the status_blocked email body.
91  */
92 function user_update_8100() {
93   $config_factory = \Drupal::configFactory();
94   $config = $config_factory->getEditable('user.mail');
95   $mail = $config->get('status_blocked');
96   if (strpos($mail['body'], '[site:account-name]') !== FALSE) {
97     $mail['body'] = str_replace('[site:account-name]', '[site:name]', $mail['body']);
98     $config->set('status_blocked', $mail)->save(TRUE);
99   }
100 }