YahnisElsts/wp-update-server

Upgrade Notice does not pass the regex.

Closed this issue · 6 comments

Hi Yahnis,

In server version 1.3.1 it seems the upgrade notice does not pass the regex check in /includes/Wpup/ZipMetadataParser.php, line 206. It is neatly in the sections, but missing in the json root. That leads to WordPress not showing the upgrade notice inline anymore.
For now I have simply removed the regex and that works:
protected function setReadmeUpgradeNotice(){
//Check if we have an upgrade notice for this version
if ( isset($this->metadata['sections']['upgrade_notice']) && isset($this->metadata['version']) ){
$this->metadata['upgrade_notice'] = trim(strip_tags($this->metadata['sections']['upgrade_notice']));
}
}

EDIT: I cannot get the code properly formatted.

The purpose of the regex is to find the upgrade notice that matches the current version. If you remove the regex, you'll make the update server return the entire "Upgrade Notice" section, which is probably not what you want if you also keep upgrade notices associated with past releases instead of removing them every time there's a new release.

Are you sure the contents of your readme.txt match the WordPress.org readme standards? In particular, the update server expects the "Upgrade Notice" section to look something like this:

== Upgrade Notice ==

= 1.0 =
Upgrade notices describe the reason a user should upgrade.  No more than 300 characters.

= 0.5 =
This version fixes a security related bug.  Upgrade immediately.

Can you post a sample of your "Upgrade Notice" section? Feel free to remove any identifying information; I just want to see the overall structure.

Thank you for the reply.
Yes, my readme.txt match the WordPress standard, with the only exception of the versions in the update notice section, because I believe that previous update notices are not only outdated, they also do not apply anymore since the update is always for the latest version.
The change log needs to reflect all previous changes. Putting the info in both sections seems redundant...

It sounds like the readme.txt does not match the standard after all: the standard readme has version numbers in the "upgrade notice" section and it sounds like yours might not.

If you don't want to retain old upgrade notices, you could still include the current version number as a heading to conform to the standard:

== Upgrade Notice ==

= 1.2.3 =
This is an upgrade notice for the current version. Lorem ipsum.

The change log needs to reflect all previous changes. Putting the info in both sections seems redundant...

As far as I know, "Upgrade Notice" is not intended to contain the full changelog. It's meant to be a short message (WordPress.org says <300 characters) that will be displayed when the users sees the update in the admin dashboard. So it's a summary while the changelog has the details.

I stand by my opinion that I find multiple upgrade notices unnecessary. They should only reflect a notice before updating.
I will simply keep my altered version then, because I do really like the rest of the update-checker, update-server and server-stats.

Noted. And you don't need to have multiple upgrade notices to use this update server. As long as you include the version number for your notice, it should be picked up by the server.

All right, it seems that, one way or another, this issue is resolved. I will close it now.