Merged in feature/314-dev-dev01 (pull request #24)

auto-patch  314-dev-dev01-2024-01-25T04_09_02

* auto-patch  314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
Tony Volpe
2024-01-25 04:11:47 +00:00
parent 6b67473553
commit 68dbe860e9
540 changed files with 3445 additions and 2131 deletions

View File

@@ -125,6 +125,8 @@ class Adapter {
/**
* Create the schema table, if necessary.
*
* @return void
*/
public function create_schema_version_table() {
if ( ! $this->has_table( $this->get_schema_version_table_name() ) ) {
@@ -137,6 +139,8 @@ class Adapter {
/**
* Starts a transaction.
*
* @return void
*/
public function start_transaction() {
if ( $this->in_transaction() === false ) {
@@ -146,6 +150,8 @@ class Adapter {
/**
* Commits a transaction.
*
* @return void
*/
public function commit_transaction() {
if ( $this->in_transaction() ) {
@@ -155,6 +161,8 @@ class Adapter {
/**
* Rollbacks a transaction.
*
* @return void
*/
public function rollback_transaction() {
if ( $this->in_transaction() ) {
@@ -293,7 +301,7 @@ class Adapter {
$query_type = $this->determine_query_type( $query );
$data = [];
if ( $query_type === Constants::SQL_SELECT || $query_type === Constants::SQL_SHOW ) {
$data = $wpdb->get_results( $query, ARRAY_A );
$data = $wpdb->get_results( $query, \ARRAY_A );
if ( $data === false ) {
return false;
}
@@ -794,10 +802,8 @@ class Adapter {
$column_type_sql .= \sprintf( '(%d)', $precision );
}
}
else {
if ( $scale ) {
throw new Exception( "Error adding $type column: precision cannot be empty if scale is specified" );
}
elseif ( $scale ) {
throw new Exception( "Error adding $type column: precision cannot be empty if scale is specified" );
}
}
elseif ( $type === 'enum' ) {

View File

@@ -7,16 +7,16 @@ namespace Yoast\WP\Lib\Migrations;
*/
class Constants {
const MYSQL_MAX_IDENTIFIER_LENGTH = 64;
const SQL_UNKNOWN_QUERY_TYPE = 1;
const SQL_SELECT = 2;
const SQL_INSERT = 4;
const SQL_UPDATE = 8;
const SQL_DELETE = 16;
const SQL_ALTER = 32;
const SQL_DROP = 64;
const SQL_CREATE = 128;
const SQL_SHOW = 256;
const SQL_RENAME = 512;
const SQL_SET = 1024;
public const MYSQL_MAX_IDENTIFIER_LENGTH = 64;
public const SQL_UNKNOWN_QUERY_TYPE = 1;
public const SQL_SELECT = 2;
public const SQL_INSERT = 4;
public const SQL_UPDATE = 8;
public const SQL_DELETE = 16;
public const SQL_ALTER = 32;
public const SQL_DROP = 64;
public const SQL_CREATE = 128;
public const SQL_SHOW = 256;
public const SQL_RENAME = 512;
public const SQL_SET = 1024;
}

View File

@@ -106,6 +106,8 @@ class Table {
* @param string $column_name The column name.
* @param string $type The column type.
* @param array $options The options.
*
* @return void
*/
public function column( $column_name, $type, $options = [] ) {
// If there is already a column by the same name then silently fail and continue.
@@ -136,6 +138,8 @@ class Table {
*
* @param string $created_column_name Created at column name.
* @param string $updated_column_name Updated at column name.
*
* @return void
*/
public function timestamps( $created_column_name = 'created_at', $updated_column_name = 'updated_at' ) {
$this->column( $created_column_name, 'datetime' );
@@ -186,13 +190,11 @@ class Table {
if ( \is_array( $this->options ) && \array_key_exists( 'options', $this->options ) ) {
$opt_str = $this->options['options'];
}
elseif ( isset( $this->adapter->db_info['charset'] ) ) {
$opt_str = ' DEFAULT CHARSET=' . $this->adapter->db_info['charset'];
}
else {
if ( isset( $this->adapter->db_info['charset'] ) ) {
$opt_str = ' DEFAULT CHARSET=' . $this->adapter->db_info['charset'];
}
else {
$opt_str = ' DEFAULT CHARSET=utf8';
}
$opt_str = ' DEFAULT CHARSET=utf8';
}
$close_sql = \sprintf( ') %s;', $opt_str );
$create_table_sql = $this->sql;
@@ -238,6 +240,8 @@ class Table {
*
* @param string $name The name.
* @param array $options The options.
*
* @return void
*/
private function init_sql( $name, $options ) {
// Are we forcing table creation? If so, drop it first.