PHP 8+ TypeError PDOStatement when visiting the admin page

Created on 10 June 2023, over 1 year ago
Updated 11 July 2024, 4 months ago

Steps to reproduce

When trying to access the admin page at
Configuration > System > IP Geolocation Views and Maps (admin/config/system/ip_geoloc)
the following fatal error is shown:

TypeError: PDOStatement::fetchAll(): Argument #2 must be of type int, string given in PDOStatement->fetchAll() (line 2299 of /home/kwbirds/public_html/includes/database/database.inc).
The website encountered an unexpected error. Please try again later.

Proposed resolution

As I understand the problem occurs because of lines 410 & 411 of the file ip_geoloc.admin.inc which should be changed
from

  $hostnames = db_query('SELECT DISTINCT hostname FROM {accesslog} ORDER BY aid DESC')->fetchCol('hostname');
  $ip_geolocations = db_query('SELECT DISTINCT ip_address FROM {ip_geoloc}')->fetchCol('ip_address');

to

  $hostnames = db_query('SELECT DISTINCT hostname FROM {accesslog} ORDER BY aid DESC')->fetchCol();
  $ip_geolocations = db_query('SELECT DISTINCT ip_address FROM {ip_geoloc}')->fetchCol();
πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡·Greece arx-e

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024