Deprecated function: Creation of dynamic property Cleantalk\Common\Firewall\Modules\Sfw::$set_cookies

Created on 6 September 2023, 10 months ago
Updated 27 November 2023, 7 months ago

Problem/Motivation

My site has been upgraded to Drupal 10.1.2 and every pageload seems to generate an error in the system log.

Deprecated function: Creation of dynamic property Cleantalk\Common\Firewall\Modules\Sfw::$set_cookies is deprecated in Cleantalk\Common\Firewall\Modules\Sfw->__construct() (line 70 of /var/www/drupal/web/modules/contrib/cleantalk/lib/Cleantalk/Common/Firewall/Modules/Sfw.php)
#0 /var/www/drupal/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real()
#1 /var/www/drupal/web/modules/contrib/cleantalk/lib/Cleantalk/Common/Firewall/Modules/Sfw.php(70): _drupal_error_handler()
#2 /var/www/drupal/web/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(115): Cleantalk\Common\Firewall\Modules\Sfw->__construct()
#3 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle()
#4 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#5 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#6 /var/www/drupal/web/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php(166): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#7 /var/www/drupal/web/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php(119): Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber->makeSubrequest()
#8 /var/www/drupal/web/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php(81): Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber->makeSubrequestToCustomPath()
#9 /var/www/drupal/web/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php(109): Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber->on404()
#10 [internal function]: Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase->onException()
#11 /var/www/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#12 /var/www/drupal/vendor/symfony/http-kernel/HttpKernel.php(240): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#13 /var/www/drupal/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable()
#14 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#15 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#16 /var/www/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#17 /var/www/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#18 /var/www/drupal/web/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(187): Drupal\page_cache\StackMiddleware\PageCache->handle()
#19 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle()
#20 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#21 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#22 /var/www/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#23 /var/www/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#24 {main}

As best I can tell, Cleantalk is still working (I get very little spam to this site because I keep it out of Search Engines)

Steps to reproduce

Upgrade from Drupal 9 to Drupal 10 using composer. Notice your site works, but every page load adds a message to the system log.

Site Info:

www-data@X:~/drupal$ drush @X status
Drupal version   : 10.1.2
Site URI         : https://X.com
DB driver        : mysql
DB hostname      : localhost
DB port          : 3306
DB username      : X
DB name          : X
Database         : Connected
Drupal bootstrap : Successful
Default theme    : bootstrap5
Admin theme      : adminimal_theme
PHP binary       : /usr/bin/php8.2
PHP config       : /etc/php/8.2/cli/php.ini
PHP OS           : Linux
PHP version      : 8.2.7
Drush script     : /var/www/drupal/vendor/drush/drush/drush
Drush version    : 12.1.3.0
Drush temp       : /tmp
Drush configs    : /var/www/drupal/vendor/drush/drush/drush.yml
Install profile  : standard
Drupal root      : /var/www/drupal/web
Site path        : sites/X.com
Files, Public    : sites/X.com/files
Files, Temp      : /tmp

Proposed resolution

N/A

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

9.2

Component

Code

Created by

🇳🇿New Zealand tjharman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tjharman
  • 🇺🇸United States Serge-M

    Hello.
    Thank you for your request.
    We will look into it and test our Anti-Spam for Drupal 10 within 3 business days.
    Please, wait.

  • Assigned to Shreya_98
  • First commit to issue fork.
  • Assigned to shubham_jain
  • 🇮🇳India shubham_jain

    Hi, I have fixed deprecated function, please review and verify.

  • @shubham_jain opened merge request.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India shubham_jain

    If the above merge doesn't solve the issue then you can code this

    private $logTable;
        private $dataTable;
        private $params = [];
    
        public function __construct($log_table, $data_table, $params = []) {

    in place of public function __construct($log_table, $data_table, $params = array())to solve the issue.

  • 🇺🇸United States Serge-M

    Hello and thank you for your effort.
    I added your suggestions to the task. Please, wait up to 3 work days.

  • 🇳🇿New Zealand tjharman

    The patch in #5 breaks the website.

    [Sat Sep 16 08:08:38.363144 2023] [proxy_fcgi:error] [pid 1851118:tid 129741197379264] [remote 192.168.0.131:51663] AH01071: Got error 'PHP message: PHP Fatal error: Attribute "AllowDynamicProperties" cannot target method (allowed targets: class) in /var/www/drupal/web/modules/contrib/cleantalk/lib/Cleantalk/Common/Firewall/Modules/Sfw.php on line 58'

  • 🇮🇳India shubham_jain

    Hi @tjharman, please use the code in comment #7 and the original code.

  • 🇷🇺Russia znaeff

    Dear customers

    We have added a new feature, now you can send debug logs without having to provide access to your site.

    Please install this version and send us the debug logs.

  • 🇬🇧United Kingdom alfaguru

    The MR above is not correct because the annotation to suppress the message applies at the class level, not at the function level, and it's being applied to the wrong class. I attach a patch that works for me with PHP 8.2.

  • 🇷🇺Russia znaeff

    Thank you @alfaguru. I will add this patch and all the info to the task. We will check it and will let you know the results.

  • 🇦🇹Austria agoradesign

    +1 for #12

  • 🇺🇸United States Serge-M

    Hello,

    We have fixed the issues and released a new version 9.3.0:
    https://www.drupal.org/project/cleantalk/releases/9.3.0

    Please, update the module and clear your website cache.

    Did it help?

  • 🇦🇹Austria agoradesign

    no, not all of them. I was already using 9.3.0 and still had one of these deprecation warnings:

    Deprecated function: Creation of dynamic property Cleantalk\Custom\Db\Db::$db_result is deprecated in Cleantalk\Custom\Db\Db->fetchAll() (Zeile 81 in /web/modules/contrib/cleantalk/lib/Cleantalk/Custom/Db/Db.php)

  • 🇷🇺Russia znaeff

    Hello agoradesign,

    The warning you specified is different. Please create a separate thread.
    Our developers will deal with this issue and within 5 working days we will report the result in your new thread.

  • Status changed to Active 7 months ago
Production build 0.69.0 2024