PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / config / migrations / 20260325155530_CreateExpiringStoreTable.php

20260325155530_CreateExpiringStoreTable.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/config/migrations/20260325155530_CreateExpiringStoreTable.php

75 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Config\Migrations;
4
5 use Yoast\WP\Lib\Migrations\Migration;
6
7 /**
8 * CreateExpiringStoreTable class.
9 *
10 * Creates a network-wide table for reliable temporary storage with expiration.
11 */
12 class CreateExpiringStoreTable extends Migration {
13
14 /**
15 * The plugin this migration belongs to.
16 *
17 * @var string
18 */
19 public static $plugin = 'free';
20
21 /**
22 * Migration up.
23 *
24 * @return void
25 */
26 public function up() {
27 $table_name = $this->get_table_name();
28 $adapter = $this->get_adapter();
29
30 if ( ! $adapter->table_exists( $table_name ) ) {
31 $table = $this->create_table( $table_name, [ 'id' => false ] );
32
33 $table->column(
34 'key_name',
35 'string',
36 [
37 'limit' => 255,
38 'null' => false,
39 'primary_key' => true,
40 ],
41 );
42
43 $table->column( 'value', 'text', [ 'null' => false ] );
44
45 $table->column( 'exp', 'datetime', [ 'null' => false ] );
46
47 $table->finish();
48
49 $this->add_index( $table_name, 'exp', [ 'name' => 'exp_index' ] );
50 }
51 }
52
53 /**
54 * Migration down.
55 *
56 * @return void
57 */
58 public function down() {
59 $this->drop_table( $this->get_table_name() );
60 }
61
62 /**
63 * Retrieves the table name to use.
64 *
65 * Uses base_prefix so the table is shared across the entire multisite network.
66 *
67 * @return string The table name to use.
68 */
69 protected function get_table_name() {
70 global $wpdb;
71
72 return $wpdb->base_prefix . 'yoast_expiring_store';
73 }
74 }
75