@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+18 -1
+18 -1
src/view/phui/PHUITagView.php
··· 100 100 return $this; 101 101 } 102 102 103 + /** 104 + * Set the href attribute 105 + * 106 + * @param string|null $href 107 + * @return self 108 + */ 103 109 public function setHref($href) { 110 + 111 + // We have not a very clear idea about what this method should receive 112 + // We suspect that PhutilURI should be allowed... but let's log everything! 113 + // https://we.phorge.it/T15316 114 + if (is_object($href)) { 115 + phlog(sprintf( 116 + 'Received unexpected type for href: %s. '. 117 + 'Please paste this log as comment in https://we.phorge.it/T15316', 118 + get_class($href))); 119 + } 120 + 104 121 $this->href = $href; 105 122 return $this; 106 123 } ··· 126 143 } 127 144 128 145 protected function getTagName() { 129 - return strlen($this->href) ? 'a' : 'span'; 146 + return phutil_nonempty_stringlike($this->href) ? 'a' : 'span'; 130 147 } 131 148 132 149 public function setContextObject($context_object) {