log( $job, '↪ Backfill unserialize skipped (dry_run)' ); return array( 'status' => 'ok' ); } $total_rows = 0; foreach ( TMDO_Entity_Registry::get_groups_for_type( $this->entity_type ) as $group ) { if ( ! $this->group_has_json_field( $group ) ) { continue; // Handled in backfill_bulk. } $result = TMDO_Entity_Migration_Engine::migrate_group( $this->entity_type, $group, array( 'sleep_ms' => 0 ) ); if ( ! empty( $result['error'] ) ) { throw new \RuntimeException( "Row-by-row backfill {$group} failed: " . $result['error'] ); } if ( ( $result['errors'] ?? 0 ) > 0 && 0 === ( $result['migrated'] ?? 0 ) ) { throw new \RuntimeException( "All rows failed during {$group} backfill — see error_log" ); } $total_rows += (int) ( $result['migrated'] ?? 0 ); $this->log( $job, sprintf( ' • row-by-row %s: %d row(s)', $group, $result['migrated'] ?? 0 ) ); } $this->log( $job, sprintf( 'Row-by-row backfill: %d rows total', $total_rows ) ); return array( 'status' => 'ok' ); } }