Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
database system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jul 2008 at 02:44 UTC
Updated:
2 Jan 2014 at 23:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bjaspan commentedComment #2
moshe weitzman commentedThis is true of theme registry as well. I think a little defensiveness like this is a good thing.
Comment #3
lilou commentedCNW because
drupal_get_schema()move into boostrap.inc.Comment #4
lilou commentedComment #6
lilou commentedSee: #335122: Test clean HEAD after every commit and http://pastebin.ca/1258476
Comment #7
mikejoconnor commentedIf the schema is NULL, I don't think we need to do the require. How about this?
Comment #8
Crell commentedWe can probably go as far as confirming that $current has a count() >= 1, just to be extra safe.
Comment #9
damien tournoud commented#305430: Prevent schema corruption was a duplicate.
Comment #10
mikejoconnor commentedHere's a new patch, including count()
Comment #11
chx commentedI believe this to be a very dangerous practice. Where will this stop? How many lines of code will we add which shields us from bad modules? There are many, many ways for a broken module to mess up your Drupal. This is summed up as "we do not babysit broken code".
Comment #12
robertdouglass commentedCan you cast it to an array?
That's not even 1 line of babysitting code - it's 7 characters.
Comment #13
robertdouglass commentedComment #14
damien tournoud commentedAgreed with Robert. Casting to an array is the way to go.
Plus I don't see how the patch in #10 solves the issue described in the original post ("passing NULL to array_merge() results in NULL").
Comment #15
chx commentedcasting is fine. it's a bit of ugly but yeah ok.
Comment #16
Crell commentedCasting sounds fine to me if that's easier. Probably needs a comment line to clarify it then, too.
I don't see that as babysitting broken code as much as keeping a typo from totally hosing an entire devel site. :-)
Comment #17
mikejoconnor commentedNew patch, casting to an array.
Comment #18
rszrama commentedSo, I intentionally hacked poll_schema(). It threw a couple of warnings but felt good about itself and said it was installed. I installed profile at the same time as my hacked poll, and profile installed just fine. In that regards, I think the patch works fine.
fwiw, I'm with chx on this one, b/c people really just shouldn't be implementing hook_schema() unless they intend it to return a valid schema array. And if for some reason a schema fails to install, I don't think the module should even be marked as installed.
Comment #19
Crell commentedThis is not along a critical path, and while one module dying because its author messed up is one thing, screwing up other modules is simply not acceptable. #17 looks good to me.
Comment #20
dries commentedSorry but that comment could be a bit more explanatory. Setting back to 'code needs work'.
Comment #21
cafuego commentedArgh, this bit me when I stuck a placeholder hook_schema() in a module. Such an easy fix.
Attached original patch with expanded comment. Also see #617546: Invalid hook_schema() result can trash entire schema for the D6 patch.
Comment #22
Crell commentedSafety from bad hooks++
Comment #23
bjaspan commentedI can't believe this little issue has required 6 patches (all basically identical) and 23 comments. Thank you, crell, for the RTBC.
<chant>commit, commit, commit</chant>
Comment #24
webchickComment looks good.
In general, I am against babysitting broken code as well, but Crell in #19 makes a good point that this doesn't just screw up your module (as when you forget to return $items from hook_menu()), this screws up everything.
Committed to HEAD.
Looks like this could be backported to D6 as well?
Comment #25
cafuego commentedI can't express in words how much I concur that it should be backported to D6. Patch attached.
Comment #26
Déja commentedAs this issue continues to plague Drupal 6.x nearly a year after this patch was submitted, I'm resubmitting cafuego's patch so that it can go through the automated testing.
I also discuss the issue and its solution in greater detail in my post at http://echodittolabs.org/blog/2010/09/butterfly-effect
Comment #27
grendzy commented+1
Confirmed this is a straight backport of the D7 commit.
Comment #29
grendzy commentedbad bot! This is a D6 patch.
Comment #30
gábor hojtsyI'm not fun of babysitting code either, but there is just too much support here. Committed to Drupal 6.