mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
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
This commit is contained in:
parent
e8ea7a4a36
commit
bcfcd9acfc
2 changed files with 4 additions and 47 deletions
|
@ -90,11 +90,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
* @return self
|
||||
*/
|
||||
public function setHref($href) {
|
||||
|
||||
// We have not a very clear idea about what this method should receive
|
||||
// So, let's log alien stuff for some time
|
||||
// https://we.phorge.it/T15316
|
||||
self::requireValidHref($href, 'href');
|
||||
PhutilURI::checkHrefType($href);
|
||||
|
||||
$this->href = $href;
|
||||
return $this;
|
||||
|
@ -161,11 +157,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
* @return self
|
||||
*/
|
||||
public function setImageHref($image_href) {
|
||||
|
||||
// We have not a very clear idea about what this method should receive
|
||||
// So, let's log alien stuff for some time
|
||||
// https://we.phorge.it/T15316
|
||||
self::requireValidHref($image_href, 'image_href');
|
||||
PhutilURI::checkHrefType($image_href);
|
||||
|
||||
$this->imageHref = $image_href;
|
||||
return $this;
|
||||
|
@ -929,30 +921,4 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
return javelin_tag('span', $options, '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Receive a href attribute and check if it has expected values
|
||||
*
|
||||
* TODO: Feel free to remove after 2023, if no more new reports arrive.
|
||||
*
|
||||
* https://we.phorge.it/T15316
|
||||
*
|
||||
* @param mixed $href Value to be checked
|
||||
* @param string $variable_name Human reference
|
||||
*/
|
||||
private static function requireValidHref($href, $variable_name) {
|
||||
|
||||
// We have not a very clear idea about what a "href" should be
|
||||
if (is_object($href) && !($href instanceof PhutilURI)) {
|
||||
|
||||
// We log stuff with a kind stack trace
|
||||
phlog(new Exception(pht(
|
||||
'The variable %s received an unexpected type: %s. '.
|
||||
'Please share this stack trace as comment in Task %s',
|
||||
$variable_name,
|
||||
get_class($href),
|
||||
'https://we.phorge.it/T15316')));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -103,20 +103,11 @@ final class PHUITagView extends AphrontTagView {
|
|||
/**
|
||||
* Set the href attribute
|
||||
*
|
||||
* @param string|null $href
|
||||
* @param string|PhutilURI|null $href
|
||||
* @return self
|
||||
*/
|
||||
public function setHref($href) {
|
||||
|
||||
// We have not a very clear idea about what this method should receive
|
||||
// We suspect that PhutilURI should be allowed... but let's log everything!
|
||||
// https://we.phorge.it/T15316
|
||||
if (is_object($href)) {
|
||||
phlog(sprintf(
|
||||
'Received unexpected type for href: %s. '.
|
||||
'Please paste this log as comment in https://we.phorge.it/T15316',
|
||||
get_class($href)));
|
||||
}
|
||||
PhutilURI::checkHrefType($href);
|
||||
|
||||
$this->href = $href;
|
||||
return $this;
|
||||
|
|
Loading…
Reference in a new issue