I just reviewed someone else's code which give a cryptic error message, warning: Invalid argument supplied for foreach() in /Applications/xampp/xamppfiles/htdocs/fl/includes/common.inc on line 3164.
, which baffled us, as the hook_schema() implementation was fine and dandy. Until I realised he had called drupal_[un]install_schema per-table instead of per-module/hook_schema()-function. It would be great if Drupal could put a more informative error message in the place of the other message. (Perhaps something like "Error: @module_schema doesn't exist.") Perhaps PHP 5's exception handling could be used for this? (I've only played with exceptions in Python, so I don't know if PHP handles them just as easily...)
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | issue_255022.d7.patch | 2.32 KB | Freso |
| #1 | physiolog.install.txt | 1.7 KB | mikl |
Comments
Comment #1
miklWell, actually, it gives four error messages:
* warning: Invalid argument supplied for foreach() in /Applications/xampp/xamppfiles/htdocs/fl/includes/common.inc on line 3164. * warning: Invalid argument supplied for foreach() in /Applications/xampp/xamppfiles/htdocs/fl/includes/common.inc on line 3110. * warning: Invalid argument supplied for foreach() in /Applications/xampp/xamppfiles/htdocs/fl/includes/common.inc on line 3164. * warning: Invalid argument supplied for foreach() in /Applications/xampp/xamppfiles/htdocs/fl/includes/common.inc on line 3085.I've attached the .install file in question for easy reproduction.
Comment #2
Freso commentedHere's a quick throw-together, untested and without tests written for it, but mostly just meant to demonstrate some try/except code in PHP. Is this something we want?
Comment #3
chx commentedWe still do not babysit broken code. If you want to reopen this, answer with justification -- why should this code sit in memory for every single uncached Drupal page load given that unlikely rarely used code ths is code that should never fire...
Comment #4
miklTested in HEAD.
Before patching, we still get errors like mention above (but only to, compared to four in 6.2)
After patching, I get no error messages, but nothing in the database either.
Comment #5
miklOh, sorry. Race condition.
I still think that we should handle errors better. A more helpful error message would have saved me an hour banging my head against the wall, thinking myself stupid.