Skip to content
Snippets Groups Projects
Commit a71aa6c3 authored by Michael Lee's avatar Michael Lee
Browse files

Upgrading drupal/honeypot (2.1.0 => 2.1.2)

parent ec8f1fc5
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Database\Connection;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\KeyValueStore\KeyValueExpirableFactory;
......@@ -21,6 +22,7 @@
* Provides a service to append Honeypot protection to forms.
*/
class HoneypotService implements HoneypotServiceInterface {
use DependencySerializationTrait;
use StringTranslationTrait;
/**
......@@ -66,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.
......@@ -126,7 +128,7 @@ public function __construct(AccountProxyInterface $account, ModuleHandlerInterfa
$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;
......@@ -323,7 +325,7 @@ public function validateTimeRestriction(array &$element, FormStateInterface $for
$triggering_element = $form_state->getTriggeringElement();
// Don't do anything if the triggering element is a preview button.
if ($triggering_element['#value'] == $this->t('Preview')) {
if ($triggering_element['#value'] == (string) $this->t('Preview')) {
return;
}
......@@ -361,7 +363,8 @@ protected function log(string $form_id, string $type): void {
'%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);
}
}
......
......@@ -3,7 +3,7 @@ type: module
description: Support module for Honeypot internal testing purposes.
package: Testing
# Information added by Drupal.org packaging script on 2022-05-07
version: '2.1.0'
# Information added by Drupal.org packaging script on 2022-10-01
version: '2.1.2'
project: 'honeypot'
datestamp: 1651894956
datestamp: 1664658206
<?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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment