update drupal

This commit is contained in:
Tessier
2020-10-15 11:59:37 +02:00
parent ebb5db14b5
commit d8b9162932
558 changed files with 5954 additions and 4475 deletions
@@ -64,7 +64,12 @@ class DbLogResourceTest extends ResourceTestBase {
// Write a log message to the DB.
$this->container->get('logger.channel.rest')->notice('Test message');
// Get the ID of the written message.
$id = Database::getConnection()->queryRange("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, [':type' => 'rest'])
$id = Database::getConnection()->select('watchdog', 'w')
->fields('w', ['wid'])
->condition('type', 'rest')
->orderBy('wid', 'DESC')
->range(0, 1)
->execute()
->fetchField();
$this->initAuthentication();
@@ -123,7 +123,9 @@ class DbLogTest extends BrowserTestBase {
'timestamp' => REQUEST_TIME,
];
\Drupal::service('logger.dblog')->log(RfcLogLevel::NOTICE, 'Test message', $context);
$wid = Database::getConnection()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = Database::getConnection()->select('watchdog');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
// Verify the links appear correctly.
$this->drupalGet('admin/reports/dblog/event/' . $wid);
@@ -153,7 +155,10 @@ class DbLogTest extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
$wid = Database::getConnection()->query("SELECT MAX(wid) FROM {watchdog} WHERE type='access denied'")->fetchField();
$query = Database::getConnection()->select('watchdog')
->condition('type', 'access denied');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
$table = $this->xpath("//table[@class='dblog-event']");
@@ -208,7 +213,9 @@ class DbLogTest extends BrowserTestBase {
$this->generateLogEntries(1, [
'referer' => NULL,
]);
$wid = $connection->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = $connection->select('watchdog');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
// Verify table headers are present, even though the referrer is missing.
@@ -222,7 +229,9 @@ class DbLogTest extends BrowserTestBase {
$this->generateLogEntries(1, [
'request_uri' => $request_uri,
]);
$wid = $connection->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = $connection->select('watchdog');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
// Verify table headers are present.
@@ -322,7 +331,9 @@ class DbLogTest extends BrowserTestBase {
}
// View the database log event page.
$wid = Database::getConnection()->query('SELECT MIN(wid) FROM {watchdog}')->fetchField();
$query = Database::getConnection()->select('watchdog');
$query->addExpression('MIN(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
$this->assertSession()->statusCodeEquals($response);
if ($response == 200) {
@@ -335,7 +346,9 @@ class DbLogTest extends BrowserTestBase {
*/
private function verifyBreadcrumbs() {
// View the database log event page.
$wid = Database::getConnection()->query('SELECT MIN(wid) FROM {watchdog}')->fetchField();
$query = Database::getConnection()->select('watchdog');
$query->addExpression('MIN(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
$this->assertEqual(current($this->xpath($xpath))->getText(), 'Recent log messages', 'DBLogs link displayed at breadcrumb in event page.');
@@ -384,7 +397,7 @@ class DbLogTest extends BrowserTestBase {
'link' => $link,
]);
$result = Database::getConnection()->queryRange('SELECT wid FROM {watchdog} ORDER BY wid DESC', 0, 1);
$result = Database::getConnection()->select('watchdog', 'w')->fields('w', ['wid'])->orderBy('wid', 'DESC')->range(0, 1)->execute();
$this->drupalGet('admin/reports/dblog/event/' . $result->fetchField());
// Check if the link exists (unescaped).
@@ -418,7 +431,7 @@ class DbLogTest extends BrowserTestBase {
// Log out user.
$this->drupalLogout();
// Fetch the row IDs in watchdog that relate to the user.
$result = Database::getConnection()->query('SELECT wid FROM {watchdog} WHERE uid = :uid', [':uid' => $user->id()]);
$result = Database::getConnection()->select('watchdog', 'w')->fields('w', ['wid'])->condition('uid', $user->id())->execute();
foreach ($result as $row) {
$ids[] = $row->wid;
}
@@ -590,7 +603,7 @@ class DbLogTest extends BrowserTestBase {
global $base_root;
$connection = Database::getConnection();
// Get a count of how many watchdog entries already exist.
$count = $connection->query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
$count = $connection->select('watchdog')->countQuery()->execute()->fetchField();
$log = [
'channel' => 'system',
'message' => 'Log entry added to test the doClearTest clear down.',
@@ -606,7 +619,7 @@ class DbLogTest extends BrowserTestBase {
// Add a watchdog entry.
$this->container->get('logger.dblog')->log($log['severity'], $log['message'], $log);
// Make sure the table count has actually been incremented.
$this->assertEqual($count + 1, $connection->query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), new FormattableMarkup('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', [':count' => $count]));
$this->assertEqual($count + 1, (int) $connection->select('watchdog')->countQuery()->execute()->fetchField(), new FormattableMarkup('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', [':count' => $count]));
// Log in the admin user.
$this->drupalLogin($this->adminUser);
// Post in order to clear the database table.
@@ -614,7 +627,7 @@ class DbLogTest extends BrowserTestBase {
// Confirm that the logs should be cleared.
$this->drupalPostForm(NULL, [], 'Confirm');
// Count the rows in watchdog that previously related to the deleted user.
$count = $connection->query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
$count = $connection->select('watchdog')->countQuery()->execute()->fetchField();
$this->assertEqual($count, 0, new FormattableMarkup('DBLog contains :count records after a clear.', [':count' => $count]));
}
@@ -803,7 +816,9 @@ class DbLogTest extends BrowserTestBase {
// Generate a single watchdog entry.
$this->generateLogEntries(1, ['user' => $tempuser, 'uid' => $tempuser_uid]);
$wid = Database::getConnection()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = Database::getConnection()->select('watchdog');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
// Check if the full message displays on the details page.
$this->drupalGet('admin/reports/dblog/event/' . $wid);
@@ -833,7 +848,9 @@ class DbLogTest extends BrowserTestBase {
// Make sure HTML tags are filtered out in admin/reports/dblog/event/ too.
$this->generateLogEntries(1, ['message' => "<script>alert('foo');</script> <strong>Lorem ipsum</strong>"]);
$wid = Database::getConnection()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = Database::getConnection()->select('watchdog');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
$this->assertNoRaw("<script>alert('foo');</script>");
$this->assertRaw("alert('foo'); <strong>Lorem ipsum</strong>");
@@ -864,7 +881,9 @@ class DbLogTest extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('/error-test/generate-warnings');
$wid = Database::getConnection()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = Database::getConnection()->select('watchdog');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
$this->drupalGet('admin/reports/dblog/event/' . $wid);
$error_user_notice = [
@@ -39,7 +39,10 @@ class ConnectionFailureTest extends KernelTestBase {
// Re-establish the default database connection.
$database = Database::getConnection();
$wid = $database->query("SELECT MAX(wid) FROM {watchdog} WHERE message = 'testConnectionFailureLogging'")->fetchField();
$query = $database->select('watchdog')
->condition('message', 'testConnectionFailureLogging');
$query->addExpression('MAX(wid)');
$wid = $query->execute()->fetchField();
$this->assertNotEmpty($wid, 'Watchdog entry has been stored in database.');
}
@@ -40,7 +40,7 @@ class DbLogTest extends KernelTestBase {
// Generate additional log entries.
$this->generateLogEntries($row_limit + 10);
// Verify that the database log row count exceeds the row limit.
$count = Database::getConnection()->query('SELECT COUNT(wid) FROM {watchdog}')->fetchField();
$count = Database::getConnection()->select('watchdog')->countQuery()->execute()->fetchField();
$this->assertGreaterThan($row_limit, $count, new FormattableMarkup('Dblog row count of @count exceeds row limit of @limit', ['@count' => $count, '@limit' => $row_limit]));
// Get the number of enabled modules. Cron adds a log entry for each module.
@@ -66,13 +66,17 @@ class DbLogTest extends KernelTestBase {
// Get last ID to compare against; log entries get deleted, so we can't
// reliably add the number of newly created log entries to the current count
// to measure number of log entries created by cron.
$last_id = $connection->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = $connection->select('watchdog');
$query->addExpression('MAX(wid)');
$last_id = $query->execute()->fetchField();
// Run a cron job.
$this->container->get('cron')->run();
// Get last ID after cron was run.
$current_id = $connection->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
$query = $connection->select('watchdog');
$query->addExpression('MAX(wid)');
$current_id = $query->execute()->fetchField();
return $current_id - $last_id;
}