diff --git a/CHANGELOG.md b/CHANGELOG.md index 19696ed1..258f354f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +1.20.2 / 2023-02-09 +=================== + + * Fix PHP 8.2 deprecation warnings + +1.20.1 / 2022-02-01 +================== + + * Fix support of the lowercase response headers + 1.20.0 / 2021-01-13 ================== diff --git a/README.md b/README.md index 8799c038..c775af36 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Cloudinary ========== +## ![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) This is the legacy version of the PHP SDK. For the current version [click here](https://github.com/cloudinary/cloudinary_php). + Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. Easily upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website's graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more. @@ -14,7 +16,7 @@ Cloudinary provides URL and HTTP based APIs that can be easily integrated with a For PHP, Cloudinary provides an extension for simplifying the integration even further. ## Getting started guide -![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **Take a look at our [Getting started guide for PHP](http://cloudinary.com/documentation/php_integration#getting_started_guide)**. +![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **Take a look at our [Getting started guide for PHP](http://cloudinary.com/documentation/php1_integration)**. ## CakePHP ## @@ -26,7 +28,7 @@ You can install through composer with: `composer require cloudinary/cloudinary_php` -Or download cloudinary_php from [here](https://github.com/cloudinary/cloudinary_php/tarball/master) +Or download cloudinary_php from [here](https://github.com/cloudinary/cloudinary_php/tree/support/1.x) *Note: cloudinary_php require PHP 5.4* @@ -65,7 +67,7 @@ Generating a 120x90 thumbnail based on automatic face detection of the Facebook For more details, see our documentation for embedding [Facebook](http://cloudinary.com/documentation/facebook_profile_pictures) and [Twitter](http://cloudinary.com/documentation/twitter_profile_pictures) profile pictures. ### Samples -You can find our simple and ready-to-use samples projects, along with documentations in the [samples folder](https://github.com/cloudinary/cloudinary_php/tree/master/samples). Please consult with the [README file](https://github.com/cloudinary/cloudinary_php/blob/master/samples/README.md), for usage and explanations. +You can find our simple and ready-to-use samples projects, along with documentations in the [samples folder](https://github.com/cloudinary/cloudinary_php/tree/support/1.x/samples). Please consult with the [README file](https://github.com/cloudinary/cloudinary_php/blob/support/1.x/samples/README.md), for usage and explanations. ## Usage @@ -98,7 +100,7 @@ Same goes for Twitter: cloudinary_url("billclinton.jpg", array("type" => "twitter_name")) -![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/php_image_manipulation) for more information about displaying and transforming images in PHP**. +![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/php1_image_manipulation) for more information about displaying and transforming images in PHP**. @@ -125,7 +127,7 @@ You can also specify your own public ID: http://res.cloudinary.com/demo/image/upload/sample_remote.jpg -![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/php_image_upload) for plenty more options of uploading to the cloud from your PHP code**. +![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/php1_image_upload) for plenty more options of uploading to the cloud from your PHP code**. ### cl\_image\_tag @@ -159,7 +161,7 @@ Parameters: - `upload-options-array` - upload options same as in Upload section above, with: - html - an associative array of html attributes for the upload field -![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser) for plenty more options of uploading directly from the browser**. +![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/php1_image_upload#direct_uploading_from_the_browser) for plenty more options of uploading directly from the browser**. ### cl\_form\_tag @@ -193,9 +195,9 @@ Additional resources are available at: * [Website](http://cloudinary.com) * [Knowledge Base](http://support.cloudinary.com/forums) * [Documentation](http://cloudinary.com/documentation) -* [Documentation for PHP integration](http://cloudinary.com/documentation/php_integration) -* [PHP image upload documentation](http://cloudinary.com/documentation/php_image_upload) -* [PHP image manipulation documentation](http://cloudinary.com/documentation/php_image_manipulation) +* [Documentation for PHP integration](http://cloudinary.com/documentation/php1_integration) +* [PHP image upload documentation](http://cloudinary.com/documentation/php1_image_upload) +* [PHP image manipulation documentation](http://cloudinary.com/documentation/php1_image_manipulation) * [Image transformations documentation](http://cloudinary.com/documentation/image_transformations) ## Support diff --git a/composer.json b/composer.json index bd93811d..816354b2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "cloudinary/cloudinary_php", - "version": "1.20.0", + "version": "1.20.2", "description": "Cloudinary PHP SDK", "keywords": ["cloudinary", "sdk", "cloud", "image management", "cdn"], "type": "library", diff --git a/src/Api/Response.php b/src/Api/Response.php index 30a0abdc..7d09d55b 100644 --- a/src/Api/Response.php +++ b/src/Api/Response.php @@ -11,16 +11,20 @@ class Response extends \ArrayObject /** * Response constructor. * - * @param \stdClass $response Response from HTTP request to Cloudinary server - * @see Api::execute() For response definition + * @param \stdClass $response Response from HTTP request to Cloudinary server * * @throws GeneralError + * @see Api::execute() For response definition + * */ public function __construct($response) { parent::__construct(\Cloudinary\Api::parse_json_response($response)); - $this->rate_limit_reset_at = strtotime($response->headers["X-FeatureRateLimit-Reset"]); - $this->rate_limit_allowed = intval($response->headers["X-FeatureRateLimit-Limit"]); - $this->rate_limit_remaining = intval($response->headers["X-FeatureRateLimit-Remaining"]); + // According to RFC 2616, header names are case-insensitive. + $headers = array_change_key_case($response->headers, CASE_LOWER); + + $this->rate_limit_reset_at = strtotime(\Cloudinary::option_get($headers, "x-featureratelimit-reset")); + $this->rate_limit_allowed = (int)\Cloudinary::option_get($headers, "x-featureratelimit-limit"); + $this->rate_limit_remaining = (int)\Cloudinary::option_get($headers, "x-featureratelimit-remaining"); } } diff --git a/src/Cloudinary.php b/src/Cloudinary.php index 901a1273..646c347d 100644 --- a/src/Cloudinary.php +++ b/src/Cloudinary.php @@ -16,7 +16,7 @@ class Cloudinary const DEFAULT_UPLOAD_PREFIX = 'https://api.cloudinary.com'; - const VERSION = "1.20.0"; + const VERSION = "1.20.2"; /** * @internal diff --git a/src/Helpers.php b/src/Helpers.php index b89f1f0b..52207437 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -253,7 +253,7 @@ function fetch_breakpoints($public_id, $srcset_data = array(), $options = array( $kbytes_step = (int)ceil($bytes_step / 1024); - $width_param = "auto:breakpoints_${min_width}_${max_width}_${kbytes_step}_${max_images}:json"; + $width_param = "auto:breakpoints_{$min_width}_{$max_width}_{$kbytes_step}_{$max_images}:json"; // We use Cloudinary::cloudinary_scaled_url function, passing special `width` parameter $breakpoints_url = Cloudinary::cloudinary_scaled_url($public_id, $width_param, $transformation, $options); @@ -827,11 +827,11 @@ function generate_media_attr($media_options) $media_query_conditions = []; if (!empty($media_options['min_width'])) { - array_push($media_query_conditions, "(min-width: ${media_options['min_width']}px)"); + array_push($media_query_conditions, "(min-width: {$media_options['min_width']}px)"); } if (!empty($media_options['max_width'])) { - array_push($media_query_conditions, "(max-width: ${media_options['max_width']}px)"); + array_push($media_query_conditions, "(max-width: {$media_options['max_width']}px)"); } if (empty($media_query_conditions)) { diff --git a/tests/ApiTest.php b/tests/ApiTest.php index b57d8061..585c0a18 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -931,6 +931,20 @@ public function test_usage_by_date() $this->assertArrayNotHasKey('used_percent', $result['bandwidth']); } + /** + * Should parse usage limits + * + * @throws Api\GeneralError + */ + public function test_response_limits() + { + $result = $this->api->ping(); + + self::assertNotEmpty($result->rate_limit_allowed); + self::assertNotEmpty($result->rate_limit_reset_at); + self::assertNotEmpty($result->rate_limit_remaining); + } + /** * Should allow deleting all resources * diff --git a/tests/MetadataTest.php b/tests/MetadataTest.php index b7db4d66..3b8d2bbc 100644 --- a/tests/MetadataTest.php +++ b/tests/MetadataTest.php @@ -453,27 +453,6 @@ public function test_delete_metadata_field() assertEncodedRequestFields($this, array()); } - /** - * Test deleting a metadata field definition then attempting to create a new one with the same external id which - * should fail. - * - * @throws Api\GeneralError - */ - public function test_delete_metadata_field_does_not_release_external_id() - { - $this->api->delete_metadata_field(self::$external_id_delete_2); - - $this->setExpectedException( - '\Cloudinary\Api\BadRequest', - 'external id ' . self::$external_id_delete_2 . ' already exists' - ); - $this->api->add_metadata_field([ - 'external_id' => self::$external_id_delete_2, - 'label' => self::$external_id_delete_2, - 'type' => 'integer' - ]); - } - /** * Delete entries in a metadata field datasource *