Fixed Flex Page cache key not taking account active language

This commit is contained in:
Matias Griese
2020-02-11 12:09:27 +02:00
parent 5104bde6d4
commit 2c78b3efca
4 changed files with 21 additions and 2 deletions

View File

@@ -14,6 +14,7 @@
* Fixed `FlexObject::triggerEvent()` not emitting events [#2816](https://github.com/getgrav/grav/issues/2816)
* Grav 1.7: Fixed saving Flex configuration with ignored values becoming null
* Grav 1.7: Fixed `bin/plugin` initialization
* Grav 1.7: Fixed Flex Page cache key not taking account active language
# v1.7.0-rc.5
## 02/03/2020

View File

@@ -19,6 +19,7 @@ use Grav\Common\Flex\Types\Pages\Traits\PageContentTrait;
use Grav\Common\Flex\Types\Pages\Traits\PageLegacyTrait;
use Grav\Common\Flex\Types\Pages\Traits\PageRoutableTrait;
use Grav\Common\Flex\Types\Pages\Traits\PageTranslateTrait;
use Grav\Common\Language\Language;
use Grav\Common\Page\Pages;
use Grav\Common\Utils;
use Grav\Framework\Filesystem\Filesystem;
@@ -129,6 +130,22 @@ class PageObject extends FlexPageObject
return parent::getFormValue($name, $default, $separator);
}
/**
* {@inheritdoc}
* @see FlexObjectInterface::getCacheKey()
*/
public function getCacheKey(): string
{
$cacheKey = parent::getCacheKey();
if ($cacheKey) {
/** @var Language $language */
$language = Grav::instance()['language'];
$cacheKey .= '_' . $language->getActive();
}
return $cacheKey;
}
/**
* @param array|bool $reorder
* @return FlexObject|\Grav\Framework\Flex\Interfaces\FlexObjectInterface

View File

@@ -81,7 +81,7 @@ trait PageTranslateTrait
}
$header = $aPage->header();
$routes = isset($header->routes) ? $header->routes : [];
$routes = $header->routes ?? [];
$route = $routes['default'] ?? $aPage->rawRoute();
if (!$route) {
$route = $aPage->route();

View File

@@ -193,13 +193,14 @@ class FlexPageObject extends FlexObject implements PageInterface, MediaManipulat
return $key;
}
/**
* {@inheritdoc}
* @see FlexObjectInterface::getCacheKey()
*/
public function getCacheKey(): string
{
return $this->hasKey() ? $this->getTypePrefix() . $this->getFlexType() . '.' . $this->getKey() . $this->getLanguage() : '';
return $this->hasKey() ? $this->getTypePrefix() . $this->getFlexType() . '.' . $this->getKey() . '.' . $this->getLanguage() : '';
}
/**