Podsumowanie koszyka
Kwota | 187,06 zł |
---|---|
Wysyłka |
Jeżeli masz już w koszyku wszystko co potrzebujesz, przejdź dalej |
Łącznie | 267,06 zł (zawiera 49,94 zł Podatek) |
26 Lat
Istnienia Firmy
Doświadczenie
Tysiące zadowolonych klientów
/** * NAPRAWA 1: ZMODYFIKUJ METODĘ refresh_all_feeds() w klasie Cron * * Plik: includes/class-product-feed-generator-cron.php * Metoda: refresh_all_feeds() */ public static function refresh_all_feeds() { error_log( 'Product Feed Generator Cron: Starting feed refresh at ' . date('Y-m-d H:i:s') ); $feeds = get_option( 'product_feed_generator_feeds', array() ); if ( empty( $feeds ) ) { error_log( 'Product Feed Generator Cron: No feeds found to refresh' ); return; } foreach ( $feeds as $feed_id => $feed_config ) { if ( isset( $feed_config['status'] ) && $feed_config['status'] === 'active' ) { error_log( "Product Feed Generator Cron: Processing feed: {$feed_config['name']}" ); // NAPRAWA: Zamiast start_background_feed_generation użyj bezpośredniego przetwarzania self::process_feed_completely( $feed_config, $feed_id ); } } error_log( 'Product Feed Generator Cron: Feed refresh completed at ' . date('Y-m-d H:i:s') ); } /** * NOWA METODA: Przetwarzanie całego feedu w jednym wywołaniu */ private static function process_feed_completely( $config, $feed_id ) { // Zwiększ limity ini_set( 'memory_limit', '512M' ); ini_set( 'max_execution_time', 300 ); // 5 minut // Wyłącz deprecated warnings $old_error_reporting = error_reporting(); error_reporting( $old_error_reporting & ~E_DEPRECATED ); try { // Załaduj generator require_once plugin_dir_path( dirname( __FILE__ ) ) . 'generator/class-product-feed-generator-core.php'; $generator = new Product_Feed_Generator_Core(); // Wygeneruj cały feed $feed_content = $generator->generate_feed( $config ); if ( is_wp_error( $feed_content ) ) { error_log( "Product Feed Generator Cron: Error generating feed {$feed_id}: " . $feed_content->get_error_message() ); return; } // Zapisz feed $upload_dir = wp_upload_dir(); $feed_dir = $upload_dir['basedir'] . '/product-feeds/'; if ( ! file_exists( $feed_dir ) ) { wp_mkdir_p( $feed_dir ); } $file_extension = $config['format'] ?? 'xml'; $filename = $feed_id . '.' . $file_extension; $filepath = $feed_dir . $filename; // Zapisz plik if ( file_put_contents( $filepath, $feed_content ) !== false ) { // Aktualizuj konfigurację $feeds = get_option( 'product_feed_generator_feeds', array() ); $feeds[ $feed_id ]['file_url'] = $upload_dir['baseurl'] . '/product-feeds/' . $filename; $feeds[ $feed_id ]['file_path'] = $filepath; $feeds[ $feed_id ]['last_updated'] = current_time( 'mysql' ); $feeds[ $feed_id ]['status'] = 'active'; update_option( 'product_feed_generator_feeds', $feeds ); error_log( "Product Feed Generator Cron: Successfully updated feed {$feed_id}" ); } else { error_log( "Product Feed Generator Cron: Failed to write feed file {$filepath}" ); } } catch ( Exception $e ) { error_log( "Product Feed Generator Cron: Exception processing feed {$feed_id}: " . $e->getMessage() ); } finally { // Przywróć error reporting error_reporting( $old_error_reporting ); } } /** * NAPRAWA 2: ALTERNATYWNE ROZWIĄZANIE - MODYFIKACJA process_feed_chunk() * * Jeśli nie chcesz zmieniać całego mechanizmu, zmodyfikuj process_feed_chunk() * aby przetwarzał wszystkie chunki w pętli: */ public function process_feed_chunk( $job_id ) { // Zwiększ limity ini_set( 'memory_limit', '512M' ); ini_set( 'max_execution_time', 300 ); // 5 minut $start_time = time(); $max_execution_time = 240; // 4 minuty (zostaw margines) error_log( "Product Feed Generator: Starting continuous processing for job '$job_id'" ); // PĘTLA: Przetwarzaj chunki dopóki nie skończysz lub nie przekroczysz czasu while ( ( time() - $start_time ) < $max_execution_time ) { // Oryginalny kod process_feed_chunk... $job = $this->initialize_job_processing( $job_id ); if ( ! $job ) { break; // Job validation failed } // ... cały kod przetwarzania chunka ... // ZMIANA: Zamiast planować następny chunk, sprawdź czy job jest ukończony if ( $is_complete ) { error_log( "Product Feed Generator: Job $job_id completed in continuous mode" ); break; // Job ukończony } // ZMIANA: Zamiast wp_schedule_single_event, kontynuuj w pętli error_log( "Product Feed Generator: Job $job_id continuing to next chunk in continuous mode" ); // Krótka przerwa między chunkami sleep( 1 ); } error_log( "Product Feed Generator: Continuous processing ended for job '$job_id'" ); }
Kwota | 187,06 zł |
---|---|
Wysyłka |
Jeżeli masz już w koszyku wszystko co potrzebujesz, przejdź dalej |
Łącznie | 267,06 zł (zawiera 49,94 zł Podatek) |
26 Lat
Istnienia Firmy
Doświadczenie
Tysiące zadowolonych klientów