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:
- Restore
return null; and update phpdoc.
- 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
Short description of the issue
Commit a7884201 ("Improvements to NullPage class") changed
NullPage::parent()to return a freshly-allocated NullPage rather thannull. 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:The
forceNew=trueargument also means every call allocates a fresh NullPage, so$page->parent()->parent()builds N new objects.Optional: Suggestion for a possible fix
Either:
return null;and update phpdoc.@return NullPage. Add a note to the upgrade docs.Setup/Environment
dev@15c749edwire/core/NullPage.php:84-89