I duplicated my entire site to a different domain name as a testing environment, so I used the readme and went by it line by line.

1. Here's what I did to patch drupal core - I'm very new to patching so I'm not sure if the output is as intended?:

[root@server xx]# patch -p0 < drupal6.patch
(Stripping trailing CRs from patch.)
patching file includes/common.inc
(Stripping trailing CRs from patch.)
patching file includes/file.inc
(Stripping trailing CRs from patch.)
patching file includes/form.inc
(Stripping trailing CRs from patch.)
patching file includes/theme.inc
(Stripping trailing CRs from patch.)
patching file themes/garland/template.php

2. And then I applied the imagecache patch:

[root@server imagecache]# patch < imagecache.patch
(Stripping trailing CRs from patch.)
patching file imagecache.module

3. Then I placed the cdn folder into /sites/all/modules

4. I enabled the module.

5. I navigated to admin/settings/cdn, and this is where my problem begins. A huge chunk of error appeared at that page:


    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/form.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/form.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/themes/garland/template.php ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/themes/garland/template.php ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/themes/garland/template.php ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/themes/garland/template.php ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/sites/all/modules/imagecache/imagecache.module ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 72.
    * warning: file_get_contents(/var/www/html/saigoheiki.com/hs/sites/all/modules/imagecache/imagecache.module ) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/saigoheiki.com/hs/sites/all/modules/cdn/cdn.requirements.inc on line 77.
    * Please fix the following problems with the installation of the CDN integration module:
          o CDN integration — Drupal core patch
            This patch has not been properly applied to the following files (or the patch has been updated):
                + /var/www/html/saigoheiki.com/hs/includes/common.inc
                + /var/www/html/saigoheiki.com/hs/includes/file.inc
                + /var/www/html/saigoheiki.com/hs/includes/form.inc
                + /var/www/html/saigoheiki.com/hs/includes/theme.inc
                + /var/www/html/saigoheiki.com/hs/themes/garland/template.php

            Please consult the installation instructions in the included README.txt.
          o CDN integration — ImageCache module patch
            This patch has not been properly applied to the following files (or the patch has been updated):
                + /var/www/html/saigoheiki.com/hs/sites/all/modules/imagecache/imagecache.module

            Please consult the installation instructions in the included README.txt.

I am puzzled as to what went wrong. The "no such file or directory" error doesn't make sense because they do exist! Even puzzling is the part that states that I have not patched both drupal core and the imagecache module.

Any ideas as to where I went wrong?

CommentFileSizeAuthor
#10 895118-10.patch773 bytesWim Leers
#7 cdn_trim_fullpath.patch972 bytesAs If
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Status: Active » Postponed (maintainer needs more info)

That doesn't make any sense! Maybe you've set strange permissions? In any case, I can't reproduce this on my computer.

Quarantine’s picture

Assigned: Wim Leers » Unassigned
Status: Postponed (maintainer needs more info) » Active

I know, this is all too strange! Can you confirm from my output of the two patches that the patch should have been applied correctly? I'm new to patching, and since it didn't say "patch is complete" or something along those lines, I'm not sure if the patches have been applied or not.

I'm a little nervous to try this on my live site, but I think I may give this a go on it. The patches can be reversed right?

Wim Leers’s picture

Assigned: Unassigned » Wim Leers

The patch is indeed applied successfully.

You can revert patches like this: "patch -p0 -R < blah.patch".

Can you go to http://dev/d6/admin/reports/status and tell me the output? It should fail similarly though. But fact is, there it is checked if the patches have been applied correctly. Oh, the irony!

Quarantine’s picture

Assigned: Wim Leers » Unassigned

Indeed, a whole bunch of "failed to open stream" errors similar to the one I first posted appeared, and under CDN integration, it states "Not/incompletely applied patch or updated patch."

I'll try and install CDN on my live site later and I'll tell you how it goes! *crosses fingers

Wim Leers’s picture

I would not recommend that …

Just create a fresh Drupal installation and see if you can reproduce it there. If you can, there must be a bug that I'm just not able to reproduce it. If you can't, it's something with your site.

Quarantine’s picture

Status: Active » Closed (fixed)

My partner managed to fix the "failed to open stream" errors somehow. He patched the files first on his Windows before reuploading the patched files onto our server. That seems to fix it for some odd reason.

As If’s picture

Status: Closed (fixed) » Needs review
FileSize
972 bytes

I was getting the same errors, and I'm really surprised many others haven't reported this. If you look carefully at the error messages you will see that there is a blank space after the argument in file_get_contents(). The attached patch removes that trailing space by trimming the $full_path prior to checking it.

Wim Leers’s picture

Status: Needs review » Postponed (maintainer needs more info)

Then please fix the cause, and not the symptom. Where did those spaces get added then? I don't see them. (Look at the "_cdn_requirements_*_patch_patterns" functions.)

As If’s picture

>> Where did those spaces get added then?

Good question, and I don't know the answer. Don't hold your breath waiting for me to figure it out ;-) My symptomatic patch does the trick for me.

But I can tell you this:
1. The installation patches applied fine (or at least they didn't report any errors).
2. The error occurs with the $kind == "core" files (common.inc, file.inc, theme.inc and garland/template.php)
3. I'm on a Linux server (so this isn't a Windows problem)

Wim Leers’s picture

Title: CDN module installation problem - "failed to open stream" errors » CDN module installation problem — "failed to open stream" errors (occurs in very rare cases)
Version: 6.x-2.0-beta4 » 6.x-2.0
Assigned: Unassigned » Wim Leers
Category: support » bug
Priority: Normal » Minor
Status: Postponed (maintainer needs more info) » Needs review
FileSize
773 bytes

Well, you're only the second person to report this problem. When I do a
dvm($full_path);
call from within _cdn_requirements_check_patch_applied(), I don't see any spaces at the end of $full_path.

However, I've changed the code a little bit where this problem *should* be being introduced on your system. This change is acceptable for me. Please let me know if this fixes it for you! :)

stellrex’s picture

I'm also experiencing this issue as described above. My log gets flooded with errors similar to the following:

file_get_contents(/home/rme/public_html/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in /home/rme/public_html/sites/all/modules/cdn/cdn.requirements.inc on line 74.

The exact same install works perfectly fine on a shared hosting account that I have, but spits out the errors when on a dedicated server. Any insight to what could be causing this?

I tried the patch, but it did not resolve this issue for me.

stellrex’s picture

Nevermind, I believe I have solved the issue I was experiencing by redoing my folder permissions. I found that apache no longer had access to some folders on my dedicated server

Wim Leers’s picture

So it wasn't a bug after all?

Leks’s picture

Status: Closed (won't fix) » Needs review

# warning: file_get_contents(xxx/includes/common.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in xxx/sites/all/modules/cdn/cdn.requirements.inc on line xx.
# warning: file_get_contents(xxx/includes/file.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in xxx/sites/all/modules/cdn/cdn.requirements.inc on line xx.
# warning: file_get_contents(xxx/includes/form.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in xxx/sites/all/modules/cdn/cdn.requirements.inc on line xx.
# warning: file_get_contents(xxx/includes/theme.inc ) [function.file-get-contents]: failed to open stream: No such file or directory in xxx/sites/all/modules/cdn/cdn.requirements.inc on line xx.
# warning: file_get_contents(xxx/themes/garland/template.php ) [function.file-get-contents]: failed to open stream: No such file or directory in xxx/sites/all/modules/cdn/cdn.requirements.inc on line xx.

CDN — Drupal core patch (for complete CDN coverage) Not/incompletely applied patch or updated patch.
This patch has not been properly applied to the following files (or the patch has been updated):

* xxx/includes/common.inc
* xxx/includes/file.inc
* xxx/includes/form.inc
* xxx/includes/theme.inc
* xxx/themes/garland/template.php

in function _cdn_requirements_check_patch_applied in file xxx/sites/all/modules/cdn/cdn.requirements.inc

function _cdn_requirements_check_patch_applied($patterns) {
  $drupal_root = realpath('.');
  $patched = TRUE;
  $unpatched_files = array();
  foreach ($patterns as $kind => $details) {
    foreach ($details as $file_info => $patterns) {
      foreach ($patterns as $pattern) {
        if ($kind == 'core') {
          $filename = $file_info;
          $full_path = $drupal_root . '/' . $filename;
        }
        else {
          list($name, $filename) = explode('|', $file_info);
          $full_path = $drupal_root . '/' . drupal_get_path($kind, $name) . '/' . $filename;
        }

        if ($full_path) {
			/* fixing */
			/*
			 * replacing $full_path on trimed filename
			 */
			$trimed_full_path = trim($full_path);
			/*-------------------------------*/
/*fix replacing $full_path on trimed filename*/
          $match = preg_match('|' . preg_quote($pattern) . '|m', file_get_contents($trimed_full_path));
          // If it didn't match, try allowing \r\n line endings and see if it
          // it then matches. This is of course also qualifies as a correctly
          // applied patch.
          if (!$match) {
/*fix replacing $full_path on trimed filename*/
            $match = preg_match('|' . preg_quote($pattern) . '|m', str_replace("\n", "\r\n", file_get_contents($trimed_full_path)));
          }
          $patched = $patched && $match;

          // Remember unpatched files.
          if (!$match && !in_array($full_path, $unpatched_files)) {
            $unpatched_files[] = $full_path;
          }
        }
      }
    }
  }
  return $unpatched_files;
}

It works for me.

Wim Leers’s picture

Can you please format that properly? It's too opaque to be understandable. Thanks!

Wim Leers’s picture

Status: Needs review » Needs work
Wim Leers’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of response.

Status: Needs review » Closed (won't fix)