E_ALL - Module admin page - .info file compatibility check

catch - November 9, 2007 - 10:18
Project:Drupal
Version:6.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:patchnewbie
Status:closed
Description

Just downloaded latest devel tarball to my /modules directory (not sites/all/modules, plain old modules), and I got this error:

warning: Invalid argument supplied for foreach() in drupal6/modules/system/system.admin.inc on line 542.

#1

patchnewbie - November 9, 2007 - 16:31
Assigned to:Anonymous» patchnewbie

This looks like a good patch for someone new to core development.

#2

Timotheos - November 11, 2007 - 21:40

This can be caused by a faulty info file. In my case it was the devel-themer module that has the line dependencies = devel rather then dependencies[] = devel

I'll file a bug report on devel but I'm not sure what is needed in core. Should drupal_parse_info_file force this to be an array? or should we just be checking in system.admin.inc to make sure it's an array?

#3

catch - November 13, 2007 - 17:00
Title:E_ALL warnings in module admin page using /modules directory» E_ALL warnings in module admin page - .info files

http://drupal.org/node/191342 was duplicate

#4

catch - November 14, 2007 - 12:23

Line 542 is from the private function _system_is_incompatible called by system_modules() - which looks like it's breaking system_update_1005() here: http://drupal.org/node/191767

#5

aufumy - December 1, 2007 - 17:16
Status:active» patch (code needs review)

If dependencies not an array in modules info files, then return true to _system_is_incompatible()

AttachmentSize
dependencies_array.patch862 bytes

#6

Pasqualle - December 16, 2007 - 17:39
Status:patch (code needs review)» patch (reviewed & tested by the community)

rerolled, tested, works

AttachmentSize
dependencies_array_1.patch908 bytes

#7

Gábor Hojtsy - December 16, 2007 - 18:19

Is the dependencies key initialized to an array if it is not set in the file?

#8

Pasqualle - December 16, 2007 - 18:47
Status:patch (reviewed & tested by the community)» patch (code needs review)

Yes, if the info file does not contain the dependency property, then it is initialized as an empty array.

So I changed the patch to reinit the value to an empty array. Is it ok, or put the original value into array?

like dependencies = devel
makes now $file->info['dependencies'] an empty array
or change it to $file->info['dependencies'] = {devel}, but then it does not need to be set here as incompatible..

AttachmentSize
dependencies_array_2.patch952 bytes

#9

Gábor Hojtsy - December 16, 2007 - 18:55

I mean what if the dependency key was not used in the .info file? Then the info file reader initializes this to an array, or not? If not, !is_array($file->info['dependencies']) will mark all modules incompatible which have no dependencies.

#10

Pasqualle - December 16, 2007 - 19:32

Yes, the info file reader initializes an empty array in this case, and the patch works correctly with those modules. Does not mark them incompatible.

#11

webernet - December 16, 2007 - 19:36

Whatever happened to "Core doesn't support broken code"?

If a .info file is malformed, then it's a bug in the .info file. This should probably be "won't fix".

#12

Gábor Hojtsy - December 16, 2007 - 21:41

weberner: uhm, no. This exact function is to check whether the module is compatible with the current core version at hand or not. Previous info files did not have an array in the dependency key, so there comes the error. We need to handle this error here, as the role of this exact function is to identify broken stuff, so it fiddles with broken stuff by definition.

#13

webernet - December 16, 2007 - 22:12
Title:E_ALL warnings in module admin page - .info files» E_ALL - Module admin page - .info file compatibility check

OK - Looked at the patch more closely, and yes, it looks like you're right. The original description and discussion made me think this was a quick fix to make things work even if the .info file was malformed.

#14

Pasqualle - December 16, 2007 - 23:10

drupal 5 format (http://drupal.org/node/101009)
dependencies = taxonomy comment

does it need to be converted, or the pach is sufficient?

#15

Gábor Hojtsy - December 17, 2007 - 09:59

Uhm, no. If the dependencies key is not an array, then that quickly shows us it is not compatible.

#16

gtcaz - January 11, 2008 - 06:26

Still seeing this in rc2.

warning: Invalid argument supplied for foreach() in modules/system/system.admin.inc on line 580.

#17

Pasqualle - January 11, 2008 - 11:31

@gtcaz: Drupal core modules do not have malformed .info file. Can you find which custom module causing this warning? Search for dependencies string in info files. If it does not have [] square brackets then it's a bug in that .info file, and should be fixed.

#18

Pasqualle - January 11, 2008 - 11:37

reroll, please review

AttachmentSize
dependencies_array_3.patch951 bytes

#19

gtcaz - January 12, 2008 - 01:13

No -- I did look for that and couldn't find anything. Attached are all the .info strings for the models and themes I have installed.

AttachmentSize
dotinfo.txt2.2 KB

#20

Pasqualle - January 12, 2008 - 03:09

@gtcaz: Thanks for the list. I found two malformed info files in event module (issue http://drupal.org/node/209103). Do you see more than two warnings, should I check the other modules too?

#21

Pasqualle - January 12, 2008 - 16:47

and here is a great opportunity to test this patch

test:
1. install drupal
2. add event module 6.x-2.x-dev (7/1/2008)
3. see the warnings on page admin/build/modules
4. apply patch
5. no warnings, the modules with malformed info files are marked incompatible with Drupal core
6. correct dependencies in the info file
7. reload page admin/build/modules, the modules should be compatible now

#22

gtcaz - January 12, 2008 - 18:10

No, I just see two warnings. Great! I'll apply the patch and report back.

#23

gtcaz - January 12, 2008 - 18:31

Patch applies cleanly. Errors are gone. Event modules marked incompatible. Excellent!

#24

Pasqualle - January 12, 2008 - 18:41
Status:patch (code needs review)» patch (reviewed & tested by the community)

thanks for the test

#25

Gábor Hojtsy - January 15, 2008 - 10:59
Status:patch (reviewed & tested by the community)» fixed

Updated the docs a bit, and committed this one. Thanks.

AttachmentSize
dependencies_array_4.patch.txt1.09 KB

#26

Anonymous (not verified) - January 29, 2008 - 11:12
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.