← All changes
|
src/actions/importing/aioseo/aioseo-validate-data-action.php
+7
-10
18.6
→
trunk
View file →
| @@ -3,16 +3,14 @@ | ||
| 3 | 3 | // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case. |
| 4 | 4 | namespace Yoast\WP\SEO\Actions\Importing\Aioseo; |
| 5 | 5 | |
| 6 | 6 | use wpdb; |
| 7 | +use Yoast\WP\SEO\Actions\Importing\Abstract_Aioseo_Importing_Action; | |
| 8 | +use Yoast\WP\SEO\Exceptions\Importing\Aioseo_Validation_Exception; | |
| 7 | 9 | use Yoast\WP\SEO\Helpers\Options_Helper; |
| 8 | -use Yoast\WP\SEO\Exceptions\Importing\Aioseo_Validation_Exception; | |
| 9 | -use Yoast\WP\SEO\Actions\Importing\Abstract_Aioseo_Importing_Action; | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Importing action for validating AIOSEO data before the import occurs. |
| 13 | - * | |
| 14 | - * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded | |
| 15 | 13 | */ |
| 16 | 14 | class Aioseo_Validate_Data_Action extends Abstract_Aioseo_Importing_Action { |
| 17 | 15 | |
| 18 | 16 | /** |
| @@ -17,14 +15,14 @@ | ||
| 17 | 15 | |
| 18 | 16 | /** |
| 19 | 17 | * The plugin of the action. |
| 20 | 18 | */ |
| 21 | - const PLUGIN = 'aioseo'; | |
| 19 | + public const PLUGIN = 'aioseo'; | |
| 22 | 20 | |
| 23 | 21 | /** |
| 24 | 22 | * The type of the action. |
| 25 | 23 | */ |
| 26 | - const TYPE = 'validate_data'; | |
| 24 | + public const TYPE = 'validate_data'; | |
| 27 | 25 | |
| 28 | 26 | /** |
| 29 | 27 | * The WordPress database instance. |
| 30 | 28 | * |
| @@ -102,9 +100,9 @@ | ||
| 102 | 100 | |
| 103 | 101 | /** |
| 104 | 102 | * Validates AIOSEO data. |
| 105 | 103 | * |
| 106 | - * @return array|false An array of validated data or false if aioseo data did not pass validation. | |
| 104 | + * @return array An array of validated data or false if aioseo data did not pass validation. | |
| 107 | 105 | * |
| 108 | 106 | * @throws Aioseo_Validation_Exception If the validation fails. |
| 109 | 107 | */ |
| 110 | 108 | public function index() { |
| @@ -115,9 +113,8 @@ | ||
| 115 | 113 | $validated_aioseo_table = $this->validate_aioseo_table(); |
| 116 | 114 | $validated_aioseo_settings = $this->validate_aioseo_settings(); |
| 117 | 115 | $validated_robot_settings = $this->validate_robot_settings(); |
| 118 | 116 | |
| 119 | - | |
| 120 | 117 | if ( $validated_aioseo_table === false || $validated_aioseo_settings === false || $validated_robot_settings === false ) { |
| 121 | 118 | throw new Aioseo_Validation_Exception(); |
| 122 | 119 | } |
| 123 | 120 | |
| @@ -144,9 +141,9 @@ | ||
| 144 | 141 | $needed_data = $this->post_importing_action->get_needed_data(); |
| 145 | 142 | |
| 146 | 143 | $aioseo_columns = $this->wpdb->get_col( |
| 147 | 144 | "SHOW COLUMNS FROM {$table}", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input. |
| 148 | - 0 | |
| 145 | + 0, | |
| 149 | 146 | ); |
| 150 | 147 | |
| 151 | 148 | return $needed_data === \array_intersect( $needed_data, $aioseo_columns ); |
| 152 | 149 | } |
| @@ -244,9 +241,9 @@ | ||
| 244 | 241 | public function get_limit() { |
| 245 | 242 | /** |
| 246 | 243 | * Filter 'wpseo_aioseo_cleanup_limit' - Allow filtering the number of validations during each action pass. |
| 247 | 244 | * |
| 248 | - * @api int The maximum number of validations. | |
| 245 | + * @param int $limit The maximum number of validations. | |
| 249 | 246 | */ |
| 250 | 247 | $limit = \apply_filters( 'wpseo_aioseo_validation_limit', 25 ); |
| 251 | 248 | |
| 252 | 249 | if ( ! \is_int( $limit ) || $limit < 1 ) { |