Problem/Motivation

If a cron job for example logs a lot, it is possible that the aggregated string is too long for a text field. We could also make the field bigger, but this seemed like a quicker fix.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Needs review » Needs work

The last submitted patch, 2: ultimate-cron-message-length.patch, failed testing.

The last submitted patch, 2: ultimate-cron-message-length.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
2.77 KB

Patch was incomplete.

Berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
Berdir’s picture

See \Drupal\ultimate_cron\Tests\LoggerWebTest::testLoggerFatal(), we need something similar, a new action that logs a string that is longer than the allowed amount, thn we need to make sure that it is cut of correctly.

tduong’s picture

The last submitted patch, 8: ultimate-cron-message-length-2785447-8-test_only.patch, failed testing.

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Tests/LoggerWebTest.php
    @@ -84,6 +84,31 @@ class LoggerWebTest extends WebTestBase {
    +    $this->assertRaw('/core/misc/icons/e32700/error.svg');
    

    see below, no need to log an error, we just care about the length here.

  2. +++ b/src/Tests/LoggerWebTest.php
    @@ -84,6 +84,31 @@ class LoggerWebTest extends WebTestBase {
    +    // Empty the logfile, our fatal errors are expected.
    +    $filename = DRUPAL_ROOT . '/sites/simpletest/' . substr($this->databasePrefix, 10) . '/error.log';
    +    file_put_contents($filename, '');
    

    this part isn't needed, we don't have any fatals. also the ignore errors stuff above.

  3. +++ b/tests/ultimate_cron_logger_test/ultimate_cron_logger_test.module
    @@ -16,6 +18,11 @@ function ultimate_cron_logger_test_cron() {
    +    \Drupal::logger('ultimate_cron_logger_test_cron')->log(RfcLogLevel::ERROR, $long_message);
    

    you can use ->error(). or lets just use ->notice() here, because this is not really an error.

The last submitted patch, 11: ultimate-cron-message-length-2785447-11-test_only.patch, failed testing.

  • Berdir committed 0277481 on 8.x-2.x
    Issue #2785447 by tduong, Berdir: Ultimate cron log messages can be too...
Berdir’s picture

Status: Needs review » Fixed

Those can go too:

diff --git a/src/Tests/LoggerWebTest.php b/src/Tests/LoggerWebTest.php
index e6b6871..89166e0 100644
--- a/src/Tests/LoggerWebTest.php
+++ b/src/Tests/LoggerWebTest.php
@@ -91,9 +91,7 @@ class LoggerWebTest extends WebTestBase {
     \Drupal::state()->set('ultimate_cron_logger_test_cron_action', 'long_message');
 
     // Run cron to get a long message log from ultimate_cron_logger_test.
-    $this->ignoreErrors = TRUE;
     $this->cronRun();
-    $this->ignoreErrors = TRUE;
 
     // Check that the long log message is properly trimmed.
     $this->drupalGet('admin/config/system/cron/jobs/logs/ultimate_cron_logger_test_cron');

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.