Steps to reproduce this bug:
All site's modules enabled at once (well except overlay... and test modules...)
Disable forum module.
Unistall forum module.
Enable back again forum module.
I get this error page:
----------------------------------------------------------------------------------------
Error
FieldException: Attempt to create field name <em class="placeholder">taxonomy_forums</em> which already exists, although it is inactive. in field_create_field() (line 258 of /home/goargoli/domains/el-drupal7.dyndns.org/public_html/modules/field/field.crud.inc).
The website encountered an unexpected error. Please try again later.
---------------------------------------------------------------------------------------
After this error i refresh the modules page and the forum module seems istalled but there is no forum in my site.
This error breaks site baddly, i re-isntalled drupal 7 alpha 5 again (deleted all tables in db, deleted all folders, completely clean install).
The strange is that this behaviour is not standard. The second time i reinstalled drupal i run the same steps and nothing happened, although when i unistalled taxonomy module, (after unistalling forum module) and trying to install forum module again, and after the message "You have to enable taxonomy module to enable forum module ...... Do you want to continue ? " i get the same above error page.
Comment | File | Size | Author |
---|---|---|---|
#39 | 821290_39_forum_taxonomy.patch | 4.5 KB | scor |
#36 | 821290_35_forum_taxonomy.patch | 4.49 KB | scor |
#31 | forum_enable_errors.patch | 2.39 KB | marcingy |
#29 | forum_enable_errors.patch | 2.92 KB | marcingy |
#28 | forum_enable_errors.patch | 2.94 KB | marcingy |
Comments
Comment #1
marcvangendMarking this as a 7.x-dev version to make sure it shows up on the "Critical issues" page as defined in the "Contributor links" block. Can you please check if this problem persists in the latest HEAD version?
Comment #2
FanisTsiros CreditAttribution: FanisTsiros commentedOh, yes this is not for HEAD. It's for alpha5
I'll check this later today. Thanks.
Comment #3
FanisTsiros CreditAttribution: FanisTsiros commentedConfirming this is for HEAD also.
New dev install - fresh db - fresh files, directories
Site with no content
Al core (and only core) modules enabled (except testing module)
Steps:
Disable Forum module.
Disable Taxonomy module.
Unistall both (taxonomy and forum)
Trying to install Forum (without enabling taxonomy) and going through confirmation message that you have to enable taxonomy module first, press Continue and the error message is there again.
I have to mention this is not true for all other combinations: disable one module at a time, unistall both, enable taxonomy module first, then enable forum module after taxonomy module is enabled.
Comment #4
catchUntested patch.
Comment #5
catchDidn't mean to change module.
Comment #6
ronald_istos CreditAttribution: ronald_istos commentedChecked the patch - fixes the problem by checking whether the appropriate field exists not through a hard coded name but actually the right machine name based on what vocabulary the install process just created and does all the right things in the uninstall phase too
Comment #7
ronald_istos CreditAttribution: ronald_istos commentedSorry, had another look and changed it back to needs review purely because ideally the comment on line 43 should be
//Create the appropriate field for forums if it doesn't already exist
rather than
// Create the 'taxonomy_forums' field if it doesn't already exist.
which is probably what caused the problem to start with...
Comment #8
ronald_istos CreditAttribution: ronald_istos commentedand here is the patch with the comment adjusted as well (everything else remains the same)
Comment #9
catchLooks fine, my patch so I won't re-RTBC.
Looking at this, I think forum module should create a single 'forum' field regardless of vocabulary, but that's a bigger change for a followup, if at all for D7.
Comment #10
FanisTsiros CreditAttribution: FanisTsiros commentedOK patch #8 applied, the problem was there again. After clearing cache, though, everything works fine for all possible combinations.
But, was really required to clear cache ?
Could someone else please review also ?
Thanks!
Comment #11
aspilicious CreditAttribution: aspilicious commentedTested this with the steps described above.
Before patch: error
After patch: works
==> RTBC
Comment #12
YesCT CreditAttribution: YesCT commentedextra space
Powered by Dreditor.
Comment #13
aspilicious CreditAttribution: aspilicious commentedDamn, missed that one...
Luckily YesCT has better eyes ;)
I rerolled, still rtbc till bot says no.
Comment #14
YesCT CreditAttribution: YesCT commenteddreditor has better eyes. :) And I felt a bit silly for marking it needs work...
Comment #15
aspilicious CreditAttribution: aspilicious commentedGreat job :). It needed work.
Comment #17
aspilicious CreditAttribution: aspilicious commentedNot my day :(
Comment #18
YesCT CreditAttribution: YesCT commentedwhy is this taxonomy and forums specific dependent?
will there be other combinations that will have a similar problem?
Comment #19
catchYes, but those modules also need to add a field_delete_field() on uninstall.
Comment #20
cross CreditAttribution: cross commentedNot sure if it related to this issue, but while testing this patch i get this.
Step to reproduce.
Install fresh D7. All settings by default.
Disable and then uninstall taxonomy.
Enable forum module and step forward confirmation about taxonomy. Feel good that there is no error and patch seems to be working.
Disable forum and taxonomy again. Uninstall it. After you confirm last step of uninstall form you get error as above.
Comment #21
kcybulski CreditAttribution: kcybulski commentedConfirmed
Comment #22
danilo_04 CreditAttribution: danilo_04 commentedYes, I had the same error.
The problem comes from the line $vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary'));
Taxonomy_vocabulary_load call the function "entity_get_info", which look for the taxonomy entity. But if the taxonomy module is already disable, then the entity doesn't exists in cache. A rapid solution would be find the vocabulary id in the database with db_query:
$query = "SELECT machine_name FROM {taxonomy_vocabulary} WHERE vid = :vid";
$result = db_query($query, array(':vid' => variable_get('forum_nav_vocabulary')));
$vocabulary = $result->fetchObject();
Comment #23
DevElCuy CreditAttribution: DevElCuy commentedPatch should include a test
Comment #24
cwgordon7 CreditAttribution: cwgordon7 commentedI've had a lot of trouble reproducing either error (either following the steps in the original issue or in #20). Is it possible that this error has been fixed in the past 10 days or so?
Comment #25
marcingy CreditAttribution: marcingy commentedFollowing the steps here http://drupal.org/node/821290#comment-3062766 I can recreate the problem on current head.
Comment #26
webchickSorry, an edge case such as this doesn't get critical status. Keep working on a fix, though!
Comment #27
catchVocabularies using the entity loader/hook_entity_info() is turning out to be more trouble than it was worth. #22 is the right fix until we have some way to reduce the interdependencies.
Comment #28
marcingy CreditAttribution: marcingy commentedThe problem is being caused is 2 fold
* The field creation code is being called because _field_info_collate_fields is not caching inactive fields although it is caching deleting fields this is generating the original error message
* However even when the above problem is solved we have a second problem as modules_enabled is being called we have the value forum whereas the field is associated with taxonomy hence the field is left inactive.
Have taken some code from #17 and and tweaked it a little to sort out the first part of issue and have also attempted to resolve the second problem and ensure we always have a working instance bundle on forums.
Comment #29
marcingy CreditAttribution: marcingy commentedReworking of patch to prevent errors when modules are enabled in certain order and incorrect signature for function call.
Comment #30
marcingy CreditAttribution: marcingy commentedPutting back to needs work as the more I think about it the need to explicitly enable is wrong. Will dig some more later.
Comment #31
marcingy CreditAttribution: marcingy commentedThe issue is caused by the following process occuring
* Taxonomy module is install first and enabled correctly but its field isn't enabled as part of the enabling process
* Forum then tries to perform operations on a field that is still inactive
* The field would then be made active when modules_enabled is invoked later in the install process of course by then it is too late.
There seems to be 4 options
* Move when modules_enabled is invoked however this seems to be a finalise process so doesn't seem to be option
* Add a call to associate fields as part of the individual install process and just clear the cache modules_enabled()
* Add a hook_enable to the taxonomy module
* Call field_associate_fields in forum_enable and add comments to explain why on earth it is happening.
Patch attached for option 4, although option 2 looks like it might be a more robust solution but I don't know enough about the impact such a change might have on the field_api.
Comment #32
marcingy CreditAttribution: marcingy commentedComment #33
catchMoving this to field system, I like the look of option #2 but I'm also not sure what the impact would be.
Comment #34
RoSk0#31: forum_enable_errors.patch queued for re-testing.
Comment #35
ksenzee#882364: re-enabling Forum module after disabling Taxonomy module causes an exception because Forum thinks taxonomy_forum is inactive was filed as a dupe of this issue. Over there I figured out the same thing that marcingy points out here: The root cause of this is that hook_modules_enabled() doesn't work as you might expect it to: #727876: Enabling modules one at a time works differently than enabling them all at once
And webchick, I'm moving this back to critical pending your reading this paragraph. You don't have to uninstall anything to cause this. All you have to do is disable taxonomy and
enable forum(edit: re-enable forum), and whoops! you get an exception. And who knows what state your site is in at that point, with forum module half-installed. I don't think it's an edge case if just enabling and disabling core modules throws up exceptions all over the place. If my impassioned plea falls on deaf ears, then by all means bump it back down. I won't cry. Much.Comment #36
scor CreditAttribution: scor commentedksenzee's right, no need to uninstall any module to trigger this bug on a fresh Drupal 7 install:
- enable forum
- disable forum
- disable taxonomy
- enable forum again and hit continue to the question "You must enable the Taxonomy module to install Forum."
#727876: Enabling modules one at a time works differently than enabling them all at once might be the "right" way to prevent this which seems like the right way to solve any similar issue but this issue might not get solved quicly, and we have a working patch here. I wrote a test for it. I would have RTBC'ed this but I'd like someone to review the test I added.
Comment #37
tloudon CreditAttribution: tloudon commentedi reviewed this in the GUI and ran the tests locally--looks good to me.
Comment #38
Dries CreditAttribution: Dries commented- Typo in documentation: should be field_associate_fields instead of field_associate_field.
- Read the PHPdoc of field_associate_fields() and couldn't really tell what it was about (see http://api.drupal.org/api/function/field_associate_fields/7). We can fix that in another issue though.
Powered by Dreditor.
Comment #39
scor CreditAttribution: scor commentedTypo fixed!
Comment #40
moshe weitzman CreditAttribution: moshe weitzman commentedComment #41
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks. Another one down.