X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fbrowser-kit%2FClient.php;h=c20395035803375e519b70da68950dc64f71d992;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=e6911d1b0707b5a182cbd25e47fa27dbd057a174;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/browser-kit/Client.php b/vendor/symfony/browser-kit/Client.php index e6911d1b0..c20395035 100644 --- a/vendor/symfony/browser-kit/Client.php +++ b/vendor/symfony/browser-kit/Client.php @@ -12,8 +12,8 @@ namespace Symfony\Component\BrowserKit; use Symfony\Component\DomCrawler\Crawler; -use Symfony\Component\DomCrawler\Link; use Symfony\Component\DomCrawler\Form; +use Symfony\Component\DomCrawler\Link; use Symfony\Component\Process\PhpProcess; /** @@ -42,11 +42,10 @@ abstract class Client private $maxRedirects = -1; private $redirectCount = 0; + private $redirects = array(); private $isMainRequest = true; /** - * Constructor. - * * @param array $server The server parameters (equivalent of $_SERVER) * @param History $history A History instance to store the browser history * @param CookieJar $cookieJar A CookieJar instance to store the cookies @@ -79,7 +78,7 @@ abstract class Client } /** - * Sets the maximum number of requests that crawler can follow. + * Sets the maximum number of redirects that crawler can follow. * * @param int $maxRedirects */ @@ -90,7 +89,7 @@ abstract class Client } /** - * Returns the maximum number of requests that crawler can follow. + * Returns the maximum number of redirects that crawler can follow. * * @return int */ @@ -234,8 +233,6 @@ abstract class Client /** * Clicks on a given link. * - * @param Link $link A Link instance - * * @return Crawler */ public function click(Link $link) @@ -328,6 +325,8 @@ abstract class Client } if ($this->followRedirects && $this->redirect) { + $this->redirects[serialize($this->history->current())] = true; + return $this->crawler = $this->followRedirect(); } @@ -345,9 +344,24 @@ abstract class Client */ protected function doRequestInProcess($request) { + $deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec'); + putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile); + $_ENV['SYMFONY_DEPRECATIONS_SERIALIZE'] = $deprecationsFile; $process = new PhpProcess($this->getScript($request), null, null); $process->run(); + if (file_exists($deprecationsFile)) { + $deprecations = file_get_contents($deprecationsFile); + unlink($deprecationsFile); + foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { + if ($deprecation[0]) { + @trigger_error($deprecation[1], E_USER_DEPRECATED); + } else { + @trigger_error($deprecation[1], E_USER_DEPRECATED); + } + } + } + if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) { throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput())); } @@ -430,7 +444,11 @@ abstract class Client */ public function back() { - return $this->requestFromRequest($this->history->back(), false); + do { + $request = $this->history->back(); + } while (array_key_exists(serialize($request), $this->redirects)); + + return $this->requestFromRequest($request, false); } /** @@ -440,7 +458,11 @@ abstract class Client */ public function forward() { - return $this->requestFromRequest($this->history->forward(), false); + do { + $request = $this->history->forward(); + } while (array_key_exists(serialize($request), $this->redirects)); + + return $this->requestFromRequest($request, false); } /** @@ -468,13 +490,14 @@ abstract class Client if (-1 !== $this->maxRedirects) { if ($this->redirectCount > $this->maxRedirects) { + $this->redirectCount = 0; throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects)); } } $request = $this->internalRequest; - if (in_array($this->internalResponse->getStatus(), array(302, 303))) { + if (\in_array($this->internalResponse->getStatus(), array(301, 302, 303))) { $method = 'GET'; $files = array(); $content = null;