From f4c4a4d57a5de60e88b79dfaab3531a2a5e7bf55 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 1 Apr 2017 15:17:26 +0200 Subject: [PATCH 1/2] Removed some unused variables --- src/Downloader.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Downloader.php b/src/Downloader.php index 7e6d19020..93bc40789 100644 --- a/src/Downloader.php +++ b/src/Downloader.php @@ -25,7 +25,6 @@ class Downloader { const ENDPOINT = 'https://flex.symfony.com'; - private $composer; private $io; private $sess; private $cache; @@ -35,13 +34,12 @@ class Downloader public function __construct(Composer $composer, IoInterface $io) { - $this->composer = $composer; $this->io = $io; - $config = $this->composer->getConfig(); + $config = $composer->getConfig(); $this->rfs = Factory::createRemoteFilesystem($io, $config); $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', self::ENDPOINT)); $this->sess = bin2hex(random_bytes(16)); - $extra = $this->composer->getPackage()->getExtra(); + $extra = $composer->getPackage()->getExtra(); if (isset($extra['flex-id']) && $extra['flex-id']) { $this->options['http'] = [ 'header' => ['Flex-ID: '.$extra['flex-id']], @@ -63,7 +61,7 @@ public function getContents($path) if ($contents = $this->cache->read($cacheKey)) { $contents = json_decode($contents, true); if (isset($contents['last-modified'])) { - $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']); + $response = $this->fetchFileIfLastModified($url, $contents['last-modified']); return true === $response ? $contents : $response; } @@ -105,7 +103,7 @@ private function fetchFile($filename, $cacheKey) return $data; } - private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime) + private function fetchFileIfLastModified($filename, $lastModifiedTime) { $options = $this->options; $retries = 3; From c51456df7712b17102d4a0a6a2de90bf717d579a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 1 Apr 2017 16:25:06 +0200 Subject: [PATCH 2/2] Reverted a variable removal (because the error was caused by a different reason) --- src/Downloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Downloader.php b/src/Downloader.php index 93bc40789..489e1a9ea 100644 --- a/src/Downloader.php +++ b/src/Downloader.php @@ -61,7 +61,7 @@ public function getContents($path) if ($contents = $this->cache->read($cacheKey)) { $contents = json_decode($contents, true); if (isset($contents['last-modified'])) { - $response = $this->fetchFileIfLastModified($url, $contents['last-modified']); + $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']); return true === $response ? $contents : $response; } @@ -103,7 +103,7 @@ private function fetchFile($filename, $cacheKey) return $data; } - private function fetchFileIfLastModified($filename, $lastModifiedTime) + private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime) { $options = $this->options; $retries = 3;