Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
node system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Aug 2010 at 10:05 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
catchwhy SELECT COUNT(*) instead of SELECT 1 here?
Also there isn't a new index on disabled.
Comment #3
dmitrig01 commentedjust curious: how would one find a bug like this?
Comment #4
damien tournoud commented@dmitrig01: all the nodes from module-defined node types lose their bodies during the D6 to D7 upgrade :)
Comment #5
mrfelton commented@dmitrig01 - try upgrading a site that has some custom node types, or actually, I think it may just be node types that are provided by a module, that you have altered. Disable all the contrib modules (including the one that was providing that node type) as recommended, then try the upgrade.
Comment #6
catchComment #7
mrfelton commentedIs there a D6 issue for this?
Comment #8
damien tournoud commentedRerolled: moved the module uninstall where it belongs (in node_modules_uninstall()) and fixed the upgrade path.
This will fail because MySQL schema.inc implementation is currently unable to create a NON NULL field.
Comment #9
catchPlease make this just 'module' - this'd be consistent with other things in core which record module ownership.
This should be 'status' - to make it consistent with modules, themes, nodes themselves etc. If not status for some reason, then at least it should be 'enabled' to avoid the double negative in queries (':disabled' => 0)
No documentation for the new parameter.
persistence.
survives
System module has to know about node module now? I think we need to allow modules to stop themselves or others to be disabled/uninstalled, but not sure this is the issue to do this, and not keen on the special casing.
Comment #10
chx commentedI am working on this. Note that the orphaned nodes losing their bodies is NOT this issue. This is one way to end up with an orphaned node but #891028: Orphan node types lose bodies on upgrade is the issue you want for that.
This issue is about a data loss as the original issue says. Try what the test does: enable poll, change the description, disable poll, reenable poll poof customization is gone.
Comment #11
mrfelton commentedI applied the patch in #8, but still get errors like the following:
Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'disabled' in 'where clause': SELECT nt.* FROM {node_type} nt WHERE (disabled = :db_condition_placeholder_0) ORDER BY nt.type ASC; Array ( [:db_condition_placeholder_0] => 0 ) in _node_types_build() (line 701 of /home/tom/workspace/d7/modules/node/node.module).
Is the upgrade patch not working?
Comment #12
chx commentedComment #13
sunHere's my initial review. Note that I have tried to remain as ignorant as possible as to what's been going on in this issue, so that I can give it a totally fresh set of eyes. Apologies if any of this was already mentioned above; I'll read the issue once I'm done here.
Regardless of what has been in Drupal 6, 5, 4, 3, or 1, in 1942, or whether the answer is 42, we call this column "module" everywhere else, and so should we do here.
Please rename to {node_type}.status.
Bogus leading slash.
Powered by Dreditor.
Comment #14
chx commentedRegardless of what has been in Drupal 6, 5, 4, 3, or 1, in 1942, or whether the answer is 42, we call this column "module" everywhere else, and so should we do here.
I am not doing that. But, I have unassigned myself from the issue so another poor sucker gets the chance to pour a few days into fixing and backporting of this.
Please rename to {node_type}.status.
No. ->disabled is API exposed as I said already and having a property and database column named different and having the opposite meanings is a no-go.
Comment #15
chx commentedif i go on i will won't fix the goddamned issue too. where is my unsubscribe link?
Comment #16
chx commentedWell. The patch, I think, already changes the API as described in this comment:
If we (who exactly?) decide that we do not care then yes, disabled can be status. But no, defining_module can not be module that's way too confusing. Especially that noone ever needs that aside from uninstall.
On the other hand if we want to abide by this doxygen then someone needs to check whether my patch breaks this (i suspect yes) and then needs to come up with a solution that does not. Good luck...
Comment #17
sunok, chx clarified once again that we cannot change ->disabled, as that is used by Node type API already, just not stored yet. Reading the patch, I'm not sure whether there is an actual difference in behavior of the property, aside from persistent storage.
Likewise, he does not want to change ->defining_module into ->module, because we just moved from ->module to ->base since D6. I don't see a real problem with that, but ok.
This mainly leaves us with the last minor issue of #13.
P.S.: I also wondered why this entire node type info is not cached... looks like low-hanging performance fruit to me. (separate issue)
Comment #18
chx commentedWell that's really one minor issue.
Comment #19
sunShouldn't we also try to populate this new column with the old 'module' column's values?
We can compare all existing module names and check whether the old module column value contains a module name as prefix. That should probably work for 99% of all cases, if not even 100%.
FYI: Also created #898360: Cache node types
Powered by Dreditor.
Comment #20
sunI think these two lines got switched and flipped and moved around a gazillion of times during D7 already, and it's really time we start to document the technical reason for their order when changing them.
Working further on #898360: Cache node types, I'm not sure whether this change is a good idea. We have to differentiate between
- "totally rebuilding stored node type information" and
- "refreshing static/db caches"
In other words: Only node_types_rebuild() should contain code that changes stored node type information.
It looks like that is as easy as moving the conditional $rebuild code "back" into node_types_rebuild().
wow. Do we really want to delete node types of uninstalled modules? For instance, that likely means that, after upgrading with Image module from D6 to D7, weird things could happen upon uninstalling the D7 Image module.
It looks like we don't use the actual count of node types, so we should use SELECT 1 instead of COUNT(*), no?
Aside from that, it's pretty ugly to have node-specific code in here... looks like a regular hook scenario to me, i.e., various modules using API of one module, so that module can be responsible for indicating that there's data to uninstall. Sounds pretty easy, but I guess you want to defer that to D8...
Powered by Dreditor.
Comment #21
catchSince the upgrade path issue is handled elsewhere, I'm downgrading this to major - behaviour has been around for a very long time, and it's 'configuration data loss' which is easily fixable/replaceable, rather than actual user content that disappears here.
Comment #22
damien tournoud commentedThis is actually worse. All the field data of a node type are lost on module disable.
This is because node_types_rebuild() calls node_type_delete() that calls field_attach_delete_bundle() that... deletes the field data.
Comment #23
chx commentedAdded prepopulate.
The reason we moved this functionality under one roof is
foreach (node_type_get_types() as $type => $info)innode_types_rebuild()-- if we want to keep that code, we would need to make thenode_type_get_typesfunction famility disabled-aware. I prefer not to.We did not have a specific static cache reset before so I did not add that.
Discussed with webchick and removed node_type_uninstall from uninstall. Sure. Makes the code simpler that's for sure.
Comment #24
chx commentedTests now pass. I only flipped the asserts for the uninstall cases.
Comment #25
chx commentedSwapped two queries in node.install in the update so now defining_module is properly prefilled with node when possible.
Comment #26
chx commentedI removed a line with $info_array which is not needed any more, reverted standard.install as node type defaults will add that 'node' and added line breaks to the test.
Comment #27
catchThe field instance move in forum_enable() is because that instance will stay there, and enabled, despite the bundle being disabled. It's sucky that this will take memory and processing despite not being used anywhere, but for today it's better than it disappearing off the face of the earth. In D8 it might be necessary to add a field_attach_disable_bundle() or something, but not now, and the node module changes would still be necessary even if we had that.
hook_node_types() is being invoked twice, but the results of the first invocation are never used.
$_node_types->types[$type_db]->disabled_changed = $disabled != $type_object->disabled;makes me sad but it's not really worse than what's already there. Which is saying something.
The tests could do with line breaks before the comments.
The test tests the contents of the node type table, but doesn't test the persistence of field instances, which is what set this back to critical, but that can be a followup.
Comment #28
catchCross-posted. Looks RTBC to me, needs the test bot run (or tests run locally and verified here).
Comment #29
catchRe-uploading in attempt to jump the test bot queue, no credit please.
Comment #30
damien tournoud commentedThis last condition needs an explict 'IN' operator... and we are missing an ->execute() here.
Comment #31
catchFixed.
Comment #32
catchAlso missing parenthesis after node_menu() in a code comment.
Comment #34
babbage commentedRe-roll of catch's patch from #32, removing errant semi-colon, to keep things moving.
Comment #36
damien tournoud commentedProperly fixed this damn query.
Comment #37
catchHow did this issue possibly go seven hours without being RTBC.
Comment #38
dries commentedInstead of 'defining_module' can we use 'module'? That is more consistent with the rest of core.
Other than that, this patch looks good. Love the tests -- very clear.
Comment #39
chx commentedRemoved the node type delete hunk. Added doxygen to the test case.
Comment #40
webchickOk. So this looks like a pretty huge patch, but it really comes down to three changes:
1. Adding two new columns to the node_type table: "defining_module" (The module defining this node type) and "disabled" (A boolean indicating whether the node type is disabled.)
2. Removes this from node_types_rebuild():
which previously would destroy node types of disabled modules. This was not consistent with my D6 testing, which keeps node types around in between module enable/disable (or at least their title, body, and taxonomy associations).
3. Tests to demonstrate the new workflow.
The end result is that modules that defined node types will stick around even after uninstalling, unless the module explicitly calls node_type_delete() in hook_uninstall(). I think this is acceptable; we did automate some of the tedious hook_install() / uninstall() tasks like schema stuff, but we're talking here about data destruction which IMO needs to be a very opt-in process.
I found a couple of minor nits which chx is re-rolling for. We needlessly changed the argument in node_type_delete() and need to revert it, and are missing PHPDoc on the testX function. I also earlier asked him to make defining_module default to 'node' so that those creating nodes programmatically don't have to make an API change, which was already taken care of.
Looks like latest patch has all of these changes. Now we wait...
Comment #41
dries commentedPlease also include #38 in the upcoming re-roll. Thanks. :)
Comment #42
catch@Dries, did you read #9 and the followups from that review? I asked the same question, chx's answer was satisfactory for me as to why we can't do that.
Comment #43
webchickI agree with Dries, and this was one thing that's been nagging at me (other than 'disabled' => 'status' which I understand why we can't do without an API change). Yeah, I've read chx's arguments and tbh they don't totally make sense to me. The reason we renamed "module" to "base" in D7 was because that column was not, in fact, the defining module. But this one is. The schema descriptions seem clear to me.
chx is concerned that people coming from D6 will be confused about the change, but "The Drop Is Always Moving." We don't call page.tpl.php page-template-not-to-be-confused-with-the-page-module-which-actually-you-now-make-in-the-ui-and-add-fields-with-cck-which-btw-is-now-in-core-as-of-drupal-7.tpl.php :P Drupal 7's code and DB schema should be written for Drupal 7. Not for Drupal 6.
So let's get that one last change in there and then get this sucker in. Yay!
Comment #44
damien tournoud commentedI disagree, but here is a reroll for #43.
Comment #45
damien tournoud commentedScratch #44. I should remember to save all the files in my editor *before* rolling the patch :)
Comment #46
juan_g commentedSeems last blocker now, rest of last minute ones just committed.
Damien Tournoud's:
Holding breath...
Comment #47
damien tournoud commentedTested this on the #934042: The Drupal.org test, and found out that I broke the update path query here.
Here is a fixed version.
Comment #48
mradcliffeIs the last foreach trivial or should the code be done within the prior foreach?
Comment #49
damien tournoud commentedI ran this version on a smaller version of drupal.org (with only a few 10,000 of nodes, users and comments), and it worked perfectly. #yay
Comment #50
webchickWell, that sounds like about the most ringing RTBC endorsement I can think of.
Committed this, the last Drupal 7 beta blocking patch, to HEAD! :D :D :D
Comment #51
Ildar Samit commentedI know I don't belong here, but wanted to say THANKS GUYS! :D
Comment #52
juan_g commentedToday is D-Day... Congratulations all!
Now, let's go build wonderful websites with Drupal 7 beta, and do a lot of real-life testing. :)
Comment #53
sunCrazy! I didn't know that this is possible. Still learning something new about DBTNG every day, thanks! :)
Powered by Dreditor.
Comment #54
giorgoskJust updated from dev of oct 5th to the beta1
and after update.php finds nothing to update I get error message similar to #11
I was wondering if this is OK passing from a dev version to a beta or is this a real BUG ??
Comment #55
damien tournoud commented@GiorgosK: this is by design. We do not support alpha-to-beta upgrades. It should be easy enough to add this column manually and populate it.
Comment #56
webchickWe don't support upgrades from D7 to D7 until beta 1, so this is not technically a bug (though I agree it's weird). See http://drupal.org/project/head2head which should get an update for that at some point. Else, if you add the columns manually that works too.
Comment #57
damien tournoud commentedThis should help for the upgrade:
Comment #58
giorgoskGreat
thanks a lot @Damien and @webchick
Comment #59
catch(hopefully last) head2head issue here #934548: Update for #895014.
Comment #61
catchThis needs to be backported to Drupal 6. Currently there is no way for the Drupal 7 upgrade path to know about node types from modules that were disabled.
Quoting chx from #1:
Coming here from #1017672: D6 to D7 update process permanently deletes comment bodies and other data, and throws fatal SQL errors.
Comment #62
carlos8f commentedsubscribing
Comment #63
joachim commentedJust spotted this one while working on the image D6 upgrade path.
Do we need to backport the extra field on the node type table, or just prevent node type deletion in node_types_rebuild()?
Comment #64
Leeteq commentedSubscribing.
Comment #65
joachim commentedHow is this going to work with the backport? If these db changes need to be made on D6 too, where should they go so that an eventual upgrade to D7 doesn't give errors?
1 days to next Drupal core point release.
Comment #66
catchWe'd need to db_field_exists() and similar checks in Drupal 7 if this gets into Drupal 6 I think so the upgrade works either way.
Comment #67
hefox commentedI think this is semi-related to what I'm seeing:
tl;dr: it's not just disabling where this crops up.
edit: I now run drush rr (registry rebuild, from registry_rebuild project) before updb to avoid issues like this.
Comment #68
RichardLynch commentedI got the same thing trying to go from D6 to D7, but two points against me for:
a) Not being on the most recent D6 first
b) Not deleting all the D6 code from my sites
That said, I just did:
alter table PREFIX_node_type add column disabled tinyint(4) default 0;
and moved on with life...
But that's just me...
Comment #69
ezra-g commentedTagging this with 'commonslove' so that it can get more attention as we work on the Commons D6=>D7 upgrade process.
Comment #70
dynamicdan commentedHave I missed something??
There is a patch to be ported from pre June 2012 that is needed for a successful upgrade from D6 to D7?? In other words, an upgrade to D7 from D6 is officially not recommended? How does a critical bug get left alone for so long? 2 years!
Comment #71
catchThe upgrade path was fixed in Drupal 7 for this issue in a different way, although it took more than 6 months after release for the patch to be committed. See #1017672: D6 to D7 update process permanently deletes comment bodies and other data, and throws fatal SQL errors for the gory details. This patch should have blocked the Drupal 7 release altogether, but for various reasons that was entirely overlooked and Drupal 7 released anyway without it.
It hasn't been fixed in Drupal 6 because no one has worked on it, but it's not strictly necessary for a successful Drupal 6-7 upgrade any more.