Hi there,
I am trying to install flag module into my drupal application. My database name is 'softconnectioninfo'. The moment I check the checkbox againt the flag module and try to install it by hitting the 'Save Configuration' button, the application throws this error message.
"PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'softconnectioninfo.flags' doesn't exist: SELECT f.fid AS fid, f.content_type AS content_type, f.name AS name, f.title AS title, f.global AS global, f.options AS options, fn.type AS type FROM {flags} f LEFT OUTER JOIN {flag_types} fn ON fn.fid = f.fid; Array ( ) in flag_get_flags() (line 1458 of C:\xampp\htdocs\softconnection\modules\flag\flag.module)."
I have tried to install it many times but the same issue persists.
Please suggest me a solution for this.
Thanks in anticipation
Comments
Comment #1
Guntas CreditAttribution: Guntas commentedCan somebody please help me with this
Comment #2
Guntas CreditAttribution: Guntas commentedplease help
Comment #3
quicksketchIt sounds like your database somehow has been put into a state where Flag module thinks its been installed (it still has an entry in the "system" database table) but the actual Flag database tables are missing. You can fix this by disabling the Flag module and then completely uninstalling it by visiting admin/modules/uninstall. The module must be disabled before it can be uninstalled. Then enable the module again and it will create all its tables from scratch.
Comment #5
mesr01 CreditAttribution: mesr01 commentedSame problem here. Plain impossible to install module. The table doesn't get created before it's used. The 'hook_install' function is empty... no dependency on Features... How is the table created?
Comment #6
quicksketchModules no longer need to have a hook_install() in D7. The contents of hook_schema() are automatically created when enabling any module. Considering thousands of sites use Flag module for D7, I'm certain that this module installs properly. I suggest following the steps in #3 above to completely uninstall and reinstall the module.
Comment #7
jhedstromI came across this issue on a recent site. I got the above errors when trying to install via drush, but installing through the UI worked just fine. Will post back if I find more.
Comment #8
Simon Georges CreditAttribution: Simon Georges commentedIt happens for example if by using an installation profile, you instantiate features with flag components used (for example in Views) in the .info file of the profile. (The same thing happens with Views containing Media, for example). Reference : #1311828: Installation fails with SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.media_type' doesn't exist.
Comment #9
joachim CreditAttribution: joachim commentedChanging back to support request.
If this is a bug in flag, please feel free to change it back, but only if you can provide clear and precise steps to reproduce the problem.
Comment #10
diwant CreditAttribution: diwant commented@simon_georges I see the same thing. Did you find a way around it?
Comment #11
Simon Georges CreditAttribution: Simon Georges commented@diwant, by changing the order of module installation, I managed to have everything working smoothly. Maybe updating to the last version of the module changed some things too...
Comment #12
vinoth.3v CreditAttribution: vinoth.3v commentedWhen Upgrading from D6 to D7 I got this error.
DB has flag table. No flags table.
Edit: Sorry, My error was because of another fbss_flag module.
Comment #13
joelpittetI had this issue and due to the errors I couldn't even get to the module admin page mentioned in #3 I worked around this by copying the schema from another site for the 4 flag tables to the messed up one and that allowed the page to load to disable and uninstall after that.
Hope that helps, here's the create syntax as well as of7.x-3.5:
Comment #14
joachim CreditAttribution: joachim commentedCan you explain how the normal install process failed to create the tables? Were there any error messages?
Also, did you try uninstalling Flag and reinstalling it? You can do that very easily using Devel module's menu.
These debugging steps would help us figure out if there is a problem that should be fixed in the module code!
Comment #15
joelpittetSo I just downloaded it (there may have been reminiscence of an old one but I don't remember installing it and this is a big commerce project), then went and clicked the flag and flag bookmark modules, and it just failed there or after the confirm message I think. Then because it was throwing that error I couldn't uninstall or disable it. So I had to copy the tables to stop the errors and then I could disable and uninstall. Now it's up an re-installed and working fine.
Likely leftover stuff though just not sure where from.
It borked drush commands and the entire site it seemed, so no devel module or drush command or cache clear seemed to let it get by that error message.
Comment #16
joachim CreditAttribution: joachim commented> there may have been reminiscence of an old one but I don't remember installing it and this is a big commerce project
That sounds like the potential problem. The tables have all changed between Flag 2 and Flag 3. If your system had previously had Flag 2 on it, and it wasn't properly uninstalled, then enabling Flag 3 would NOT create the tables.
Comment #17
joelpittetSorry can't be more help than that, just giving people a suggestion in passing with the same issue incase they get stuck. But if someone else sees this please do provide steps that lead to the error.
Comment #18
joachim CreditAttribution: joachim commentedWhat does your {system} table say for the flag module -- does it have a schema version? Also, do you have any {flag_FOO} tables that are not part of Flag 3 -- such as {flags} (plural) or {flag_content}? Those would both be definite signs that you previously had Flag 2 installed.
Comment #19
joelpittetI don't but I likely deleted them if I noticed them using the schema module (extra tables). I bet you're right though it may have been leftovers from 2.x
Comment #20
kevinquillen CreditAttribution: kevinquillen commentedFresh install of Flag, this is the error:
Error: Call to undefined function flag_get_flags() in /docroot/sites/default/modules/contrib/flag/flag.info.inc, line 19
Comment #21
joachim CreditAttribution: joachim commentedflag_get_flags() is defined in flag.module. If the module was properly installed, there's no way that's not loaded!
Comment #22
kevinquillen CreditAttribution: kevinquillen commentedI downloaded the module with Drush, and did
drush en -y flag
. It said it installed (v 7306). Then I cleared cache, and got that error.Comment #23
ak CreditAttribution: ak commentedFresh installation of 7.x-3.5 is broken for me as well.
Comment #24
joachim CreditAttribution: joachim commentedI can't reproduce this problem.
Here's what I did:
* installed Drupal core 7.28 from scratch
* enabled Flag 7.x-3.5
* cleared all caches at admin/config/development/performance
No error messages.
Comment #25
kevinquillen CreditAttribution: kevinquillen commentedI enabled it via Drush and not the UI if that makes a difference.
Comment #26
joachim CreditAttribution: joachim commentedIt shouldn't, but I can give that a try too.
Comment #27
nerdsteinNote the condition with db_table_exists...
Comment #28
joachim CreditAttribution: joachim commented> if(db_table_exists('flag')){
Why on earth would you need that? Installing the module creates that table.
Comment #29
nerdsteinThat is what breaks upon install when using drush. For some reason, it's being triggered before the tables are created. I know it seems surprising, but it works.
Comment #30
AnybodySame problem here when I install the latest flag version via Drush in a new Drupal 7.30 environment.
Comment #31
joachim CreditAttribution: joachim commentedConfirming I get this with Drush:
So the thing is that our entity info uses the {flag} table to define its entity bundles. But that's not unusual: profile2 and node do the same thing.
First thing to investigate therefore would be how Profile2 avoids this problem (or even, does it?!) if anyone cares to do some investigating.
Comment #32
joachim CreditAttribution: joachim commentedHad a look at Profile2's code. It's exactly the same as ours in this respect:
- hook_schema() defines a table that holds data that defines bundles
- hook_entity_info() queries this table to declare the bundles
Just tried this again and I can't reproduce it now.
Could this be related to upgrading from older versions of Flag?
Comment #33
kip stanning CreditAttribution: kip stanning commentedi had the same problem. had to repeat the advice given above several times. one problem that had to be solved was that drush stopped completely to run after it threw that error message about the flag table not being found and the site just delivered a WSOD, so the already enabled module could not be disabled. i removed the flag folder from sites/all/modules, i went to the database and deleted the flag tables and thanks to @quickscetch #3 also visited the system table to delete all entries where filename contained the string "flag". what possibly also helped was usind drush registry_rebuild as suggested (in other circumstances) by @eosrei here: https://www.drupal.org/node/2161847#comment-8552543
great thing to have you around, guys! thank you!
Comment #34
kevinquillen CreditAttribution: kevinquillen commentedPossibly a residual effect, yes. I get in this bind now and then, registry rebuild gets me out of it.
Comment #35
joachim CreditAttribution: joachim commentedA *registry* rebuild?
That's not the same problem as the OP then -- a registry rebuild lets Drupal know about classes, whereas the OP is about database tables.
Comment #36
JMC CreditAttribution: JMC commentedI have just experienced this exact error (through the UI, I didn't try it via drush) and I tried a few things before finding that installing Flag 2.2 first and then Flag 3.6 worked.
For what it's worth, here are some details in case it gives any hints as to the cause:
Given that 3.6 installs fine on a clean Drupal install I'm not sure what the difference was with my old site, but hopefully this should be a workaround for some people in the same situation.