global $wgRepositoryPackageStates;
$currentVersion = urlencode( $currentVersion );
- $states = urlencode( implode( '|', $wgRepositoryPackageStates ) );
+ $states = urlencode( implode( '|', $wgRepositoryPackageStates ) );
$response = Http::get(
"$this->location?format=json&action=updates&mediawiki=$currentVersion&state=$states",
return false;
}
+ /**
+ * @see PackageRepository::coreHasUpdate
+ *
+ * @since 1.17
+ */
+ public function getLatestCoreVersion() {
+ global $wgRepositoryPackageStates;
+
+ $states = urlencode( implode( '|', $wgRepositoryPackageStates ) );
+
+ // TODO: use $states
+
+ $response = Http::get(
+ "$this->location?format=json&action=mwreleases",
+ 'default',
+ array( 'sslVerifyHost' => true, 'sslVerifyCert' => true )
+ );
+
+ if ( $response === false ) {
+ return false;
+ }
+
+ $response = FormatJson::decode( $response );
+
+ $current = false;
+
+ if ( property_exists( $response, 'mwreleases' ) ) {
+ foreach ( $response->mwreleases as $release ) {
+ if ( property_exists( $release, 'current' ) && property_exists( $release, 'version') ) {
+ $current = $release->version;
+ }
+ }
+ }
+
+ return $current;
+ }
+
/**
* @see PackageRepository::installationHasUpdates
*
*/
public abstract function coreHasUpdate( $currentVersion );
+ /**
+ * Returns the latest MediaWiki release, or false when the request fails.
+ *
+ * @since 1.17
+ *
+ * @return Mixed: string or false
+ */
+ public abstract function getLatestCoreVersion();
+
/**
* Checks if there are any updates for this MediaWiki installation and extensions.
*
public function envLatestVersion() {
global $wgVersion;
- $latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json';
- $latestInfo = Http::get( $latestInfoUrl );
-
+ $repository = wfGetRepository();
+ $currentVersion = $repository->getLatestCoreVersion();
+
+ /*
if( !$latestInfo ) {
$this->showMessage( 'config-env-latest-can-not-check', $latestInfoUrl );
return;
}
+ */
$this->setVar( '_ExternalHTTP', true );
- $latestInfo = FormatJson::decode($latestInfo);
- if ($latestInfo === false || !isset( $latestInfo->mwreleases ) ) {
+ if ( $currentVersion === false ) {
# For when the request is successful but there's e.g. some silly man in
# the middle firewall blocking us, e.g. one of those annoying airport ones
$this->showMessage( 'config-env-latest-data-invalid', $latestInfoUrl );
return;
}
- foreach( $latestInfo->mwreleases as $rel ) {
- if( isset( $rel->current ) ) {
- $currentVersion = $rel->version;
- }
- }
-
if( version_compare( $wgVersion, $currentVersion, '<' ) ) {
$this->showMessage( 'config-env-latest-old' );
$this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion );