@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.

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

+4 -47
+2 -36
src/view/phui/PHUIObjectItemView.php
··· 90 90 * @return self 91 91 */ 92 92 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); 98 94 99 95 $this->href = $href; 100 96 return $this; ··· 161 157 * @return self 162 158 */ 163 159 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); 169 161 170 162 $this->imageHref = $image_href; 171 163 return $this; ··· 927 919 } 928 920 929 921 return javelin_tag('span', $options, ''); 930 - } 931 - 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 922 } 957 923 958 924 }
+2 -11
src/view/phui/PHUITagView.php
··· 103 103 /** 104 104 * Set the href attribute 105 105 * 106 - * @param string|null $href 106 + * @param string|PhutilURI|null $href 107 107 * @return self 108 108 */ 109 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 - } 110 + PhutilURI::checkHrefType($href); 120 111 121 112 $this->href = $href; 122 113 return $this;