Skip to content

Commit c727b6a

Browse files
author
ogorkun
committed
Merge branch '2.4-develop' of https://github.com/magento-commerce/magento2ce into AC-522
2 parents b24864b + ed5c06d commit c727b6a

File tree

220 files changed

+8208
-3779
lines changed

Some content is hidden

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

220 files changed

+8208
-3779
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ atlassian*
3232
/package.json
3333
/.php_cs
3434
/.php_cs.cache
35+
/.php-cs-fixer.php
36+
/.php-cs-fixer.cache
3537
/grunt-config.json
3638
/pub/media/*.*
3739
!/pub/media/.htaccess

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
->exclude('setup/vendor')
2222
->exclude('var');
2323

24-
return PhpCsFixer\Config::create()
25-
->setFinder($finder)
24+
$config = new PhpCsFixer\Config();
25+
$config->setFinder($finder)
2626
->setRules([
2727
'@PSR2' => true,
2828
'array_syntax' => ['syntax' => 'short'],
2929
'concat_space' => ['spacing' => 'one'],
3030
'include' => true,
3131
'new_with_braces' => true,
3232
'no_empty_statement' => true,
33-
'no_extra_consecutive_blank_lines' => true,
33+
'no_extra_blank_lines' => true,
3434
'no_leading_import_slash' => true,
3535
'no_leading_namespace_whitespace' => true,
3636
'no_multiline_whitespace_around_double_arrow' => true,
37-
'no_multiline_whitespace_before_semicolons' => true,
37+
'multiline_whitespace_before_semicolons' => true,
3838
'no_singleline_whitespace_before_semicolons' => true,
3939
'no_trailing_comma_in_singleline_array' => true,
4040
'no_unused_imports' => true,
@@ -44,3 +44,4 @@
4444
'standardize_not_equals' => true,
4545
'ternary_operator_spaces' => true,
4646
]);
47+
return $config;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="GoToWebSetupPageActionGroup">
11+
<annotations>
12+
<description>Go to the Web Setup Page</description>
13+
</annotations>
14+
15+
<amOnPage url="{{WebSetupPage.url}}" stepKey="goToWebSetupPage"/>
16+
<waitForPageLoad stepKey="waitForWebSetupPageLoad" time="10"/>
17+
<seeElementInDOM selector="{{WebSetupPageLandingSection.section}}" stepKey="assertSetupPageHasLandingSection"/>
18+
<seeElementInDOM selector="{{WebSetupPageLicenseSection.section}}" stepKey="assertSetupPageHasLicenseSection"/>
19+
</actionGroup>
20+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="WebSetupShowLandingSectionActionGroup">
11+
<annotations>
12+
<description>Action for showing landing section and closing license section on Web Setup Page</description>
13+
</annotations>
14+
15+
<click selector="{{WebSetupPageLicenseSection.go_back_button}}" stepKey="showLandingSection"/>
16+
<waitForElementVisible selector="{{WebSetupPageLandingSection.section}}" stepKey="waitForVisibleWebSetupPageLandingSection" time="5"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="WebSetupShowLicenseSectionActionGroup">
11+
<annotations>
12+
<description>Action for showing license section on Web Setup Page</description>
13+
</annotations>
14+
15+
<click selector="{{WebSetupPageLandingSection.terms_and_agreement_link}}" stepKey="showLicenseSection"/>
16+
<waitForElementVisible selector="{{WebSetupPageLicenseSection.section}}" stepKey="waitForVisibleWebSetupPageLicenseSection" time="5"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
10+
<page name="WebSetupPage" url="setup/" area="storefront" module="Magento_Backend">
11+
<section name="WebSetupLandingPageSection"/>
12+
<section name="WebSetupLicensePageSection"/>
13+
</page>
14+
</pages>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="WebSetupPageLandingSection">
11+
<element name="section" type="text" selector="section[data-section=landing]"/>
12+
<element name="logo" type="text" selector="section[data-section=landing] > img.logo"/>
13+
<element name="version" type="text" selector="section[data-section=landing] > p.text-version"/>
14+
<element name="welcome" type="text" selector="section[data-section=landing] > p.text-welcome"/>
15+
<element name="terms_and_agreement_link" type="text" selector="section[data-section=landing] > p.text-welcome > a[href^='javascript:showSection'][href*='license']"/>
16+
</section>
17+
</sections>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="WebSetupPageLicenseSection">
11+
<element name="section" type="text" selector="section[data-section=license]"/>
12+
<element name="license_text" type="text" selector="section[data-section=license] div.license-text"/>
13+
<element name="go_back_button" type="button" selector="section[data-section=license] div.page-license-footer button[onclick^='showSection'][onclick*='landing']"/>
14+
</section>
15+
</sections>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="WebSetupPageTest">
11+
<annotations>
12+
<features value="Setup"/>
13+
<stories value="Setup Magento via Web Interface"/>
14+
<title value="Setup Magento via Web Interface"/>
15+
<description value="Setup Magento via Web Interface should show only landing section with logo, version, and welcome and licence section"/>
16+
<severity value="MAJOR"/>
17+
</annotations>
18+
<actionGroup ref="GoToWebSetupPageActionGroup" stepKey="goToWebSetupPage"/>
19+
<seeElement selector="{{WebSetupPageLandingSection.section}}" stepKey="assertLandingSectionVisibleInSetupPage"/>
20+
<dontSeeElement selector="{{WebSetupPageLicenseSection.section}}" stepKey="assertLicenseSectionInvisibleInSetupPage"/>
21+
<seeElement selector="{{WebSetupPageLandingSection.logo}}" stepKey="assertSetupPageLogoVisibleInSetupPage"/>
22+
<seeElement selector="{{WebSetupPageLandingSection.version}}" stepKey="assertVersionVisibleInSetupPage"/>
23+
<seeElement selector="{{WebSetupPageLandingSection.welcome}}" stepKey="assertWelcomeVisibleInSetupPage"/>
24+
<actionGroup ref="WebSetupShowLicenseSectionActionGroup" stepKey="showLicense"/>
25+
<seeElement selector="{{WebSetupPageLicenseSection.section}}" stepKey="assertLicenseSectionVisibleInSetupPage"/>
26+
<dontSeeElement selector="{{WebSetupPageLandingSection.section}}" stepKey="assertLandingSectionInvisibleInSetupPage"/>
27+
<actionGroup ref="WebSetupShowLandingSectionActionGroup" stepKey="goBackToLanding"/>
28+
<seeElement selector="{{WebSetupPageLandingSection.section}}" stepKey="assertLandingSectionVisibleAfterGoingBackFromLicenseSection"/>
29+
<dontSeeElement selector="{{WebSetupPageLicenseSection.section}}" stepKey="assertLicenseSectionInvisibleAfterGoingBackFromLicenseSection"/>
30+
</test>
31+
</tests>

app/code/Magento/Backup/Model/Fs/Collection.php

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

810
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -92,12 +94,17 @@ public function __construct(
9294
* Create .htaccess file and deny backups directory access from web
9395
*
9496
* @return void
97+
* @throws \Magento\Framework\Exception\FileSystemException
9598
*/
9699
protected function _hideBackupsForApache()
97100
{
98101
$filename = '.htaccess';
99-
if (!$this->_varDirectory->isFile($filename)) {
100-
$this->_varDirectory->writeFile($filename, 'deny from all');
102+
$driver = $this->_varDirectory->getDriver();
103+
$absolutePath = $driver->getAbsolutePath($this->_varDirectory->getAbsolutePath(), $filename);
104+
if (!$driver->isFile($absolutePath)) {
105+
$resource = $driver->fileOpen($absolutePath, 'w+');
106+
$driver->fileWrite($resource, 'deny from all');
107+
$driver->fileClose($resource);
101108
}
102109
}
103110

app/code/Magento/Backup/Test/Unit/Model/Fs/CollectionTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ public function testConstructor()
3434
)->disableOriginalConstructor()
3535
->getMock();
3636
$backupData->expects($this->any())->method('getExtensions')->willReturn([]);
37-
37+
$driver = $this->getMockBuilder(
38+
Filesystem\DriverInterface::class
39+
)->disableOriginalConstructor()
40+
->getMock();
3841
$directoryWrite->expects($this->any())->method('create')->with('backups');
39-
$directoryWrite->expects($this->any())->method('getAbsolutePath')->with('backups');
42+
$directoryWrite->expects($this->any())->method('getAbsolutePath')->willReturn('');
43+
$directoryWrite->expects($this->at(3))->method('getAbsolutePath')->with('backups');
4044
$directoryWrite->expects($this->any())->method('isDirectory')->willReturn(true);
45+
$directoryWrite->expects($this->any())->method('getDriver')->willReturn($driver);
4146
$targetDirectory = $this->getMockBuilder(TargetDirectory::class)
4247
->disableOriginalConstructor()
4348
->getMock();

app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ public function execute()
108108

109109
$result['url'] = $this->productMediaConfig->getTmpMediaUrl($result['file']);
110110
$result['file'] = $result['file'] . '.tmp';
111-
} catch (\Exception $e) {
111+
} catch (LocalizedException $e) {
112112
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
113+
} catch (\Throwable $e) {
114+
$result = ['error' => 'Something went wrong while saving the file(s).', 'errorcode' => 0];
113115
}
114116

115117
/** @var \Magento\Framework\Controller\Result\Raw $response */

app/code/Magento/Catalog/Model/Product.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ public function beforeSave()
883883

884884
$this->getTypeInstance()->beforeSave($this);
885885

886-
$hasOptions = $this->getData('has_options') === "1";
887-
$hasRequiredOptions = $this->getData('required_options') === "1";
886+
$hasOptions = $this->getData('has_options') === "1" && $this->isProductHasOptions();
887+
$hasRequiredOptions = $this->getData('required_options') === "1" && $this->isProductHasOptions();
888888

889889
/**
890890
* $this->_canAffectOptions - set by type instance only
@@ -934,6 +934,21 @@ public function beforeSave()
934934
parent::beforeSave();
935935
}
936936

937+
/**
938+
* Check based on options data
939+
*
940+
* @return bool
941+
*/
942+
private function isProductHasOptions() : bool
943+
{
944+
if ($this->getData('options') === null) {
945+
$result = true;
946+
} else {
947+
$result = is_array($this->getData('options')) && count($this->getData('options')) > 0;
948+
}
949+
return $result;
950+
}
951+
937952
/**
938953
* Check/set if options can be affected when saving product
939954
*

app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Catalog\Model\Product\Option\Type\File;
89

910
use Magento\Catalog\Model\Product;
10-
use Magento\Framework\App\Filesystem\DirectoryList;
1111
use Magento\Catalog\Model\Product\Exception as ProductException;
12+
use Magento\Framework\App\Filesystem\DirectoryList;
13+
use Magento\Framework\App\ObjectManager;
1214
use Magento\Framework\Exception\LocalizedException;
1315
use Magento\Framework\Math\Random;
14-
use Magento\Framework\App\ObjectManager;
1516
use Magento\MediaStorage\Model\File\Uploader;
1617

1718
/**
@@ -254,8 +255,12 @@ protected function initFilesystem()
254255

255256
// Directory listing and hotlink secure
256257
$path = $this->path . '/.htaccess';
257-
if (!$this->mediaDirectory->isFile($path)) {
258-
$this->mediaDirectory->writeFile($path, "Order deny,allow\nDeny from all");
258+
$driver = $this->mediaDirectory->getDriver();
259+
$absolutePath = $driver->getAbsolutePath($this->mediaDirectory->getAbsolutePath(), $path);
260+
if (!$driver->isFile($absolutePath)) {
261+
$resource = $driver->fileOpen($absolutePath, 'w+');
262+
$driver->fileWrite($resource, "Order deny,allow\nDeny from all");
263+
$driver->fileClose($resource);
259264
}
260265
}
261266

0 commit comments

Comments
 (0)