mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
Fix PHP 8.1 "strlen(null)" exception which blocks rendering the Projects page (and log alien values)
Summary: `strlen()` was used in Phabricator to check if a generic value is a non-empty string. This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a general replacement. In this specific case we use `phutil_nonempty_stringlike()` since we are not sure if the variable `href` should be just a string or other objects. In order not to leave these cases to chance, we have added a log line, which can be removed in the future. Note: this may highlight other absurd input values that might be worth correcting instead of just ignoring. If phutil_nonempty_string() throws an exception in your instance, report it to Phorge to evaluate and fix that specific corner case. Closes T15303 Ref T15316 Test Plan: Applied this change (on top of D25144, D25145, D25146, D25147, D25150, D25142) and `/project/` rendered in web browser. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15303, T15316 Differential Revision: https://we.phorge.it/D25153
This commit is contained in:
parent
b44665aefe
commit
4d88095f2a
1 changed files with 18 additions and 1 deletions
|
@ -100,7 +100,24 @@ final class PHUITagView extends AphrontTagView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the href attribute
|
||||
*
|
||||
* @param string|null $href
|
||||
* @return self
|
||||
*/
|
||||
public function setHref($href) {
|
||||
|
||||
// We have not a very clear idea about what this method should receive
|
||||
// We suspect that PhutilURI should be allowed... but let's log everything!
|
||||
// https://we.phorge.it/T15316
|
||||
if (is_object($href)) {
|
||||
phlog(sprintf(
|
||||
'Received unexpected type for href: %s. '.
|
||||
'Please paste this log as comment in https://we.phorge.it/T15316',
|
||||
get_class($href)));
|
||||
}
|
||||
|
||||
$this->href = $href;
|
||||
return $this;
|
||||
}
|
||||
|
@ -126,7 +143,7 @@ final class PHUITagView extends AphrontTagView {
|
|||
}
|
||||
|
||||
protected function getTagName() {
|
||||
return strlen($this->href) ? 'a' : 'span';
|
||||
return phutil_nonempty_stringlike($this->href) ? 'a' : 'span';
|
||||
}
|
||||
|
||||
public function setContextObject($context_object) {
|
||||
|
|
Loading…
Reference in a new issue