Commit 90d6fc33 authored by KR Moorhouse's avatar KR Moorhouse Committed by Eric Windham

Issue#3740

parent bc596466
......@@ -141,8 +141,10 @@ abstract class NF_Abstracts_RequiredUpdate
if ( ! $this->debug ) {
// Run the query.
return $this->db->query( $sql );
}
// Otherwise, return false.
} // Otherwise...
// Append the query to the response object.
$this->response[ 'queries' ][] = $sql;
// Return false.
return false;
}
}
\ No newline at end of file
......@@ -17,11 +17,11 @@ return apply_filters( 'ninja_forms_required_updates', array(
'requires' => array( 'CacheCollateActions' ),
'nicename' => __( 'Update Fields Tables', 'ninja-forms' ),
),
// 'CacheCollateObjects' => array(
// 'class_name' => 'NF_Updates_CacheCollateObjects',
// 'requires' => array( 'CacheCollateForms' ),
// 'nicename' => __( 'Update Objects Tables', 'ninja-forms' ),
// ),
'CacheCollateObjects' => array(
'class_name' => 'NF_Updates_CacheCollateObjects',
'requires' => array( 'CacheCollateFields' ),
'nicename' => __( 'Update Objects Tables', 'ninja-forms' ),
),
// 'OrphanSubs' => array(
// 'class_name' => 'NF_Updates_OrphanSubs',
// 'requires' => array( 'CacheCollateFields' ),
......
......@@ -2,6 +2,11 @@
class NF_Database_Migrations_ObjectMeta extends NF_Abstracts_Migration
{
/**
* Constructor method for the NF_Database_Migrations_ObjectMeta class.
*
* @since 3.0.0
*/
public function __construct()
{
parent::__construct(
......@@ -10,6 +15,13 @@ class NF_Database_Migrations_ObjectMeta extends NF_Abstracts_Migration
);
}
/**
* Function to run our initial migration.
*
* @since 3.0.0
*
* @updated UPDATE_VERSION_ON_MERGE
*/
public function run()
{
$query = "CREATE TABLE IF NOT EXISTS {$this->table_name()} (
......@@ -17,10 +29,30 @@ class NF_Database_Migrations_ObjectMeta extends NF_Abstracts_Migration
`parent_id` int NOT NULL,
`key` longtext NOT NULL,
`value` longtext,
`meta_key` longtext,
`meta_value` longtext,
UNIQUE KEY (`id`)
) {$this->charset_collate( true )};";
dbDelta( $query );
}
/**
* Function to ensure proper collation of the object_meta table.
*
* @since UPDATE_VERSION_ON_MERGE
*/
public function cache_collate_objects()
{
// If the meta_key column has not already been defined...
if ( ! $this->column_exists( 'meta_key' ) ) {
global $wpdb;
// Modify our table.
$query = "ALTER TABLE {$this->table_name()}
ADD `meta_key` longtext {$this->charset_collate()},
ADD `meta_value` longtext {$this->charset_collate()};";
$wpdb->query( $query );
}
}
}
......@@ -2,6 +2,11 @@
class NF_Database_Migrations_Objects extends NF_Abstracts_Migration
{
/**
* Constructor method for the NF_Database_Migrations_Objects class.
*
* @since 3.0.0
*/
public function __construct()
{
parent::__construct(
......@@ -10,6 +15,13 @@ class NF_Database_Migrations_Objects extends NF_Abstracts_Migration
);
}
/**
* Function to run our initial migration.
*
* @since 3.0.0
*
* @updated UPDATE_VERSION_ON_MERGE
*/
public function run()
{
$query = "CREATE TABLE IF NOT EXISTS {$this->table_name()} (
......@@ -18,10 +30,29 @@ class NF_Database_Migrations_Objects extends NF_Abstracts_Migration
`title` longtext,
`created_at` TIMESTAMP,
`updated_at` DATETIME,
`object_title` longtext,
UNIQUE KEY (`id`)
) {$this->charset_collate( true )};";
dbDelta( $query );
}
/**
* Function to ensure proper collation of the objects table.
*
* @since UPDATE_VERSION_ON_MERGE
*/
public function cache_collate_objects()
{
// If the object_title column has not already been defined...
if ( ! $this->column_exists( 'object_title' ) ) {
global $wpdb;
// Modify our table.
$query = "ALTER TABLE {$this->table_name()}
ADD `object_title` longtext {$this->charset_collate()},
MODIFY `type` longtext {$this->charset_collate()};";
$wpdb->query( $query );
}
}
}
......@@ -2,6 +2,11 @@
class NF_Database_Migrations_Relationships extends NF_Abstracts_Migration
{
/**
* Constructor method for the NF_Database_Migrations_Relationships class.
*
* @since 3.0.0
*/
public function __construct()
{
parent::__construct(
......@@ -10,6 +15,11 @@ class NF_Database_Migrations_Relationships extends NF_Abstracts_Migration
);
}
/**
* Function to run our initial migration.
*
* @since 3.0.0
*/
public function run()
{
$query = "CREATE TABLE IF NOT EXISTS {$this->table_name()} (
......@@ -26,4 +36,19 @@ class NF_Database_Migrations_Relationships extends NF_Abstracts_Migration
dbDelta( $query );
}
/**
* Function to ensure proper collation of the relationships table.
*
* @since UPDATE_VERSION_ON_MERGE
*/
public function cache_collate_objects()
{
global $wpdb;
// Modify our table.
$query = "ALTER TABLE {$this->table_name()}
MODIFY `child_type` longtext {$this->charset_collate()} NOT NULL,
MODIFY `parent_type` longtext {$this->charset_collate()} NOT NULL;";
$wpdb->query( $query );
}
}
......@@ -686,20 +686,20 @@ class NF_Updates_CacheCollateFields extends NF_Abstracts_RequiredUpdate
$this->form[ 'submission_updates' ] = $this->submission_updates;
array_push( $this->running[ 0 ][ 'forms' ], $this->form );
} else { // Otherwise... (The step is complete.)
// If all steps have been completed...
if ( empty( $this->running[ 0 ][ 'forms' ] ) ) {
// Run our cleanup method.
$this->cleanup();
} else {
// Increment our step count.
$this->running[ 0 ][ 'current' ] = intval( $this->running[ 0 ][ 'current' ] ) + 1;
}
// Increment our step count.
$this->running[ 0 ][ 'current' ] = intval( $this->running[ 0 ][ 'current' ] ) + 1;
}
// Prepare to output our number of steps and current step.
$this->response[ 'stepsTotal' ] = $this->running[ 0 ][ 'steps' ];
$this->response[ 'currentStep' ] = $this->running[ 0 ][ 'current' ];
// If all steps have been completed...
if ( empty( $this->running[ 0 ][ 'forms' ] ) ) {
// Run our cleanup method.
$this->cleanup();
}
// Record our current location in the process.
update_option( 'ninja_forms_doing_required_updates', $this->running );
// Prepare to output the number of updates remaining.
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment