Skip to content

PHP 8: Attempt to read property "type" on null in ProcessVersionControl.module:668 #53

Description

@inreti-sb

Bug

On PHP 8.x, the following warning is thrown whenever renderHTML() iterates over a field that no longer exists in the database (e.g. a field that was deleted after version-control data was recorded for it):

Warning: Attempt to read property "type" on null in .../modules/VersionControl/ProcessVersionControl.module:668

Affected line

ProcessVersionControl.module, line 668:

if ($diff && wire('fields')->get($field)->type instanceof FieldtypeFile) $diff = "";

wire('fields')->get($field) returns null when the field no longer exists. PHP 7 silently ignored the property access on null; PHP 8 emits a warning (and depending on error_reporting, can break page output).

Environment

  • ProcessWire: 3.0.255
  • VersionControl: 1.3.5
  • PHP: 8.4

Proposed fix

Add a null-guard before accessing ->type:

if ($diff && ($f = wire('fields')->get($field)) && $f->type instanceof FieldtypeFile) $diff = "";

One-line change, no behaviour change — simply skips the FieldtypeFile check when the field no longer exists in ProcessWire.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions