Hi,

The coder module doesn't process install files when there is a schema file present. For example, in the avatar selection module, there is a avatar_selection.install and a avatar_selection.schema, while for the lightbox2 module, there is just a lightbox2.install file. I noticed when running the coder on these modules, that it only ever found 4 files and only reported on avatar_selection.module, avatar_selection.schema, lightbox2.module and lightbox2.install. It didn't report on the avatar_selection.install file. I further tested this by adding t() around the messages in the calls to watchdog() in both install files. A warning was given about the one added to lightbox2.install, but no warning was given about the one added to avatar_selection.install.

I may not have described the problem particularly well, so let me know if you have any questions.

Cheers,
Stella

Comments

stella’s picture

StatusFileSize
new1.85 KB
new1.85 KB

Hi,

This applies to both the 5.x and 6.x versions, and probably 4.7.x too but I haven't checked that one.

The problem is with the calls to drupal_system_listing(). The drupal_system_listing() function returns of array of system file object of the given type that match the specified regular expression. For each file found it returns a "name" (e.g. "coder"), a "basename" (e.g. "coder.module") and a "filename" (e.g. /var/www/drupal_5.3/sites/all/modules/coder/coder.module).

The problem is that whenever this function is called in the coder module, the module specifies that the returned array should use the "name" as the key for the array. This causes problems when more than two files have the same "name". For example, if you were to have a coder.install and a coder.schema file, then the returned array would be:

Array ( [coder] => stdClass Object ( [filename] => /var/www/drupal_5.3_20071114/html/sites/all/modules/coder/coder.schema [basename] => coder.schema [name] => coder ) ) 

The entry for "coder.schema" overwrites the "coder.install" entry since they both use the same key ("coder"). Changing the key to "basename", means we get an array like:

Array ( [coder.install] => stdClass Object ( [filename] => /var/www/drupal_5.3_20071114/html/sites/all/modules/coder/coder.install [basename] => coder.install [name] => coder ) [coder.schema] => stdClass Object ( [filename] => /var/www/drupal_5.3_20071114/html/sites/all/modules/coder/coder.schema [basename] => coder.schema [name] => coder ) ) 

The attached patches should fix the issue for 5.x and 6.x versions.

Cheers,
Stella

stella’s picture

Status: Active » Needs review
douggreen’s picture

+1

Good catch, please commit it. I confirm that the difference between 'name' and 'basename' in file_scan_directory (in file.inc) is that 'name' strips off the file extension.

douggreen’s picture

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

Status: Reviewed & tested by the community » Fixed

Fixed and checked into CVS for both 5.x and 6.x versions.

Cheers,
Stella

douggreen’s picture

I noticed that it wasn't picking up all of the test files. So I replaced 'basename' with 'filename' in all calls to drupal_system_listing. This was probably broken for awhile, and wasn't caused by this recent patch. But I'm putting this note here, because this patch still didn't fix the problem. I think using 'filename' should make everything unique now.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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