Skip to content

NullPage::parent() now returns a NullPage instead of null — undocumented BC break (a7884201) #2243

@adrianbj

Description

@adrianbj

Short description of the issue

Commit a7884201 ("Improvements to NullPage class") changed NullPage::parent() to return a freshly-allocated NullPage rather than null. The phpdoc still says @return null. Callers doing strict-null checks (if($page->parent() === null)) silently change behavior.

Expected behavior

Either keep returning null (semantically a non-existent page has no parent), or update the phpdoc and call this out in the changelog as a BC break.

Actual behavior

wire/core/NullPage.php:84-89:

public function parent($selector = '') {
    return $this->wire()->pages->newNullPage(true);
}

The forceNew=true argument also means every call allocates a fresh NullPage, so $page->parent()->parent() builds N new objects.

Optional: Suggestion for a possible fix

Either:

  1. Restore return null; and update phpdoc.
  2. If the new behavior is intentional, cache the NullPage and update phpdoc to @return NullPage. Add a note to the upgrade docs.

Setup/Environment

  • ProcessWire version: dev @ 15c749ed
  • File: wire/core/NullPage.php:84-89
  • Changed in commit a7884201

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions