Commit c8a5c8e3 authored by webchick's avatar webchick

Issue #2052923 by Berdir: Update Guzzle to latest version.

parent edcc7560
......@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "99355ea2b3166a2c7d7029c8ddc76f4e",
"hash": "eb2c59507a34a3831afe33b16c4d5775",
"packages": [
{
"name": "doctrine/annotations",
......@@ -449,17 +449,17 @@
},
{
"name": "guzzle/common",
"version": "v3.1.2",
"version": "v3.7.1",
"target-dir": "Guzzle/Common",
"source": {
"type": "git",
"url": "git://github.com/guzzle/common.git",
"reference": "v3.1.2"
"url": "https://github.com/guzzle/common.git",
"reference": "v3.7.1"
},
"dist": {
"type": "zip",
"url": "https://github.com/guzzle/common/archive/v3.1.2.zip",
"reference": "v3.1.2",
"url": "https://api.github.com/repos/guzzle/common/zipball/v3.7.1",
"reference": "v3.7.1",
"shasum": ""
},
"require": {
......@@ -469,7 +469,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.7-dev"
}
},
"autoload": {
......@@ -489,21 +489,21 @@
"event",
"exception"
],
"time": "2013-01-28 00:07:40"
"time": "2013-07-05 20:17:54"
},
{
"name": "guzzle/http",
"version": "v3.1.2",
"version": "v3.7.1",
"target-dir": "Guzzle/Http",
"source": {
"type": "git",
"url": "git://github.com/guzzle/http.git",
"reference": "v3.1.2"
"url": "https://github.com/guzzle/http.git",
"reference": "v3.7.1"
},
"dist": {
"type": "zip",
"url": "https://github.com/guzzle/http/archive/v3.1.2.zip",
"reference": "v3.1.2",
"url": "https://api.github.com/repos/guzzle/http/zipball/v3.7.1",
"reference": "v3.7.1",
"shasum": ""
},
"require": {
......@@ -518,7 +518,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.7-dev"
}
},
"autoload": {
......@@ -546,21 +546,21 @@
"http",
"http client"
],
"time": "2013-01-26 08:20:43"
"time": "2013-07-02 19:53:26"
},
{
"name": "guzzle/parser",
"version": "v3.1.2",
"version": "v3.7.1",
"target-dir": "Guzzle/Parser",
"source": {
"type": "git",
"url": "git://github.com/guzzle/parser.git",
"reference": "v3.1.2"
"url": "https://github.com/guzzle/parser.git",
"reference": "v3.7.1"
},
"dist": {
"type": "zip",
"url": "https://github.com/guzzle/parser/archive/v3.1.2.zip",
"reference": "v3.1.2",
"url": "https://api.github.com/repos/guzzle/parser/zipball/v3.7.1",
"reference": "v3.7.1",
"shasum": ""
},
"require": {
......@@ -569,7 +569,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.7-dev"
}
},
"autoload": {
......@@ -590,31 +590,34 @@
"message",
"url"
],
"time": "2013-01-12 21:43:21"
"time": "2013-06-11 00:24:07"
},
{
"name": "guzzle/stream",
"version": "v3.1.2",
"version": "v3.7.1",
"target-dir": "Guzzle/Stream",
"source": {
"type": "git",
"url": "https://github.com/guzzle/stream",
"reference": "v3.0.7"
"url": "https://github.com/guzzle/stream.git",
"reference": "v3.7.1"
},
"dist": {
"type": "zip",
"url": "https://github.com/guzzle/stream/archive/v3.0.7.zip",
"reference": "v3.0.7",
"url": "https://api.github.com/repos/guzzle/stream/zipball/v3.7.1",
"reference": "v3.7.1",
"shasum": ""
},
"require": {
"guzzle/common": "self.version",
"php": ">=5.3.2"
},
"suggest": {
"guzzle/http": "To convert Guzzle request objects to PHP streams"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.7-dev"
}
},
"autoload": {
......@@ -640,7 +643,7 @@
"component",
"stream"
],
"time": "2012-12-07 16:45:11"
"time": "2013-06-27 00:50:43"
},
{
"name": "kriswallsmith/assetic",
......
......@@ -45,16 +45,22 @@ public function fetch(Feed $feed) {
try {
$response = $request->send();
// In case of a 304 Not Modified, there is no new content, so return
// FALSE.
if ($response->getStatusCode() == 304) {
return FALSE;
}
$feed->source_string = $response->getBody(TRUE);
$feed->etag = $response->getEtag();
$feed->modified = strtotime($response->getLastModified());
$feed->http_headers = $response->getHeaders();
// Update the feed URL in case of a 301 redirect.
if ($previous_response = $response->getPreviousResponse()) {
if ($previous_response->getStatusCode() == 301 && $location = $previous_response->getLocation()) {
$feed->url->value = $location;
}
if ($response->getEffectiveUrl() != $feed->url->value) {
$feed->url->value = $response->getEffectiveUrl();
}
return TRUE;
}
......
......@@ -236,11 +236,9 @@ function locale_translation_http_check($uri) {
->send();
$result = array();
// In case of a permanent redirected response, return the final location.
if ($previous = $response->getPreviousResponse()) {
if ($previous->getStatusCode() == 301) {
$result['location'] = $previous->getLocation();
}
// Return the effective URL if it differs from the requested.
if ($response->getEffectiveUrl() != $uri) {
$result['location'] = $response->getEffectiveUrl();
}
$result['last_modified'] = $response->getLastModified() ? strtotime($response->getLastModified()) : 0;
......
......@@ -83,20 +83,19 @@ function testStatisticsSettings() {
$this->drupalGet('node/' . $this->test_node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->test_node->id();
$post = http_build_query(array('nid' => $nid));
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
// Hit the node again (the counter is incremented after the hit, so
// "1 view" will actually be shown when the node is hit the second time).
$this->drupalGet('node/' . $this->test_node->id());
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$this->assertText('1 view', 'Node is viewed once.');
$this->drupalGet('node/' . $this->test_node->id());
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$this->assertText('2 views', 'Node is viewed 2 times.');
}
......@@ -109,11 +108,10 @@ function testDeleteNode() {
$this->drupalGet('node/' . $this->test_node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->test_node->id();
$post = http_build_query(array('nid' => $nid));
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$result = db_select('node_counter', 'n')
->fields('n', array('nid'))
......@@ -144,13 +142,12 @@ function testExpiredLogs() {
$this->drupalGet('node/' . $this->test_node->id());
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->test_node->id();
$post = http_build_query(array('nid' => $nid));
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$this->drupalGet('node/' . $this->test_node->id());
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$this->assertText('1 view', 'Node is viewed once.');
// statistics_cron() will subtract
......
......@@ -85,11 +85,10 @@ function testLogging() {
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
$nid = $this->node->id();
$post = http_build_query(array('nid' => $nid));
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Testing an uncached page.');
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '1');
......@@ -97,7 +96,7 @@ function testLogging() {
// Verify logging of a cached page.
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Testing a cached page.');
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '2');
......@@ -106,7 +105,7 @@ function testLogging() {
$this->drupalLogin($this->auth_user);
$this->drupalGet($path);
// Manually calling statistics.php, simulating ajax behavior.
$this->client->post($stats_path, $headers, $post)->send();
$this->client->post($stats_path, array(), $post)->send();
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '3');
......
......@@ -80,12 +80,11 @@ public function testNodeCounterIntegration() {
$this->drupalGet('node/' . $this->node->id());
// Manually calling statistics.php, simulating ajax behavior.
// @see \Drupal\statistics\Tests\StatisticsLoggingTest::testLogging().
$post = http_build_query(array('nid' => $this->node->id()));
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$client = \Drupal::httpClient();
$client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10)));
$client->post($stats_path, array(), $post)->send();
$client->post($stats_path, array(), array('nid' => $this->node->id()))->send();
$this->drupalGet('test_statistics_integration');
$expected = statistics_get($this->node->id());
......
......@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitae9396db2008f9b266cde1fb85dfa4f8::getLoader();
return ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8::getLoader();
......@@ -2,7 +2,7 @@
// autoload_real.php generated by Composer
class ComposerAutoloaderInitae9396db2008f9b266cde1fb85dfa4f8
class ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8
{
private static $loader;
......@@ -19,9 +19,9 @@ public static function getLoader()
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitae9396db2008f9b266cde1fb85dfa4f8', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitae9396db2008f9b266cde1fb85dfa4f8', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
......
This diff is collapsed.
......@@ -11,22 +11,14 @@
*/
class AbstractHasDispatcher implements HasDispatcherInterface
{
/**
* @var EventDispatcherInterface
*/
/** @var EventDispatcherInterface */
protected $eventDispatcher;
/**
* {@inheritdoc}
*/
public static function getAllEvents()
{
return array();
}
/**
* {@inheritdoc}
*/
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
......@@ -34,9 +26,6 @@ public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
return $this;
}
/**
* {@inheritdoc}
*/
public function getEventDispatcher()
{
if (!$this->eventDispatcher) {
......@@ -46,17 +35,11 @@ public function getEventDispatcher()
return $this->eventDispatcher;
}
/**
* {@inheritdoc}
*/
public function dispatch($eventName, array $context = array())
{
$this->getEventDispatcher()->dispatch($eventName, new Event($context));
}
/**
* {@inheritdoc}
*/
public function addSubscriber(EventSubscriberInterface $subscriber)
{
$this->getEventDispatcher()->addSubscriber($subscriber);
......
......@@ -7,16 +7,12 @@
/**
* Default event for Guzzle notifications
*/
class Event extends SymfonyEvent implements \ArrayAccess, \IteratorAggregate
class Event extends SymfonyEvent implements ToArrayInterface, \ArrayAccess, \IteratorAggregate
{
/**
* @var array
*/
/** @var array */
private $context;
/**
* Constructor
*
* @param array $context Contextual information
*/
public function __construct(array $context = array())
......@@ -24,43 +20,33 @@ public function __construct(array $context = array())
$this->context = $context;
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
return new \ArrayIterator($this->context);
}
/**
* {@inheritdoc}
*/
public function offsetGet($offset)
{
return array_key_exists($offset, $this->context) ? $this->context[$offset] : null;
return isset($this->context[$offset]) ? $this->context[$offset] : null;
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{
$this->context[$offset] = $value;
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return array_key_exists($offset, $this->context);
return isset($this->context[$offset]);
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
{
unset($this->context[$offset]);
}
public function toArray()
{
return $this->context;
}
}
......@@ -7,9 +7,7 @@
*/
class ExceptionCollection extends \Exception implements GuzzleException, \IteratorAggregate, \Countable
{
/**
* @var array Array of Exceptions
*/
/** @var array Array of Exceptions */
protected $exceptions = array();
/**
......@@ -21,7 +19,10 @@ class ExceptionCollection extends \Exception implements GuzzleException, \Iterat
*/
public function setExceptions(array $exceptions)
{
$this->exceptions = $exceptions;
$this->exceptions = array();
foreach ($exceptions as $exception) {
$this->add($exception);
}
return $this;
}
......@@ -35,18 +36,20 @@ public function setExceptions(array $exceptions)
*/
public function add($e)
{
if ($this->message) {
$this->message .= "\n";
}
if ($e instanceof self) {
foreach ($e as $exception) {
$this->exceptions[] = $exception;
$this->message .= '(' . get_class($e) . ")";
foreach (explode("\n", $e->getMessage()) as $message) {
$this->message .= "\n {$message}";
}
} elseif ($e instanceof \Exception) {
$this->exceptions[] = $e;
$this->message .= '(' . get_class($e) . ') ' . $e->getMessage();
}
$this->message = implode("\n", array_map(function($e) {
return $e->getMessage();
}, $this->exceptions));
return $this;
}
......
......@@ -22,7 +22,7 @@ public static function getAllEvents();
*
* @param EventDispatcherInterface $eventDispatcher
*
* @return HasDispatcherInterface
* @return self
*/
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher);
......@@ -46,7 +46,7 @@ public function dispatch($eventName, array $context = array());
*
* @param EventSubscriberInterface $subscriber Event subscriber
*
* @return AbstractHasDispatcher
* @return self
*/
public function addSubscriber(EventSubscriberInterface $subscriber);
}
......@@ -7,5 +7,23 @@
*/
class Version
{
const VERSION = '3.1.2';
const VERSION = '3.7.1';
/**
* @var bool Set this value to true to enable warnings for deprecated functionality use. This should be on in your
* unit tests, but probably not in production.
*/
public static $emitWarnings = false;
/**
* Emit a deprecation warning
*
* @param string $message Warning message
*/
public static function warn($message)
{
if (self::$emitWarnings) {
trigger_error('Deprecation warning: ' . $message, E_USER_DEPRECATED);
}
}
}
......@@ -14,7 +14,7 @@
"target-dir": "Guzzle/Common",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.7-dev"
}
}
}
......@@ -9,14 +9,10 @@
*/
class AbstractEntityBodyDecorator implements EntityBodyInterface
{
/**
* @var EntityBodyInterface Decorated entity body
*/
/** @var EntityBodyInterface Decorated entity body */
protected $body;
/**
* Wrap a entity body
*
* @param EntityBodyInterface $body Entity body to decorate
*/
public function __construct(EntityBodyInterface $body)
......@@ -24,9 +20,6 @@ public function __construct(EntityBodyInterface $body)
$this->body = $body;
}
/**
* {@inheritdoc}
*/
public function __toString()
{
return (string) $this->body;
......@@ -39,68 +32,49 @@ public function __toString()
* @param array $args Method arguments
*
* @return mixed
* @codeCoverageIgnore
*/
public function __call($method, array $args = null)
public function __call($method, array $args)
{
return call_user_func_array(array($this->body, $method), $args);
}
/**
* {@inheritdoc}
* @codeCoverageIgnore
*/
public function close()
{
return $this->body->close();
}
public function setRewindFunction($callable)
{
return $this->body->setRewindFunction($callable);
$this->body->setRewindFunction($callable);
return $this;
}
/**
* {@inheritdoc}
* @codeCoverageIgnore
*/
public function rewind()
{
return $this->body->rewind();
}
/**
* {@inheritdoc}
* @codeCoverageIgnore
*/
public function compress($filter = 'zlib.deflate')
{
return $this->body->compress($filter);
}
/**
* {@inheritdoc}
* @codeCoverageIgnore
*/
public function uncompress($filter = 'zlib.inflate')
{
return $this->body->uncompress($filter);
}
/**
* {@inheritdoc}
*/
public function getContentLength()
{
return $this->body->getContentLength();
return $this->getSize();
}
/**
* {@inheritdoc}
*/
public function getContentType()
{
return $this->body->getContentType();
}
/**
* {@inheritdoc}
*/
public function getContentMd5($rawOutput = false, $base64Encode = false)
{
$hash = Stream::getHash($this, 'md5', $rawOutput);
......@@ -108,162 +82,140 @@ public function getContentMd5($rawOutput = false, $base64Encode = false)
return $hash && $base64Encode ? base64_encode($hash) : $hash;
}
/**
* {@inheritdoc}
*/
public function getContentEncoding()
{
return $this->body->getContentEncoding();
}
/**
* {@inheritdoc}