Drupal from 10.6.17 to 11.4.7
This commit is contained in:
@@ -35,17 +35,17 @@ function login_tracker_user_login($account) {
|
||||
\Drupal::moduleHandler()->alter('login_tracker_login_data', $data, $account);
|
||||
$data = serialize($data);
|
||||
|
||||
$keys = [
|
||||
'record_id' => NULL,
|
||||
];
|
||||
$fields = [
|
||||
'uid' => $account->id(),
|
||||
'login_timestamp' => \Drupal::time()->getRequestTime(),
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
\Drupal::database()->merge('login_tracker')
|
||||
->key($keys)
|
||||
// Core 11 narrowed Merge::key() to a string field, so the historical
|
||||
// merge->key(['record_id' => NULL]) trick no longer works. A plain insert
|
||||
// is exactly what it did (the NULL key never matched, forcing an insert
|
||||
// per login).
|
||||
\Drupal::database()->insert('login_tracker')
|
||||
->fields($fields)
|
||||
->execute();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the materio_flag module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fix flag configs with empty labels.
|
||||
*
|
||||
* Flag lists (flag_lists) can create relflag_* flag configs without a label.
|
||||
* Core 10 silently tolerated NULL labels, but core 11 typed
|
||||
* Html::escape() as string, which makes \Drupal::token()->getInfo() fatal
|
||||
* (the flag tokens build t('@flag flag link', ['@flag' => $flag->label()])).
|
||||
*
|
||||
* Give every flag a string label: the related flagging collection name when
|
||||
* available, the flag ID as a fallback.
|
||||
*/
|
||||
function materio_flag_update_10200(&$sandbox = NULL) {
|
||||
$flags = \Drupal::service('flag')->getAllFlags();
|
||||
$fixed = 0;
|
||||
foreach ($flags as $id => $flag) {
|
||||
$label = $flag->label();
|
||||
if (is_string($label) && $label !== '') {
|
||||
continue;
|
||||
}
|
||||
$new_label = $id;
|
||||
if (preg_match('/^relflag_(\d+)_/', $id, $matches)) {
|
||||
$collection = \Drupal::entityTypeManager()->getStorage('flagging_collection')->load($matches[1]);
|
||||
if ($collection && is_string($collection->label()) && $collection->label() !== '') {
|
||||
$new_label = $collection->label();
|
||||
}
|
||||
}
|
||||
$flag->set('label', $new_label)->save();
|
||||
$fixed++;
|
||||
}
|
||||
return t('@count flag(s) with an empty label have been fixed.', ['@count' => $fixed]);
|
||||
}
|
||||
Reference in New Issue
Block a user