humbug / phar-updater

A thing to make PHAR self-updates easy and secure
BSD 3-Clause "New" or "Revised" License
368 stars 27 forks source link

Make newVersionAvailable() more flexible #14

Closed pjcdawkins closed 8 years ago

pjcdawkins commented 8 years ago

Currently the updater will select the most recent available remote version, provided that it's different from the local version. This PR accounts for the local version being newer than all of the remote versions.

pjcdawkins commented 8 years ago

... I see this breaks with the ShaStrategy because that doesn't have sequential 'version' numbers

aik099 commented 8 years ago

In what cases local version can be larger, than all remote ones?

pjcdawkins commented 8 years ago

Mainly, if you're attempting to update from unstable to stable - you might have 2.0.0-beta locally, but the remote only has 1.1.0, 1.2.0, and 2.0.0-beta available. The 'strategy', looking for stable updates, reports that the most recent remote version is 1.2.0. But you actually only want to update if the most recent remote version is 2.0.0 or higher.

pjcdawkins commented 8 years ago

... although I now realise this (checking against the local version) can also be done in the Strategy... it seems unclear which class has the responsibility but instanceof already rings alarm bells