I'm getting This PHP errors

Warning: file_get_contents(): Unable to access //netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js in drupal_build_js_cache() (line 4940 of /hosting/www/killua.me/public/includes/common.inc).

Warning: file_get_contents(//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js): failed to open stream: No such file or directory in drupal_build_js_cache() (line 4940 of /hosting/www/killua.me/public/includes/common.inc).

CommentFileSizeAuthor
#1 2031247-do-no-preprocess-js-css-cdn.patch2.19 KBwiifm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wiifm’s picture

Priority: Normal » Major
Status: Active » Needs review
FileSize
2.19 KB

Encountered the same issue with CSS and JS aggregation turned on. The problem lies in the fact that you should not aggregate resources hosted on CDN's.

Attached is a patch that forces the the preprocessing to FALSE.

Bumping to major as this has serious side effects for people wishing to use this theme in a production environment.

markhalliwell’s picture

Status: Needs review » Needs work
+++ b/includes/theme.inc
@@ -213,7 +213,7 @@ function bootstrap_item_list($variables) {
- 
+

This isn't in the scope of this issue.

+++ b/includes/theme.inc
@@ -342,27 +340,21 @@ function bootstrap_js_alter(&$js) {
+  // Add CDN.
+  if (theme_get_setting('cdn_bootstrap')) {
+    $cdn = '//netdna.bootstrapcdn.com/twitter-bootstrap/'. theme_get_setting('cdn_bootstrap_version')  .'/js/bootstrap.min.js';
+    $js[$cdn] = drupal_js_defaults();
+    $js[$cdn]['data'] = $cdn;
+    $js[$cdn]['type'] = 'external';
+    $js[$cdn]['every_page'] = TRUE;
+    $js[$cdn]['weight'] = -100;

Need to add 'preprocess' => FALSE here too.

+++ b/includes/theme.inc
@@ -342,27 +340,21 @@ function bootstrap_js_alter(&$js) {
-  
+

This isn't in the scope of this issue.

+++ b/includes/theme.inc
@@ -455,5 +447,5 @@ function bootstrap_preprocess_table(&$variables) {
-  
+

This isn't in the scope of this issue.

wiifm’s picture

Status: Needs work » Needs review

Hey @Mark Carver, my editor automatically strips trailing whitespace, I can re-roll a patch if you want or you can git add -p to commit only the parts of the patch you like after applying.

As for drupal_js_defaults() this indeed defaults to 'preprocess' => TRUE, but if you read drupal_add_js() it mentions if type is external "These files will not be aggregated if JavaScript aggregation is enabled".

This is a snippet from the head section of my site with this patch (and CSS and JS aggregation enabled):

<link type="text/css" rel="stylesheet" href="http://d7.local/sites/default/files/css/css_QlcoQUd7qxLb4Z7QV0aXLNWA5s3UHYPwdwSZgDMuCYw.css" media="all" />
<link type="text/css" rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://d7.local/sites/default/files/css/css_6MtKBDk9cc22fhT_PAe_nEcuptyrSVvZfoap5frJ36A.css" media="all" />
...
<script src="http://d7.local/sites/default/files/js/js_46jsQJlhy_nuSr1m4Au-mVGlkOMzn1eiC3culmdzChg.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="http://d7.local/sites/default/files/js/js_0YwP-JU25TjxsYCLiu8r0HAue6xHJ2t0awz9e7gD3uI.js"></script>

Potentially there could be a comment above the code to indicate that the external JS is not aggregated.

markhalliwell’s picture

Status: Needs review » Fixed

No, this is fine for now. I just forgot it does it that. This will all get refactored anyway once I backport some of the D8 improvements to the logic. Normally I don't like committing whitespace issues in the same patch is all, but I also hate when maintainers do what I just did, sorry lol

Fixed in commit: 020f5ed.

wiifm’s picture

Thanks for the attribution, and your hardwork with this theme.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Namero’s picture

Hello,

i am having the same error message, can i use the patch created by "wiifm" or it need the revisions by "Mark Carver"?