wintercms / winter

Free, open-source, self-hosted CMS platform based on the Laravel PHP Framework.
https://wintercms.com
MIT License
1.38k stars 194 forks source link

Migrations are not performed if version number starts with a "v" #466

Closed multiwebinc closed 2 years ago

multiwebinc commented 2 years ago

Winter CMS Build

1.1

PHP Version

7.4

Database engine

SQLite

Plugins installed

No response

Issue description

As per the documentation at https://wintercms.com/docs/plugin/updates, in the "version.yaml" file, versions are prepended with "v", however, in practice, this does not work. The migration files referenced under that version are not executed if the version begins with a "v".

Steps to replicate

Straight from the documentation at https://wintercms.com/docs/plugin/updates:

"v1.1.1":
    - "v1.1.1/some_upgrade_file.php"
    - "v1.1.1/some_seeding_file.php"

The above two scripts are not executed. However the following works correctly:

1.1.1:
    - "v1.1.1/some_upgrade_file.php"
    - "v1.1.1/some_seeding_file.php"

Workaround

No response

multiwebinc commented 2 years ago

In modules/system/classes/versionManager.php > updatePlugin()

if ($currentVersion == $databaseVersion) {
    $this->note(' - <info>Nothing to update.</info>');
    return;
}

Note: 'string' == 0 returns true prior to PHP 8 (see https://www.php.net/manual/en/types.comparisons.php). Before any migrations are performed, the version is set to 0.

LukeTowers commented 2 years ago

@multiwebinc can you try: if ($currentVersion === (string) $databaseVersion) { instead?

multiwebinc commented 2 years ago

@LukeTowers Close. However, for some reason, it skips the initial version.

multiwebinc commented 2 years ago

Ok, I got it figured out. PR coming.

github-actions[bot] commented 2 years ago

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue. If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

LukeTowers commented 2 years ago

@multiwebinc is this fixed in the 1.2 branch? See https://github.com/wintercms/winter/commit/af311f7001d9f07c802166faafaa0d5715a2dc78

multiwebinc commented 2 years ago

@LukeTowers I apologize for the delay in getting back to you on this. I just tested it and it appears to be working for me.