Page MenuHomePhorge

D25356.1734946638.diff
No OneTemporary

D25356.1734946638.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
Mon, Dec 23, 09:37 (15 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1026889
Default Alt Text
D25356.1734946638.diff (1 KB)

Event Timeline