Version check question

Ask for help or provide support to other members.
Post Reply
Phemisters
Posts: 3
Joined: Fri May 02, 2025 8:12 am

Version check question

Post by Phemisters »

I am a new WonderCMS user. I've been trying out a personal theme (based on Sky) and noticed today that my latest version was not appearing when I checked for updates in the Themes admin area.

I think this is because my version went from 1.0.9 to 1.0.10 and the version check is a simple text check (and since 1 comes before 9 it fails to be detected as newer).

I don't have much php experience, but I see there is a version_compare function and this might be a possible fix for this, if it is a real problem affecting other users:

Code: Select all

--- a/index.php
+++ b/index.php
@@ -1279,7 +1279,7 @@ EOT;
                                $exists = is_dir($this->rootDir . "/$type/" . $dirName);
                                $currentVersion = $exists ? $this->getModuleVersion($type, $dirName) : null;
                                $newVersion = $addon['version'];
-                               $update = $newVersion !== null && $currentVersion !== null && $newVersion > $currentVersion;
+                               $update = $newVersion !== null && $currentVersion !== null && (version_compare($newVersion, $currentVersion) > 0);
                                if ($update) {
                                        $this->alert('info',
                                                'New ' . $type . ' update available. <b><a data-toggle="wcms-modal" href="#settingsModal" data-target-tab="#' . $type . '">Open ' . $type . '</a></b>');
Updated with more info:

---- Include this in your post for support:
1. Version 3.5.0 of WonderCMS

2. What type of server do you have. (Apache, NGINX, IIS) LiteSpeed

3. What version of PHP do you have. 8.2.28

4. Does your hosting provider/server meet the minimum WonderCMS requirements? (https://wondercms.com/requirements - or send your hosting provider this link and ask them if they meet the minimum requirements). Yes, I have checked and they all seem okay.

5. Are you using a custom theme or any plugins, which ones? I'm using a minimally modified sky theme 9some font sizes and colours changed) and I have Summernote editor (3.5.0) and simple blog(3.5.0)
User avatar
NorfolkGreg
Posts: 175
Joined: Wed Sep 01, 2021 7:50 am

Re: Version check question

Post by NorfolkGreg »

I only reckon to understand HTML and CSS and know nothing of PHP, or JavaScript but do have had a theme added to the official list.

Going by some of the answers to questions I have seen on the forum the usual suspect when a failure to update properly occurs is the
wcms-modules.json file.

The new documentation site seems to have a vital line missing from the original Github documentation (The last one seen below).

Code: Select all

{
    "version": 1,
    "themes": {
        "theme-name": {
            "name": "Name of your theme",
            "repo": "https://github.com/yourUsername/theme-name/tree/master",
            "zip": "https://github.com/yourUsename/theme-name/archive/master.zip",
            "summary": "My sample theme",
            "version": "2.0.0",
            "image": "https://raw.githubusercontent.com/yourUsername/theme-name/master/preview.jpg"
        }
    }
}
Note: Leave the first version: 1 at the top as it is, it is used for reading the format of the module.
User avatar
NorfolkGreg
Posts: 175
Joined: Wed Sep 01, 2021 7:50 am

Re: Version check question

Post by NorfolkGreg »

Ah, I see it is there, but now it only appears once, under the plugin version of the file.
Phemisters
Posts: 3
Joined: Fri May 02, 2025 8:12 am

Re: Version check question

Post by Phemisters »

NorfolkGreg wrote: Sun May 04, 2025 9:26 pm Going by some of the answers to questions I have seen on the forum the usual suspect when a failure to update properly occurs is the
wcms-modules.json file.
I think my wcms-modules.json file is valid, it is currently like this:

Code: Select all

{
    "version": 1,
    "themes": {
        "wcms-small": {
            "name": "Wcms-small",
            "repo": "https://github.com/Phemisters/wcms-small/tree/main",
            "zip": "https://github.com/Phemisters/wcms-small/archive/main.zip",
            "summary": "Personal Wonder CMS theme based on Sky",
            "version": "1.0.16",
            "image": "https://raw.githubusercontent.com/Phemisters/wcms-small/main/preview.jpg"
        }
    }
}
The update worked as soon as I tried my suggested change to the version check.
User avatar
NorfolkGreg
Posts: 175
Joined: Wed Sep 01, 2021 7:50 am

Re: Version check question

Post by NorfolkGreg »

Glad it worked for you.

I haven't done a theme update since v3.5.0 was released. It's hard to believe it, but perhaps something has changed that makes the original update check fail.
Phemisters
Posts: 3
Joined: Fri May 02, 2025 8:12 am

Re: Version check question

Post by Phemisters »

NorfolkGreg wrote: Mon May 05, 2025 8:17 am It's hard to believe it, but perhaps something has changed that makes the original update check fail.
The updates worked up to (and including) 1.0.9, but when it went to 1.0.10 it failed (until I made a change to the version check).
User avatar
NorfolkGreg
Posts: 175
Joined: Wed Sep 01, 2021 7:50 am

Re: Version check question

Post by NorfolkGreg »

I haven't looked at your code, and probably wouldn't understand it if I did but, given what you say, it did make me think of the Y2K bug. (Was it really a quarter century ago? :) )
Post Reply