diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-11-07 12:42:24 +0300 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-11-07 12:42:24 +0300 |
commit | 2b42cce4dd17e448191eedd972aa93a46d8973f8 (patch) | |
tree | eb2fcaf78f0144609e1c15f368fd2e27f11c80be | |
parent | 3a81ffcc3c0807a9349bb5fa0df8ee08130e0c00 (diff) |
Bump microsoft/azure-storage-blob to 1.5.4
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
19 files changed, 188 insertions, 78 deletions
diff --git a/composer.json b/composer.json index 2f55bacb..d700146a 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "icewind/streams": "v0.7.5", "laravel/serializable-closure": "^1.2", "mexitek/phpcolors": "^1.0", - "microsoft/azure-storage-blob": "^1.5", + "microsoft/azure-storage-blob": "^1.5.4", "mlocati/ip-lib": "^1.18", "nextcloud/lognormalizer": "^1.0", "nikic/php-parser": "^4.2", diff --git a/composer.lock b/composer.lock index ad063ebc..f00e435c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5d03b9b89f1c45926f27051ab5d41b36", + "content-hash": "d2b492639f133e19e03d552b16686e16", "packages": [ { "name": "aws/aws-crt-php", @@ -2211,16 +2211,16 @@ }, { "name": "microsoft/azure-storage-blob", - "version": "1.5.2", + "version": "1.5.4", "source": { "type": "git", "url": "https://github.com/Azure/azure-storage-blob-php.git", - "reference": "2475330963372d519387cb8135d6a9cfd42272da" + "reference": "1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Azure/azure-storage-blob-php/zipball/2475330963372d519387cb8135d6a9cfd42272da", - "reference": "2475330963372d519387cb8135d6a9cfd42272da", + "url": "https://api.github.com/repos/Azure/azure-storage-blob-php/zipball/1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf", + "reference": "1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf", "shasum": "" }, "require": { @@ -2253,22 +2253,22 @@ ], "support": { "issues": "https://github.com/Azure/azure-storage-blob-php/issues", - "source": "https://github.com/Azure/azure-storage-blob-php/tree/v1.5.2" + "source": "https://github.com/Azure/azure-storage-blob-php/tree/v1.5.4" }, - "time": "2020-12-29T02:22:11+00:00" + "time": "2022-09-02T02:13:06+00:00" }, { "name": "microsoft/azure-storage-common", - "version": "1.5.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/Azure/azure-storage-common-php.git", - "reference": "e5738035891546075bd369954e8af121d65ebd6d" + "reference": "8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Azure/azure-storage-common-php/zipball/e5738035891546075bd369954e8af121d65ebd6d", - "reference": "e5738035891546075bd369954e8af121d65ebd6d", + "url": "https://api.github.com/repos/Azure/azure-storage-common-php/zipball/8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0", + "reference": "8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0", "shasum": "" }, "require": { @@ -2301,9 +2301,9 @@ ], "support": { "issues": "https://github.com/Azure/azure-storage-common-php/issues", - "source": "https://github.com/Azure/azure-storage-common-php/tree/v1.5.1" + "source": "https://github.com/Azure/azure-storage-common-php/tree/v1.5.2" }, - "time": "2020-12-28T07:59:51+00:00" + "time": "2021-10-09T03:03:47+00:00" }, { "name": "mlocati/ip-lib", diff --git a/composer/installed.json b/composer/installed.json index 4c501a73..0286a2fe 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -2301,24 +2301,24 @@ }, { "name": "microsoft/azure-storage-blob", - "version": "1.5.2", - "version_normalized": "1.5.2.0", + "version": "1.5.4", + "version_normalized": "1.5.4.0", "source": { "type": "git", "url": "https://github.com/Azure/azure-storage-blob-php.git", - "reference": "2475330963372d519387cb8135d6a9cfd42272da" + "reference": "1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Azure/azure-storage-blob-php/zipball/2475330963372d519387cb8135d6a9cfd42272da", - "reference": "2475330963372d519387cb8135d6a9cfd42272da", + "url": "https://api.github.com/repos/Azure/azure-storage-blob-php/zipball/1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf", + "reference": "1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf", "shasum": "" }, "require": { "microsoft/azure-storage-common": "~1.5", "php": ">=5.6.0" }, - "time": "2020-12-29T02:22:11+00:00", + "time": "2022-09-02T02:13:06+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2346,30 +2346,30 @@ ], "support": { "issues": "https://github.com/Azure/azure-storage-blob-php/issues", - "source": "https://github.com/Azure/azure-storage-blob-php/tree/v1.5.2" + "source": "https://github.com/Azure/azure-storage-blob-php/tree/v1.5.4" }, "install-path": "../microsoft/azure-storage-blob" }, { "name": "microsoft/azure-storage-common", - "version": "1.5.1", - "version_normalized": "1.5.1.0", + "version": "1.5.2", + "version_normalized": "1.5.2.0", "source": { "type": "git", "url": "https://github.com/Azure/azure-storage-common-php.git", - "reference": "e5738035891546075bd369954e8af121d65ebd6d" + "reference": "8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Azure/azure-storage-common-php/zipball/e5738035891546075bd369954e8af121d65ebd6d", - "reference": "e5738035891546075bd369954e8af121d65ebd6d", + "url": "https://api.github.com/repos/Azure/azure-storage-common-php/zipball/8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0", + "reference": "8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0", "shasum": "" }, "require": { "guzzlehttp/guzzle": "~6.0|^7.0", "php": ">=5.6.0" }, - "time": "2020-12-28T07:59:51+00:00", + "time": "2021-10-09T03:03:47+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2397,7 +2397,7 @@ ], "support": { "issues": "https://github.com/Azure/azure-storage-common-php/issues", - "source": "https://github.com/Azure/azure-storage-common-php/tree/v1.5.1" + "source": "https://github.com/Azure/azure-storage-common-php/tree/v1.5.2" }, "install-path": "../microsoft/azure-storage-common" }, diff --git a/composer/installed.php b/composer/installed.php index 73c5966a..293abb41 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'nextcloud/3rdparty', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '52ea73b49bc3831eccce0653e3d902ea6600e976', + 'reference' => '3a81ffcc3c0807a9349bb5fa0df8ee08130e0c00', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -299,18 +299,18 @@ 'dev_requirement' => false, ), 'microsoft/azure-storage-blob' => array( - 'pretty_version' => '1.5.2', - 'version' => '1.5.2.0', - 'reference' => '2475330963372d519387cb8135d6a9cfd42272da', + 'pretty_version' => '1.5.4', + 'version' => '1.5.4.0', + 'reference' => '1023ce1dbf062351a32ca5ec72ad1fd4a504f1bf', 'type' => 'library', 'install_path' => __DIR__ . '/../microsoft/azure-storage-blob', 'aliases' => array(), 'dev_requirement' => false, ), 'microsoft/azure-storage-common' => array( - 'pretty_version' => '1.5.1', - 'version' => '1.5.1.0', - 'reference' => 'e5738035891546075bd369954e8af121d65ebd6d', + 'pretty_version' => '1.5.2', + 'version' => '1.5.2.0', + 'reference' => '8ca7b1bf4c9ca7c663e75a02a0035b05b37196a0', 'type' => 'library', 'install_path' => __DIR__ . '/../microsoft/azure-storage-common', 'aliases' => array(), @@ -337,7 +337,7 @@ 'nextcloud/3rdparty' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '52ea73b49bc3831eccce0653e3d902ea6600e976', + 'reference' => '3a81ffcc3c0807a9349bb5fa0df8ee08130e0c00', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), diff --git a/microsoft/azure-storage-blob/ChangeLog.md b/microsoft/azure-storage-blob/ChangeLog.md index 212e1fa4..9ac67da4 100644 --- a/microsoft/azure-storage-blob/ChangeLog.md +++ b/microsoft/azure-storage-blob/ChangeLog.md @@ -1,3 +1,11 @@ +2022.08 - version 1.5.4 +* Check `$copyProgress` is not null before using it in `strpos`. + +2021.09 - version 1.5.3 +* Upgraded dependency for `azure-storage-common` to version 1.5.2. +* Resolved some interface inconsistency between `IBlob`/`BlobRestProxy`. +* Imported `Psr\Http\Message\StreamInterface` in `IBlob`. + 2020.12 - version 1.5.2 * Resolved an issue where access condition does not work for large block blob uploads. * Guzzle version is now updated to support both 6.x and 7.x. diff --git a/microsoft/azure-storage-blob/README.md b/microsoft/azure-storage-blob/README.md index 949cc7f3..2bd850f8 100644 --- a/microsoft/azure-storage-blob/README.md +++ b/microsoft/azure-storage-blob/README.md @@ -1,6 +1,6 @@ # Microsoft Azure Storage Blob PHP Client Library -This project provides a PHP client library that makes it easy to access Microsoft Azure Storage blob services. For documentation on how to host PHP applications on Microsoft Azure, please see the [Microsoft Azure PHP Developer Center](http://www.windowsazure.com/en-us/develop/php/). +This project provides a PHP client library that makes it easy to access Microsoft Azure Storage blob services. For documentation on how to host PHP applications on Microsoft Azure, please see the [Microsoft Azure PHP Developer Center](https://www.windowsazure.com/en-us/develop/php/). [![Latest Stable Version](https://poser.pugx.org/microsoft/azure-storage-blob/v/stable)](https://packagist.org/packages/microsoft/azure-storage-blob) @@ -17,7 +17,7 @@ This project provides a PHP client library that makes it easy to access Microsof * create block and page blobs (from a stream or a string), work with blob blocks and pages, delete blobs * work with blob properties, metadata, leases, snapshot a blob -Please check details on [API reference documents](http://azure.github.io/azure-storage-php). +Please check details on [API reference documents](https://azure.github.io/azure-storage-php). # Getting Started ## Minimum Requirements @@ -52,7 +52,7 @@ cd ./azure-storage-php } } ``` -2. Download **[composer.phar](http://getcomposer.org/composer.phar)** in your project root. +2. Download **[composer.phar](https://getcomposer.org/composer.phar)** in your project root. 3. Open a command prompt and execute this in your project root @@ -137,7 +137,7 @@ To use proxies during HTTP requests, set system variable `HTTP_PROXY` and the pr ### Error: Unable to get local issuer certificate cURL can't verify the validity of Microsoft certificate when trying to issue a request call to Azure Storage Services. You must configure cURL to use a certificate when issuing https requests by the following steps: -1. Download the cacert.pem file from [cURL site](http://curl.haxx.se/docs/caextract.html). +1. Download the cacert.pem file from [cURL site](https://curl.haxx.se/docs/caextract.html). 2. Then either: * Open your php.ini file and add the following line: @@ -153,7 +153,7 @@ cURL can't verify the validity of Microsoft certificate when trying to issue a r ## Code samples -You can find samples in the [sample folder](samples) +You can find samples in the [samples folder](https://github.com/Azure/azure-storage-php/tree/master/samples) # Migrate from [Azure SDK for PHP](https://github.com/Azure/azure-sdk-for-php/) @@ -164,11 +164,11 @@ For now, Microsoft Azure Storage PHP client libraries share almost the same inte # Need Help? -Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow](http://go.microsoft.com/fwlink/?LinkId=234489) and [github issues](https://github.com/Azure/azure-storage-php/issues) if you have trouble with the provided code. +Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow](https://go.microsoft.com/fwlink/?LinkId=234489) and [github issues](https://github.com/Azure/azure-storage-php/issues) if you have trouble with the provided code. # Contribute Code or Provide Feedback -If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/). +If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](https://opensource.microsoft.com/program/#program-contributing). You can find more details for contributing in the [CONTRIBUTING.md](CONTRIBUTING.md). If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-storage-php/issues) section of the project. diff --git a/microsoft/azure-storage-blob/composer.json b/microsoft/azure-storage-blob/composer.json index b74c369e..3dd32f25 100644 --- a/microsoft/azure-storage-blob/composer.json +++ b/microsoft/azure-storage-blob/composer.json @@ -1,6 +1,6 @@ { "name": "microsoft/azure-storage-blob", - "version": "1.5.2", + "version": "1.5.4", "description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.", "keywords": [ "php", "azure", "storage", "sdk", "blob" ], "license": "MIT", diff --git a/microsoft/azure-storage-blob/src/Blob/BlobRestProxy.php b/microsoft/azure-storage-blob/src/Blob/BlobRestProxy.php index d2d3cc3f..ca7a6c59 100644 --- a/microsoft/azure-storage-blob/src/Blob/BlobRestProxy.php +++ b/microsoft/azure-storage-blob/src/Blob/BlobRestProxy.php @@ -89,6 +89,7 @@ use MicrosoftAzure\Storage\Common\LocationMode; use MicrosoftAzure\Storage\Common\Models\Range; use MicrosoftAzure\Storage\Common\SharedAccessSignatureHelper; use Psr\Http\Message\StreamInterface; +use GuzzleHttp\Psr7\Utils; /** * This class constructs HTTP requests and receive HTTP responses for blob @@ -759,7 +760,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob get_class(new Range(0)) ) ); - $body = Psr7\stream_for($content); + $body = Utils::streamFor($content); $method = Resources::HTTP_PUT; $headers = array(); @@ -1834,7 +1835,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreateBlockBlobOptions $options = null ) { - $body = Psr7\stream_for($content); + $body = Utils::streamFor($content); //If the size of the stream is not seekable or larger than the single //upload threshold then call concurrent upload. Otherwise call putBlob. @@ -1915,7 +1916,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreatePageBlobFromContentOptions $options = null ) { - $body = Psr7\stream_for($content); + $body = Utils::streamFor($content); $self = $this; if (is_null($options)) { @@ -2417,7 +2418,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreateBlobPagesOptions $options = null ) { - $contentStream = Psr7\stream_for($content); + $contentStream = Utils::streamFor($content); //because the content is at most 4MB long, can retrieve all the data //here at once. $body = $contentStream->getContents(); @@ -2516,7 +2517,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $postParams = array(); $queryParams = $this->createBlobBlockQueryParams($options, $blockId); $path = $this->createPath($container, $blob); - $contentStream = Psr7\stream_for($content); + $contentStream = Utils::streamFor($content); $body = $contentStream->getContents(); $options->setLocationMode(LocationMode::PRIMARY_ONLY); @@ -2597,7 +2598,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $queryParams = array(); $path = $this->createPath($container, $blob); - $contentStream = Psr7\stream_for($content); + $contentStream = Utils::streamFor($content); $length = $contentStream->getSize(); $body = $contentStream->getContents(); @@ -3791,7 +3792,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob ); }); } - + /** * Undeletes a blob. * @@ -3810,7 +3811,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob ) { $this->undeleteBlobAsync($container, $blob, $options)->wait(); } - + /** * Undeletes a blob. * diff --git a/microsoft/azure-storage-blob/src/Blob/Internal/BlobResources.php b/microsoft/azure-storage-blob/src/Blob/Internal/BlobResources.php index 73eb34ba..a94adb8f 100644 --- a/microsoft/azure-storage-blob/src/Blob/Internal/BlobResources.php +++ b/microsoft/azure-storage-blob/src/Blob/Internal/BlobResources.php @@ -41,7 +41,7 @@ class BlobResources extends Resources { // @codingStandardsIgnoreStart - const BLOB_SDK_VERSION = '1.5.2'; + const BLOB_SDK_VERSION = '1.5.4'; const STORAGE_API_LATEST_VERSION = '2017-11-09'; // Error messages diff --git a/microsoft/azure-storage-blob/src/Blob/Internal/IBlob.php b/microsoft/azure-storage-blob/src/Blob/Internal/IBlob.php index 4066db4b..fa9ce6b3 100644 --- a/microsoft/azure-storage-blob/src/Blob/Internal/IBlob.php +++ b/microsoft/azure-storage-blob/src/Blob/Internal/IBlob.php @@ -28,6 +28,7 @@ use MicrosoftAzure\Storage\Blob\Models as BlobModels; use MicrosoftAzure\Storage\Common\Models\ServiceOptions; use MicrosoftAzure\Storage\Common\Models\ServiceProperties; use MicrosoftAzure\Storage\Common\Models\Range; +use Psr\Http\Message\StreamInterface; /** * This interface has all REST APIs provided by Windows Azure for Blob service. @@ -1127,6 +1128,82 @@ interface IBlob ); /** + * Downloads a blob to a file, the result contains its metadata and + * properties. The result will not contain a stream pointing to the + * content of the file. + * + * @param string $path The path and name of the file + * @param string $container name of the container + * @param string $blob name of the blob + * @param BlobModels\GetBlobOptions $options optional parameters + * + * @return BlobModels\GetBlobResult + * + * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx + */ + public function saveBlobToFile( + $path, + $container, + $blob, + BlobModels\GetBlobOptions $options = null + ); + + /** + * Creates promise to download a blob to a file, the result contains its + * metadata and properties. The result will not contain a stream pointing + * to the content of the file. + * + * @param string $path The path and name of the file + * @param string $container name of the container + * @param string $blob name of the blob + * @param BlobModels\GetBlobOptions $options optional parameters + * + * @return \GuzzleHttp\Promise\PromiseInterface + * @throws \Exception + * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx + */ + public function saveBlobToFileAsync( + $path, + $container, + $blob, + BlobModels\GetBlobOptions $options = null + ); + + /** + * Undeletes a blob. + * + * @param string $container name of the container + * @param string $blob name of the blob + * @param BlobModels\UndeleteBlobOptions $options optional parameters + * + * @return void + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob + */ + public function undeleteBlob( + $container, + $blob, + BlobModels\UndeleteBlobOptions $options = null + ); + + /** + * Undeletes a blob. + * + * @param string $container name of the container + * @param string $blob name of the blob + * @param BlobModels\UndeleteBlobOptions $options optional parameters + * + * @return \GuzzleHttp\Promise\PromiseInterface + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob + */ + public function undeleteBlobAsync( + $container, + $blob, + BlobModels\UndeleteBlobOptions $options = null + ); + + /** * Reads or downloads a blob from the system, including its metadata and * properties. * diff --git a/microsoft/azure-storage-blob/src/Blob/Models/CopyState.php b/microsoft/azure-storage-blob/src/Blob/Models/CopyState.php index dd140c77..732e28ed 100644 --- a/microsoft/azure-storage-blob/src/Blob/Models/CopyState.php +++ b/microsoft/azure-storage-blob/src/Blob/Models/CopyState.php @@ -74,7 +74,7 @@ class CopyState $copyProgress = Utilities::tryGetValue($clean, 'copyprogress'); - if (strpos($copyProgress, '/') !== false) { + if (!is_null($copyProgress) && strpos($copyProgress, '/') !== false) { $parts = explode('/', $copyProgress); $bytesCopied = intval($parts[0]); $totalBytes = intval($parts[1]); @@ -112,7 +112,7 @@ class CopyState $result->setSource(Utilities::tryGetValue($clean, Resources::X_MS_COPY_SOURCE)); $copyProgress = Utilities::tryGetValue($clean, Resources::X_MS_COPY_PROGRESS); - if (strpos($copyProgress, '/') !== false) { + if (!is_null($copyProgress) && strpos($copyProgress, '/') !== false) { $parts = explode('/', $copyProgress); $bytesCopied = intval($parts[0]); $totalBytes = intval($parts[1]); diff --git a/microsoft/azure-storage-common/ChangeLog.md b/microsoft/azure-storage-common/ChangeLog.md index 0f3418b8..00885e97 100644 --- a/microsoft/azure-storage-common/ChangeLog.md +++ b/microsoft/azure-storage-common/ChangeLog.md @@ -1,3 +1,12 @@ +2021.09 - version 1.5.2 +* Added support for guzzle 7.3. +* Resolve some warnings when calling `Psr7\stream_for`, uses `Utils::streamFor` instead. +* Added colon to non-UTC timestamps. +* Fixed type hint for `ServiceException::getResponse()`. +* Fixed random number range that might cause an overflow in the guid generation. +* Added logic to convert to exception when promise is rejected with string. +* Compares `strlen` result with an integer instead of string. + 2020.12 - version 1.5.1 * Guzzle version is now updated to support both 6.x and 7.x. diff --git a/microsoft/azure-storage-common/composer.json b/microsoft/azure-storage-common/composer.json index 8afe15c5..84db042c 100644 --- a/microsoft/azure-storage-common/composer.json +++ b/microsoft/azure-storage-common/composer.json @@ -1,6 +1,6 @@ { "name": "microsoft/azure-storage-common", - "version": "1.5.1", + "version": "1.5.2", "description": "This project provides a set of common code shared by Azure Storage Blob, Table, Queue and File PHP client libraries.", "keywords": [ "php", "azure", "storage", "sdk", "common" ], "license": "MIT", diff --git a/microsoft/azure-storage-common/src/Common/Exceptions/ServiceException.php b/microsoft/azure-storage-common/src/Common/Exceptions/ServiceException.php index 040e3464..f262a3ed 100644 --- a/microsoft/azure-storage-common/src/Common/Exceptions/ServiceException.php +++ b/microsoft/azure-storage-common/src/Common/Exceptions/ServiceException.php @@ -168,7 +168,7 @@ class ServiceException extends \LogicException /** * Gets the response of the failue. * - * @return string + * @return ResponseInterface */ public function getResponse() { diff --git a/microsoft/azure-storage-common/src/Common/Internal/Authentication/SharedKeyAuthScheme.php b/microsoft/azure-storage-common/src/Common/Internal/Authentication/SharedKeyAuthScheme.php index afc23fcb..7a7be4ab 100644 --- a/microsoft/azure-storage-common/src/Common/Internal/Authentication/SharedKeyAuthScheme.php +++ b/microsoft/azure-storage-common/src/Common/Internal/Authentication/SharedKeyAuthScheme.php @@ -24,6 +24,7 @@ namespace MicrosoftAzure\Storage\Common\Internal\Authentication; +use GuzzleHttp\Psr7\Query; use GuzzleHttp\Psr7\Request; use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter; use MicrosoftAzure\Storage\Common\Internal\Resources; @@ -305,7 +306,7 @@ class SharedKeyAuthScheme implements IAuthScheme $signedKey = $this->getAuthorizationHeader( $requestHeaders, $request->getUri(), - \GuzzleHttp\Psr7\parse_query( + Query::parse( $request->getUri()->getQuery() ), $request->getMethod() diff --git a/microsoft/azure-storage-common/src/Common/Internal/Resources.php b/microsoft/azure-storage-common/src/Common/Internal/Resources.php index 48128d4f..d3eff1cc 100644 --- a/microsoft/azure-storage-common/src/Common/Internal/Resources.php +++ b/microsoft/azure-storage-common/src/Common/Internal/Resources.php @@ -241,7 +241,7 @@ class Resources const BEARER = 'Bearer '; // Header values - const COMMON_SDK_VERSION = '1.5.1'; + const COMMON_SDK_VERSION = '1.5.2'; const INT32_MAX = 2147483647; const INT32_MIN = -2147483648; diff --git a/microsoft/azure-storage-common/src/Common/Internal/ServiceRestProxy.php b/microsoft/azure-storage-common/src/Common/Internal/ServiceRestProxy.php index 1b911e59..15ef327e 100644 --- a/microsoft/azure-storage-common/src/Common/Internal/ServiceRestProxy.php +++ b/microsoft/azure-storage-common/src/Common/Internal/ServiceRestProxy.php @@ -297,7 +297,7 @@ class ServiceRestProxy extends RestProxy // add query parameters into headers if ($queryParams != null) { - $queryString = Psr7\build_query($queryParams); + $queryString = Psr7\Query::build($queryParams); $uri = $uri->withQuery($queryString); } @@ -306,7 +306,7 @@ class ServiceRestProxy extends RestProxy if (empty($body)) { if (empty($headers[Resources::CONTENT_TYPE])) { $headers[Resources::CONTENT_TYPE] = Resources::URL_ENCODED_CONTENT_TYPE; - $actualBody = Psr7\build_query($postParameters); + $actualBody = Psr7\Query::build($postParameters); } } else { $actualBody = $body; @@ -402,25 +402,39 @@ class ServiceRestProxy extends RestProxy ); }, function ($reason) use ($expected) { - if (!($reason instanceof RequestException)) { - throw $reason; - } - $response = $reason->getResponse(); - if ($response != null) { - self::throwIfError( - $response, - $expected - ); - } else { - //if could not get response but promise rejected, throw reason. - throw $reason; - } - return $response; + return $this->onRejected($reason, $expected); } ); } /** + * @param string|\Exception $reason Rejection reason. + * @param array|int $expected Expected Status Codes. + * + * @return ResponseInterface + */ + protected function onRejected($reason, $expected) + { + if (!($reason instanceof \Exception)) { + throw new \RuntimeException($reason); + } + if (!($reason instanceof RequestException)) { + throw $reason; + } + $response = $reason->getResponse(); + if ($response != null) { + self::throwIfError( + $response, + $expected + ); + } else { + //if could not get response but promise rejected, throw reason. + throw $reason; + } + return $response; + } + + /** * Generate the request options using the given service options and stored * information. * diff --git a/microsoft/azure-storage-common/src/Common/Internal/Utilities.php b/microsoft/azure-storage-common/src/Common/Internal/Utilities.php index 158e920b..5765e4f5 100644 --- a/microsoft/azure-storage-common/src/Common/Internal/Utilities.php +++ b/microsoft/azure-storage-common/src/Common/Internal/Utilities.php @@ -433,7 +433,7 @@ class Utilities $cloned = clone $value; $cloned->setTimezone(new \DateTimeZone('UTC')); - return str_replace('+0000', 'Z', $cloned->format("Y-m-d\TH:i:s.u0O")); + return str_replace('+00:00', 'Z', $cloned->format("Y-m-d\TH:i:s.u0P")); } /** @@ -562,7 +562,7 @@ class Utilities mt_rand(0, 64) + 128, // 8 bits for "clock_seq_hi", with // the most significant 2 bits being 10, // required by version 4 GUIDs. - mt_rand(0, 256), // 8 bits for "clock_seq_low" + mt_rand(0, 255), // 8 bits for "clock_seq_low" mt_rand(0, 65535), // 16 bits for "node 0" and "node 1" mt_rand(0, 65535), // 16 bits for "node 2" and "node 3" mt_rand(0, 65535) // 16 bits for "node 4" and "node 5" diff --git a/microsoft/azure-storage-common/src/Common/SharedAccessSignatureHelper.php b/microsoft/azure-storage-common/src/Common/SharedAccessSignatureHelper.php index 2031821e..d5cc81f4 100644 --- a/microsoft/azure-storage-common/src/Common/SharedAccessSignatureHelper.php +++ b/microsoft/azure-storage-common/src/Common/SharedAccessSignatureHelper.php @@ -291,7 +291,7 @@ class SharedAccessSignatureHelper } Validate::isTrue( - strlen($input) == '', + strlen($input) == 0, sprintf( Resources::STRING_NOT_WITH_GIVEN_COMBINATION, implode(', ', $array) |