|
83 | 83 | $tempFolder = $null
|
84 | 84 | $finalDllName = $null
|
85 | 85 | $additionalFiles = @()
|
| 86 | + $newExtensions = @() |
86 | 87 | try {
|
87 | 88 | if (Test-Path -Path $Extension -PathType Leaf) {
|
88 | 89 | if ($Version -ne '') {
|
|
95 | 96 | throw 'You can''t specify the -MaximumStability argument if you specify an existing file with the -Extension argument'
|
96 | 97 | }
|
97 | 98 | $dllPath = [System.IO.Path]::GetFullPath($Extension)
|
98 |
| - $newExtension = Get-PhpExtensionDetail -PhpVersion $phpVersion -Path $dllPath |
| 99 | + $newExtensions += Get-PhpExtensionDetail -PhpVersion $phpVersion -Path $dllPath |
99 | 100 | $moveDll = $false
|
100 | 101 | }
|
101 | 102 | else {
|
|
165 | 166 | $dllFiles = @()
|
166 | 167 | }
|
167 | 168 | }
|
| 169 | + $additionalExtensionsDll = @() |
| 170 | + $dllNames = $dllFiles | Where-Object -Property Name -Like "php_*.dll" | Select-Object -ExpandProperty Name |
| 171 | + if ($dllNames -is [array] -and $dllNames.Length -eq 2 -and $dllNames -contains 'php_http.dll' -and $dllNames -contains 'php_raphf.dll') { |
| 172 | + $newExtensions += Get-PhpExtensionDetail -PhpVersion $phpVersion -Path $(Join-Path -Path $tempFolder -ChildPath 'php_raphf.dll') |
| 173 | + $additionalExtensionsDll += 'php_raphf.dll' |
| 174 | + } |
168 | 175 | $dllPath = $null
|
169 | 176 | foreach ($dllFile in $dllFiles) {
|
| 177 | + if ($additionalExtensionsDll -contains $dllFile.Name) { |
| 178 | + continue |
| 179 | + } |
170 | 180 | if ($dllFile.Name -like "php_*.dll") {
|
171 | 181 | if ($dllPath) {
|
172 | 182 | throw ("Multiple PHP DLL found in archive downloaded from {0}" -f $availablePackageVersion.PackageArchiveUrl)
|
|
184 | 194 | $keepDownloadedFile = $true
|
185 | 195 | $dllPath = $downloadedFile
|
186 | 196 | }
|
187 |
| - $newExtension = Get-PhpExtensionDetail -PhpVersion $phpVersion -Path $dllPath |
| 197 | + $newExtensions += Get-PhpExtensionDetail -PhpVersion $phpVersion -Path $dllPath |
188 | 198 | $moveDll = $true
|
189 | 199 | }
|
190 | 200 | catch {
|
|
202 | 212 | }
|
203 | 213 | }
|
204 | 214 | }
|
205 |
| - $oldExtension = Get-PhpExtension -Path $phpVersion.ExecutablePath | Where-Object { $_.Handle -eq $newExtension.Handle } |
206 |
| - if ($null -ne $oldExtension) { |
207 |
| - if ($oldExtension.Type -eq $Script:EXTENSIONTYPE_BUILTIN) { |
208 |
| - Write-Verbose ("'{0}' is a builtin extension" -f $oldExtension.Name) |
209 |
| - } |
210 |
| - Write-Verbose ("Upgrading extension '{0}' from version {1} to version {2}" -f $oldExtension.Name, $oldExtension.Version, $newExtension.Version) |
211 |
| - if (-Not(Test-IsFileWritable($oldExtension.Filename))) { |
212 |
| - throw "Unable to write to the file $($oldExtension.Filename)" |
213 |
| - } |
214 |
| - if ($moveDll) { |
215 |
| - Move-Item -Path $dllPath -Destination $oldExtension.Filename -Force |
216 |
| - } else { |
217 |
| - Copy-Item -Path $dllPath -Destination $oldExtension.Filename -Force |
218 |
| - } |
219 |
| - try { |
220 |
| - Reset-Acl -Path $oldExtension.Filename |
221 |
| - } catch { |
222 |
| - Write-Debug -Message "Failed to reset the ACL for $($oldExtension.Filename): $($_.Exception.Message)" |
223 |
| - } |
224 |
| - foreach ($additionalFile in $additionalFiles) { |
225 |
| - $additionalFileDestination = Join-Path -Path $AdditionalFilesPath -ChildPath $(Split-Path -Path $additionalFile -Leaf) |
226 |
| - Copy-Item -LiteralPath $additionalFile -Destination $additionalFileDestination -Force |
| 215 | + foreach ($newExtension in $newExtensions) { |
| 216 | + $oldExtension = Get-PhpExtension -Path $phpVersion.ExecutablePath | Where-Object { $_.Handle -eq $newExtension.Handle } |
| 217 | + if ($null -ne $oldExtension) { |
| 218 | + if ($oldExtension.Type -eq $Script:EXTENSIONTYPE_BUILTIN) { |
| 219 | + Write-Verbose ("'{0}' is a builtin extension" -f $oldExtension.Name) |
| 220 | + } |
| 221 | + Write-Verbose ("Upgrading extension '{0}' from version {1} to version {2}" -f $oldExtension.Name, $oldExtension.Version, $newExtension.Version) |
| 222 | + if (-Not(Test-IsFileWritable($oldExtension.Filename))) { |
| 223 | + throw "Unable to write to the file $($oldExtension.Filename)" |
| 224 | + } |
| 225 | + if ($moveDll) { |
| 226 | + Move-Item -Path $newExtension.Filename -Destination $oldExtension.Filename -Force |
| 227 | + } else { |
| 228 | + Copy-Item -Path $newExtension.Filename -Destination $oldExtension.Filename -Force |
| 229 | + } |
227 | 230 | try {
|
228 |
| - Reset-Acl -Path $additionalFileDestination |
| 231 | + Reset-Acl -Path $oldExtension.Filename |
229 | 232 | } catch {
|
230 |
| - Write-Debug -Message "Failed to reset the ACL for $($additionalFileDestination): $($_.Exception.Message)" |
| 233 | + Write-Debug -Message "Failed to reset the ACL for $($oldExtension.Filename): $($_.Exception.Message)" |
| 234 | + } |
| 235 | + foreach ($additionalFile in $additionalFiles) { |
| 236 | + $additionalFileDestination = Join-Path -Path $AdditionalFilesPath -ChildPath $(Split-Path -Path $additionalFile -Leaf) |
| 237 | + Copy-Item -LiteralPath $additionalFile -Destination $additionalFileDestination -Force |
| 238 | + try { |
| 239 | + Reset-Acl -Path $additionalFileDestination |
| 240 | + } catch { |
| 241 | + Write-Debug -Message "Failed to reset the ACL for $($additionalFileDestination): $($_.Exception.Message)" |
| 242 | + } |
| 243 | + } |
| 244 | + if ($oldExtension.State -eq $Script:EXTENSIONSTATE_DISABLED -and -Not($DontEnable)) { |
| 245 | + Enable-PhpExtension -Extension $oldExtension.Name -Path $phpVersion.ExecutablePath |
231 | 246 | }
|
232 | 247 | }
|
233 |
| - if ($oldExtension.State -eq $Script:EXTENSIONSTATE_DISABLED -and -Not($DontEnable)) { |
234 |
| - Enable-PhpExtension -Extension $oldExtension.Name -Path $phpVersion.ExecutablePath |
235 |
| - } |
236 |
| - } |
237 |
| - else { |
238 |
| - Write-Verbose ("Installing new extension '{0}' version {1}" -f $newExtension.Name, $newExtension.Version) |
239 |
| - if (-not($NoDependencies)) { |
240 |
| - Install-PhpExtensionPrerequisite -Extension $newExtension.Handle -InstallPath $AdditionalFilesPath -PhpPath $phpVersion.ActualFolder |
241 |
| - } |
242 |
| - if ($null -eq $finalDllName) { |
243 |
| - $newExtensionFilename = [System.IO.Path]::Combine($phpVersion.ExtensionsPath, [System.IO.Path]::GetFileName($dllPath)) |
244 |
| - } else { |
245 |
| - $newExtensionFilename = [System.IO.Path]::Combine($phpVersion.ExtensionsPath, [System.IO.Path]::GetFileName($finalDllName)) |
246 |
| - } |
247 |
| - if ($moveDll) { |
248 |
| - Write-Verbose "Moving ""$dllPath"" to ""$newExtensionFilename""" |
249 |
| - Move-Item -Path $dllPath -Destination $newExtensionFilename |
250 |
| - } else { |
251 |
| - Write-Verbose "Copying ""$dllPath"" to ""$newExtensionFilename""" |
252 |
| - Copy-Item -Path $dllPath -Destination $newExtensionFilename |
253 |
| - } |
254 |
| - try { |
255 |
| - Reset-Acl -Path $newExtensionFilename |
256 |
| - } catch { |
257 |
| - Write-Debug -Message "Failed to reset the ACL for $($newExtensionFilename): $($_.Exception.Message)" |
258 |
| - } |
259 |
| - foreach ($additionalFile in $additionalFiles) { |
260 |
| - $additionalFileDestination = Join-Path -Path $AdditionalFilesPath -ChildPath $(Split-Path -Path $additionalFile -Leaf) |
261 |
| - Copy-Item -LiteralPath $additionalFile -Destination $additionalFileDestination -Force |
| 248 | + else { |
| 249 | + Write-Verbose ("Installing new extension '{0}' version {1}" -f $newExtension.Name, $newExtension.Version) |
| 250 | + if (-not($NoDependencies)) { |
| 251 | + Install-PhpExtensionPrerequisite -Extension $newExtension.Handle -InstallPath $AdditionalFilesPath -PhpPath $phpVersion.ActualFolder |
| 252 | + } |
| 253 | + if ($null -eq $finalDllName) { |
| 254 | + $newExtensionFilename = [System.IO.Path]::Combine($phpVersion.ExtensionsPath, [System.IO.Path]::GetFileName($newExtension.Filename)) |
| 255 | + } else { |
| 256 | + $newExtensionFilename = [System.IO.Path]::Combine($phpVersion.ExtensionsPath, [System.IO.Path]::GetFileName($finalDllName)) |
| 257 | + } |
| 258 | + if ($moveDll) { |
| 259 | + Write-Verbose "Moving ""$($newExtension.Filename)"" to ""$newExtensionFilename""" |
| 260 | + Move-Item -Path $newExtension.Filename -Destination $newExtensionFilename |
| 261 | + } else { |
| 262 | + Write-Verbose "Copying ""$($newExtension.Filename)"" to ""$newExtensionFilename""" |
| 263 | + Copy-Item -Path $newExtension.Filename -Destination $newExtensionFilename |
| 264 | + } |
262 | 265 | try {
|
263 |
| - Reset-Acl -Path $additionalFileDestination |
| 266 | + Reset-Acl -Path $newExtensionFilename |
264 | 267 | } catch {
|
265 |
| - Write-Debug -Message "Failed to reset the ACL for $($additionalFileDestination): $($_.Exception.Message)" |
| 268 | + Write-Debug -Message "Failed to reset the ACL for $($newExtensionFilename): $($_.Exception.Message)" |
| 269 | + } |
| 270 | + foreach ($additionalFile in $additionalFiles) { |
| 271 | + $additionalFileDestination = Join-Path -Path $AdditionalFilesPath -ChildPath $(Split-Path -Path $additionalFile -Leaf) |
| 272 | + Copy-Item -LiteralPath $additionalFile -Destination $additionalFileDestination -Force |
| 273 | + try { |
| 274 | + Reset-Acl -Path $additionalFileDestination |
| 275 | + } catch { |
| 276 | + Write-Debug -Message "Failed to reset the ACL for $($additionalFileDestination): $($_.Exception.Message)" |
| 277 | + } |
| 278 | + } |
| 279 | + if (-Not($DontEnable)) { |
| 280 | + Write-Verbose "Enabling extension ""$($newExtension.Name)"" for ""$($phpVersion.ExecutablePath)""" |
| 281 | + Enable-PhpExtension -Extension $newExtension.Name -Path $phpVersion.ExecutablePath |
266 | 282 | }
|
267 | 283 | }
|
268 |
| - if (-Not($DontEnable)) { |
269 |
| - Write-Verbose "Enabling extension ""$($newExtension.Name)"" for ""$($phpVersion.ExecutablePath)""" |
270 |
| - Enable-PhpExtension -Extension $newExtension.Name -Path $phpVersion.ExecutablePath |
271 |
| - } |
| 284 | + $additionalFiles = @() |
272 | 285 | }
|
273 | 286 | }
|
274 | 287 | finally {
|
|
0 commit comments