mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Remap versioned ClassNames during build process
This commit is contained in:
parent
747c0770e7
commit
2d1d2aea79
@ -9,6 +9,7 @@ use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Security\Permission;
|
||||
|
||||
@ -325,10 +326,19 @@ class DatabaseAdmin extends Controller
|
||||
echo "<li>Correcting $badRecordCount obsolete classname values for $newClassName</li>\n";
|
||||
}
|
||||
$table = $schema->baseDataTable($baseDataClass);
|
||||
DB::prepared_query(
|
||||
"UPDATE \"$table\" SET \"ClassName\" = ? WHERE \"ClassName\" = ?",
|
||||
[ $newClassName, $oldClassName ]
|
||||
);
|
||||
|
||||
$updateQuery = "UPDATE \"$table%s\" SET \"ClassName\" = ? WHERE \"ClassName\" = ?";
|
||||
$updateQueries = [sprintf($updateQuery, '')];
|
||||
|
||||
// Remap versioned table ClassName values as well
|
||||
if (singleton($newClassName)->has_extension(Versioned::class)) {
|
||||
$updateQueries[] = sprintf($updateQuery, '_Live');
|
||||
$updateQueries[] = sprintf($updateQuery, '_Versions');
|
||||
}
|
||||
|
||||
foreach ($updateQueries as $query) {
|
||||
DB::prepared_query($query, [$newClassName, $oldClassName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user