Skip to content

Commit 8171c56

Browse files
Merge MAGETWO-90725 into 2.3-bugfixes-081018
2 parents d4c4e87 + 41f81e0 commit 8171c56

File tree

1 file changed

+38
-1
lines changed
  • app/code/Magento/PageCache/Model/System/Config/Backend

1 file changed

+38
-1
lines changed

app/code/Magento/PageCache/Model/System/Config/Backend/Ttl.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,47 @@
66

77
namespace Magento\PageCache\Model\System\Config\Backend;
88

9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\Escaper;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
913
/**
1014
* Backend model for processing Public content cache lifetime settings
1115
*
1216
* Class Ttl
1317
*/
1418
class Ttl extends \Magento\Framework\App\Config\Value
1519
{
20+
/**
21+
* @var Escaper
22+
*/
23+
private $escaper;
24+
25+
/**
26+
* Ttl constructor.
27+
* @param \Magento\Framework\Model\Context $context
28+
* @param \Magento\Framework\Registry $registry
29+
* @param ScopeConfigInterface $config
30+
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
31+
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
32+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
33+
* @param array $data
34+
* @param Escaper|null $escaper
35+
*/
36+
public function __construct(
37+
\Magento\Framework\Model\Context $context,
38+
\Magento\Framework\Registry $registry,
39+
ScopeConfigInterface $config,
40+
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
41+
?\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
42+
?\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
43+
array $data = [],
44+
?Escaper $escaper = null
45+
) {
46+
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
47+
$this->escaper = $escaper ?: ObjectManager::getInstance()->create(Escaper::class);
48+
}
49+
1650
/**
1751
* Throw exception if Ttl data is invalid or empty
1852
*
@@ -24,7 +58,10 @@ public function beforeSave()
2458
$value = $this->getValue();
2559
if ($value < 0 || !preg_match('/^[0-9]+$/', $value)) {
2660
throw new \Magento\Framework\Exception\LocalizedException(
27-
__('Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.', $value)
61+
__(
62+
'Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.',
63+
$this->escaper->escapeHtml($value)
64+
)
2865
);
2966
}
3067
return $this;

0 commit comments

Comments
 (0)