Skip to content

Commit 1cdfdbd

Browse files
committed
MAGETWO-58924: SQL error wait timeout error when saving categories
- fix sample data
1 parent bef7496 commit 1cdfdbd

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\CatalogUrlRewrite\Model\Map;
77

8-
use Magento\Catalog\Model\ResourceModel\Category\Collection;
98
use Magento\Catalog\Model\ResourceModel\Category;
109
use Magento\Catalog\Model\CategoryRepository;
1110
use Magento\Catalog\Api\Data\CategoryInterface;
@@ -21,24 +20,18 @@ class DataCategoryHashMap implements HashMapInterface
2120
/** @var CategoryRepository */
2221
private $categoryRepository;
2322

24-
/** @var Collection */
25-
private $collection;
26-
2723
/** @var Category */
2824
private $categoryResource;
2925

3026
/**
3127
* @param CategoryRepository $categoryRepository
32-
* @param Collection $collection
3328
* @param Category $categoryResource
3429
*/
3530
public function __construct(
3631
CategoryRepository $categoryRepository,
37-
Collection $collection,
3832
Category $categoryResource
3933
) {
4034
$this->categoryRepository = $categoryRepository;
41-
$this->collection = $collection;
4235
$this->categoryResource = $categoryResource;
4336
}
4437

@@ -52,8 +45,7 @@ public function getAllData($categoryId)
5245
{
5346
if (!isset($this->hashMap[$categoryId])) {
5447
$category = $this->categoryRepository->get($categoryId);
55-
$this->hashMap[$categoryId] = $this->collection->addIdFilter($this->getAllCategoryChildrenIds($category))
56-
->getAllIds();
48+
$this->hashMap[$categoryId] = $this->getAllCategoryChildrenIds($category);
5749
}
5850
return $this->hashMap[$categoryId];
5951
}

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Map;
77

8-
use Magento\Catalog\Model\ResourceModel\Category\Collection;
98
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource;
109
use Magento\Framework\DB\Select;
1110
use Magento\Catalog\Model\CategoryRepository;
@@ -22,9 +21,6 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
2221
/** @var CategoryRepository|\PHPUnit_Framework_MockObject_MockObject */
2322
private $categoryRepository;
2423

25-
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject */
26-
private $collection;
27-
2824
/** @var CategoryResource|\PHPUnit_Framework_MockObject_MockObject */
2925
private $categoryResource;
3026

@@ -34,7 +30,6 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase
3430
protected function setUp()
3531
{
3632
$this->categoryRepository = $this->getMock(CategoryRepository::class, [], [], '', false);
37-
$this->collection = $this->getMock(Collection::class, ['addIdFilter', 'getAllIds'], [], '', false);
3833
$this->categoryResource = $this->getMock(
3934
CategoryResource::class,
4035
['getConnection', 'getEntityTable'],
@@ -47,7 +42,6 @@ protected function setUp()
4742
DataCategoryHashMap::class,
4843
[
4944
'categoryRepository' => $this->categoryRepository,
50-
'collection' => $this->collection,
5145
'categoryResource' => $this->categoryResource
5246
]
5347
);
@@ -68,15 +62,6 @@ public function testGetAllData()
6862
$this->categoryRepository->expects($this->any())
6963
->method('get')
7064
->willReturn($categoryMock);
71-
$categoryMock->expects($this->any())
72-
->method('getResourceCollection')
73-
->willReturn($this->collection);
74-
$this->collection->expects($this->any())
75-
->method('addIdFilter')
76-
->willReturnSelf();
77-
$this->collection->expects($this->exactly(3))
78-
->method('getAllIds')
79-
->willReturnOnConsecutiveCalls($categoryIds, $categoryIdsOther, $categoryIds);
8065
$categoryMock->expects($this->any())
8166
->method('getResource')
8267
->willReturn($this->categoryResource);
@@ -97,7 +82,7 @@ public function testGetAllData()
9782
->willReturnSelf();
9883
$connectionAdapterMock->expects($this->any())
9984
->method('fetchCol')
100-
->willReturnOnConsecutiveCalls($categoryIds, $categoryIdsOther);
85+
->willReturnOnConsecutiveCalls($categoryIds, $categoryIdsOther, $categoryIds);
10186

10287
$this->assertEquals($categoryIds, $this->model->getAllData(1));
10388
$this->assertEquals($categoryIds[2], $this->model->getData(1, 2));

0 commit comments

Comments
 (0)