follow up r76111. I had picked the wrong timedifference for the filecache.
[lhc/web/wiklou.git] / includes / DistributionRepository.php
index 197e640..8aabb51 100644 (file)
@@ -17,7 +17,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  * Repository class for interaction with repositories provided by
  * the Distirbution extension and the MediaWiki API.
  * 
- * @since 0.1
+ * @since 1.17
  * 
  * @ingroup Deployment
  * 
@@ -30,7 +30,7 @@ class DistributionRepository extends PackageRepository {
         * 
         * @param $location String: path to the api of the MediaWiki install providing the repository.
         * 
-        * @since 0.1
+        * @since 1.17
         */
        public function __construct( $location ) {
                parent::__construct( $location );
@@ -39,7 +39,7 @@ class DistributionRepository extends PackageRepository {
        /**
         * @see PackageRepository::findExtenions
         * 
-        * @since 0.1
+        * @since 1.17
         * 
         * @param $filterType String
         * @param $filterValue String
@@ -75,7 +75,7 @@ class DistributionRepository extends PackageRepository {
        /**
         * @see PackageRepository::extensionHasUpdate
         * 
-        * @since 0.1
+        * @since 1.17
         */             
        public function extensionHasUpdate( $extensionName, $currentVersion ) {
                global $wgRepositoryPackageStates;
@@ -106,13 +106,13 @@ class DistributionRepository extends PackageRepository {
        /**
         * @see PackageRepository::coreHasUpdate
         * 
-        * @since 0.1
+        * @since 1.17
         */                     
        public function coreHasUpdate( $currentVersion ) {
                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",
@@ -133,10 +133,45 @@ class DistributionRepository extends PackageRepository {
                return false;
        }
        
+       /**
+        * @see PackageRepository::coreHasUpdate
+        * 
+        * @since 1.17
+        */             
+       public function getLatestCoreVersion() {
+               // TODO: use $states
+               //global $wgRepositoryPackageStates;
+               //$states = urlencode( implode( '|', $wgRepositoryPackageStates ) );
+               
+               $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
         * 
-        * @since 0.1
+        * @since 1.17
         */                     
        public function installationHasUpdates( $coreVersion, array $extensions ) {
                global $wgRepositoryPackageStates;