PrivateTempStore::set() will fail if $key is too long

Created on 29 June 2023, over 1 year ago
Updated 11 November 2023, about 1 year ago

Problem/Motivation

When PrivateTempStore::set() writes to database table key_value_expire, the name column must be no more than 128 characters. If the $key param to ::set() is too long, it will exceed this.

This problem is the cause of 🐛 Data too long for column 'name' error when exporting as anonymous user Needs review .

The key written to the database comes from ::createkey(), which prepends the value from ::getOwner(). In the case of anonymous users, this is 44 characters.

Proposed resolution

Update ::createkey() function to check length of the key and if it exceeds the set limit then

  1. hash the key
  2. Trim the original key from last (max length - hashed key length)
  3. Prefix the trimmed key from step 2 to hashed key created in step 1

Thus the key length will be limited and we will also preserve as much initial part of original key for the purpose of diagnosing.

Remaining tasks

Agree on what steps to take. Implement.

User interface changes

None.

API changes

If a throw statement is added, the error generated when the key is too long would change.

If the comprehensive fix is implemented, longer values for $key would be a possible.

Data model changes

None.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Base 

Last updated about 5 hours ago

Created by

🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

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

Comments & Activities

Production build 0.71.5 2024