Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed autoincrement id fetching cache problem in import/export module #3730

Merged
merged 20 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,15 @@
"contributions": [
"code"
]
},
{
"login": "leissbua",
"name": "Michael Leiss",
"avatar_url": "https://avatars.githubusercontent.com/u/68073221?v=4",
"profile": "https://github.com/leissbua",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a href="#contributors-"><img src="https://img.shields.io/badge/all_contributors-156-orange.svg" alt="All Contributors"></a>
<a href="#contributors-"><img src="https://img.shields.io/badge/all_contributors-157-orange.svg" alt="All Contributors"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a href="https://packagist.org/packages/openmage/magento-lts"><img src="https://poser.pugx.org/openmage/magento-lts/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/openmage/magento-lts"><img src="https://poser.pugx.org/openmage/magento-lts/license.svg" alt="License"></a>
Expand Down Expand Up @@ -590,6 +590,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://juhoholsa.com/"><img src="https://avatars.githubusercontent.com/u/15036353?v=4" loading="lazy" width="100" alt=""/><br /><sub><b>Juho Hölsä</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/seifer7"><img src="https://avatars.githubusercontent.com/u/13601073?v=4" loading="lazy" width="100" alt=""/><br /><sub><b>Kane</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Sdfendor"><img src="https://avatars.githubusercontent.com/u/2728018?v=4" loading="lazy" width="100" alt=""/><br /><sub><b>Kevin Jakob</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/leissbua"><img src="https://avatars.githubusercontent.com/u/68073221?v=4" loading="lazy" width="100" alt=""/><br /><sub><b>leissbua</b></sub></a></td>
</tr>
</tbody>
</table>
Expand Down
23 changes: 22 additions & 1 deletion app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Mage_ImportExport_Model_Resource_Helper_Mysql4 extends Mage_Core_Model_Res
public const DB_MAX_PACKET_SIZE = 1048576; // Maximal packet length by default in MySQL
public const DB_MAX_PACKET_COEFFICIENT = 0.85; // The coefficient of useful data from maximum packet length

/**
* Semaphore to disable schema stats only once
*
* @var bool
*/
private static $instantInformationSchemaStatsExpiry = false;

/**
* Returns maximum size of packet, that we can send to DB
*
Expand All @@ -49,11 +56,25 @@ public function getMaxDataSize()
public function getNextAutoincrement($tableName)
{
$adapter = $this->_getReadAdapter();
$this->setInformationSchemaStatsExpiry();
$entityStatus = $adapter->showTableStatus($tableName);

if (empty($entityStatus['Auto_increment'])) {
Mage::throwException(Mage::helper('importexport')->__('Cannot get autoincrement value'));
}
return $entityStatus['Auto_increment'];
}

/**
* Set information_schema_stats_expiry to 0 if not already set.
*/
public function setInformationSchemaStatsExpiry(): void
{
if (!self::$instantInformationSchemaStatsExpiry) {
try {
$this->_getReadAdapter()->query('SET information_schema_stats_expiry = 0;');
} catch (Exception $e) {
}
self::$instantInformationSchemaStatsExpiry = true;
}
}
}
Loading