Skip to content

Commit c7832d0

Browse files
committed
ACP2E-2692: "Base table or view not found" error occurs when partial reindex
1 parent 881ca23 commit c7832d0

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

lib/internal/Magento/Framework/Mview/View/ChangelogBatchWalker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function walk(
8080
$idsTable = $this->idsTableBuilder->build($changelog);
8181

8282
try {
83-
$connection->createTemporaryTable($idsTable);
83+
$connection->createTable($idsTable);
8484

8585
$columns = $this->getIdsColumns($idsTable);
8686

@@ -122,7 +122,7 @@ public function walk(
122122
yield $ids;
123123
}
124124
} finally {
125-
$connection->dropTemporaryTable($idsTable->getName());
125+
$connection->dropTable($idsTable->getName());
126126
}
127127
}
128128

lib/internal/Magento/Framework/Mview/View/ChangelogBatchWalker/IdsTableBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function build(ChangelogInterface $changelog): Table
5050
['unsigned' => true, 'nullable' => false],
5151
'Entity ID'
5252
);
53-
$table->setOption('type', 'memory');
5453
$table->addIndex(
5554
self::INDEX_NAME_UNIQUE,
5655
[
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Framework\Test\Unit\Mview\View\ChangelogBatchWalker;
20+
21+
use Magento\Framework\App\ResourceConnection;
22+
use Magento\Framework\DB\Adapter\AdapterInterface;
23+
use Magento\Framework\DB\Ddl\Table;
24+
use Magento\Framework\Mview\View\ChangelogBatchWalker\IdsTableBuilder;
25+
use Magento\Framework\Mview\View\ChangelogInterface;
26+
use PHPUnit\Framework\TestCase;
27+
28+
class IdsTableBuilderTest extends TestCase
29+
{
30+
/**
31+
* @var ResourceConnection
32+
*/
33+
private $resourceConnection;
34+
35+
/**
36+
* @var ChangelogInterface
37+
*/
38+
private $changeLog;
39+
40+
/**
41+
* @var AdapterInterface
42+
*/
43+
private $connection;
44+
45+
/**
46+
* @var Table
47+
*/
48+
private $table;
49+
50+
/**
51+
* @var IdsTableBuilder
52+
*/
53+
private $model;
54+
55+
protected function setUp(): void
56+
{
57+
$this->changeLog = $this->getMockBuilder(ChangelogInterface::class)
58+
->getMockForAbstractClass();
59+
$this->connection = $this->getMockBuilder(AdapterInterface::class)
60+
->getMockForAbstractClass();
61+
$this->table = $this->getMockBuilder(Table::class)
62+
->disableOriginalConstructor()
63+
->getMock();
64+
65+
$this->resourceConnection = $this->getMockBuilder(ResourceConnection::class)
66+
->disableOriginalConstructor()
67+
->getMock();
68+
$this->resourceConnection->expects($this->any())
69+
->method('getConnection')
70+
->willReturn($this->connection);
71+
$this->connection->expects($this->any())
72+
->method('newTable')
73+
->willReturn($this->table);
74+
75+
$this->model = new IdsTableBuilder($this->resourceConnection);
76+
}
77+
78+
public function testBuildDoNotCreateMemoryTable() : void
79+
{
80+
$this->table->expects($this->never())
81+
->method('setOption')
82+
->with('type', 'memory');
83+
84+
$this->model->build($this->changeLog);
85+
}
86+
}

0 commit comments

Comments
 (0)