r71031 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71030‎ | r71031 | r71032 >
Date:14:38, 13 August 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on update detection
Modified paths:
  • /trunk/extensions/Deployment/includes/DistributionRepository.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Deployment/includes/DistributionRepository.php
@@ -92,13 +92,13 @@
9393 return false;
9494 }
9595
96 - $extensionsWithUpdates = FormatJson::decode( $response )->extensions;
 96+ $response = FormatJson::decode( $response );
9797
98 - if ( !property_exists( $extensionsWithUpdates, $extensionName ) ) {
99 - return false;
 98+ if ( property_exists( $response, 'extensions' ) && property_exists( $response->extensions, $extensionName ) ) {
 99+ return $response->extensions->$extensionName;
100100 }
101101
102 - return $extensionsWithUpdates->$extensionName;
 102+ return false;
103103 }
104104
105105 /**
@@ -107,7 +107,28 @@
108108 * @since 0.1
109109 */
110110 public function coreHasUpdate( $currentVersion ) {
111 - // TODO
 111+ global $wgRepositoryPackageStates;
 112+
 113+ // TODO: use $wgRepositoryPackageStates
 114+
 115+ $currentVersion = urlencode( $currentVersion );
 116+
 117+ $response = Http::get(
 118+ "$this->location?format=json&action=updates&mediawiki=$currentVersion",
 119+ 'default',
 120+ array( 'sslVerifyHost' => true, 'sslVerifyCert' => true )
 121+ );
 122+
 123+ if ( $response === false ) {
 124+ return false;
 125+ }
 126+
 127+ $response = FormatJson::decode( $response );
 128+
 129+ if ( property_exists( $response, 'mediawiki' ) ) {
 130+ return $response->mediawiki;
 131+ }
 132+
112133 return false;
113134 }
114135
@@ -117,8 +138,47 @@
118139 * @since 0.1
119140 */
120141 public function installationHasUpdates( $coreVersion, array $extensions ) {
121 - // TODO
122 - return false;
 142+ global $wgRepositoryPackageStates;
 143+
 144+ // TODO: use $wgRepositoryPackageStates
 145+
 146+ $coreVersion = urlencode( $coreVersion );
 147+
 148+ $extensionParams = array();
 149+
 150+ foreach ( $extensions as $extensionName => $extensionVersion ) {
 151+ $extensionParams[] = urlencode( $extensionName ) . ';' . urlencode( $extensionVersion );
 152+ }
 153+
 154+ $extensionParams = implode( '|', $extensionParams );
 155+
 156+ $response = Http::get(
 157+ "$this->location?format=json&action=updates&mediawiki=$coreVersion&extensions=",
 158+ 'default',
 159+ array( 'sslVerifyHost' => true, 'sslVerifyCert' => true )
 160+ );
 161+
 162+ if ( $response === false ) {
 163+ return false;
 164+ }
 165+
 166+ $response = FormatJson::decode( $response );
 167+
 168+ $updates = array();
 169+
 170+ if ( property_exists( $response, 'mediawiki' ) ) {
 171+ $updates['MediaWiki'] = $response->mediawiki;
 172+ }
 173+
 174+ if ( property_exists( $response, 'extensions' ) ) {
 175+ foreach ( $extensions as $extensionName => $extensionVersion ) {
 176+ if ( property_exists( $response->extensions, $extensionName ) ) {
 177+ $updates[$extensionName] = $response->extensions->$extensionName;
 178+ }
 179+ }
 180+ }
 181+
 182+ return count( $updates ) > 0 ? $updates : false;
123183 }
124184
125185 }
\ No newline at end of file

Status & tagging log