Static field info caches cannot be rebuilt during the same requests

Created on 6 February 2017, about 8 years ago
Updated 12 March 2025, 26 days ago

Problem/Motivation

field_encrypt.inc statically caches field info (metadata) using PHP's native static variables. While this probably serves to achieve the desired performance improvement, such caches can never be modified from outside the functions they are defined in. In practice, it means they are not kept up-to-date with system changes during the same request, and their functions will act on stale data, causing bugs that are hard to find and fix.

Proposed resolution

Use drupal_static(), which is Drupal 7's solution to flushable static caches in procedural contexts. Such caches can easily be cleared by calling drupal_static_reset(), which is what core does to keep all static caches up-to-date with the system during the same request.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom Xano Southampton

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.

Production build 0.71.5 2024