Views _initHandler incorrect code documentation

Created on 3 May 2024, 8 months ago

Problem/Motivation

Update code comments to reflect reality.

Currently in core/modules/views/src/ViewExecutable.php _initHandler has a comment suggesting that expected values for the 'key' should be a string that is in the set ('argument', 'field', 'sort', 'filter', 'relationship')

While trying to debug a views handler issue I noticed that even on a clean install if viewing Watchdog various other values show up here:
namely 'empty', 'footer', and 'header'.

Steps to reproduce

On a clean install of drupal either:
A) set a conditional breakpoint in web/core/modules/views/src/ViewExecutable.php _initHandler on $key being not one of the above mentioned values or
B) edit web/core/modules/views/src/ViewExecutable.php and use some php to do the same at the start of the function i.e.

if (!in_array($key, ['argument', 'field', 'sort', 'filter', 'relationship'])){  
\Drupal::logger('viewdebug')->error('@key - key not on the list.', ['@key'=> $key]);
}

Head to admin/reports/dblog refresh the page and watch the entries show up.

Proposed resolution

I'm unclear if this is a case of
A) code documentation not keeping up with reality; or
B) or there being actual problems here.
I'm inclined to A)

Remaining tasks

Assuming A above update drupal core comments.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Documentation 

Last updated 1 day ago

No maintainer
Created by

🇳🇿New Zealand luke.stewart

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

Comments & Activities

Production build 0.71.5 2024