SQLSTATE[42S22] column not found : Log Analyze Page Error (may be related to issue 3335947)

Created on 13 February 2023, almost 2 years ago
Updated 11 May 2023, over 1 year ago

Just noticed this error on admin autoban/analyze page (which may be related to https://www.drupal.org/project/autoban/issues/3335947 πŸ› Deprecated function: trim(): Passing null to parameter #1 ($string) in AutobanController.php Needs review - not sure, it could be unrelated) Near as I can tell it was introduced with changes in 8.x-1.8 which included a new feature.

The following error (which I didn't notice until now and appears for both version 8.x 1.8 and dev):

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'log.messagelog.type' in 'group statement': SELECT "log"."message" AS "message", "log"."type" AS "type", COUNT(*) AS "cnt" FROM "watchdog" "log" WHERE "log"."type" NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4) GROUP BY "log"."messagelog"."type" HAVING (COUNT(*) >= :threshold) ORDER BY "cnt" DESC; Array ( [:db_condition_placeholder_0] => autoban [:db_condition_placeholder_1] => cron [:db_condition_placeholder_2] => php [:db_condition_placeholder_3] => system [:db_condition_placeholder_4] => user [:threshold] => 5 ) in Drupal\autoban\Form\AutobanAnalyzeForm->getAnalyzeResult() (line 286 of modules/contrib/autoban/src/Form/AutobanAnalyzeForm.php).
Drupal\Core\Database\StatementWrapper->execute(Array, Array) (Line: 946)
Drupal\Core\Database\Connection->query('SELECT "log"."message" AS "message", "log"."type" AS "type", COUNT(*) AS "cnt"
FROM
{watchdog} "log"
WHERE "log"."type" NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4)
GROUP BY "log"."messagelog"."type"
HAVING (COUNT(*) >= :threshold)
ORDER BY "cnt" DESC', Array, Array) (Line: 525)
Drupal\Core\Database\Query\Select->execute() (Line: 329)
Drupal\Core\Database\Query\SelectExtender->execute() (Line: 286)
Drupal\autoban\Form\AutobanAnalyzeForm->getAnalyzeResult(Array, '5', 'autoban
cron
php
system
user') (Line: 92)
Drupal\autoban\Form\AutobanAnalyzeForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm('autoban_analyze_form', Object) (Line: 281)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 57)
Drupal\advban\AdvbanMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

The above is displayed instead of the log analyze page:

Dblog recorded this:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'log.messagelog.type' in 'group statement': SELECT "log"."message" AS "message", "log"."type" AS "type", COUNT(*) AS "cnt" FROM "watchdog" "log" WHERE "log"."type" NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4) GROUP BY "log"."messagelog"."type" HAVING (COUNT(*) >= :threshold) ORDER BY "cnt" DESC; Array ( [:db_condition_placeholder_0] => autoban [:db_condition_placeholder_1] => cron [:db_condition_placeholder_2] => php [:db_condition_placeholder_3] => system [:db_condition_placeholder_4] => user [:threshold] => 5 ) in Drupal\autoban\Form\AutobanAnalyzeForm->getAnalyzeResult() (line 286 of /var/www/html/web/modules/contrib/autoban/src/Form/AutobanAnalyzeForm.php).

For good measure my setup is Drupal version 9.5.3, PHP 8.1.13 on Apache 2.4.38 (I have one site using Autoban 8.x-1.8 and another on 8.x-1.x-dev)

If you need more information let me know..

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sidgrafix

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

Comments & Activities

  • Issue created by @sidgrafix
  • I have the same problem:
    Dblog message:
    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'log.messagelog.type' in 'group statement': SELECT "log"."message" AS "message", "log"."type" AS "type", COUNT(*) AS "cnt" FROM "watchdog" "log" WHERE "log"."type" NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5, :db_condition_placeholder_6, :db_condition_placeholder_7, :db_condition_placeholder_8, :db_condition_placeholder_9, :db_condition_placeholder_10) GROUP BY "log"."messagelog"."type" HAVING (COUNT(*) >= :threshold) ORDER BY "cnt" DESC; Array ( [:db_condition_placeholder_0] => autoban [:db_condition_placeholder_1] => cron [:db_condition_placeholder_2] => php [:db_condition_placeholder_3] => system [:db_condition_placeholder_4] => user [:db_condition_placeholder_5] => locale [:db_condition_placeholder_6] => smtp [:db_condition_placeholder_7] => content [:db_condition_placeholder_8] => menu [:db_condition_placeholder_9] => xmlsitemap [:db_condition_placeholder_10] => advanced ban [:threshold] => 2 ) in Drupal\autoban\Form\AutobanAnalyzeForm->getAnalyzeResult() (line 286 of /___/public_html/modules/autoban/src/Form/AutobanAnalyzeForm.php).

  • Getting the same error when I click on Log analyze tab.

    I am using Autoban with the Core ban module. Drupal 9.5.5 and PHP 8.0.27

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'log.messagelog.type' in 'group statement': SELECT "log"."message" AS "message", "log"."type" AS "type", COUNT(*) AS "cnt" FROM "watchdog" "log" WHERE "log"."type" NOT IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5, :db_condition_placeholder_6, :db_condition_placeholder_7, :db_condition_placeholder_8, :db_condition_placeholder_9, :db_condition_placeholder_10, :db_condition_placeholder_11, :db_condition_placeholder_12, :db_condition_placeholder_13, :db_condition_placeholder_14, :db_condition_placeholder_15, :db_condition_placeholder_16, :db_condition_placeholder_17, :db_condition_placeholder_18) GROUP BY "log"."messagelog"."type" HAVING (COUNT(*) >= :threshold) ORDER BY "cnt" DESC; Array ( [:db_condition_placeholder_0] => autoban [:db_condition_placeholder_1] => cron [:db_condition_placeholder_2] => php [:db_condition_placeholder_3] => system [:db_condition_placeholder_4] => user [:db_condition_placeholder_5] => content [:db_condition_placeholder_6] => serial_launcher [:db_condition_placeholder_7] => ultimate_cron_lock [:db_condition_placeholder_8] => database_logger [:db_condition_placeholder_9] => feeds [:db_condition_placeholder_10] => image [:db_condition_placeholder_11] => content_lock_timeout [:db_condition_placeholder_12] => advanced ban [:db_condition_placeholder_13] => search_api [:db_condition_placeholder_14] => search_api_pantheon [:db_condition_placeholder_15] => access denied [:db_condition_placeholder_16] => menu [:db_condition_placeholder_17] => redirect [:db_condition_placeholder_18] => simple_sitemap [:threshold] => 3 ) in Drupal\autoban\Form\AutobanAnalyzeForm->getAnalyzeResult() (line 286 of /code/web/modules/contrib/autoban/src/Form/AutobanAnalyzeForm.php).

  • In order to use multiple groupBy's in a query they must be separated into separate calls instead of listing them together.

    When I updated

    $query->groupBy('log.message, log.type');
    

    to

    $query->groupBy('log.message');
    $query->groupBy('log.type');
    

    Analyze logs admin section started working again. I'll see if I can make a patch in a little bit so that it can be committed and fixed.

  • @catapipper opened merge request.
  • Status changed to Needs review over 1 year ago
  • Status changed to RTBC over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

    Had this issue: used the change in the MR and the issue was resolved.

  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    Merged, many thanks

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • πŸ‡ͺπŸ‡ΈSpain lapurddrupal

    I got the same Error: 1054 Unknown column 'log.messagelog.type....... after installing autoban 8.1 recently via composer.
    Where is a patch I may use? Drupal 9.5.8, PHP 8.1.16 .

  • πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

    You can use the dev version of the module, or get a patch from the MR by adding .patcxh to its URL: so https://git.drupalcode.org/project/autoban/-/merge_requests/7.patch

  • πŸ‡ͺπŸ‡ΈSpain lapurddrupal

    Thanks a lot MrDaleSmith, it cured the problem.

Production build 0.71.5 2024