As the title states, the info_array in node_types_build gets rewritten for each module_invoke. Please correct me if i'm wrong, but I tried creating two modules with hook_node_info and the first content type always gets disabled on clear cache. Dsm revealed that the $info_array does indeed pose a problem when it checks for isset($info_array[$type_db]), so it disables the content type. Here's a small patch that fixes the problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 986296-21-node-type-status.patch | 4.34 KB | carlos8f |
| #14 | 986296-14-node-type-status-TESTS-ONLY.patch | 3.25 KB | carlos8f |
| #14 | 986296-14-node-type-status.patch | 4.33 KB | carlos8f |
| #8 | 986296-8.patch | 1.21 KB | tstoeckler |
| #3 | node_types_build.patch | 613 bytes | blup |
Comments
Comment #1
blup commentedI meant "checks for empty($info_array[$type_db])". Also changing status.
Comment #3
blup commentedTrying again from the root directory.
Comment #4
blup commentedComment #5
blup commentedHmm, am i the only one concerned about this? This seems like quite a serious issue. Here's the commented excerpt:
Comment #6
damien tournoud commentedEw. This makes impossible for any module to implement hook_node_info(). Bumping to critical.
Comment #7
tstoecklerPowered by Dreditor.
This means we would be iterating over the same node types over and over again.
The second foreach should be taken out of the first one.
Powered by Dreditor.
Comment #8
tstoecklerSomething like this.
Comment #10
tstoecklerJavaScriptTestCase? Let's try it one more time.
#8: 986296-8.patch queued for re-testing.
Comment #11
damien tournoud commentedThe only thing to fix is this line:
We should have a empy{$_node_types->names[$type_db]) here.
Comment #12
dmitrig01 commentedWhat about adding a test here that enables blog and poll modules and ensure both work?
Comment #13
carlos8f commentedI agree with #11. $info_array is just a temporary variable, and shouldn't be used in the empty() check later.
And another issue I recently found: _node_types_build() also has a static cache that is a little too sticky. #993992: _node_types_build() labels content types 'is_new' when they're not, and has static caching bugs
Comment #14
carlos8f commentedQuickie patch and tests.
Comment #16
int commented#14: 986296-14-node-type-status.patch queued for re-testing.
Comment #17
tstoeckler+ $this->assertTrue(isset($types['book']) && empty($types['book']->disabled), t("Book module's node type disabled."));The assert message should be "Book module's node type still active."
+ // Re-enabe the modules and verify that the types are active again.Typo: Re-enabe -> Re-enable
Also thanks @Damien Tournoud for seeing the simple (and correct solution) over the complicated one :)
This is a critical, and the only problems I found are trivial documentation typos. Otherwise the code looks good, is a much better fix than the previous patches, and the tests prove it works (and, well, it comes with tests). This is RTBC for me, but I'll let this get another review first.
Comment #21
carlos8f commentedThanks for catching those typos.
Comment #22
tstoecklerThanks. Looks great! Setting 0.5 RTBC.
Comment #23
agentrickardPatch looks good. Tests are clean.
Comment #24
webchickOh boy! 2-line critical bug fixes with 30 lines of tests. My favourite! :D
Committed to HEAD. Thanks!
Comment #26
pillarsdotnet commentedMarked #943588: node_type_delete(): hook_node_type_delete will fail for a disabled node_type. Trying to get property of non-object in hook_node_type_delete() as a duplicate of this issue.