Opened 10 years ago
Closed 10 years ago
#5563 closed defect (bug) (fixed)
wp_signups table upgrade problem
Reported by: | Denis-de-Bernardy | Owned by: | |
---|---|---|---|
Milestone: | 2.0.1 | Priority: | highest |
Severity: | major | Version: | 2.0 |
Component: | New User Experience | Keywords: | has-patch |
Cc: |
Description
Any odds that this WP ticket might be related to BP?
https://core.trac.wordpress.org/ticket/27855
WordPress database error: [Incorrect table definition; there can be only one auto column and it must be defined as a key] ALTER TABLE wp_signups ADD COLUMN signup_id bigint(20) NOT NULL auto_increment
Attachments (6)
Change History (34)
#1
@
10 years ago
- Component changed from Core to Update/Install
- Summary changed from Possible BP bug during WP upgrades to wp_signups table upgrade problem
#4
@
10 years ago
- Keywords has-patch added
Thanks for getting to this before I was able to, JJJ.
Using r8302 still caused the DB error that Denis-de-Bernardy posted.
02.patch gets rid of these errors.
- I made some changes to
bp_core_maybe_upgrade_signups()
to check to see if thesignup_id
column exists in thewp_signups
table. If it doesn't exist, then we proceed with upgrading the signups table.
- We also need to upgrade the signups table before installing the signups table for cases where Gravity Forms already created the table.
I was able to test on a fresh install of WP, then activating Gravity Forms / Gravity Forms User Registration, then activating BP trunk and the DB errors are gone.
One last test I want to do is on a BP 2.0 install that still has this bug and then upgrading to trunk to see the errors are gone.
#6
@
10 years ago
How can you upgrade the signup table if you haven't created it yet?
Let's say Gravity Forms created the table first with the older schema and we run bp_core_install_signups() without upgrading / altering the wp_signups
table.
bp_core_install_signups() uses dbDelta() and dbDelta() doesn't like the discrepancies between these two different schemas and will cause the DB error above.
#7
@
10 years ago
Hi,
Just noticed after updating trunk & testing an upgrade i had this Database error :
WordPress database error: [Duplicate column name 'signup_id'] ALTER TABLE wp_signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST WordPress database error: [Can't DROP 'domain'; check that column/key exists] ALTER TABLE wp_signups DROP INDEX domain
#8
@
10 years ago
Hi imath, that's what I encountered myself.
02.patch should fix this.
If you have a backup, revert to it, then apply 02.patch and redo the upgrade and see if that fixes the issue.
#13
@
10 years ago
- Keywords 2nd-opinion added; has-patch removed
- Priority changed from normal to highest
- Severity changed from normal to major
Tested same as Ray above, and now appears fixed.
Ray, able to test and report back?
#14
@
10 years ago
- Keywords has-patch added
Almost there! Got these errors when upgrading from an existing BP 2.0 install with the wp_signups problem:
WordPress database error Duplicate column name 'signup_id' for query ALTER TABLE wp_signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST WordPress database error Can't DROP 'domain'; check that column/key exists for query ALTER TABLE wp_signups DROP INDEX domain
04.patch
should fix this.
#15
@
10 years ago
I don't understand how that patch fixes those database errors. Looks to me like those errors weren't because of that code at all. Care to elaborate, or clear your error log and try again?
#16
follow-up:
↓ 17
@
10 years ago
I don't understand how that patch fixes those database errors. Looks to me like those errors weren't because of that code at all. Care to elaborate, or clear your error log and try again?
$wpdb->signups
is not defined in those exists()
functions so the check will return false. What happens then is the upgrade or install scripts will attempt to do their thang causing the DB errors.
#17
in reply to:
↑ 16
@
10 years ago
Replying to r-a-y:
$wpdb->signups
is not defined in thoseexists()
functions so the check will return false. What happens then is the upgrade or install scripts will attempt to do their thang causing the DB errors.
These two empty checks are inverse. If $wpdb->signups
is already defined in bp_core_signups_table_exists()
then we know for sure the table exists so return true (without the additional database query). If it's not defined in bp_core_signups_id_column_exists()
then we know the column does not exist so return false (without the additional database query).
Seems like that's the intended sequence? Why would we want to remove those checks, and accidentally check for a column in a table that might not exist?
Would it be easier to suppress the errors inside bp_core_upgrade_signups()
also? Does the existing code even work for you at all in terms of updating the signups table from the old version to the new?
I'm still fuzzy on how bp_core_upgrade_signups()
is being ran if the column already exists; that's the only way those error messages would occur. Is bp_core_signups_id_column_exists()
broken?
#18
@
10 years ago
If $wpdb->signups is already defined in bp_core_signups_table_exists() then we know for sure the table exists so return true (without the additional database query).
The problem is $wpdb->signups
is not defined in bp_core_signups_table_exists()
. It doesn't exist on single-site for me where I've done my testing.
However, a check is done for $wpdb->signups
in bp_core_signups_id_column_exists()
. This is where the function is failing since $wpdb->signups
doesn't exist.
05.patch
is a more, accurate fix for this issue.
#19
@
10 years ago
I still don't think this solves the problem correctly. We should not be forcing $wpdb->signups
since all we're doing is checking if the signups table is already installed, not necessarily installing it (at least not at this point.)
#20
@
10 years ago
To be clear, $wpdb->signups
is only defined if it doesn't exist. 05.patch
defines it after $wpdb->signups
doesn't exist.
See line 464 where bp_core_signups_table_exists()
bails if $wpdb->signups
exists:
https://buddypress.trac.wordpress.org/browser/trunk/bp-core/bp-core-update.php#L462
If the issue is with defining $wpdb->signups, we can code around this with a direct $wpdb->base_prefix . 'signups'
in both exists() functions.
#21
@
10 years ago
06 removes the helper functions, since they would need to return a few different values depending on the current state of the signups table. Instead, let's suppress errors before and after, and always query for the existence of the table, and of the column to check for updates.
Thoughts?
#24
follow-up:
↓ 25
@
10 years ago
- Keywords 2nd-opinion removed
- Resolution set to fixed
- Status changed from new to closed
Thoughts?
I always prefer simplification :) Just tested and we're good to go! Marking this one as fixed.
#25
in reply to:
↑ 24
@
10 years ago
Replying to r-a-y:
I always prefer simplification :) Just tested and we're good to go! Marking this one as fixed.
Thanks for your help!
This ticket was mentioned in IRC in #buddypress-dev by imathfromparis. View the logs.
10 years ago
#27
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Hi,
I am trying to appy this patch. I have tried through ssh on the server and I have also tried also looking through the target file (I assume bp-core-update.php) and trying to do it manually. However the line numbers do not seem to correspond to the original file and some of the non-changed content is different. I have the most up to date version of BP.
I admittedly have never applied a patch but some guidance from you guys would be great becasue I can't seem to figure it out. When I used patch on it I got an error:
2 out of 2 hunks FAILED -- saving rejects to file bp-core-update.php.rej
Thanks!
#28
@
10 years ago
- Resolution set to fixed
- Status changed from reopened to closed
justsayno1 - You need to apply the changesets marked with 2.0-branch: r8309, r8311, r8312.
Or you can download the latest 2.0-branch of BuddyPress:
https://buddypress.trac.wordpress.org/changeset/8325/branches/2.0?old_path=%2F&format=zip
Please do not reopen tickets unless you have verified that the problem still persists.
This is an edge case conflict with the Gravity Forms User Registration plugin.
They also create their own
wp_signups
table to address issues with single-site registration. However, they did not add in the changes that were made to the DB schema in WP 3.7:https://core.trac.wordpress.org/changeset/25179
Looks like we'll need to run WP's upgrade script ourselves.
In particular, adding in the query additions that are in upgrade.php from that changeset to our upgrader if the
wp_signups
table already exists.