Skip to content

Commit bcfcd9a

Browse files
committed
Unify type-checking for setHref() type methods
Summary: Adopt `PhutilURI::checkHrefType()` to unify type-check of some PHUI objects. Ref T15316. Depends on D25356. Test Plan: In production. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15316 Differential Revision: https://we.phorge.it/D25357
1 parent e8ea7a4 commit bcfcd9a

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

src/view/phui/PHUIObjectItemView.php

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ public function getObject() {
9090
* @return self
9191
*/
9292
public function setHref($href) {
93-
94-
// We have not a very clear idea about what this method should receive
95-
// So, let's log alien stuff for some time
96-
// https://we.phorge.it/T15316
97-
self::requireValidHref($href, 'href');
93+
PhutilURI::checkHrefType($href);
9894

9995
$this->href = $href;
10096
return $this;
@@ -161,11 +157,7 @@ public function setImageURI($image_uri) {
161157
* @return self
162158
*/
163159
public function setImageHref($image_href) {
164-
165-
// We have not a very clear idea about what this method should receive
166-
// So, let's log alien stuff for some time
167-
// https://we.phorge.it/T15316
168-
self::requireValidHref($image_href, 'image_href');
160+
PhutilURI::checkHrefType($image_href);
169161

170162
$this->imageHref = $image_href;
171163
return $this;
@@ -929,30 +921,4 @@ private function renderHandleIcon(PhabricatorObjectHandle $handle, $label) {
929921
return javelin_tag('span', $options, '');
930922
}
931923

932-
933-
/**
934-
* Receive a href attribute and check if it has expected values
935-
*
936-
* TODO: Feel free to remove after 2023, if no more new reports arrive.
937-
*
938-
* https://we.phorge.it/T15316
939-
*
940-
* @param mixed $href Value to be checked
941-
* @param string $variable_name Human reference
942-
*/
943-
private static function requireValidHref($href, $variable_name) {
944-
945-
// We have not a very clear idea about what a "href" should be
946-
if (is_object($href) && !($href instanceof PhutilURI)) {
947-
948-
// We log stuff with a kind stack trace
949-
phlog(new Exception(pht(
950-
'The variable %s received an unexpected type: %s. '.
951-
'Please share this stack trace as comment in Task %s',
952-
$variable_name,
953-
get_class($href),
954-
'https://we.phorge.it/T15316')));
955-
}
956-
}
957-
958924
}

src/view/phui/PHUITagView.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,11 @@ public function setName($name) {
103103
/**
104104
* Set the href attribute
105105
*
106-
* @param string|null $href
106+
* @param string|PhutilURI|null $href
107107
* @return self
108108
*/
109109
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-
}
110+
PhutilURI::checkHrefType($href);
120111

121112
$this->href = $href;
122113
return $this;

0 commit comments

Comments
 (0)