Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ jobs:
include:
- { wp: 46, php: 56 }
- { wp: 46, php: 70 }
- { wp: 57, php: 73 }
- { wp: 60, php: 74 }
- { wp: 63, php: 80 }
- { wp: 67, php: 82 }
- { wp: 69, php: 83 }
- { wp: 70, php: 84 }
- { wp: 71, php: 85 }
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
6 changes: 2 additions & 4 deletions config/wp-version.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
46_70=wordpress:4.6-php7.0-apache
57_73=wordpress:5.7-php7.3-apache
60_74=wordpress:6.0-php7.4-apache
63_80=wordpress:6.3-php8.0-apache
67_82=wordpress:6.7-php8.2-apache
69_83=wordpress:6.9-php8.3-apache
70_84=wordpress:beta-7.0-RC2-php8.4-apache
70_84=wordpress:7.0-php8.4-apache
71_85=wordpress:beta-7.1-php8.5-apache
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: TinyPNG
Donate link: https://tinypng.com/
Tags: compress images, compression, image size, page speed, performance
Requires at least: 4.0
Tested up to: 7.0
Tested up to: 7.1
Stable tag: 3.7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down
8 changes: 7 additions & 1 deletion src/class-tiny-compress-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ private function set_request_options( $client ) {
The client does not let us override cURL properties yet, so we have
to use a reflection property. */
$property = new ReflectionProperty( $client, 'options' );
$property->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
/**
* No effect since PHP 8.1 and deprecated since PHP 8.5
* https://www.php.net/manual/en/reflectionproperty.setaccessible.php
*/
$property->setAccessible( true );
}
$options = $property->getValue( $client );

// Set API request timeout to prevent indefinite hanging
Expand Down
20 changes: 18 additions & 2 deletions test/fixtures/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function request( $method, $url, $body = null, $header = array() ) {
if ( is_string( $response ) ) {
$status = curl_getinfo( $request, CURLINFO_HTTP_CODE );
$headerSize = curl_getinfo( $request, CURLINFO_HEADER_SIZE );
curl_close( $request );
self::closeRequest( $request );
Comment thread
coderabbitai[bot] marked this conversation as resolved.

$headers = self::parseHeaders( substr( $response, 0, $headerSize ) );
$body = substr( $response, $headerSize );
Expand Down Expand Up @@ -107,11 +107,27 @@ function request( $method, $url, $body = null, $header = array() ) {
);
} else {
$message = sprintf( '%s (#%d)', curl_error( $request ), curl_errno( $request ) );
curl_close( $request );
self::closeRequest( $request );
throw new ConnectionException( 'Error while connecting: ' . $message );
}// End if().
}

/**
* curl_close() is deprecated in >8.5, does nothing in >8.0
*
* @param \Tinify\CurlMock $request
*/
protected static function closeRequest( $request ) {
if ( PHP_VERSION_ID < 80000 ) {
curl_close( $request );
} elseif (
is_object($request) &&
method_exists($request, 'close')
) {
$request->close();
}
}

protected static function parseHeaders( $headers ) {
if ( ! is_array( $headers ) ) {
$headers = explode( "\r\n", $headers );
Expand Down
Loading