2007-04-10 10:10:27 +00:00
|
|
|
<?php
|
|
|
|
|
2009-05-13 19:42:18 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Install, update and uninstall functions for the dblog module.
|
|
|
|
*/
|
|
|
|
|
Issue #3081144 by mindbet, phenaproxima, Akram Khan, Arantxio, dagmar, daffie, Berdir, catch, Niall Jackson, larowlan, vacho, anantjain60, amit.drupal: Database primary keys can exceed maximum integer storeable (has actually occurred, in watchdog)
2023-04-17 14:04:57 +00:00
|
|
|
use Drupal\Core\Database\Database;
|
|
|
|
|
2007-10-05 14:43:26 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_schema().
|
2007-10-05 14:43:26 +00:00
|
|
|
*/
|
|
|
|
function dblog_schema() {
|
2017-03-04 01:20:24 +00:00
|
|
|
$schema['watchdog'] = [
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Table that contains logs of all system events.',
|
2017-03-04 01:20:24 +00:00
|
|
|
'fields' => [
|
|
|
|
'wid' => [
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'serial',
|
|
|
|
'not null' => TRUE,
|
Issue #3081144 by mindbet, phenaproxima, Akram Khan, Arantxio, dagmar, daffie, Berdir, catch, Niall Jackson, larowlan, vacho, anantjain60, amit.drupal: Database primary keys can exceed maximum integer storeable (has actually occurred, in watchdog)
2023-04-17 14:04:57 +00:00
|
|
|
'size' => 'big',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Primary Key: Unique watchdog event ID.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'uid' => [
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
2012-10-04 20:27:03 +00:00
|
|
|
'unsigned' => TRUE,
|
2007-10-10 11:39:35 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2009-02-26 07:30:29 +00:00
|
|
|
'description' => 'The {users}.uid of the user who triggered the event.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'type' => [
|
2015-05-05 16:42:09 +00:00
|
|
|
'type' => 'varchar_ascii',
|
2008-12-28 20:41:19 +00:00
|
|
|
'length' => 64,
|
2007-10-10 11:39:35 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Type of log message, for example "user" or "page not found."',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'message' => [
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'size' => 'big',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Text of log message to be passed into the t() function.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'variables' => [
|
2010-06-25 17:47:22 +00:00
|
|
|
'type' => 'blob',
|
2007-10-10 11:39:35 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
'size' => 'big',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'severity' => [
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
'size' => 'tiny',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'link' => [
|
2015-05-19 11:17:46 +00:00
|
|
|
'type' => 'text',
|
2008-08-21 19:36:39 +00:00
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Link to view the result of the event.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'location' => [
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'URL of the origin of the event.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'referer' => [
|
2008-12-03 19:22:09 +00:00
|
|
|
'type' => 'text',
|
2008-08-21 19:36:39 +00:00
|
|
|
'not null' => FALSE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'URL of referring page.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'hostname' => [
|
2015-05-05 16:42:09 +00:00
|
|
|
'type' => 'varchar_ascii',
|
2007-10-10 11:39:35 +00:00
|
|
|
'length' => 128,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Hostname of the user who triggered the event.',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
'timestamp' => [
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Unix timestamp of when event occurred.',
|
Issue #3215062 by quietone, gambry, ravi.shankar, dww, daffie, yogeshmpawar, aarti zikre, alexpott, mfb, larowlan, longwave, catch: Update hook_schema for Y2038
2022-07-23 05:46:46 +00:00
|
|
|
'size' => 'big',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'primary key' => ['wid'],
|
|
|
|
'indexes' => [
|
|
|
|
'type' => ['type'],
|
|
|
|
'uid' => ['uid'],
|
|
|
|
'severity' => ['severity'],
|
|
|
|
],
|
|
|
|
];
|
2007-10-05 14:43:26 +00:00
|
|
|
|
|
|
|
return $schema;
|
|
|
|
}
|
2017-05-08 12:30:36 +00:00
|
|
|
|
|
|
|
/**
|
Issue #3087644 by jibran, Berdir, alexpott, longwave, Wim Leers, amateescu, catch, xjm, larowlan, dpi, quietone: Remove Drupal 8 updates up to and including 88**
2020-01-24 23:52:03 +00:00
|
|
|
* Implements hook_update_last_removed().
|
2017-05-08 12:30:36 +00:00
|
|
|
*/
|
Issue #3087644 by jibran, Berdir, alexpott, longwave, Wim Leers, amateescu, catch, xjm, larowlan, dpi, quietone: Remove Drupal 8 updates up to and including 88**
2020-01-24 23:52:03 +00:00
|
|
|
function dblog_update_last_removed() {
|
|
|
|
return 8600;
|
2018-04-11 14:09:21 +00:00
|
|
|
}
|
Issue #3215062 by quietone, gambry, ravi.shankar, dww, daffie, yogeshmpawar, aarti zikre, alexpott, mfb, larowlan, longwave, catch: Update hook_schema for Y2038
2022-07-23 05:46:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the year 2038 date limitation.
|
|
|
|
*/
|
|
|
|
function dblog_update_10100(&$sandbox = NULL) {
|
|
|
|
$connection = \Drupal::database();
|
|
|
|
if ($connection->schema()->tableExists('watchdog') && $connection->databaseType() != 'sqlite') {
|
|
|
|
$new = [
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
'description' => 'Unix timestamp of when event occurred.',
|
|
|
|
'size' => 'big',
|
|
|
|
];
|
|
|
|
$connection->schema()->changeField('watchdog', 'timestamp', 'timestamp', $new);
|
|
|
|
}
|
|
|
|
}
|
Issue #3081144 by mindbet, phenaproxima, Akram Khan, Arantxio, dagmar, daffie, Berdir, catch, Niall Jackson, larowlan, vacho, anantjain60, amit.drupal: Database primary keys can exceed maximum integer storeable (has actually occurred, in watchdog)
2023-04-17 14:04:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the 'wid' of the 'watchdog' table to a big integer.
|
|
|
|
*/
|
|
|
|
function dblog_update_10101(&$sandbox = NULL) {
|
|
|
|
$schema = Database::getConnection()->schema();
|
|
|
|
|
|
|
|
// Increase the size of the field.
|
|
|
|
$new_specification = [
|
|
|
|
'size' => 'big',
|
|
|
|
'type' => 'serial',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => 'Primary Key: Unique watchdog event ID.',
|
|
|
|
];
|
|
|
|
$schema->changeField('watchdog', 'wid', 'wid', $new_specification);
|
|
|
|
|
|
|
|
}
|