Skip to content

Commit 799a90d

Browse files
author
Alexander Akimov
authored
Merge pull request #3253 from magento-tsg/2.2.7-develop-pr45
[TSG] Upporting for 2.2 (pr45) (2.2.7-develop)
2 parents 52498f2 + 449516b commit 799a90d

File tree

41 files changed

+580
-435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+580
-435
lines changed

.htaccess

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@
364364
Require all denied
365365
</IfVersion>
366366
</Files>
367+
<Files .user.ini>
368+
<IfVersion < 2.4>
369+
order allow,deny
370+
deny from all
371+
</IfVersion>
372+
<IfVersion >= 2.4>
373+
Require all denied
374+
</IfVersion>
375+
</Files>
367376

368377
# For 404s and 403s that aren't handled by the application, show plain 404 response
369378
ErrorDocument 404 /pub/errors/404.php

.htaccess.sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@
341341
Require all denied
342342
</IfVersion>
343343
</Files>
344+
<Files .user.ini>
345+
<IfVersion < 2.4>
346+
order allow,deny
347+
deny from all
348+
</IfVersion>
349+
<IfVersion >= 2.4>
350+
Require all denied
351+
</IfVersion>
352+
</Files>
344353

345354
# For 404s and 403s that aren't handled by the application, show plain 404 response
346355
ErrorDocument 404 /pub/errors/404.php

app/code/Magento/Backend/Block/System/Store/Delete/Form.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,39 @@
55
*/
66
namespace Magento\Backend\Block\System\Store\Delete;
77

8+
use Magento\Backup\Helper\Data as BackupHelper;
9+
use Magento\Framework\App\ObjectManager;
10+
811
/**
912
* Adminhtml cms block edit form
1013
*
1114
* @author Magento Core Team <core@magentocommerce.com>
1215
*/
1316
class Form extends \Magento\Backend\Block\Widget\Form\Generic
1417
{
18+
/**
19+
* @var BackupHelper
20+
*/
21+
private $backup;
22+
23+
/**
24+
* @param \Magento\Backend\Block\Template\Context $context
25+
* @param \Magento\Framework\Registry $registry
26+
* @param \Magento\Framework\Data\FormFactory $formFactory
27+
* @param array $data
28+
* @param BackupHelper|null $backup
29+
*/
30+
public function __construct(
31+
\Magento\Backend\Block\Template\Context $context,
32+
\Magento\Framework\Registry $registry,
33+
\Magento\Framework\Data\FormFactory $formFactory,
34+
array $data = [],
35+
BackupHelper $backup = null
36+
) {
37+
parent::__construct($context, $registry, $formFactory, $data);
38+
$this->backup = $backup ?? ObjectManager::getInstance()->get(BackupHelper::class);
39+
}
40+
1541
/**
1642
* Init form
1743
*
@@ -25,7 +51,7 @@ protected function _construct()
2551
}
2652

2753
/**
28-
* {@inheritdoc}
54+
* @inheritDoc
2955
*/
3056
protected function _prepareForm()
3157
{
@@ -45,15 +71,21 @@ protected function _prepareForm()
4571

4672
$fieldset->addField('item_id', 'hidden', ['name' => 'item_id', 'value' => $dataObject->getId()]);
4773

74+
$backupOptions = ['0' => __('No')];
75+
$backupSelected = '0';
76+
if ($this->backup->isEnabled()) {
77+
$backupOptions['1'] = __('Yes');
78+
$backupSelected = '1';
79+
}
4880
$fieldset->addField(
4981
'create_backup',
5082
'select',
5183
[
5284
'label' => __('Create DB Backup'),
5385
'title' => __('Create DB Backup'),
5486
'name' => 'create_backup',
55-
'options' => ['1' => __('Yes'), '0' => __('No')],
56-
'value' => '1'
87+
'options' => $backupOptions,
88+
'value' => $backupSelected
5789
]
5890
);
5991

app/code/Magento/Backend/Controller/Adminhtml/System/Store.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Store controller
1515
*
1616
* @author Magento Core Team <core@magentocommerce.com>
17+
* @SuppressWarnings(PHPMD.AllPurposeAction)
1718
*/
1819
abstract class Store extends Action
1920
{
@@ -86,6 +87,8 @@ protected function createPage()
8687
* Backup database
8788
*
8889
* @return bool
90+
*
91+
* @deprecated Backup module is to be removed.
8992
*/
9093
protected function _backupDatabase()
9194
{

app/code/Magento/Backup/Controller/Adminhtml/Index.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
*/
66
namespace Magento\Backup\Controller\Adminhtml;
77

8+
use Magento\Backup\Helper\Data as Helper;
9+
use Magento\Framework\App\ObjectManager;
10+
811
/**
912
* Backup admin controller
1013
*
1114
* @author Magento Core Team <core@magentocommerce.com>
1215
* @api
1316
* @since 100.0.2
17+
* @SuppressWarnings(PHPMD.AllPurposeAction)
1418
*/
1519
abstract class Index extends \Magento\Backend\App\Action
1620
{
@@ -48,27 +52,47 @@ abstract class Index extends \Magento\Backend\App\Action
4852
*/
4953
protected $maintenanceMode;
5054

55+
/**
56+
* @var Helper
57+
*/
58+
private $helper;
59+
5160
/**
5261
* @param \Magento\Backend\App\Action\Context $context
5362
* @param \Magento\Framework\Registry $coreRegistry
5463
* @param \Magento\Framework\Backup\Factory $backupFactory
5564
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
5665
* @param \Magento\Backup\Model\BackupFactory $backupModelFactory
5766
* @param \Magento\Framework\App\MaintenanceMode $maintenanceMode
67+
* @param Helper|null $helper
5868
*/
5969
public function __construct(
6070
\Magento\Backend\App\Action\Context $context,
6171
\Magento\Framework\Registry $coreRegistry,
6272
\Magento\Framework\Backup\Factory $backupFactory,
6373
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
6474
\Magento\Backup\Model\BackupFactory $backupModelFactory,
65-
\Magento\Framework\App\MaintenanceMode $maintenanceMode
75+
\Magento\Framework\App\MaintenanceMode $maintenanceMode,
76+
Helper $helper = null
6677
) {
6778
$this->_coreRegistry = $coreRegistry;
6879
$this->_backupFactory = $backupFactory;
6980
$this->_fileFactory = $fileFactory;
7081
$this->_backupModelFactory = $backupModelFactory;
7182
$this->maintenanceMode = $maintenanceMode;
83+
$this->helper = $helper ?? ObjectManager::getInstance()->get(Helper::class);
7284
parent::__construct($context);
7385
}
86+
87+
/**
88+
* @inheritDoc
89+
*/
90+
public function dispatch(\Magento\Framework\App\RequestInterface $request)
91+
{
92+
if (!$this->helper->isEnabled()) {
93+
return $this->_redirect('*/*/disabled');
94+
}
95+
96+
return parent::dispatch($request);
97+
}
7498
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Backup\Controller\Adminhtml\Index;
10+
11+
use Magento\Backend\App\Action;
12+
use Magento\Backend\App\Action\Context;
13+
use Magento\Framework\View\Result\PageFactory;
14+
15+
/**
16+
* Inform that backup is disabled.
17+
*/
18+
class Disabled extends Action
19+
{
20+
/**
21+
* @see _isAllowed()
22+
*/
23+
const ADMIN_RESOURCE = 'Magento_Backend::backup';
24+
25+
/**
26+
* @var PageFactory
27+
*/
28+
private $pageFactory;
29+
30+
/**
31+
* @param Context $context
32+
* @param PageFactory $pageFactory
33+
*/
34+
public function __construct(Context $context, PageFactory $pageFactory)
35+
{
36+
parent::__construct($context);
37+
$this->pageFactory = $pageFactory;
38+
}
39+
40+
/**
41+
* @inheritDoc
42+
*/
43+
public function execute()
44+
{
45+
return $this->pageFactory->create();
46+
}
47+
}

app/code/Magento/Backup/Cron/SystemBackup.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Framework\App\Filesystem\DirectoryList;
99
use Magento\Store\Model\ScopeInterface;
1010

11+
/**
12+
* Performs scheduled backup.
13+
*/
1114
class SystemBackup
1215
{
1316
const XML_PATH_BACKUP_ENABLED = 'system/backup/enabled';
@@ -101,6 +104,10 @@ public function __construct(
101104
*/
102105
public function execute()
103106
{
107+
if (!$this->_backupData->isEnabled()) {
108+
return $this;
109+
}
110+
104111
if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) {
105112
return $this;
106113
}

app/code/Magento/Backup/Helper/Data.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\Backup\Helper;
710

811
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -285,4 +288,14 @@ public function extractDataFromFilename($filename)
285288

286289
return $result;
287290
}
291+
292+
/**
293+
* Is backup functionality enabled.
294+
*
295+
* @return bool
296+
*/
297+
public function isEnabled(): bool
298+
{
299+
return $this->scopeConfig->isSetFlag('system/backup/functionality_enabled');
300+
}
288301
}

0 commit comments

Comments
 (0)