| @@ -142,17 +142,19 @@ | ||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Get completed migrations IDs |
| 146 | + * | |
| 147 | + * @return array | |
| 146 | 148 | */ |
| 147 | - public function getCompletedMigrationsIDs(): array | |
| 149 | + public function getCompletedMigrationsIDs() | |
| 148 | 150 | { |
| 149 | 151 | $migrations = []; |
| 150 | 152 | |
| 151 | 153 | try { |
| 152 | - $result = DB::table('give_migrations') | |
| 153 | - ->where('status', MigrationLogStatus::SUCCESS) | |
| 154 | - ->getAll(); | |
| 154 | + $result = DB::get_results( | |
| 155 | + DB::prepare("SELECT * FROM {$this->migration_table} WHERE status = %s", MigrationLogStatus::SUCCESS) | |
| 156 | + ); | |
| 155 | 157 | } catch (\Exception $exception) { |
| 156 | 158 | // This exception should happen only once, during the migration system storage update. |
| 157 | 159 | // But, we will log this error just in case to see if this is a repeating problem. |
| 158 | 160 | error_log($exception->getMessage()); |
| @@ -194,12 +196,12 @@ | ||
| 194 | 196 | public function getFailedMigrationsCountByIds($migrationIds) |
| 195 | 197 | { |
| 196 | 198 | try { |
| 197 | 199 | $query = sprintf( |
| 198 | - "SELECT count(id) FROM %s WHERE id IN ('%s') AND status = '%s'", | |
| 200 | + "SELECT count(id) FROM %s WHERE id IN ('%s') AND status != '%s'", | |
| 199 | 201 | $this->migration_table, |
| 200 | 202 | implode("','", array_map('esc_sql', $migrationIds)), |
| 201 | - MigrationLogStatus::FAILED | |
| 203 | + MigrationLogStatus::SUCCESS | |
| 202 | 204 | ); |
| 203 | 205 | |
| 204 | 206 | return DB::get_var($query); |
| 205 | 207 | } catch (\Exception $exception) { |