Download & Extend

No .info files reported on theme upload when zip created with certain programs

Project:Drupal core
Version:7.x-dev
Component:update.module
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)
Issue tags:.info file, theme uploader, Update manager, zip

Issue Summary

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.

AttachmentSizeStatusTest resultOperations
zen.zip209.08 KBIgnored: Check issue status.NoneNone

Comments

#1

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.

#2

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 '/' ?)

#3

Status:active» needs review
Issue tags:+Update manager

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.

AttachmentSizeStatusTest resultOperations
1019834-3.patch599 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 31,541 pass(es).View details

#4

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().

#5

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 :)

#6

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

#7

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...

#8

Status:needs work» needs review

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).

AttachmentSizeStatusTest resultOperations
1019834-8-handle_some_weird_zip_files.patch1.14 KBIdlePASSED: [[SimpleTest]]: [MySQL] 31,501 pass(es).View details

#9

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.

#10

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.

#11

Issue tags:+Update manager, +zip

#12

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.

#13

Status:reviewed & tested by the community» needs review

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.

AttachmentSizeStatusTest resultOperations
1019834-12-fix_unable_to_read_project_name_for_some_zip_archivers.patch1.79 KBIdlePASSED: [[SimpleTest]]: [MySQL] 31,496 pass(es).View details

#14

I wonder if it'd be easier to just do

$project = strtok($files[0], '/\\');

#15

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

AttachmentSizeStatusTest resultOperations
1019834-15-even_better.patch1.6 KBIdlePASSED: [[SimpleTest]]: [MySQL] 31,544 pass(es).View details

#16

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.

#17

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:

<?php
$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. :)

#18

bfroehle, I'm pretty sure.

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

with regular theme files located in mysubtheme then running:

<?php
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

#19

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.

#20

Status:needs review» reviewed & tested by the community

#21

Status:reviewed & tested by the community» fixed

Committed to HEAD, thanks!

#22

Status:fixed» closed (fixed)

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

#23

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

nobody click here