Firewall Class doesn't use db table prefix

Created on 28 April 2021, over 3 years ago
Updated 22 March 2023, almost 2 years ago

Problem/Motivation

When the \Cleantalk\Common\Firewall\Firewall class is constructed, it uses a hard-coded table name constant without respecting defined database table prefixes.

Steps to reproduce

  1. Have a Drupal database defined with a table prefix.
  2. Install cleantalk and enable the firewall.
  3. Run cron.
  4. Check the logs, Drupal\cleantalk\CleantalkFuncs::apbct_sfw_send_logs() should generate a SQLSTATE error: Base table or view not found.

Proposed resolution

Check for a prefix and add that.

🐛 Bug report
Status

RTBC

Version

9.2

Component

Code

Created by

🇳🇱Netherlands basvredeling Amsterdam

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to RTBC almost 2 years ago
  • 🇸🇮Slovenia joco_sp

    I see that this is implemented in the 9.1.x. When will it be committed? Because it's still a problem in the latest stable 9.2.3 version of the module.

  • 🇷🇺Russia znaeff

    Hello,

    Please contact us by our private ticket system:

    https://cleantalk.org/my/support/open

    We need more details about the issue.

  • 🇸🇮Slovenia joco_sp

    The same issue:
    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DB_NAME.cleantalk_sfw' doesn't exist ..... in Cleantalk\Custom\Db\Db->fetchAll() (line 81 of /contrib/cleantalk/lib/Cleantalk/Custom/Db/Db.php)

    It looks like everywhere the table_name is used, the prefix is not added to it.

  • 🇷🇺Russia znaeff

    I will ask our developers to check this. We will contact you within 3-4 business days.

  • 🇷🇺Russia znaeff

    We plan to release a new version with the fixes within 1-2 months. You can try to re-install the plugin. Some users reported that it helped

  • 🇸🇮Slovenia joco_sp

    This is quite a long period, because the problem creates a WSOD.

    Reinstalling the module doesn't help, because there is a bug in the code. Where the db_prefix is not added to the table name. Therefore if you have a database with tables that have prefixes, when the query is used, you get the WSOD. I first thought it was just in \Cleantalk\Common\Firewall\Firewall, but then I got also other errors. So, I suspect this is a problem on multiple places.

    The attached patch solves the issue in 328 line \Cleantalk\Common\Firewall\Firewall::sfw_send_logs(), but not in line 81 of /contrib/cleantalk/lib/Cleantalk/Custom/Db/Db.php).

    I'm using core 9.5.4. PHP 8. Module version 9.2.3.

  • 🇷🇺Russia znaeff

    I will ask our developers to check this. We will contact you within 3-4 business days.

  • 🇷🇺Russia znaeff

    https://www.drupal.org/project/cleantalk/issues/3211127#comment-14961877 🐛 Firewall Class doesn't use db table prefix RTBC
    The issue has been resolved and all fixes are in the 9.1 and later versions.

  • 🇸🇮Slovenia joco_sp

    I just updated the module to v9.2.3 in another project and I'm still getting the same error.

    I see the change in the 9.1.x branch, but not in the 9.2.3 tag. Hopefully will be committed to the next release, because this error is breaking the module for who has the database table prefix + firewall enabled.

    @znaeff tnx for the fix in the 9.1.x version. For now, until we don't get the version with that fixed, I applied the patch from the 9.1.x commit and it looks like this fixed the problem. We will test it on multiple projects and come back if we'll still have this issue.

  • 🇷🇺Russia znaeff

    This fix will be included in the next stable release.

Production build 0.71.5 2024