1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 01:34:31 +02:00

Fix issue where LanguageSupportPageNames::pageNotAvailableInLanguage wasn't working properly when redirect options selected

This commit is contained in:
Ryan Cramer
2021-10-18 08:16:26 -04:00
parent c9fef983bc
commit a4555e1271
2 changed files with 19 additions and 6 deletions

View File

@@ -367,7 +367,7 @@ class PagesRequest extends Wire {
}
// check for redirect
if($this->responseCode >= 300 && $this->responseCode < 400) {
if(empty($this->redirectUrl) && $this->responseCode >= 300 && $this->responseCode < 400) {
// 301 permRedirect, 302 tempRedirect, 307 or 308
$this->setRedirectPath($info['redirect'], $info['response']);
}

View File

@@ -178,7 +178,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
$language = $this->wire()->user->language;
$pages = $this->wire()->pages;
$page = $this->wire()->page;
$process = $page->process;
$process = $page ? $page->process : null;
$pageNumUrlPrefix = $this->get("pageNumUrlPrefix$language");
if($process && $page->template->name === 'admin' && in_array('WirePageEditor', wireClassImplements($process))) {
@@ -461,16 +461,29 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
if($page->editable()) return true;
if($page->id == $this->wire()->config->http404PageID) return true;
$redirect404 = (int) $this->redirect404;
if(!$redirect404 || $redirect404 === 404) return false;
if(!$redirect404 || $redirect404 === 404 || $language->isDefault()) return false;
$default = $this->wire()->languages->getDefault();
if(!$page->viewable($default)) return false;
if($redirect404 === 200) return true;
$url = $page->localUrl($default);
if($redirect404 === 301) return array(301, $url);
if($redirect404 === 302) return array(302, $url);
$url = $this->getPageUrl($page, $default);
if($redirect404 === 302 || $redirect404 === 301) return array($redirect404, $url);
return false;
}
/**
* Given a page and language, return the URL to the page in that language
*
* @param Page $page
* @param Language $language
* @return string
* @since 3.0.187
*
*/
public function getPageUrl(Page $page, Language $language) {
$path = $this->getPagePath($page, $language);
return $this->wire()->config->urls->root . ltrim($path, '/');
}
/**
* Given a page and language, return the path to the page in that language
*