| @@ -73,21 +73,11 @@ | ||
| 73 | 73 | * |
| 74 | 74 | * @var bool |
| 75 | 75 | * @since 0.0.1 |
| 76 | 76 | */ |
| 77 | - protected $db_upgradable; | |
| 77 | + private $db_upgradable; | |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * Previously stored version of this table before the current upgrade | |
| 81 | - * (0 when the table had no recorded version yet). Exposed so child classes | |
| 82 | - * can gate one-time data migrations in run_data_migrations(). | |
| 83 | - * | |
| 84 | - * @var int | |
| 85 | - * @since 1.3.0 | |
| 86 | - */ | |
| 87 | - protected $prev_version = 0; | |
| 88 | - | |
| 89 | - /** | |
| 90 | 80 | * Current table database result caches. |
| 91 | 81 | * |
| 92 | 82 | * @var array<mixed> |
| 93 | 83 | * @since 0.0.1 |
| @@ -146,18 +136,8 @@ | ||
| 146 | 136 | return []; |
| 147 | 137 | } |
| 148 | 138 | |
| 149 | 139 | /** |
| 150 | - * Run one-time data migrations for this table after its columns are in | |
| 151 | - * place. Called only while the table is upgradable (see register.php). | |
| 152 | - * No-op by default; override in a child class and gate on $this->prev_version. | |
| 153 | - * | |
| 154 | - * @return void | |
| 155 | - * @since 1.3.0 | |
| 156 | - */ | |
| 157 | - public function run_data_migrations() {} | |
| 158 | - | |
| 159 | - /** | |
| 160 | 140 | * Start the database upgrade process. |
| 161 | 141 | * |
| 162 | 142 | * @return void |
| 163 | 143 | * @since 0.0.1 |
| @@ -166,10 +146,8 @@ | ||
| 166 | 146 | $versions = Helper::get_suredonation_option( self::VERSION_OPTION_KEY, [] ); |
| 167 | 147 | $versions = is_array( $versions ) ? $versions : []; |
| 168 | 148 | $prev_version = ! empty( $versions[ $this->table_suffix ] ) ? absint( $versions[ $this->table_suffix ] ) : false; |
| 169 | 149 | |
| 170 | - $this->prev_version = $prev_version ? (int) $prev_version : 0; | |
| 171 | - | |
| 172 | 150 | if ( ! $prev_version ) { |
| 173 | 151 | $this->db_upgradable = true; |
| 174 | 152 | return; |
| 175 | 153 | } |
| @@ -262,13 +240,8 @@ | ||
| 262 | 240 | // the interpolated column-definition string, turning literal `DEFAULT ''` |
| 263 | 241 | // into `DEFAULT \'\'`, which MySQL rejects with a syntax error. The |
| 264 | 242 | // table name, column list, and charset are all hardcoded DDL (not user |
| 265 | 243 | // input), so direct concatenation is safe. |
| 266 | - // | |
| 267 | - // Column definitions must quote string literals with single quotes. | |
| 268 | - // wpdb strips the composite `ANSI` sql_mode on connect but not a | |
| 269 | - // standalone `ANSI_QUOTES`, under which `DEFAULT ""` parses as an empty | |
| 270 | - // identifier and fails the statement permanently on every retry. | |
| 271 | 244 | $query = sprintf( |
| 272 | 245 | 'CREATE TABLE IF NOT EXISTS `%s` ( %s ) %s', |
| 273 | 246 | esc_sql( $this->get_tablename() ), |
| 274 | 247 | $columns_list, |