/** * Tests corrupted log entries can still display available data. */ public function testDbLogCorrupted() { $this->installEntitySchema('user'); $dblog_controller = DbLogController::create($this->container); // Check message with properly serialized data. $message = (object) ['message' => 'Sample message with placeholder: @placeholder', 'variables' => serialize(['@placeholder' => 'test placeholder'])]; $this->assertEquals('Sample message with placeholder: test placeholder', $dblog_controller->formatMessage($message)); // Check that controller work with corrupted data. $message->variables = 'BAD SERIALIZED DATA'; $formatted = $dblog_controller->formatMessage($message); $this->assertEquals('Log data is corrupted and cannot be unserialized: Sample message with placeholder: @placeholder', $formatted); }
/** * Gets the watchdog severity constant corresponding to the CSS class. * * @param string $class * CSS class attribute. * * @return int|null * The watchdog severity constant or NULL if not found. */ protected function getSeverityConstant($class) { $map = array_flip(DbLogController::getLogLevelClassMap()); // Find the class that contains the severity. $classes = explode(' ', $class); foreach ($classes as $class) { if (isset($map[$class])) { return $map[$class]; } } return NULL; }