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
← All changes | inc/class-upgrade-history.php +18 -15 18.9 → trunk View file →
@@ -32,9 +32,9 @@
32 32
33 33 /**
34 34 * Retrieves the content of the history items currently stored.
35 35 *
36 - * @return array The contents of the history option.
36 + * @return array<array<string>> The contents of the history option.
37 37 */
38 38 public function get() {
39 39 $data = get_option( $this->get_option_name(), [] );
40 40 if ( ! is_array( $data ) ) {
@@ -46,11 +46,13 @@
46 46
47 47 /**
48 48 * Adds a new history entry in the storage.
49 49 *
50 - * @param string $old_version The version we are upgrading from.
51 - * @param string $new_version The version we are upgrading to.
52 - * @param array $option_names The options that need to be stored.
50 + * @param string $old_version The version we are upgrading from.
51 + * @param string $new_version The version we are upgrading to.
52 + * @param array<string> $option_names The options that need to be stored.
53 + *
54 + * @return void
53 55 */
54 56 public function add( $old_version, $new_version, array $option_names ) {
55 57 $option_data = [];
56 58 if ( $option_names !== [] ) {
@@ -73,25 +75,26 @@
73 75
74 76 /**
75 77 * Retrieves the data for the specified option names from the database.
76 78 *
77 - * @param array $option_names The option names to retrieve.
79 + * @param array<string> $option_names The option names to retrieve.
78 80 *
79 - * @return array
81 + * @return array<int|string, array<string|int|bool|float>> The retrieved data.
80 82 */
81 83 protected function get_options_data( array $option_names ) {
82 84 $wpdb = $this->get_wpdb();
83 85
84 - $sql = $wpdb->prepare(
85 - '
86 - SELECT option_value, option_name FROM ' . $wpdb->options . ' WHERE
87 - option_name IN ( ' . implode( ',', array_fill( 0, count( $option_names ), '%s' ) ) . ' )
88 - ',
89 - $option_names
86 + $results = $wpdb->get_results(
87 + $wpdb->prepare(
88 + '
89 + SELECT %i, %i FROM ' . $wpdb->options . ' WHERE
90 + %i IN ( ' . implode( ',', array_fill( 0, count( $option_names ), '%s' ) ) . ' )
91 + ',
92 + array_merge( [ 'option_value', 'option_name', 'option_name' ], $option_names ),
93 + ),
94 + ARRAY_A,
90 95 );
91 96
92 - $results = $wpdb->get_results( $sql, ARRAY_A );
93 -
94 97 $data = [];
95 98 foreach ( $results as $result ) {
96 99 $data[ $result['option_name'] ] = maybe_unserialize( $result['option_value'] );
97 100 }
@@ -101,9 +104,9 @@
101 104
102 105 /**
103 106 * Stores the new history state.
104 107 *
105 - * @param array $data The data to store.
108 + * @param array<array<string>> $data The data to store.
106 109 *
107 110 * @return void
108 111 */
109 112 protected function set( array $data ) {