Skip to content

Commit

Permalink
Merge pull request #811 from abraham/v1-backport
Browse files Browse the repository at this point in the history
Backport updates
  • Loading branch information
abraham committed Nov 29, 2019
2 parents ed70c5d + 9938981 commit d54b71c
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 102 deletions.
27 changes: 16 additions & 11 deletions .travis.yml
@@ -1,17 +1,22 @@
language: php
dist: trusty
dist: bionic
php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- nightly
- hhvm
sudo: false
before_script:
- composer self-update
- composer install --prefer-source --no-interaction
script:
- vendor/bin/phpcs src tests --standard=PSR2
- tests/scripts/cacert.sh
- vendor/bin/phpunit
- composer self-update
- composer install --no-interaction
script: vendor/bin/phpunit
matrix:
allow_failures:
- php: nightly
include:
- name: Lint
script: vendor/bin/phpcs src tests --standard=PSR2
- name: cacert.pem current
script: tests/scripts/cacert.sh
cache:
directories:
- $HOME/.composer/cache/files
3 changes: 2 additions & 1 deletion README.md
@@ -1,4 +1,5 @@
<span itemprop="name">TwitterOAuth</span> [![Build Status](https://img.shields.io/travis/abraham/twitteroauth.svg)](https://travis-ci.org/abraham/twitteroauth) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/abraham/twitteroauth/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/abraham/twitteroauth/?branch=master) [![Issues Count](https://img.shields.io/github/issues/abraham/twitteroauth.svg)](https://github.com/abraham/twitteroauth/issues) [![Latest Version](https://img.shields.io/packagist/v/abraham/twitteroauth.svg)](https://packagist.org/packages/abraham/twitteroauth)
<span itemprop="name">TwitterOAuth</span> [![Build Status](https://img.shields.io/travis/abraham/twitteroauth.svg)](https://travis-ci.org/abraham/twitteroauth) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/abraham/twitteroauth/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/abraham/twitteroauth/?branch=master) [![Issues Count](https://img.shields.io/github/issues/abraham/twitteroauth.svg)](https://github.com/abraham/twitteroauth/issues) [![Latest Version](https://img.shields.io/packagist/v/abraham/twitteroauth.svg)](https://packagist.org/packages/abraham/twitteroauth) [![Downloads this Month](https://img.shields.io/packagist/dm/abraham/twitteroauth.svg)](https://packagist.org/packages/abraham/twitteroauth)

------------

<p itemprop="description">The most popular PHP library for Twitter's OAuth REST API.</p>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -18,7 +18,7 @@
"issues": "https://github.com/abraham/twitteroauth/issues"
},
"require": {
"php": "^5.6 || ^7.0 || ^7.1 || ^7.2",
"php": "^7.2 || ^7.3",
"ext-curl": "*"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/SignatureMethod.php
Expand Up @@ -58,7 +58,7 @@ public function checkSignature(Request $request, Consumer $consumer, Token $toke
// Avoid a timing leak with a (hopefully) time insensitive compare
$result = 0;
for ($i = 0; $i < strlen($signature); $i++) {
$result |= ord($built{$i}) ^ ord($signature{$i});
$result |= ord($built[$i]) ^ ord($signature[$i]);
}

return $result == 0;
Expand Down
18 changes: 8 additions & 10 deletions src/TwitterOAuth.php
Expand Up @@ -341,18 +341,13 @@ private function uploadMediaChunked($path, array $parameters)
*/
private function mediaInitParameters(array $parameters)
{
$return = [
$allowed_keys = ['media_type', 'additional_owners', 'media_category', 'shared'];
$base = [
'command' => 'INIT',
'media_type' => $parameters['media_type'],
'total_bytes' => filesize($parameters['media'])
];
if (isset($parameters['additional_owners'])) {
$return['additional_owners'] = $parameters['additional_owners'];
}
if (isset($parameters['media_category'])) {
$return['media_category'] = $parameters['media_category'];
}
return $return;
$allowed_parameters = array_intersect_key($parameters, array_flip($allowed_keys));
return array_merge($base, $allowed_parameters);
}

/**
Expand Down Expand Up @@ -548,7 +543,10 @@ private function request($url, $method, $authorization, array $postfields, $json

// Throw exceptions on cURL errors.
if (curl_errno($curlHandle) > 0) {
throw new TwitterOAuthException(curl_error($curlHandle), curl_errno($curlHandle));
$error = curl_error($curlHandle);
$errorNo = curl_errno($curlHandle);
curl_close($curlHandle);
throw new TwitterOAuthException($error, $errorNo);
}

$this->response->setHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
Expand Down

0 comments on commit d54b71c

Please sign in to comment.