-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Cast absoluteUrl() argument to string #10610
FIX Cast absoluteUrl() argument to string #10610
Conversation
10c7b02
to
2ffa27d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See silverstripe/silverstripe-cms#2806 (comment) for a discussion on this approach. Strongly typing the return type of the given methods is out of scope for CMS 5.
Some to remove here where it's not necessary though. It's a fairly small PR so I think it's reasonable to only do this where the variable can actually be something other than a string.
tests/php/Control/DirectorTest.php
Outdated
$this->assertEquals("http://www.mysite.com:9090/mysite/", Director::absoluteURL((string) $url, Director::BASE)); | ||
$this->assertEquals("http://www.mysite.com:9090/", Director::absoluteURL((string) $url, Director::ROOT)); | ||
$this->assertEquals("http://www.mysite.com:9090/mysite/sub-page/", Director::absoluteURL((string) $url, Director::REQUEST)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEquals("http://www.mysite.com:9090/mysite/", Director::absoluteURL((string) $url, Director::BASE)); | |
$this->assertEquals("http://www.mysite.com:9090/", Director::absoluteURL((string) $url, Director::ROOT)); | |
$this->assertEquals("http://www.mysite.com:9090/mysite/sub-page/", Director::absoluteURL((string) $url, Director::REQUEST)); | |
$this->assertEquals("http://www.mysite.com:9090/mysite/", Director::absoluteURL($url, Director::BASE)); | |
$this->assertEquals("http://www.mysite.com:9090/", Director::absoluteURL($url, Director::ROOT)); | |
$this->assertEquals("http://www.mysite.com:9090/mysite/sub-page/", Director::absoluteURL($url, Director::REQUEST)); |
Not necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
tests/php/Control/ControllerTest.php
Outdated
@@ -475,7 +475,7 @@ public function testRedirectBackByBackUrl() | |||
$externalAbsoluteUrl = 'http://myhost.com/some-url'; | |||
$response = $this->get('TestController/redirectbacktest?BackURL=' . urlencode($externalAbsoluteUrl ?? '')); | |||
$this->assertEquals( | |||
Director::absoluteURL($link), | |||
Director::absoluteURL((string) $link), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Director::absoluteURL((string) $link), | |
Director::absoluteURL($link), |
Not necessary here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -145,15 +145,15 @@ protected function handleExpiredPassword(HTTPRequest $request): ?HTTPResponse | |||
return null; | |||
} | |||
|
|||
$currentUrl = $this->absoluteUrl($request->getURL(true)); | |||
$currentUrl = $this->absoluteUrl((string) $request->getURL(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$currentUrl = $this->absoluteUrl((string) $request->getURL(true)); | |
$currentUrl = $this->absoluteUrl($request->getURL(true)); |
Not necessary here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be keen to understand how this cast-to-string is affecting that unit test - I would have expected the CI to fail by throwing an exception if the problem was that the wrong type is being passed to a strongly-typed parameter.
@@ -863,7 +863,7 @@ public static function get_tinymce_lang_url(): string | |||
$dir = static::config()->get('lang_dir'); | |||
if ($lang !== 'en' && !empty($dir)) { | |||
$resource = ModuleResourceLoader::singleton()->resolveResource($dir); | |||
return Director::absoluteURL($resource->getRelativeResource($lang . '.js')->getURL()); | |||
return Director::absoluteURL((string) $resource->getRelativeResource($lang . '.js')->getURL()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Director::absoluteURL((string) $resource->getRelativeResource($lang . '.js')->getURL()); | |
return Director::absoluteURL($resource->getRelativeResource($lang . '.js')->getURL()); |
Not necessary here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -666,7 +666,7 @@ protected function getConfig() | |||
$plugins = []; | |||
foreach ($this->getPlugins() as $plugin => $path) { | |||
if ($path instanceof ModuleResource) { | |||
$path = Director::absoluteURL($path->getURL()); | |||
$path = Director::absoluteURL((string) $path->getURL()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$path = Director::absoluteURL((string) $path->getURL()); | |
$path = Director::absoluteURL($path->getURL()); |
Not needed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/Control/RequestHandler.php
Outdated
@@ -581,7 +581,7 @@ public function Link($action = null) | |||
*/ | |||
public function redirect(string $url, int $code = 302): HTTPResponse | |||
{ | |||
$url = Director::absoluteURL($url); | |||
$url = Director::absoluteURL((string) $url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$url = Director::absoluteURL((string) $url); | |
$url = Director::absoluteURL($url); |
Not needed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/Control/HTTP.php
Outdated
* function($url) { | ||
* return Director::absoluteURL($url, true); | ||
* return Director::absoluteURL((string) $url, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do function(string $url)
here instead to promote good standards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/Control/HTTP.php
Outdated
@@ -52,7 +52,7 @@ public static function filename2url($filename) | |||
} | |||
|
|||
$relativePath = ltrim(substr($filename ?? '', $baseLength ?? 0), '/\\'); | |||
return Director::absoluteURL($relativePath); | |||
return Director::absoluteURL((string) $relativePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Director::absoluteURL((string) $relativePath); | |
return Director::absoluteURL($relativePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
2ffa27d
to
2e59d0f
Compare
2e59d0f
to
700288d
Compare
Issue https://github.com/silverstripeltd/product-issues/issues/642
Similar to silverstripe/silverstripe-elemental#1029