Skip to content
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

Deprecate unused, private OC_Helper::linkToPublic #11685

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions lib/private/legacy/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@
class OC_Helper {
private static $templateManager;

/**
* Creates an absolute url for public use
* @param string $service id
* @param bool $add_slash
* @return string the url
*
* Returns a absolute url to the given service.
*/
public static function linkToPublic($service, $add_slash = false) {
if ($service === 'files') {
$url = OC::$server->getURLGenerator()->getAbsoluteURL('/s');
} else {
$url = OC::$server->getURLGenerator()->getAbsoluteURL(OC::$server->getURLGenerator()->linkTo('', 'public.php').'?service='.$service);
}
return $url . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '');
}

/**
* Make a human file size
* @param int $bytes file size in bytes
Expand Down
7 changes: 6 additions & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,14 @@ public static function linkToRemote( $service ) {
* @param string $service id
* @return string the url
* @since 4.5.0
* @deprecated 15.0.0 - use OCP\IURLGenerator
*/
public static function linkToPublic($service) {
return \OC_Helper::linkToPublic($service);
$urlGenerator = \OC::$server->getURLGenerator();
if ($service === 'files') {
return $urlGenerator->getAbsoluteURL('/s');
}
return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
}

/**
Expand Down
38 changes: 0 additions & 38 deletions tests/lib/LegacyHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,44 +222,6 @@ function streamCopyDataProvider() {
);
}

// Url generator methods

/**
* @small
* test linkToPublic URL construction
*/
public function testLinkToPublic() {
\OC::$WEBROOT = '';
$result = \OC_Helper::linkToPublic('files');
$this->assertEquals('http://localhost/s', $result);
$result = \OC_Helper::linkToPublic('files', false);
$this->assertEquals('http://localhost/s', $result);
$result = \OC_Helper::linkToPublic('files', true);
$this->assertEquals('http://localhost/s/', $result);

$result = \OC_Helper::linkToPublic('other');
$this->assertEquals('http://localhost/public.php?service=other', $result);
$result = \OC_Helper::linkToPublic('other', false);
$this->assertEquals('http://localhost/public.php?service=other', $result);
$result = \OC_Helper::linkToPublic('other', true);
$this->assertEquals('http://localhost/public.php?service=other/', $result);

\OC::$WEBROOT = '/owncloud';
$result = \OC_Helper::linkToPublic('files');
$this->assertEquals('http://localhost/owncloud/s', $result);
$result = \OC_Helper::linkToPublic('files', false);
$this->assertEquals('http://localhost/owncloud/s', $result);
$result = \OC_Helper::linkToPublic('files', true);
$this->assertEquals('http://localhost/owncloud/s/', $result);

$result = \OC_Helper::linkToPublic('other');
$this->assertEquals('http://localhost/owncloud/public.php?service=other', $result);
$result = \OC_Helper::linkToPublic('other', false);
$this->assertEquals('http://localhost/owncloud/public.php?service=other', $result);
$result = \OC_Helper::linkToPublic('other', true);
$this->assertEquals('http://localhost/owncloud/public.php?service=other/', $result);
}

/**
* Tests recursive folder deletion with rmdirr()
*/
Expand Down