Skip to content

Commit

Permalink
Merge branch '2.4-develop' of github.com:magento/magento2 into 1703-d…
Browse files Browse the repository at this point in the history
…eleted-tags-not-removed
  • Loading branch information
yolouiese committed Aug 11, 2020
2 parents 8d9d0a5 + b817af4 commit 512942e
Show file tree
Hide file tree
Showing 79 changed files with 1,294 additions and 196 deletions.
20 changes: 16 additions & 4 deletions app/code/Magento/Backend/Block/Widget/Grid/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Magento\Framework\App\Filesystem\DirectoryList;

/**
* Class Export for exporting grid data as CSV file or MS Excel 2003 XML Document file
*
* @api
* @deprecated 100.2.0 in favour of UI component implementation
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -69,6 +71,8 @@ public function __construct(
}

/**
* Internal constructor, that is called from real constructor
*
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
Expand Down Expand Up @@ -242,6 +246,7 @@ protected function _getExportTotals()

/**
* Iterate collection and call callback method per item
*
* For callback method first argument always is item object
*
* @param string $callback
Expand Down Expand Up @@ -273,7 +278,12 @@ public function _exportIterateCollection($callback, array $args)

$collection = $this->_getRowCollection($originalCollection);
foreach ($collection as $item) {
call_user_func_array([$this, $callback], array_merge([$item], $args));
//phpcs:ignore Magento2.Functions.DiscouragedFunction
call_user_func_array(
[$this, $callback],
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge([$item], $args)
);
}
}
}
Expand Down Expand Up @@ -307,7 +317,7 @@ protected function _exportCsvItem(
*/
public function getCsvFile()
{
$name = md5(microtime());
$name = hash('sha256', microtime());
$file = $this->_path . '/' . $name . '.csv';

$this->_directory->create($this->_path);
Expand Down Expand Up @@ -432,11 +442,11 @@ public function getRowRecord(\Magento\Framework\DataObject $data)
*/
public function getExcelFile($sheetName = '')
{
$collection = $this->_getRowCollection();
$collection = $this->_getPreparedCollection();

$convert = new \Magento\Framework\Convert\Excel($collection->getIterator(), [$this, 'getRowRecord']);

$name = md5(microtime());
$name = hash('sha256', microtime());
$file = $this->_path . '/' . $name . '.xml';

$this->_directory->create($this->_path);
Expand Down Expand Up @@ -551,6 +561,8 @@ public function _getPreparedCollection()
}

/**
* Get export page size
*
* @return int
*/
public function getExportPageSize()
Expand Down
24 changes: 18 additions & 6 deletions app/code/Magento/Backend/Block/Widget/Grid/Extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Magento\Framework\App\Filesystem\DirectoryList;

/**
* Extended Grid Widget
*
* @api
* @deprecated 100.2.0 in favour of UI component implementation
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
Expand Down Expand Up @@ -177,7 +179,10 @@ class Extended extends \Magento\Backend\Block\Widget\Grid implements \Magento\Ba
protected $_path = 'export';

/**
* Initialization
*
* @return void
* @throws \Magento\Framework\Exception\FileSystemException
*/
protected function _construct()
{
Expand Down Expand Up @@ -297,6 +302,7 @@ public function addColumn($columnId, $column)
);
$this->getColumnSet()->getChildBlock($columnId)->setGrid($this);
} else {
// phpcs:ignore Magento2.Exceptions.DirectThrow
throw new \Exception(__('Please correct the column format and try again.'));
}

Expand Down Expand Up @@ -471,10 +477,6 @@ protected function _prepareMassactionColumn()
protected function _prepareCollection()
{
if ($this->getCollection()) {
if ($this->getCollection()->isLoaded()) {
$this->getCollection()->clear();
}

parent::_prepareCollection();

if (!$this->_isExport) {
Expand Down Expand Up @@ -663,6 +665,7 @@ public function setEmptyCellLabel($label)
*/
public function getRowUrl($item)
{
// phpstan:ignore "Call to an undefined static method"
$res = parent::getRowUrl($item);
return $res ? $res : '#';
}
Expand All @@ -680,6 +683,7 @@ public function getMultipleRows($item)

/**
* Retrieve columns for multiple rows
*
* @return array
*/
public function getMultipleRowColumns()
Expand Down Expand Up @@ -943,6 +947,7 @@ protected function _getExportTotals()

/**
* Iterate collection and call callback method per item
*
* For callback method first argument always is item object
*
* @param string $callback
Expand Down Expand Up @@ -972,7 +977,12 @@ public function _exportIterateCollection($callback, array $args)
$page++;

foreach ($collection as $item) {
call_user_func_array([$this, $callback], array_merge([$item], $args));
//phpcs:ignore Magento2.Functions.DiscouragedFunction
call_user_func_array(
[$this, $callback],
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge([$item], $args)
);
}
}
}
Expand Down Expand Up @@ -1009,6 +1019,7 @@ public function getCsvFile()
$this->_isExport = true;
$this->_prepareGrid();

// phpcs:ignore Magento2.Security.InsecureFunction
$name = md5(microtime());
$file = $this->_path . '/' . $name . '.csv';

Expand Down Expand Up @@ -1153,6 +1164,7 @@ public function getExcelFile($sheetName = '')
[$this, 'getRowRecord']
);

// phpcs:ignore Magento2.Security.InsecureFunction
$name = md5(microtime());
$file = $this->_path . '/' . $name . '.xml';

Expand Down Expand Up @@ -1244,7 +1256,7 @@ public function setCollection($collection)
}

/**
* get collection object
* Get collection object
*
* @return \Magento\Framework\Data\Collection
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function testPrepareLoadedCollection()
$layout->expects($this->any())->method('getBlock')->willReturn($columnSet);

$collection = $this->createMock(Collection::class);
$collection->expects($this->atLeastOnce())->method('isLoaded')->willReturn(true);
$collection->expects($this->atLeastOnce())->method('clear');
$collection->expects($this->never())->method('isLoaded');
$collection->expects($this->never())->method('clear');
$collection->expects($this->atLeastOnce())->method('load');

/** @var Extended $block */
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/CategoryData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,8 @@
<data key="level">0</data>
<var key="parent_id" entityType="category" entityKey="id"/>
</entity>
<entity name="AssignProductToCategory" type="category_product_link">
<var key="category_id" entityKey="id" entityType="category"/>
<var key="sku" entityKey="sku" entityType="product"/>
</entity>
</entities>
8 changes: 8 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Metadata/CategoryMeta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@
<operation name="DeleteCategory" dataType="category" type="delete" auth="adminOauth" url="/V1/categories/{id}" method="DELETE">
<contentType>application/json</contentType>
</operation>

<operation name="AssignProductToCategory" dataType="category_product_link" type="create" auth="adminOauth" url="/V1/categories/{id}/products" method="POST">
<contentType>application/json</contentType>
<object key="productLink" dataType="category_product_link">
<field key="sku">string</field>
<field key="category_id">string</field>
</object>
</operation>
</operations>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="ProductWYSIWYGSection">
<element name="Switcher" type="button" selector="select#dropdown-switcher"/>
<element name="v436" type="button" selector="//select[@id='dropdown-switcher']/option[text()='TinyMCE 4.3.6']"/>
<element name="v3" type="button" selector="//select[@id='dropdown-switcher']/option[text()='TinyMCE 3.6(Deprecated)']"/>
<element name="v436" type="button" selector="//select[@id='dropdown-switcher']/option[text()='TinyMCE 4.3.6']" deprecated="New element was introduced. Please use 'ProductWYSIWYGSection.v4910'"/>
<element name="v3" type="button" selector="//select[@id='dropdown-switcher']/option[text()='TinyMCE 3.6(Deprecated)']" deprecated="New element was introduced. Please use 'ProductWYSIWYGSection.v4910'"/>
<element name="v4910" type ="button" selector="//select[@id='dropdown-switcher']/option[text()='TinyMCE 4.9.10']" />
<element name="TinymceDescription3" type="button" selector="//span[text()='Description']"/>
<element name="SaveConfig" type="button" selector="#save"/>
<element name="v4" type="button" selector="#category_form_description_v4"/>
Expand Down
Loading

0 comments on commit 512942e

Please sign in to comment.