Plugin Directory

Changeset 3432432


Ignore:
Timestamp:
01/05/2026 06:31:18 AM (3 months ago)
Author:
secondlinethemes
Message:

up to 1.5.5

Location:
podcast-importer-secondline
Files:
170 added
4 edited

Legend:

Unmodified
Added
Removed
  • podcast-importer-secondline/trunk/app/ActionScheduler.php

    r3080347 r3432432  
    6868
    6969  public function _image_sync( $post_id, $image_path ) {
     70    $post_id = intval( $post_id );
     71
     72    // Early exit if post no longer exists (deleted after queue)
     73    if( !get_post_status( $post_id ) )
     74      return;
     75
     76    // Early exit if post already has a thumbnail (safety check for queued actions)
     77    if( has_post_thumbnail( $post_id ) )
     78      return;
     79
     80    // Check retry count - stop after max retries to prevent infinite loop
     81    $retry_count = intval( get_post_meta( $post_id, '_secondline_image_retry_count', true ) );
     82    $max_retries = apply_filters( 'podcast_importer_secondline_image_max_retries', 3 );
     83
     84    if( $retry_count >= $max_retries ) {
     85      // Max retries reached, mark as permanently failed and stop
     86      update_post_meta( $post_id, '_secondline_image_import_failed', true );
     87      return;
     88    }
     89
    7090    if( !function_exists( 'media_sideload_image' ) ) {
    7191      require_once( ABSPATH . 'wp-admin/includes/media.php' );
     
    7595
    7696    $corrected_image_path = str_replace('?.jpg', '?img.jpg', $image_path);
    77     $image_contents = wp_remote_get( $corrected_image_path );
    78     $image_contents = wp_remote_retrieve_body( $image_contents );
     97    $image_response = wp_remote_get( $corrected_image_path );
     98
     99    // Check for WP_Error from wp_remote_get
     100    if( is_wp_error( $image_response ) ) {
     101      update_post_meta( $post_id, '_secondline_image_retry_count', $retry_count + 1 );
     102      return;
     103    }
     104
     105    $image_contents = wp_remote_retrieve_body( $image_response );
     106
     107    if( empty( $image_contents ) ) {
     108      update_post_meta( $post_id, '_secondline_image_retry_count', $retry_count + 1 );
     109      return;
     110    }
     111
     112    $image_md5 = md5( $image_contents );
    79113
    80114    global $wpdb;
    81115
    82     $post_id = intval( $post_id );
    83 
    84116    $attachment_post_id = $wpdb->get_var(
    85       'SELECT post_id
    86                FROM ' . $wpdb->postmeta . '
    87               WHERE meta_key = "secondline_attachment_md5"
    88                 AND meta_value = ' . $wpdb->prepare( "%s", md5( $image_contents ) )
     117      $wpdb->prepare(
     118        "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'secondline_attachment_md5' AND meta_value = %s",
     119        $image_md5
     120      )
    89121    );
    90122
    91123    if( null === $attachment_post_id ) {
    92       $attachment_post_id = media_sideload_image($corrected_image_path, $post_id, get_the_title( $post_id ), 'id' );
     124      $attachment_post_id = media_sideload_image( $corrected_image_path, $post_id, get_the_title( $post_id ), 'id' );
    93125
    94       update_post_meta( $attachment_post_id, 'secondline_attachment_md5', md5( $image_contents ) );
     126      if( is_wp_error( $attachment_post_id ) ) {
     127        update_post_meta( $post_id, '_secondline_image_retry_count', $retry_count + 1 );
     128        return;
     129      }
     130
     131      update_post_meta( $attachment_post_id, 'secondline_attachment_md5', $image_md5 );
    95132    } else {
    96133      $attachment_post_id = intval( $attachment_post_id );
    97134    }
    98135
    99     set_post_thumbnail( $post_id, $attachment_post_id );
     136    $result = set_post_thumbnail( $post_id, $attachment_post_id );
     137
     138    // If thumbnail was set successfully, clear retry count
     139    if( $result ) {
     140      delete_post_meta( $post_id, '_secondline_image_retry_count' );
     141      delete_post_meta( $post_id, '_secondline_image_import_failed' );
     142    } else {
     143      // set_post_thumbnail failed
     144      update_post_meta( $post_id, '_secondline_image_retry_count', $retry_count + 1 );
     145    }
    100146  }
    101147
  • podcast-importer-secondline/trunk/app/Helper/Importer/FeedItem.php

    r3290687 r3432432  
    3737
    3838  public $audio_url;
     39  public $item_link_url = '';
    3940  public $audio_feed_url  = '';
    4041  public $audio_feed_host = '';
     
    5556    global $wpdb;
    5657
    57     $this->current_post_id = intval($wpdb->get_var('SELECT post_id FROM ' . $wpdb->postmeta . ' WHERE ( meta_key = "secondline_imported_guid" AND meta_value LIKE "%' . esc_sql($wpdb->esc_like( $this->_guid )) . '%")' ) );
     58    $this->current_post_id = intval($wpdb->get_var(
     59      $wpdb->prepare(
     60        'SELECT post_id FROM ' . $wpdb->postmeta . ' WHERE meta_key = %s AND meta_value = %s LIMIT 1',
     61        'secondline_imported_guid',
     62        $this->_guid
     63      )
     64    ));
    5865
    5966    $this->episode_number = podcast_importer_secondline_sanitize_feed_value($this->feed_item_itunes->episode );
     
    246253      return;
    247254
     255    // Skip if post already has a featured image
     256    if( has_post_thumbnail( $this->current_post_id ) )
     257      return;
     258
     259    // Skip if image import has permanently failed for this post (max retries exceeded)
     260    if( get_post_meta( $this->current_post_id, '_secondline_image_import_failed', true ) )
     261      return;
     262
     263    // Prevent duplicate queue entries for the same post/image combination
     264    if( \PodcastImporterSecondLine\Helper\Scheduler::is_action_scheduled(
     265      PODCAST_IMPORTER_SECONDLINE_ALIAS . '_scheduler_image_sync',
     266      [ $this->current_post_id, $image_url ]
     267    ) )
     268      return;
     269
    248270    as_enqueue_async_action( PODCAST_IMPORTER_SECONDLINE_ALIAS . '_scheduler_image_sync', [ $this->current_post_id, $image_url ], PODCAST_IMPORTER_SECONDLINE_ALIAS );
    249271  }
  • podcast-importer-secondline/trunk/podcast-importer-secondline.php

    r3377272 r3432432  
    33 * Plugin Name:       Podcast Importer SecondLine
    44 * Description:       A simple podcast import plugin with ongoing podcast feed import features.
    5  * Version:           1.5.4
     5 * Version:           1.5.5
    66 * Author:            SecondLineThemes
    77 * Author URI:        https://secondlinethemes.com/
     
    1515    die;
    1616
    17 define( 'PODCAST_IMPORTER_SECONDLINE_VERSION', '1.5.4' );
     17define( 'PODCAST_IMPORTER_SECONDLINE_VERSION', '1.5.5' );
    1818define( "PODCAST_IMPORTER_SECONDLINE_BASE_FILE_PATH", __FILE__ );
    1919define( "PODCAST_IMPORTER_SECONDLINE_BASE_PATH", dirname( PODCAST_IMPORTER_SECONDLINE_BASE_FILE_PATH ) );
  • podcast-importer-secondline/trunk/readme.txt

    r3377272 r3432432  
    44Tags: podcast, import, feed, rss, episodes
    55Requires at least: 4.8
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.1
    88Stable tag: trunk
     
    6868
    6969== Changelog ==
     70
     71= 1.5.5 =
     72* Improved: Episode image imports now retry up to 3 times before stopping, preventing infinite loops on broken image URLs.
     73* Improved: Prevented duplicate tasks from being queued during feed syncs.
    7074
    7175= 1.5.4 =
Note: See TracChangeset for help on using the changeset viewer.