From cbcba7774c0cc0a7679105193efc93019eac1598 Mon Sep 17 00:00:00 2001 From: Daniel LaBarge Date: Thu, 19 Dec 2013 17:30:08 -0600 Subject: [PATCH 1/3] Added configuration option for follow_location. --- src/config/config.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/config/config.php b/src/config/config.php index c8b8373..888c134 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -91,6 +91,24 @@ 'build_path' => 'builds', + /* + |-------------------------------------------------------------------------- + | Open Base Dir Restrictions + |-------------------------------------------------------------------------- + | + | Some hosts run with open base directory restrictions which prevents certain + | PHP functions from working. Basset relies on Curl's CURLOPT_FOLLOWLOCATION + | to follow location headers when assets don't have recognizable extensions. + | This configuration option lets the developer disable the code that implements + | this known restriction. + | + | Note: that disabling this option could cause redirects on remote assets to + | not be loaded correctly. + | + */ + + 'follow_location' => true, + /* |-------------------------------------------------------------------------- | Debug From b75db65a8c0aa14bc990488094d1a28cec5a087e Mon Sep 17 00:00:00 2001 From: Daniel LaBarge Date: Thu, 19 Dec 2013 17:39:17 -0600 Subject: [PATCH 2/3] Modified detectGroupFromContentType() to use follow_location configuration switch. --- src/Basset/Asset.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Basset/Asset.php b/src/Basset/Asset.php index 18a21d2..e57764b 100644 --- a/src/Basset/Asset.php +++ b/src/Basset/Asset.php @@ -6,6 +6,7 @@ use Basset\Factory\FactoryManager; use Assetic\Filter\FilterInterface; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Facades\Config; class Asset extends Filterable { @@ -296,9 +297,11 @@ protected function detectGroupFromContentType() $this->getLogger()->warning('Attempting to determine asset group using cURL. This may have a considerable effect on application speed.'); $handler = curl_init($this->absolutePath); - + + $follow_location = Config::get('basset::follow_location', true); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); - curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($handler, CURLOPT_FOLLOWLOCATION, $follow_location); curl_setopt($handler, CURLOPT_HEADER, true); curl_setopt($handler, CURLOPT_NOBODY, true); curl_setopt($handler, CURLOPT_SSL_VERIFYPEER, false); @@ -415,4 +418,4 @@ public function prepareFilters($production = false) return $filters->filter(function($filter) { return $filter instanceof FilterInterface; }); } -} \ No newline at end of file +} From 85ba09935f16fc7ebfae9a3f37fa90b49b7f9392 Mon Sep 17 00:00:00 2001 From: Daniel LaBarge Date: Mon, 20 Jan 2014 14:33:44 -0600 Subject: [PATCH 3/3] Fix deprecated FileSystem@getRemote() --- src/Basset/Asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Basset/Asset.php b/src/Basset/Asset.php index e57764b..78a4bb6 100644 --- a/src/Basset/Asset.php +++ b/src/Basset/Asset.php @@ -382,7 +382,7 @@ public function isRaw() */ public function getContent() { - return $this->files->getRemote($this->absolutePath); + return file_get_contents($this->absolutePath); } /**