Commit 5e5d871a authored by Conrad Lara's avatar Conrad Lara Committed by Tim Rohaly
Browse files

Issue #3279917 by plach, cmlara: LogicException: The database connection is not serializable

parent ff6aa0f5
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -68,11 +68,11 @@ class HoneypotService implements HoneypotServiceInterface {
  protected $connection;

  /**
   * The Honeypot logger channel.
   * The Honeypot logger channel factory.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  protected $logger;
  protected $loggerFactory;

  /**
   * The datetime.time service.
@@ -128,7 +128,7 @@ class HoneypotService implements HoneypotServiceInterface {
    $this->keyValue = $key_value->get('honeypot_time_restriction');
    $this->killSwitch = $kill_switch;
    $this->connection = $connection;
    $this->logger = $logger_factory->get('honeypot');
    $this->loggerFactory = $logger_factory;
    $this->timeService = $time_service;
    $this->stringTranslation = $string_translation;
    $this->cacheBackend = $cache_backend;
@@ -363,7 +363,8 @@ class HoneypotService implements HoneypotServiceInterface {
        '%form'  => $form_id,
        '@cause' => ($type == 'honeypot') ? $this->t('submission of a value in the honeypot field') : $this->t('submission of the form in less than minimum required time'),
      ];
      $this->logger->notice('Blocked submission of %form due to @cause.', $variables);
      $this->loggerFactory->get('honeypot')
        ->notice('Blocked submission of %form due to @cause.', $variables);
    }
  }

+42 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\honeypot\FunctionalJavascript;

use Drupal\Tests\file\FunctionalJavascript\FileFieldWidgetTest;

/**
 * Tests the file field widget with the Honeypot module enabled.
 *
 * @group honeypot
 */
class HoneypotFileFieldTest extends FileFieldWidgetTest {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'honeypot',
    'node',
    'file',
    'file_module_test',
    'field_ui',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();

    // Set up required Honeypot configuration.
    $honeypot_config = \Drupal::configFactory()->getEditable('honeypot.settings');
    $honeypot_config->set('element_name', 'url');
    // Disable time_limit protection.
    $honeypot_config->set('time_limit', 0);
    // Test protecting all forms.
    $honeypot_config->set('protect_all_forms', TRUE);
    $honeypot_config->set('log', FALSE);
    $honeypot_config->save();
  }

}