mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
mvc: fix PHP warnings and dance around null/0.0.0 ambiguity
If we have a model and no data we assume and write 0.0.0, but if we have a legacy data we want to have null to designate that we do actually migrate although from the top point of view 0.0.0 are the same.
This commit is contained in:
parent
84f0bcdbdb
commit
74fe31682f
@ -644,7 +644,7 @@ abstract class BaseModel
|
||||
{
|
||||
if ($this->internal_mountpoint == ':memory:') {
|
||||
return false;
|
||||
} elseif (version_compare($this->internal_current_model_version, $this->internal_model_version, '<')) {
|
||||
} elseif (version_compare($this->internal_current_model_version ?? '0.0.0', $this->internal_model_version, '<')) {
|
||||
$upgradePerformed = false;
|
||||
$migObjects = array();
|
||||
$logger = new Logger(
|
||||
@ -667,7 +667,7 @@ abstract class BaseModel
|
||||
uksort($versions, "version_compare");
|
||||
foreach ($versions as $mig_version => $filename) {
|
||||
if (
|
||||
version_compare($this->internal_current_model_version, $mig_version, '<') &&
|
||||
version_compare($this->internal_current_model_version ?? '0,0.0', $mig_version, '<') &&
|
||||
version_compare($this->internal_model_version, $mig_version, '>=')
|
||||
) {
|
||||
// execute upgrade action
|
||||
@ -690,10 +690,8 @@ abstract class BaseModel
|
||||
$upgradePerformed = true;
|
||||
} catch (Exception $e) {
|
||||
$logger->error("failed migrating from version " .
|
||||
$this->internal_current_model_version .
|
||||
" to " . $mig_version . " in " .
|
||||
$class_info->getName() .
|
||||
" [skipping step]");
|
||||
$this->getVersion() . " to " . $mig_version . " in " .
|
||||
$class_info->getName() . " [skipping step]");
|
||||
}
|
||||
$this->internal_current_model_version = $mig_version;
|
||||
}
|
||||
@ -724,6 +722,6 @@ abstract class BaseModel
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->internal_current_model_version;
|
||||
return $this->internal_current_model_version ?? '<unversioned>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,6 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir
|
||||
$version_post = $mdl->getVersion();
|
||||
if ($version_pre != $version_post) {
|
||||
if ($mig_performed) {
|
||||
$version_pre = !empty($version_pre) ? $version_pre : '<unversioned>';
|
||||
echo "Migrated " . $mdl_class_info->getName() .
|
||||
" from " . $version_pre .
|
||||
" to " . $version_post . "\n";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user