Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix closure-compiler's error "redirection limit reached" #618

Closed
wants to merge 2 commits into from

Conversation

ToX82
Copy link
Contributor

@ToX82 ToX82 commented Nov 3, 2017

Since a few days, the js minification was complaining about a redirection limit in the closure-compiler call. This was generating an error each time I have tried to use this tool.

After a bit of investigation I have found out that it was missing some parameters that are now mandatory. Plus, it now works in https only.

ToX82 added 2 commits November 3, 2017 10:24
Since a few days, the js minification was complaining about a redirection limit in the closure-compiler call. This was generating an error each time I have tried to use this tool.

After a bit of investigation I have found out that it was missing some parameters that are now mandatory. Plus, it now works in https only.
Fix closure-compiler's "redirection limit reached"
@ToX82
Copy link
Contributor Author

ToX82 commented Nov 3, 2017

After a little more digging into the code I have found that setting a few more parameters in my call could solve the same problem:

    $content = \Minify_JS_ClosureCompiler::minify($content, [
        'compilerUrl' => 'https://closure-compiler.appspot.com/compile',
        'compilation_level' => 'SIMPLE',
        'output_format' => 'text',
        'output_info' => 'compiled_code',
    ]);

Still, I think that setting the default url to https would be useful, since http seems to be deprecated. Also, having those parameters set as default in ClosureCompiler.php would make the code more straightforward for other users in my situation.

@glensc
Copy link
Collaborator

glensc commented Nov 3, 2017

you should never create pull-request from your master branch. as anything you add to your master branch will be included to the pull-request.

however. i can cherry-pick your first commit

@glensc
Copy link
Collaborator

glensc commented Nov 3, 2017

but forcing https on environments that lack https support (openssl module, required ssl certs), can create more damage than keeping http:// protocol. so such change not okay for minor patch version.

as you're stating http:// still works. i'd keep it in.

@glensc
Copy link
Collaborator

glensc commented Nov 3, 2017

ran test locally. http:// url always redirects regardless of the passed parameters.

[~/scm/minify (pr-618)★] ➔ git diff
diff --git a/lib/Minify/JS/ClosureCompiler.php b/lib/Minify/JS/ClosureCompiler.php
index b842622..d87aa61 100644
--- a/lib/Minify/JS/ClosureCompiler.php
+++ b/lib/Minify/JS/ClosureCompiler.php
@@ -54,7 +54,7 @@ class Minify_JS_ClosureCompiler
     /**
      * @var string $url URL of compiler server. defaults to Google's
      */
-    protected $serviceUrl = 'https://closure-compiler.appspot.com/compile';
+    protected $serviceUrl = 'http://closure-compiler.appspot.com/compile';

     /**
      * @var int $maxBytes The maximum JS size that can be sent to the compiler server in bytes

[~/scm/minify (pr-618)★] ➔ phpunit tests/JsClosureCompilerTest.php
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

EE.E.EE

Time: 1.5 seconds, Memory: 7.25MB

There were 5 errors:

1) JsClosureCompilerTest::test1
file_get_contents(http://closure-compiler.appspot.com/compile): failed to open stream: Redirection limit reached, aborting

/home/glen/scm/minify/lib/Minify/JS/ClosureCompiler.php:185
/home/glen/scm/minify/lib/Minify/JS/ClosureCompiler.php:141
/home/glen/scm/minify/lib/Minify/JS/ClosureCompiler.php:86
/home/glen/scm/minify/tests/JsClosureCompilerTest.php:116
/home/glen/scm/minify/tests/JsClosureCompilerTest.php:17

@glensc glensc closed this in 9ed7f9d Nov 3, 2017
glensc added a commit that referenced this pull request Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants