When I installed the module both locally, and again on my server, it seemed to install fine, no errors. But when I went to the configure page, I see this:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cw_62303_foodhero.st_table' doesn't exist: SELECT st.st_option, st.st_value FROM {st_table} st; Array ( ) in get_options_array() (line 332 of /...../sites/all/modules/sharethis/sharethis.module).

On both sites, I had to uninstall the module (not just deactivate it, but also uninstall), then install it again, and it worked the second time. Weird?

CommentFileSizeAuthor
#10 variables.patch8.33 KBrobloach

Comments

robloach’s picture

Title: sharethis table not created on install » Get rid of ShareThis table and use Variables table instead
Version: 7.x-2.1 » 7.x-2.x-dev
Assigned: Unassigned » robloach

We don't really need a whole new table for this. The upgrade path should be supported though.

jvalencia’s picture

If you use the variables table though, there is the chance of namespace conflicts.

robloach’s picture

Not if we prefix the variables with "sharethis_" :-) .

jvalencia’s picture

What's the upgrade path then?

robloach’s picture

I'll upload a patch here for testing once I get some time to work on it.

jvalencia’s picture

Looking forward to it :-)

jvalencia’s picture

Thinking about it some more...
If we add some of the other widgets ShareThis uses to the module, we may add another dozen or so variables. Would we still want to put them in the variable table? Is there any benefit?

robloach’s picture

The variables table is loaded on each page load and heavily cached. Probably more performant to use that versus our own table which we have to query ourselves each time we want some settings.... Thoughts?

jvalencia’s picture

Just thinking for the future, perhaps I'll add the widgets in their own dependent modules like I did the block. Then we could use the variables table prefixed with each of the module names (ie sharethis_option, sharethis_bar_option, sharethis_block_option)

That should work?

robloach’s picture

Status: Active » Needs review
StatusFileSize
new8.33 KB

Yup! You have the right idea :-) . Here's a patch that switches from st_table over to the variables table. Mind testing it a little? Seems to work on my end... Make sure to run update.php to transition over your old values.

robloach’s picture

Status: Needs review » Fixed

I went through another thorough test of this and it was all good. I cleaned up the code a bit more and committed it. We could go even further than this and remove the _submit handler completely now... But that's for another issue: #1300526: Remove the Submit handler. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.