From 78ffe0fd087e3e2941c7d85b71f294985a8007ad Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 25 Jan 2016 18:34:52 +0000 Subject: [PATCH] Avoid checking CA files several times --- src/Composer/Util/RemoteFilesystem.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 699a279fb..81f18fa19 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -842,6 +842,12 @@ class RemoteFilesystem */ private function validateCaFile($filename) { + static $files = array(); + + if (isset($files[$filename])) { + return $files[$filename]; + } + if ($this->io->isDebug()) { $this->io->writeError('Checking CA file '.realpath($filename)); } @@ -854,10 +860,10 @@ class RemoteFilesystem || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50422) || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50506) ) { - return !empty($contents); + return $files[$filename] = !empty($contents); } - return (bool) openssl_x509_parse($contents); + return $files[$filename] = (bool) openssl_x509_parse($contents); } /**