You are here

private function SpiController::get404s in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::get404s()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::get404s()

Grabs the last 404 errors in logs.

Grabs the last 404 errors in logs, excluding the checks we run for drupal files like README.

Return value

array An array of the pages not found and some associated data.

1 call to SpiController::get404s()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 485

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function get404s() {
  $data = [];
  $row = 0;
  if ($this
    ->moduleHandler()
    ->moduleExists('dblog')) {
    $result = Database::getConnection()
      ->select('watchdog', 'w')
      ->fields('w', [
      'message',
      'hostname',
      'referer',
      'timestamp',
    ])
      ->condition('w.type', 'page not found', '=')
      ->condition('w.timestamp', \Drupal::time()
      ->getRequestTime() - 3600, '>')
      ->condition('w.message', [
      "UPGRADE.txt",
      "MAINTAINERS.txt",
      "README.txt",
      "INSTALL.pgsql.txt",
      "INSTALL.txt",
      "LICENSE.txt",
      "INSTALL.mysql.txt",
      "COPYRIGHT.txt",
      "CHANGELOG.txt",
    ], 'NOT IN')
      ->orderBy('w.timestamp', 'DESC')
      ->range(0, 10)
      ->execute();
    foreach ($result as $record) {
      $data[$row]['message'] = $record->message;
      $data[$row]['hostname'] = $record->hostname;
      $data[$row]['referer'] = $record->referer;
      $data[$row]['timestamp'] = $record->timestamp;
      $row++;
    }
  }
  return $data;
}