Page MenuHomePhorge

D25356.1729969483.diff
No OneTemporary

D25356.1729969483.diff

diff --git a/src/parser/PhutilURI.php b/src/parser/PhutilURI.php
--- a/src/parser/PhutilURI.php
+++ b/src/parser/PhutilURI.php
@@ -561,4 +561,32 @@
return false;
}
+ /**
+ * This is just a complicated type-check - we'll eventually replace it with a
+ * native type-hint of `PhutilURI | string | null`, when this type-hint is
+ * available (php 8.0).
+ *
+ * Before php 8, and after we suspect there aren't many more cases where this
+ * fails, we'll replace the log with an exception.
+ */
+ public static function checkHrefType($value) {
+ if ($value === null || is_string($value)) {
+ return;
+ }
+
+ if ($value instanceof PhutilURI) {
+ return;
+ }
+
+ $report_type = is_object($value) ? get_class($value) : gettype($value);
+
+ // We log stuff with a kind stack trace
+ phlog(
+ pht(
+ 'Unexpected value type provided for an HREF field - %s. '.
+ 'Please share this stack trace as comment in Task %s',
+ $report_type,
+ 'https://we.phorge.it/T15316'));
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 26, 19:04 (13 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
949343
Default Alt Text
D25356.1729969483.diff (1 KB)

Event Timeline