Error if tablesort heading 'data' is mixed-case

Created on 9 September 2022, almost 3 years ago
Updated 21 August 2025, 2 days ago

Problem/Motivation

In this case a database query is not being used - just the tablesort related header functionality in render().
The render process for #type=>table converts the header array into column headers with links that have query parameters of sort column and sort direction. The module code then gets these values and sorts the rows accordingly (eg with usort).

If the 'data' value of the table header is mixed-case, after a few re-sorts you get error:

Notice: Undefined index: route:[language]=en:/otherrefs:order=link&sort=desc
 in Drupal\Core\Cache\DatabaseBackend->getMultiple() (line 121 of core/lib/Drupal/Core/Cache/DatabaseBackend.php).

This is the render process calling cache processing (ie not reading the table's data).
If you change the 'data' values to lowercase and clear caches - all seems fine.

Related to this, the header render process should use the 'field' element for sorting not the 'data' element - which should be used just for display.
This is happening in template_preprocess_table(&$variables) (web/core/includes/theme.inc) and TableSort::header($cell_content, $cell, $variables['header'], $ts);

Steps to reproduce

Set the 'data' values to mixed case and resort a few times.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

render system

Created by

πŸ‡¬πŸ‡§United Kingdom Jons

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This came up as a daily BSI target

    Not sure I fully follow the issue, can you provide more concrete steps to reproduce this issue? Assuming it's still a bug in D11.

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

    Hi @smustgrave
    I've not tried on D11, but unless there has been major changes (or fixed) I imagine its still there.
    I can't find the original code with the issue as was a while ago.

Production build 0.71.5 2024