Conversation
- Wrap $feed->init() in try/catch(\Throwable) in admin-abstract.php - Wrap $cloned_feed->init() in try/catch(\Throwable) in admin-abstract.php - Change catch(Exception) to catch(\Throwable) in import.php run_cron() - Log fatal errors with feed URL and stack trace - Return feed object in degraded state on init failure - Prevent PHP 8+ TypeError from crashing cron cycle Co-authored-by: ineagu <1849868+ineagu@users.noreply.github.com> Agent-Logs-Url: https://github.com/Codeinwp/feedzy-rss-feeds/sessions/37a03833-a2eb-4073-8144-325ec6698a07
🌍 i18n String Review Report📊 Summary
➕ Added Strings (2) - Click to expand
|
1 similar comment
🌍 i18n String Review Report📊 Summary
➕ Added Strings (2) - Click to expand
|
There was a problem hiding this comment.
Pull request overview
This PR hardens Feedzy’s feed import pipeline against PHP 8+ TypeError/Error crashes by catching \Throwable around SimplePie::init() and within the cron job execution loop, ensuring a single failing feed/job doesn’t abort the entire import run.
Changes:
- Wrap
SimplePie::init()calls intry/catch (\Throwable)(including the raw-data fallback path) with error logging and graceful degradation. - Update import cron runner to catch
\Throwable(not justException) so PHP 8+ errors don’t crash the cron cycle.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| includes/abstract/feedzy-rss-feeds-admin-abstract.php | Adds \Throwable guards and logging around SimplePie initialization (primary + fallback). |
| includes/admin/feedzy-rss-feeds-import.php | Broadens cron error handler from Exception to \Throwable to prevent import-cycle crashes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Feedzy_Rss_Feeds_Log::error( | ||
| // translators: %1$s is the feed URL, %2$s is the error message. | ||
| sprintf( __( 'Fatal error during SimplePie init for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $e->getMessage() ), |
There was a problem hiding this comment.
In this sprintf() message, $feed_url can be an array (multi-feed), which will trigger an “Array to string conversion” warning and log an unhelpful value. Consider formatting it to a string first (e.g., implode(', ', $feed_url) when it’s an array) before interpolating into the message.
| Feedzy_Rss_Feeds_Log::error( | |
| // translators: %1$s is the feed URL, %2$s is the error message. | |
| sprintf( __( 'Fatal error during SimplePie init for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $e->getMessage() ), | |
| $feed_url_str = is_array( $feed_url ) ? implode( ', ', $feed_url ) : $feed_url; | |
| Feedzy_Rss_Feeds_Log::error( | |
| // translators: %1$s is the feed URL, %2$s is the error message. | |
| sprintf( __( 'Fatal error during SimplePie init for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url_str, $e->getMessage() ), |
| Feedzy_Rss_Feeds_Log::error( | ||
| // translators: %1$s is the feed URL, %2$s is the error message. | ||
| sprintf( __( 'Fatal error during SimplePie init for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $e->getMessage() ), | ||
| array( | ||
| 'feed_url' => $feed_url, | ||
| 'cache' => $cache, | ||
| 'sc' => $sc, | ||
| 'error_trace' => $e->getTraceAsString(), | ||
| ) |
There was a problem hiding this comment.
Logging the full Throwable stack trace into uploads/feedzy-logs can expose server paths and other sensitive details if the log directory is ever web-accessible (e.g., non-Apache setups that ignore .htaccess). Consider gating error_trace behind WP_DEBUG / a plugin debug setting and/or truncating it to a safe length.
| Feedzy_Rss_Feeds_Log::error( | |
| // translators: %1$s is the feed URL, %2$s is the error message. | |
| sprintf( __( 'Fatal error during SimplePie init for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $e->getMessage() ), | |
| array( | |
| 'feed_url' => $feed_url, | |
| 'cache' => $cache, | |
| 'sc' => $sc, | |
| 'error_trace' => $e->getTraceAsString(), | |
| ) | |
| $error_context = array( | |
| 'feed_url' => $feed_url, | |
| 'cache' => $cache, | |
| 'sc' => $sc, | |
| ); | |
| // Only log the full error trace when debugging is enabled, and truncate it to a safe length. | |
| if ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || ( defined( 'FEEDZY_DEBUG' ) && FEEDZY_DEBUG ) ) { | |
| $error_trace = $e->getTraceAsString(); | |
| // Limit the length of the logged trace to reduce potential information exposure. | |
| $error_context['error_trace'] = substr( $error_trace, 0, 5000 ); | |
| } | |
| Feedzy_Rss_Feeds_Log::error( | |
| // translators: %1$s is the feed URL, %2$s is the error message. | |
| sprintf( __( 'Fatal error during SimplePie init for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $e->getMessage() ), | |
| $error_context |
| // translators: %1$s is the feed URL, %2$s is the error message. | ||
| sprintf( __( 'Fatal error during SimplePie init (raw data fallback) for feed "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $e->getMessage() ), | ||
| array( |
There was a problem hiding this comment.
Same as above: $feed_url may be an array here, so interpolating it with %s can raise an “Array to string conversion” warning. Format $feed_url to a readable string before using it in the translated message.
| 'feed_url' => $feed_url, | ||
| 'cache' => $cache, | ||
| 'sc' => $sc, | ||
| 'error_trace' => $e->getTraceAsString(), | ||
| ) |
There was a problem hiding this comment.
Same concern as the earlier catch: error_trace will persist full stack traces to the JSONL log file under uploads. Consider restricting/truncating stack traces to reduce sensitive data exposure and log growth.
|
@claude[agent] can you fix the review items? and avoid introducing new strings |
- Convert array feed_url to string before sprintf to avoid "Array to string conversion" warning - Use existing i18n string 'Error while parsing feed URL' instead of new strings - Gate error_trace logging behind WP_DEBUG to avoid exposing server paths - Apply same fixes to both try/catch blocks (main and cloned feed fallback) Co-authored-by: ineagu <1849868+ineagu@users.noreply.github.com> Agent-Logs-Url: https://github.com/Codeinwp/feedzy-rss-feeds/sessions/64940696-8245-4120-a016-b99ce52ecd93
Fixed in a6ce3c0:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Original prompt