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

811 redirection error if the url contains parameters #812

Merged
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
4 changes: 0 additions & 4 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ function customFieldCallback( $pDI, $format, $limitEllipsis, $meta_key ) {
}
});

add_filter('oo_is_detailpage_redirection', function($value) {
return $value;
});

$pEstateRedirection = apply_filters('oo_is_detailpage_redirection', true);

add_action('parse_request', function(WP $pWP) use ($pDI, $pEstateRedirection) {
Expand Down
8 changes: 2 additions & 6 deletions plugin/Controller/EstateDetailUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,9 @@ public function getUrlWithEstateTitle(int $estateId, string $title = null, strin
$urlLsSwitcher = $urlElements['scheme'] . '://' . $urlElements['host'] . $newPath . '/' . $urlTemp;

if (!empty($getParameters)) {
if ($pEstateRedirection) {
$urlLsSwitcher .= '';
} elseif(!$tickerUrlHasTitleFlag) {
$urlLsSwitcher .= '?' . http_build_query($getParameters);
}
$urlLsSwitcher = add_query_arg($getParameters,$urlLsSwitcher);
}

return $urlLsSwitcher;
}
}
}
2 changes: 1 addition & 1 deletion plugin/Utility/Redirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ public function getUri()
public function getCurrentLink(): string
{
global $wp;
return home_url(add_query_arg($_GET, trailingslashit($wp->request)));
return home_url(add_query_arg($_GET, $wp->request));
}
}
18 changes: 9 additions & 9 deletions tests/TestClassEstateDetailUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function testGetUrlWithFilterTrueAndEnableOptionShowTitleWithParameter()
$title = 'test-title';
$pInstance = $this->_pContainer->get(EstateDetailUrl::class);
$url = 'https://www.onoffice.de/detail/123?lang=en';
$expectedUrl = 'https://www.onoffice.de/detail/123-test-title';
$expectedUrl = 'https://www.onoffice.de/detail/123-test-title?lang=en';
$this->assertEquals($expectedUrl, $pInstance->getUrlWithEstateTitle($estateId, $title, $url, false, $pEstateRedirection));
}

Expand All @@ -169,7 +169,7 @@ public function testGetUrlWithFilterTrueAndDisableOptionShowTitleWithParameter()
$title = 'test-title';
$pInstance = $this->_pContainer->get(EstateDetailUrl::class);
$url = 'https://www.onoffice.de/detail/123?lang=en';
$expectedUrl = 'https://www.onoffice.de/detail/123';
$expectedUrl = 'https://www.onoffice.de/detail/123?lang=en';
$this->assertEquals($expectedUrl, $pInstance->getUrlWithEstateTitle($estateId, $title, $url, false, $pEstateRedirection));
}

Expand Down Expand Up @@ -210,16 +210,16 @@ public function testGetUrlWithFilterFalseAndEnableOptionShowTitleWithParameter()
$expectedUrlHasTitleWithoutParamster = 'https://www.onoffice.de/detail/123-test-title';
$this->assertEquals($expectedUrlHasTitleWithoutParamster, $pInstance->getUrlWithEstateTitle($estateId, $title, $urlHasTitleWithoutParamster, false, $pEstateRedirection));

$urlWithoutTitle = 'https://www.onoffice.de/detail/123/?lang=en';
$urlWithoutTitle = 'https://www.onoffice.de/detail/123?lang=en';
$expectedUrlWithoutTitle = 'https://www.onoffice.de/detail/123?lang=en';
$this->assertEquals($expectedUrlWithoutTitle, $pInstance->getUrlWithEstateTitle($estateId, $title, $urlWithoutTitle, false, $pEstateRedirection));

$urlHasTitleHasParamster = 'https://www.onoffice.de/detail/123-test-title';
$expectedUrlHasTitleHasParamster = 'https://www.onoffice.de/detail/123-test-title';
$this->assertEquals($expectedUrlHasTitleHasParamster, $pInstance->getUrlWithEstateTitle($estateId, $title, $urlHasTitleHasParamster, true, $pEstateRedirection));
$urlHasTitleHasParameter = 'https://www.onoffice.de/detail/123-test-title?lang=en';
$expectedUrlHasTitleHasParameter = 'https://www.onoffice.de/detail/123-test-title?lang=en';
$this->assertEquals($expectedUrlHasTitleHasParameter, $pInstance->getUrlWithEstateTitle($estateId, $title, $urlHasTitleHasParameter, true, $pEstateRedirection));

$urlHasTitle = 'https://www.onoffice.de/detail/123-test-title/?lang=en';
$expectedUrlHasTitle = 'https://www.onoffice.de/detail/123-test-title';
$urlHasTitle = 'https://www.onoffice.de/detail/123-test-title?lang=en';
$expectedUrlHasTitle = 'https://www.onoffice.de/detail/123-test-title?lang=en';
$this->assertEquals($expectedUrlHasTitle, $pInstance->getUrlWithEstateTitle($estateId, $title, $urlHasTitle, true, $pEstateRedirection));
}
}
}
2 changes: 1 addition & 1 deletion tests/TestClassRedirectIfOldUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function stestInstance()
*/
public function testGetCurrentLink()
{
$this->assertEquals( 'http://example.org/detail-view/123/', $this->_pRedirectIfOldUrl->getCurrentLink() );
$this->assertEquals( 'http://example.org/detail-view/123', $this->_pRedirectIfOldUrl->getCurrentLink() );
}

/**
Expand Down
Loading