Index: trunk/extensions/Deployment/includes/DistributionRepository.php |
— | — | @@ -92,13 +92,13 @@ |
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | |
96 | | - $extensionsWithUpdates = FormatJson::decode( $response )->extensions; |
| 96 | + $response = FormatJson::decode( $response ); |
97 | 97 | |
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; |
100 | 100 | } |
101 | 101 | |
102 | | - return $extensionsWithUpdates->$extensionName; |
| 102 | + return false; |
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
— | — | @@ -107,7 +107,28 @@ |
108 | 108 | * @since 0.1 |
109 | 109 | */ |
110 | 110 | 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 | + |
112 | 133 | return false; |
113 | 134 | } |
114 | 135 | |
— | — | @@ -117,8 +138,47 @@ |
118 | 139 | * @since 0.1 |
119 | 140 | */ |
120 | 141 | 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; |
123 | 183 | } |
124 | 184 | |
125 | 185 | } |
\ No newline at end of file |