Attached is an exact copy of http://ftp.drupal.org/files/projects/zen-7.x-3.x-dev.zip that has been extracted and re-zipped up using the built in windows "send to Compressed (zipped) folder" functionality. When it's uploaded to drupal it the theme uploader reports "zen.zip does not contain any .info files." and it is rejected.

If the same files are zipped using winrar, they work fine. Normally I would just use winrar, but this is going to frustrate many theme designers and I'm building a theme generator at http://cooltemplate.com and the library that I'm using to create zips also has the problem.

I suspected that there was a problem with the path separators being different but I changed my code to produce forward slashes instead of backslashes and it didn't fix the problem. Now I suspect that it may have something to do with the various compression methods that are supported by zip files and different zip creation programs will choose between them and one of them is not supported. Although I just checked and the zen.info appears to be using "Deflated" in both the original and the attached broken zip according to windows.

So now I have no idea what is causing it but there is definitely a valid zen.info in the attached zip file and it's not being recognized by the theme uploader.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lone Coder’s picture

In order to help designers, the "zen.zip does not contain any .info files." error message should be more elaborate and specify exactly where the .info files are required. That a subfolder is required in the root of the archive and that each subfolder must have a .info files. I dunno if that's the requirement but it seems like it is and should say so if it is.

bfroehle’s picture

The problem is that in update_manager_install_form_submit, we determine the $project by:

  // Unfortunately, we can only use the directory name for this. :(
  $project = drupal_substr($files[0], 0, -1);

However for the provided zip file, $files[0] is zen/CHANGELOG.txt, not zen/ as in the zip provided on drupal.org.

What we'll need to do is find the name of top level directory in $files[0]... perhaps

// Unfortunately, we can only use the directory name for this. :(
$project = explode('/', $files[0], 2);
$project = $project[0];

(I'm not sure how $files[0] is provided in Windows... is the delimiter still '/' ?)

bfroehle’s picture

Status: Active » Needs review
Issue tags: +Update manager
FileSize
599 bytes

Implemented my idea in #2. Now is this safe to use on Windows since it assumes the path delimiter is '/' ?

Essentially if $files[0] is MODULE/aaa/bbb/ccc.file (or the Windows analog), we want to set $project to MODULE.

bfroehle’s picture

For safety, maybe we should do:

$project = explode('/', str_replace('\\', '/', $files[0]), 2);
$project = $project[0];

Can any Windows / path gurus comment?

Edit:
Also, we'll need to apply this same fix later on in update_manager_archive_extract().

carlos8f’s picture

Version: 7.0 » 7.x-dev
Component: upload.module » update.module
Priority: Critical » Major

Applying correct queue/status. Uploading a theme still works the old fashioned way :)

webchick’s picture

Status: Needs review » Needs work

Hm. I thought we had a DIRECTORY_SEPARATOR constant or similar.

Oh, PHP does. :) http://php.net/manual/en/dir.constants.php

bfroehle’s picture

Thanks webchick! Although I still worry that since this file listing is coming from the php zip module, it might differ from more core PHP conventions...

bfroehle’s picture

Status: Needs work » Needs review
FileSize
1.14 KB

Revised patch taking into account the comments in #4-7. (Manually tested and was able to install the provided zen.zip from both URL and local file upload).

Lone Coder’s picture

Awesome. Thanks so much for figuring out the problem and getting a patch going! I'm so glad to know what the problem is and know I wasn't wasting my time submitting the bug report.

Now that I understand the problem I might be able to tweak the zips my site is generating so they'll work.

Thanks again.

Lone Coder’s picture

Issue tags: -Update manager, -zip

Awesome. Thanks so much for figuring out the problem and getting a patch going! I'm so glad to know what the problem is and know I wasn't wasting my time submitting the bug report.

Now that I understand the problem I might be able to tweak the zips my site is generating so they'll work.

Thanks again.

Tor Arne Thune’s picture

Issue tags: +Update manager, +zip
Sarenc’s picture

Status: Needs review » Reviewed & tested by the community

Interestingly when listing files of an archive created by Drupal's own implementation of Archive_Tar the trailing slash doesn't exist. This patch is much appreciated.

bfroehle’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.79 KB

I'm uploading a new patch which should be easier to read and has some more descriptive comments.

No substantive code change, except that it assigns a partial result ($path = str_replace('\\', '/', $files[0]);) to a variable which is unused elsewhere in each function.

bfroehle’s picture

I wonder if it'd be easier to just do

$project = strtok($files[0], '/\\');
bfroehle’s picture

Implemented #14 and tested locally. Much prettier code. :)

Sarenc’s picture

Just a note that there are actually three possibilities here in regards to the first file listed by $archive->listContents();.

1) the expected behaviour: module/
2) no directory name by itself: module/readme.txt
3) the directory name with no trailing slash: module

As I noted above the third possibility is how Drupal's own implementation of Archive_Tar produces tar archives.

The latest patch does seem to account for all these possibilities.

bfroehle’s picture

Sarenc: Are you sure? If so, it would have be impossible for the Drupal 7.0 code to work with tar formats but I haven't seen any bug reports mentioning that.

Edit: Even so, it doesn't matter. For example:

$files = array('module/', 'module/readme.txt', 'module', '/module', '/module/readme.txt', '/module');
foreach ($files as $file) {
  print strtok($file, '/\\') . "\n";
}

will return 6 lines of module as one would expect. :)

Sarenc’s picture

bfroehle, I'm pretty sure.

Given a directory of sites/default/files/temp/mysubtheme

with regular theme files located in mysubtheme then running:

chdir('sites/default/files/temp');
$obj = new Archive_Tar('mysubtheme.tar');
$handle = opendir('./'); 
$obj->create('./mysubtheme');

when running $files = $archive->listContents(); we get 'mysubtheme' for $files[0] not 'mysubtheme/'

maybe the archiving method could be changed but as you say strtok($files[0], '/\\'); works regardless so it doesn't matter in the end :)

Cheers

bfroehle’s picture

Well, the patch in #15 seems pretty well tested by now (especially in light of the experimentation with strtok in #17), but I'm not going to mark RTBC since I was the patch author.

Sarenc’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD, thanks!

Status: Fixed » Closed (fixed)

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

Dewsworld’s picture

In my case, making zip with winrar also giving the same problem for my custom module

Mauro Colella’s picture

Version: 7.x-dev » 7.38
Issue summary: View changes
Status: Closed (fixed) » Needs work

The issue is still current on HHVM 3.8, on Ubuntu 15.04, using the nginx web server.

  • webchick committed c481e81 on 8.3.x
    #1019834 by bfroehle: Fixed No .info files reported on theme upload when...

  • webchick committed c481e81 on 8.3.x
    #1019834 by bfroehle: Fixed No .info files reported on theme upload when...

  • webchick committed c481e81 on 8.4.x
    #1019834 by bfroehle: Fixed No .info files reported on theme upload when...

  • webchick committed c481e81 on 8.4.x
    #1019834 by bfroehle: Fixed No .info files reported on theme upload when...

  • webchick committed c481e81 on 9.1.x
    #1019834 by bfroehle: Fixed No .info files reported on theme upload when...

Version: 7.38 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.