diff --git a/plugins/CoreUpdater/UpdateCommunication.php b/plugins/CoreUpdater/UpdateCommunication.php index 28269d743a5c3171231e19caae3e5782ce4764e1..5b4253f8f3549a79d151e029d702b5e1e3f9ca85 100644 --- a/plugins/CoreUpdater/UpdateCommunication.php +++ b/plugins/CoreUpdater/UpdateCommunication.php @@ -58,10 +58,6 @@ class UpdateCommunication { $latestVersion = $this->getLatestVersion(); - if (!$this->isVersionLike($latestVersion)) { - return; - } - $host = SettingsPiwik::getPiwikUrl(); $subject = Piwik::translate('CoreUpdater_NotificationSubjectAvailableCoreUpdate', $latestVersion); @@ -109,7 +105,18 @@ class UpdateCommunication { UpdateCheck::check(); - return UpdateCheck::isNewestVersionAvailable(); + $hasUpdate = UpdateCheck::isNewestVersionAvailable(); + + if (!$hasUpdate) { + return false; + } + + $latestVersion = self::getLatestVersion(); + if (!$this->isVersionLike($latestVersion)) { + return false; + } + + return $hasUpdate; } private function hasNotificationAlreadyReceived() diff --git a/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php b/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php index 206f12177980e72e31149accb49036ffc2bc1fcc..4b2dcec99aded00a3644b72fd2a1fa4f1d0bdd10 100644 --- a/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php +++ b/tests/PHPUnit/Integration/Plugins/CorePluginsAdmin/UpdateCommunicationTest.php @@ -92,7 +92,6 @@ class Plugins_CorePluginsAdmin_UpdateCommunicationTest extends DatabaseTestCase return array( array('33.0.0', '33.0.0', $this->never(), '33.0.0'), // shouldNotSend_IfAlreadyNotified array('31.0.0', '33.0.0', $this->never(), '33.0.0'), // shouldNotSend_IfAlreadyNotifiedAboutLaterRelease - array('3333.3333.3333-beta10', '31.0.0', $this->never(), '31.0.0'), // shouldNotSend_IfLatestVersionIsNotVersionLike, array('33.0.0', false, $this->once(), '33.0.0'), // shouldSend_IfUpdateAvailableAndNeverSentAnyBefore array('33.0.0', '31.0.0', $this->once(), '33.0.0'), // shouldSend_IfUpdateAvailable, ); diff --git a/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php b/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php index c7cf5aa3a26dc7db745e563989f058d83cfeb81f..109f80c0226fe0a00954348dbbab1a4997a158e8 100644 --- a/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php +++ b/tests/PHPUnit/Integration/Plugins/CoreUpdater/UpdateCommunicationTest.php @@ -58,6 +58,7 @@ class Plugins_CoreUpdater_UpdateCommunicationTest extends DatabaseTestCase array(Version::VERSION, false, $this->never(), false), // shouldNotSend_IfNoUpdateAvailable array('33.0.0', '33.0.0', $this->never(), '33.0.0'), // shouldNotSend_IfAlreadyNotified array('31.0.0', '33.0.0', $this->never(), '33.0.0'), // shouldNotSend_IfAlreadyNotifiedAboutLaterRelease + array('3333.3333.3333-beta10', '31.0.0', $this->never(), '31.0.0'), // shouldNotSend_IfLatestVersionIsNotVersionLike, array('33.0.0', false, $this->once(), '33.0.0'), // shouldSend_IfUpdateAvailableAndNeverSentAnyBefore array('33.0.0', '31.0.0', $this->once(), '33.0.0'), // shouldSend_IfUpdateAvailable );