Skip to content

PDOException: no such column: [tablename].rid when using <struct_table> after PHP 8.1 upgrade #735

Open
@etwas7B

Description

@etwas7B

Environment:

DokuWiki Version: 2024-02-06 "Kaos"
PHP Version: 8.1.2 (Upgraded from PHP 7.2)
Struct Plugin Version: Latest available
SQLite Plugin Version: Latest available
Other relevant plugins: maybe Bootswrapper

Description:

After successfully upgrading the server environment from PHP 7.2 to PHP 8.1 and updating DokuWiki and all plugins (including Struct and SQLite) to their latest versions, most functionalities work correctly.

However, pages containing Struct aggregation tables (<struct_table>...</struct_table>) now fail to render properly. Instead, a PDOException is thrown, indicating a missing column named rid.

Error Message:

The specific error displayed on the page (or found in logs) is:
PDOException: SQLSTATE[HY000]: General error: 1 no such column: data_lookup_webtools_projekte.rid
(Note: The table name like data_lookup_webtools_projekte varies depending on the specific struct schema/table being queried. I have observed this error for multiple different struct tables, e.g., also for data_schema_hotline.rid)

The DokuWiki error log shows the following stack trace leading to the exception:

2025-04-16 10:46:21	/var/www/html/dokuwiki/lib/plugins/sqlite/SQLiteDB.php(151)	PDOException: SQLSTATE[HY000]: General error: 1 no such column: data_lookup_webtools_projekte.rid
  #0 /var/www/html/dokuwiki/lib/plugins/struct/meta/Search.php(471): dokuwiki\plugin\sqlite\SQLiteDB->query()
  #1 /var/www/html/dokuwiki/lib/plugins/struct/meta/Search.php(393): dokuwiki\plugin\struct\meta\Search->run()
  #2 /var/www/html/dokuwiki/lib/plugins/struct/meta/Search.php(403): dokuwiki\plugin\struct\meta\Search->getResult()
  #3 /var/www/html/dokuwiki/lib/plugins/struct/meta/AggregationTable.php(28): dokuwiki\plugin\struct\meta\Search->getCount()
  #4 /var/www/html/dokuwiki/lib/plugins/struct/syntax/table.php(126): dokuwiki\plugin\struct\meta\AggregationTable->render()
  #5 /var/www/html/dokuwiki/inc/parser/renderer.php(126): syntax_plugin_struct_table->render()
  #6 /var/www/html/dokuwiki/inc/parserutils.php(535): Doku_Renderer->plugin()
  #7 /var/www/html/dokuwiki/inc/parserutils.php(299): p_render_metadata()
  #8 /var/www/html/dokuwiki/inc/common.php(262): p_get_metadata()
  #9 /var/www/html/dokuwiki/doku.php(101): pageinfo()
  #10 {main}

Schema Information:

I have verified the schema of the affected Struct data tables in the struct.sqlite3 database (located in /data/meta/). The tables correctly contain the pid, rev, latest columns and the user-defined columns, but do not contain a column named rid. pid is the INTEGER PRIMARY KEY.

Example CREATE TABLE statement for one of the affected tables:

CREATE TABLE data_lookup_webtools_projekte (
    pid INTEGER PRIMARY KEY,
    rev INTEGER NOT NULL DEFAULT 0,
    latest BOOLEAN NOT NULL DEFAULT 1,
    col1 DEFAULT '',
    col2 DEFAULT '',
    col3 DEFAULT '',
    col4 DEFAULT '',
    col5 DEFAULT '',
    published INT DEFAULT NULL
)

Analysis:

The error and stack trace strongly suggest that the Struct plugin, specifically within the Search->getCount() method called during the rendering of <struct_table> aggregations, is generating an SQL query that incorrectly references a column named [tablename].rid. Since this column does not exist (SQLite uses the pid column as the rowid alias due to INTEGER PRIMARY KEY), the query fails.

This issue appears to be specific to the interaction with PHP 8.1, as it did not occur under PHP 7.2 with the same data and configuration (before updates). It seems like a bug in the SQL generation logic within the Struct plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions