Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

388: Fix project path during upgrade #410

Merged
merged 6 commits into from Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion glotpress.php
Expand Up @@ -27,7 +27,7 @@
*/

define( 'GP_VERSION', '2.1.0-alpha' );
define( 'GP_DB_VERSION', '940' );
define( 'GP_DB_VERSION', '950' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

940 was a SVN revision, should we change the version to a date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered where the number came from.

Either just an incrementing number (I chose ten, but any increment would do) or date.

Date is kind of ugly and does limit us to once change a day 😉.

define( 'GP_ROUTING', true );
define( 'GP_PLUGIN_FILE', __FILE__ );
define( 'GP_PATH', dirname( __FILE__ ) . '/' );
Expand Down
25 changes: 24 additions & 1 deletion gp-includes/install-upgrade.php
@@ -1,5 +1,16 @@
<?php
/**
* Install/Upgrade routines for the database.
*
* @package GlotPress
* @since 1.0.0
*/

/**
* Runs the install/upgrade of the database.
*
* @since 1.0.0
*/
function gp_upgrade_db() {
global $wpdb;

Expand All @@ -10,9 +21,21 @@ function gp_upgrade_db() {
update_option( 'gp_db_version', GP_DB_VERSION );
}

/**
* Updates existing data in the database during an upgrade.
*
* @since 1.0.0
*
* @param int $db_version The current version of the database before the upgrade.
*/
function gp_upgrade_data( $db_version ) {
global $wpdb;

if ( $db_version < 190 ) {
$wpdb->query("UPDATE $wpdb->gp_translations SET status = REPLACE(REPLACE(status, '-', ''), '+', '');");
$wpdb->query( "UPDATE {$wpdb->gp_translations} SET status = REPLACE(REPLACE(status, '-', ''), '+', '');" );
}

if ( $db_version < 950 ) {
$wpdb->query( "UPDATE {$wpdb->gp_projects} SET `path` = SUBSTRING(`path`, 1, CHAR_LENGTH(`path`) - 1) WHERE `path` LIKE '%/';" );
}
}
2 changes: 1 addition & 1 deletion gp-includes/schema.php
Expand Up @@ -92,7 +92,7 @@ function gp_schema_get() {
priority TINYINT NOT NULL DEFAULT 0,
date_added DATETIME DEFAULT NULL,
PRIMARY KEY (id),
KEY project_id_status (project_id, status),
KEY project_id_status (project_id,status),
KEY singular_plural_context (singular(63),plural(63),context(63))
) $charset_collate;";

Expand Down