PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | libraries/freemius/includes/class-fs-garbage-collector.php +36 -8 2.3 → 3.4 View file →
@@ -58,9 +58,11 @@
58 58
59 59 $options = $this->load_options();
60 60 $has_updated_option = false;
61 61
62 - $products_to_clean = $this->get_products_to_clean();
62 + $filtered_products = $this->get_filtered_products();
63 + $products_to_clean = $filtered_products['products_to_clean'];
64 + $active_products_by_id_map = $filtered_products['active_products_by_id_map'];
63 65
64 66 foreach( $products_to_clean as $product ) {
65 67 $slug = $product->slug;
66 68
@@ -84,12 +86,27 @@
84 86 $updated = true;
85 87 } else if ( array_key_exists( "{$slug}:{$this->_type}", $option ) ) { /* admin_notices */
86 88 unset( $option[ "{$slug}:{$this->_type}" ] );
87 89 $updated = true;
88 - } else if ( isset( $product->id ) && array_key_exists( $product->id, $option ) ) { /* all_licenses */
89 - unset( $option[ $product->id ] );
90 - $updated = true;
91 - } else if ( isset( $product->file ) && array_key_exists( $product->file, $option ) ) { /* file_slug_map */
90 + } else if ( isset( $product->id ) && array_key_exists( $product->id, $option ) ) { /* all_licenses, add-ons, and id_slug_type_path_map */
91 + $is_inactive_by_id = ! isset( $active_products_by_id_map[ $product->id ] );
92 + $is_inactive_by_slug = (
93 + 'id_slug_type_path_map' === $option_name &&
94 + (
95 + ! isset( $option[ $product->id ]['slug'] ) ||
96 + $slug === $option[ $product->id ]['slug']
97 + )
98 + );
99 +
100 + if ( $is_inactive_by_id || $is_inactive_by_slug ) {
101 + unset( $option[ $product->id ] );
102 + $updated = true;
103 + }
104 + } else if ( /* file_slug_map */
105 + isset( $product->file ) &&
106 + array_key_exists( $product->file, $option ) &&
107 + $slug === $option[ $product->file ]
108 + ) {
92 109 unset( $option[ $product->file ] );
93 110 $updated = true;
94 111 }
95 112
@@ -144,8 +161,14 @@
144 161 foreach( $this->_storage_data as $slug => $product_data ) {
145 162 if ( ! isset( $products[ $slug ] ) ) {
146 163 $products[ $slug ] = (object) $product_data;
147 164 }
165 +
166 + // This is needed to handle a scenario in which there are duplicate sets of data for the same product, but one of them needs to be removed.
167 + $products[ $slug ] = clone $products[ $slug ];
168 +
169 + // The reason for having the line above. This also handles a scenario in which the slug is either empty or not empty but incorrect.
170 + $products[ $slug ]->slug = $slug;
148 171 }
149 172
150 173 $this->update_gc_timestamp( $products );
151 174
@@ -151,10 +174,11 @@
151 174
152 175 return $products;
153 176 }
154 177
155 - private function get_products_to_clean() {
156 - $products_to_clean = array();
178 + private function get_filtered_products() {
179 + $products_to_clean = array();
180 + $active_products_by_id_map = array();
157 181
158 182 $products = $this->get_products();
159 183
160 184 foreach ( $products as $slug => $product_data ) {
@@ -162,8 +186,9 @@
162 186 continue;
163 187 }
164 188
165 189 if ( $this->is_product_active( $slug ) ) {
190 + $active_products_by_id_map[ $product_data->id ] = true;
166 191 continue;
167 192 }
168 193
169 194 $is_addon = ( ! empty( $product_data->parent_plugin_id ) );
@@ -177,9 +202,12 @@
177 202 array_unshift( $products_to_clean, $product_data );
178 203 }
179 204 }
180 205
181 - return $products_to_clean;
206 + return array(
207 + 'products_to_clean' => $products_to_clean,
208 + 'active_products_by_id_map' => $active_products_by_id_map,
209 + );
182 210 }
183 211
184 212 /**
185 213 * @param string $slug