[Scummvm-git-logs] scummvm-web master -> 558eab0e55c16cc8a5c8a6ae8d07fa9df6575176
lephilousophe
noreply at scummvm.org
Sat Jun 21 09:18:00 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://api.github.com/repos/scummvm/scummvm-web .
Summary:
558eab0e55 BUILD: Improve error handling when importing data
Commit: 558eab0e55c16cc8a5c8a6ae8d07fa9df6575176
https://github.com/scummvm/scummvm-web/commit/558eab0e55c16cc8a5c8a6ae8d07fa9df6575176
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-06-21T11:17:40+02:00
Commit Message:
BUILD: Improve error handling when importing data
Try to insert again when it failed without the faulty elements.
Changed paths:
include/DataUtils.php
diff --git a/include/DataUtils.php b/include/DataUtils.php
index cfaf0cb0..b334f010 100644
--- a/include/DataUtils.php
+++ b/include/DataUtils.php
@@ -72,7 +72,6 @@ class DataUtils
Promise\Utils::unwrap($promises);
DataUtils::convertYamlToOrm();
-
// Clear the cache at the end of all data operations
\file_put_contents('.clear-cache', '');
}
@@ -113,21 +112,28 @@ class DataUtils
private static function convertYamlToOrm()
{
foreach (self::OBJECT_NAMES as $name => $object) {
+ $failures = array();
+
$query = "ScummVM\\OrmObjects\\{$object}Query";
if ($query::create()->count() > 0) {
continue;
}
$file = DIR_DATA . "/" . DEFAULT_LOCALE . "/$name.yaml";
$data = Yaml::parseFile($file);
+ $data = array_values($data);
echo "Writing $object data to database\n";
$class = "ScummVM\\OrmObjects\\$object";
$mapClass = $class::TABLE_MAP;
$con = Propel::getConnection($mapClass::DATABASE_NAME);
- // Use a transation to speed up writes
- $con->beginTransaction();
- foreach ($data as $item) {
- try {
+ do {
+ $newFailures = array();
+ // Use a transation to speed up writes
+ $con->beginTransaction();
+ foreach ($data as $i => $item) {
+ if (in_array($i, $failures)) {
+ continue;
+ }
foreach ($item as $key => $val) {
if ($val === '') {
unset($item[$key]);
@@ -138,14 +144,30 @@ class DataUtils
if ($object === 'Demo' || $object === 'DirectorDemo') {
$item['platform_id'] = $item['platform'];
}
- $dbItem->fromArray($item, TableMap::TYPE_FIELDNAME);
- $dbItem->save($con);
- } catch (\Exception $ex) {
- echo json_encode($item) . "\n";
- echo $ex->getMessage() . "\n";
+ try {
+ $dbItem->fromArray($item, TableMap::TYPE_FIELDNAME);
+ $dbItem->save($con);
+ } catch (\Exception $ex) {
+ $newFailures[] = $i;
+
+ echo json_encode($item) . "\n";
+ echo $ex->getMessage() . "\n";
+ $prev = $ex->getPrevious();
+ if ($prev) {
+ echo " > " . $prev->getMessage() . "\n";
+ }
+ }
}
- }
- $con->commit();
+ if ($con->isCommitable()) {
+ $con->commit();
+ // If we could commit, we are done
+ break;
+ } else {
+ $con->rollback();
+ }
+ $failures = array_merge($failures, $newFailures);
+ // If there are no new failure, we will get an infinite loop
+ } while (count($newFailures));
}
}
}
More information about the Scummvm-git-logs
mailing list