From 036efde9d57a6082c5f4e7ce9124e29ec92b47c3 Mon Sep 17 00:00:00 2001 From: Luca Dobrescu Date: Fri, 17 Jul 2026 11:44:46 +0300 Subject: [PATCH 01/13] fix: include feed source URL and import ID in log context for easier troubleshooting Scope the logger context to each import run so every entry written while a job runs carries import_id, import_title and source; log single-feed parse failures that were previously swallowed; surface the import and feed URL as badges in the logs viewer with fallbacks for legacy job_id/source entries. Co-Authored-By: Claude Fable 5 --- css/settings.css | 28 +++ .../feedzy-rss-feeds-admin-abstract.php | 24 ++- includes/admin/feedzy-rss-feeds-import.php | 60 +++++- includes/layouts/feedzy-logs-viewer.php | 58 +++++- tests/e2e/specs/log-attribution.spec.js | 178 ++++++++++++++++++ tests/e2e/utils.js | 118 +++++++++++- 6 files changed, 439 insertions(+), 27 deletions(-) create mode 100644 tests/e2e/specs/log-attribution.spec.js diff --git a/css/settings.css b/css/settings.css index c555bfaf0..e365c7e8a 100644 --- a/css/settings.css +++ b/css/settings.css @@ -2821,6 +2821,34 @@ button.feedzy-action-button { margin-top: 10px; } +/* Import/feed attribution badges */ +.fz-log-container__badges { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin-top: 6px; +} + +.fz-log-context-import, +.fz-log-context-feed-url { + display: inline-block; + padding: 1px 8px; + border-radius: 10px; + font-size: 0.85em; + word-break: break-all; + overflow-wrap: break-word; +} + +.fz-log-context-import { + background-color: #eef2ff; + color: #3730a3; +} + +.fz-log-context-feed-url { + background-color: #ecfdf5; + color: #065f46; +} + /* Right section - Context */ .fz-log-container__right { flex: 1; diff --git a/includes/abstract/feedzy-rss-feeds-admin-abstract.php b/includes/abstract/feedzy-rss-feeds-admin-abstract.php index 1a04b0704..b65e67211 100644 --- a/includes/abstract/feedzy-rss-feeds-admin-abstract.php +++ b/includes/abstract/feedzy-rss-feeds-admin-abstract.php @@ -896,15 +896,26 @@ private function init_single_feed( $feed_url, $cache, $sc, $allow_https = FEEDZY $feed->init(); - if ( ! $feed->get_type() ) { - return $feed; - } - $error = $feed->error(); if ( is_array( $error ) ) { $error = implode( '|', $error ); } + if ( ! $feed->get_type() ) { + if ( ! empty( $error ) ) { + Feedzy_Rss_Feeds_Log::error( + // translators: %1$s is the feed URL, %2$s is the error message. + sprintf( __( 'Error while parsing feed URL "%1$s": %2$s', 'feedzy-rss-feeds' ), $feed_url, $error ), + array( + 'feed_url' => $feed_url, + 'cache' => $cache, + 'sc' => $sc, + ) + ); + } + return $feed; + } + if ( ! empty( $error ) ) { $feed = $this->handle_feed_error( $feed, $cloned_feed, $feed_url, $cache, $sc, $allow_https, $default_agent, $error ); } @@ -1169,8 +1180,9 @@ private function handle_feed_error( $feed, $cloned_feed, $feed_url, $cache, $sc, Feedzy_Rss_Feeds_Log::debug( sprintf( 'Using raw data for feed: %s', $feed_url ), array( - 'cache' => $cache, - 'sc' => $sc, + 'feed_url' => $feed_url, + 'cache' => $cache, + 'sc' => $sc, ) ); diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 0827bc946..118c9b718 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1413,7 +1413,9 @@ private function run_now() { isset( $job->post_title ) ? $job->post_title : 'Unknown Job' ), array( - 'job_id' => $job_id, + 'job_id' => $job_id, + 'import_id' => (int) $job_id, + 'import_title' => isset( $job->post_title ) ? $job->post_title : '', ) ); @@ -1612,8 +1614,10 @@ public function run_cron( $max = 100, $job_id = 0 ) { Feedzy_Rss_Feeds_Log::debug( 'Cron job run for: ' . $job->post_title, array( - 'job_id' => $job->ID, - 'result' => $result, + 'job_id' => $job->ID, + 'import_id' => $job->ID, + 'import_title' => $job->post_title, + 'result' => $result, ) ); @@ -1623,8 +1627,10 @@ public function run_cron( $max = 100, $job_id = 0 ) { Feedzy_Rss_Feeds_Log::debug( 'Previous run did not return any results, running again for job: ' . $job->post_title, array( - 'job_id' => $job->ID, - 'result' => $result, + 'job_id' => $job->ID, + 'import_id' => $job->ID, + 'import_title' => $job->post_title, + 'result' => $result, ) ); } @@ -1638,8 +1644,10 @@ public function run_cron( $max = 100, $job_id = 0 ) { // translators: %1$s is the import job title, %2$s is the error message. sprintf( __( 'Error when running "%1$s": %2$s', 'feedzy-rss-feeds' ), $job->post_title, $e->getMessage() ), array( - 'job_id' => $job->ID, - 'error' => $e->getMessage(), + 'job_id' => $job->ID, + 'import_id' => $job->ID, + 'import_title' => $job->post_title, + 'error' => $e->getMessage(), ) ); } @@ -1647,17 +1655,49 @@ public function run_cron( $max = 100, $job_id = 0 ) { } /** - * Runs a specific job. - * + * Runs a specific job, scoping the logger context to it. + * + * Every log entry written while the job runs (including feed fetch/parse + * errors logged deeper in the stack) is tagged with the import ID, title + * and source, so it can be traced back to this job. + * * @param \WP_Post $job The custom post type with the job options. * @param int $max The import feed limit. * * @return int The number of imported items. - * + * * @since 1.6.1 * @access private */ private function run_job( $job, $max ) { + $logger = Feedzy_Rss_Feeds_Log::get_instance(); + $logger->set_context( + array( + 'import_id' => $job->ID, + 'import_title' => $job->post_title, + 'source' => (string) get_post_meta( $job->ID, 'source', true ), + ) + ); + + try { + return $this->run_job_logic( $job, $max ); + } finally { + $logger->set_context( array() ); + } + } + + /** + * The logic of running a specific job. + * + * @param \WP_Post $job The custom post type with the job options. + * @param int $max The import feed limit. + * + * @return int The number of imported items. + * + * @since 1.6.1 + * @access private + */ + private function run_job_logic( $job, $max ) { Feedzy_Rss_Feeds_Usage::get_instance()->track_rss_import(); Feedzy_Rss_Feeds_Log::get_instance()->enable_error_messages_retention(); diff --git a/includes/layouts/feedzy-logs-viewer.php b/includes/layouts/feedzy-logs-viewer.php index 7735e67e4..e56eec995 100644 --- a/includes/layouts/feedzy-logs-viewer.php +++ b/includes/layouts/feedzy-logs-viewer.php @@ -76,7 +76,25 @@ class="btn btn-ghost" foreach ( $logs_entries as $log ) : ?>
[ ] - +
+ +
+ + + + + + + + +
+
- -
+ +
diff --git a/tests/e2e/specs/log-attribution.spec.js b/tests/e2e/specs/log-attribution.spec.js new file mode 100644 index 000000000..ee9cf738b --- /dev/null +++ b/tests/e2e/specs/log-attribution.spec.js @@ -0,0 +1,178 @@ +/** + * WordPress dependencies + */ +import { test, expect } from '@wordpress/e2e-test-utils-playwright'; +import { + CUSTOM_FEED_URL, + INVALID_FEED_URL, + clearLogs, + createAndRunSampleImport, + createSampleImport, + deleteAllFeedImports, + runImportByName, + setLoggingLevel, +} from '../utils'; + +test.describe('Log attribution (#1278)', () => { + test.beforeEach(async ({ requestUtils }) => { + await deleteAllFeedImports(requestUtils); + await requestUtils.deleteAllPosts(); + await requestUtils.deleteAllMedia(); + await clearLogs(requestUtils); + }); + + test('log entries identify the import that produced them', async ({ + page, + admin, + }) => { + await setLoggingLevel(page, admin, 'debug'); + + const importName = await createAndRunSampleImport(page); + + await admin.visitAdminPage('admin.php?page=feedzy-settings&tab=logs'); + await expect( + page.getByRole('heading', { name: 'Recent Logs' }) + ).toBeVisible(); + + // Log entries were written for the run. + expect(await page.locator('.fz-log-container').count()).toBeGreaterThan( + 0 + ); + + // Entries are attributed to the import that produced them. + expect( + await page + .locator('.fz-log-container .fz-log-context-import') + .count() + ).toBeGreaterThan(0); + expect( + await page + .locator('.fz-log-context-import', { hasText: importName }) + .count() + ).toBeGreaterThan(0); + + // Entries expose the feed source URL. + expect( + await page + .locator('.fz-log-context-feed-url', { + hasText: 'sample-feed.xml', + }) + .count() + ).toBeGreaterThan(0); + }); + + test('errors from a failing feed are attributed to that import', async ({ + page, + admin, + }) => { + await setLoggingLevel(page, admin, 'debug'); + + const goodName = await createSampleImport( + page, + CUSTOM_FEED_URL, + `Healthy import ${Date.now()}` + ); + await runImportByName(page, goodName); + + const badName = await createSampleImport( + page, + INVALID_FEED_URL, + `Broken import ${Date.now()}` + ); + await runImportByName(page, badName, { expectSuccess: false }); + + // Open the logs tab filtered down to errors only. + await admin.visitAdminPage( + 'admin.php?page=feedzy-settings&tab=logs&logs_type=error' + ); + + expect( + await page.locator('.fz-log-container--error').count() + ).toBeGreaterThan(0); + + // The error entries point at the broken import... + expect( + await page + .locator('.fz-log-container--error .fz-log-context-import', { + hasText: badName, + }) + .count() + ).toBeGreaterThan(0); + + // ...and its feed URL. + expect( + await page + .locator('.fz-log-container--error .fz-log-context-feed-url', { + hasText: 'nonexistent-feed.xml', + }) + .count() + ).toBeGreaterThan(0); + + // The healthy import is not blamed for them. + expect( + await page + .locator('.fz-log-container--error .fz-log-context-import', { + hasText: goodName, + }) + .count() + ).toBe(0); + }); + + test('front-end fetches are not attributed to an import and unattributed entries still render', async ({ + page, + admin, + requestUtils, + }) => { + const frontEndFeedUrls = + 'https://example.com/missing-feed-2.xml, https://example.com/missing-feed-3.xml'; + + await setLoggingLevel(page, admin, 'debug'); + + // Import-scoped entries exist. + await createAndRunSampleImport(page); + + // Trigger a front-end (shortcode) fetch of broken feeds, outside any import run. + const post = await requestUtils.createPost({ + title: 'Feedzy shortcode page', + content: `[feedzy-rss feeds="${frontEndFeedUrls}"]`, + status: 'publish', + }); + await page.goto(post.link); + + await admin.visitAdminPage('admin.php?page=feedzy-settings&tab=logs'); + + // The front-end fetch error carries the feed URL badge but no import badge. + expect( + await page + .locator('.fz-log-container', { + has: page.locator('.fz-log-context-feed-url', { + hasText: 'missing-feed-2.xml', + }), + hasNot: page.locator('.fz-log-context-import'), + }) + .count() + ).toBeGreaterThan(0); + + // It is never falsely attributed to the import that ran earlier. + expect( + await page + .locator('.fz-log-container', { + has: page.locator('.fz-log-context-feed-url', { + hasText: 'missing-feed-2.xml', + }), + }) + .locator('.fz-log-context-import') + .count() + ).toBe(0); + + // Backward compatibility: entries whose context has no attribution keys + // (this one only has a `feed_urls` array) render fine, without a badge row. + const keylessEntry = page.locator('.fz-log-container', { + hasText: 'No feeds could be fetched', + }); + expect(await keylessEntry.count()).toBeGreaterThan(0); + expect( + await keylessEntry.locator('.fz-log-container__badges').count() + ).toBe(0); + }); +}); diff --git a/tests/e2e/utils.js b/tests/e2e/utils.js index 1ed2ef8dd..a3730ecf4 100644 --- a/tests/e2e/utils.js +++ b/tests/e2e/utils.js @@ -8,6 +8,8 @@ const { RequestUtils } = require('@wordpress/e2e-test-utils-playwright'); export const CUSTOM_FEED_URL = 'https://s3.amazonaws.com/verti-utils/sample-feed.xml'; +export const INVALID_FEED_URL = 'https://example.com/nonexistent-feed.xml'; + /** * Close the tour modal if it is visible. * @@ -215,7 +217,7 @@ export async function getPostsByFeedzy(requestUtils) { * @param {import('playwright').Page} page * @param {string} feedUrl * - * @return {Promise} The promise that resolves when the import is created and run. + * @return {Promise} The promise that resolves with the import name when the import is created and run. */ export async function createAndRunSampleImport( page, @@ -233,4 +235,118 @@ export async function createAndRunSampleImport( .click({ force: true }); await runFeedImport(page); + + return importName; +} + +/** + * Create a sample import with the given feed URL without running it. + * + * @param {import('playwright').Page} page The page object. + * @param {string} feedUrl The feed URL to import from. + * @param {string} importName The name of the import. + * @return {Promise} The promise that resolves with the import name once the import is saved and activated. + */ +export async function createSampleImport(page, feedUrl, importName) { + await page.goto('/wp-admin/post-new.php?post_type=feedzy_imports'); + await tryCloseTourModal(page); + + await page.getByPlaceholder('Add a name for your import').fill(importName); + await addFeeds(page, [feedUrl]); + + // Prevent the "unsaved changes" beforeunload dialog from cancelling the + // form submission (auto-dismissed dialogs abort the navigation). + await page.evaluate(() => { + window.onbeforeunload = null; + if (window.jQuery) { + window.jQuery(window).off('beforeunload'); + } + }); + + await Promise.all([ + // `commit` avoids stalling on slow-loading subresources of the target page. + page.waitForURL(/wp-admin\/(post|edit)\.php/, { waitUntil: 'commit' }), + page + .getByRole('button', { name: 'Save & Activate importing' }) + .click({ force: true }), + ]); + + return importName; +} + +/** + * Run a specific import from the imports list by its name. + * + * @param {import('playwright').Page} page The page object. + * @param {string} importName The name of the import to run. + * @param {Object} [options] Options. + * @param {boolean} [options.expectSuccess] Whether the run is expected to import items. + * @return {Promise} The promise that resolves when the run request completes. + */ +export async function runImportByName( + page, + importName, + { expectSuccess = true } = {} +) { + await page.goto('/wp-admin/edit.php?post_type=feedzy_imports'); + await page.locator('.feedzy-import-status-row').first().waitFor(); + + await page + .locator('tr', { hasText: importName }) + .getByRole('button', { name: 'Run Now' }) + .click(); + + const runNowResponse = await page.waitForResponse( + (response) => + response.url().includes('/wp-admin/admin-ajax.php') && + response.request().method() === 'POST' && + response + .request() + .postData() + .includes('action=feedzy&_action=run_now') + ); + + const responseBody = await runNowResponse.json(); + expect(responseBody.success).toBe(true); + expect(responseBody.data.import_success).toBe(expectSuccess); +} + +/** + * Set the logging level in Feedzy settings. + * + * @param {import('playwright').Page} page The page object. + * @param {import('@wordpress/e2e-test-utils-playwright/build-types/admin').Admin} admin The admin utils object. + * @param {string} level The logging level to set. + * @return {Promise} The promise that resolves when the settings are saved. + */ +export async function setLoggingLevel(page, admin, level) { + await admin.visitAdminPage('admin.php?page=feedzy-settings'); + + await page.locator('select[name="logs-logging-level"]').selectOption(level); + + await page + .getByRole('button', { name: 'Save Settings' }) + .click({ force: true }); + + await page.waitForSelector('.fz-snackbar-notice.updated'); +} + +/** + * Delete the Feedzy log file. + * + * @param {RequestUtils} requestUtils The request utils object. + * @return {Promise} The promise that resolves when the logs are deleted. + */ +export async function clearLogs(requestUtils) { + try { + await requestUtils.rest({ + method: 'DELETE', + path: '/feedzy/v1/logs', + }); + } catch (error) { + // The endpoint returns 404 when there is no log file yet. + if (error?.code !== 'no_logs') { + throw error; + } + } } From 4bf031c7a4238988e8cd11c26a662f719c2d6e6d Mon Sep 17 00:00:00 2001 From: Luca Dobrescu Date: Fri, 17 Jul 2026 11:57:40 +0300 Subject: [PATCH 02/13] fix: avoid introducing new translatable strings in the logs viewer The Translations Diff CI job fails on any POT change; render the import ID as a plain (#ID) suffix and drop the badge tooltips so the badges add no new strings. Co-Authored-By: Claude Fable 5 --- includes/layouts/feedzy-logs-viewer.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/layouts/feedzy-logs-viewer.php b/includes/layouts/feedzy-logs-viewer.php index e56eec995..079d4a1b9 100644 --- a/includes/layouts/feedzy-logs-viewer.php +++ b/includes/layouts/feedzy-logs-viewer.php @@ -122,20 +122,19 @@ class="fz-log-container fz-log-container--
- + - +
From 697a98a16113d738c92b1a98d80212f067893f4e Mon Sep 17 00:00:00 2001 From: Luca Dobrescu Date: Fri, 17 Jul 2026 12:29:02 +0300 Subject: [PATCH 03/13] fix: resolve WordPress.org plugin check errors Add direct-access guards to 26 PHP files; replace unlink() with wp_delete_file(); annotate the deliberate direct-filesystem fast paths; rename chosen-sprite@2x.png (special character) and the SimplePie util file that false-matched the core-library check (class name unchanged, resolved via an autoloader class map). Also raise the run-now wait timeout in the e2e helper for slow import runs. Co-Authored-By: Claude Fable 5 --- feedzy-rss-feed.php | 11 ++++++++++ form/form.php | 5 +++++ includes/admin/feedzy-rss-feeds-actions.php | 5 +++++ includes/admin/feedzy-rss-feeds-import.php | 20 ++++++------------ includes/admin/feedzy-rss-feeds-log.php | 2 ++ includes/admin/feedzy-rss-feeds-options.php | 5 +++++ includes/admin/feedzy-rss-feeds-upgrader.php | 5 +++++ includes/feedzy-rss-feeds-feed-tweaks.php | 5 +++++ includes/layouts/feedzy-documentation.php | 5 +++++ includes/layouts/feedzy-improve.php | 5 +++++ includes/layouts/feedzy-license.php | 5 +++++ includes/layouts/feedzy-pro.php | 8 ++++++- includes/layouts/feedzy-schedules.php | 5 +++++ includes/layouts/feedzy-subscribe-notice.php | 5 +++++ includes/layouts/feedzy-support.php | 5 +++++ includes/layouts/feedzy-tutorial.php | 5 +++++ includes/layouts/header.php | 5 +++++ includes/layouts/integration.php | 5 +++++ includes/layouts/settings.php | 5 +++++ includes/layouts/setup-wizard.php | 5 +++++ ...pie.php => feedzy-rss-feeds-util-feed.php} | 5 +++++ includes/views/ai-quota-view.php | 5 +++++ .../views/amazon-product-advertising-view.php | 5 +++++ ...sen-sprite@2x.png => chosen-sprite-2x.png} | Bin includes/views/css/chosen.css | 2 +- includes/views/import-metabox-edit.php | 5 +++++ includes/views/misc-view.php | 5 +++++ includes/views/openai-view.php | 5 +++++ includes/views/openrouter-view.php | 5 +++++ includes/views/spinnerchief-view.php | 5 +++++ includes/views/wordai-view.php | 5 +++++ tests/e2e/utils.js | 4 +++- 32 files changed, 156 insertions(+), 16 deletions(-) rename includes/util/{feedzy-rss-feeds-util-simplepie.php => feedzy-rss-feeds-util-feed.php} (98%) rename includes/views/css/{chosen-sprite@2x.png => chosen-sprite-2x.png} (100%) diff --git a/feedzy-rss-feed.php b/feedzy-rss-feed.php index ff08055c0..1cc3cbfb2 100644 --- a/feedzy-rss-feed.php +++ b/feedzy-rss-feed.php @@ -59,6 +59,17 @@ function deactivate_feedzy_rss_feeds() { * @since 3.0.0 */ function feedzy_rss_feeds_autoload( $class_to_load ) { + // Class files named differently from the autoloader convention + // (e.g. to avoid matching core-library filename patterns). + $class_map = array( + 'Feedzy_Rss_Feeds_Util_SimplePie' => 'includes/util/feedzy-rss-feeds-util-feed.php', + ); + if ( isset( $class_map[ $class_to_load ] ) ) { + require_once plugin_dir_path( __FILE__ ) . $class_map[ $class_to_load ]; + + return true; + } + $namespaces = array( 'Feedzy_Rss_Feeds' ); foreach ( $namespaces as $namespace ) { if ( substr( $class_to_load, 0, strlen( $namespace ) ) === $namespace ) { diff --git a/form/form.php b/form/form.php index 582d91476..c1fafd5ae 100644 --- a/form/form.php +++ b/form/form.php @@ -12,6 +12,11 @@ * @subpackage feedzy-rss-feeds/form */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + $html_parts = Feedzy_Rss_Feeds_Ui_Lang::get_form_elements(); ?> diff --git a/includes/admin/feedzy-rss-feeds-actions.php b/includes/admin/feedzy-rss-feeds-actions.php index 604684924..61ac1fb03 100644 --- a/includes/admin/feedzy-rss-feeds-actions.php +++ b/includes/admin/feedzy-rss-feeds-actions.php @@ -9,6 +9,11 @@ * @subpackage feedzy-rss-feeds/includes/admin */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + if ( ! class_exists( 'Feedzy_Rss_Feeds_Actions' ) ) { /** * Singleton class for content action process. diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 118c9b718..c65343a24 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -3196,8 +3196,7 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title ) ); - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink - unlink( $local_file ); + wp_delete_file( $local_file ); return false; } @@ -3214,8 +3213,7 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title ) ); - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink - unlink( $local_file ); + wp_delete_file( $local_file ); return false; } @@ -3227,7 +3225,7 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title $correct_local_file = preg_replace( '/\.[a-z0-9]+$/i', $correct_extension, $local_file ); if ( $correct_local_file !== $local_file ) { - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename, WordPress.WP.AlternativeFunctions.rename_rename -- renaming a temp file created by download_url(). if ( rename( $local_file, $correct_local_file ) ) { $local_file = $correct_local_file; } else { @@ -3241,8 +3239,7 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title ) ); - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink - unlink( $local_file ); + wp_delete_file( $local_file ); return false; } @@ -3323,7 +3320,7 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title $extension = ! empty( $extension ) ? '.' . $extension : str_replace( 'image/', '.', $type ); $new_local_file = preg_replace( '/\.tmp$/', $extension, $local_file ); - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename, WordPress.WP.AlternativeFunctions.rename_rename -- renaming a temp file created by download_url(). $renamed = rename( $local_file, $new_local_file ); if ( $renamed ) { $local_file = $new_local_file; @@ -3353,8 +3350,7 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title ) ); - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink - unlink( $local_file ); + wp_delete_file( $local_file ); return false; } @@ -3374,10 +3370,8 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title ) ); - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink if ( file_exists( $file_array['tmp_name'] ) ) { - // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink - unlink( $file_array['tmp_name'] ); + wp_delete_file( $file_array['tmp_name'] ); } return false; diff --git a/includes/admin/feedzy-rss-feeds-log.php b/includes/admin/feedzy-rss-feeds-log.php index 6c0a35c37..f50a7bf3a 100644 --- a/includes/admin/feedzy-rss-feeds-log.php +++ b/includes/admin/feedzy-rss-feeds-log.php @@ -611,6 +611,7 @@ private function tail_file( $lines = 50 ) { break; } } + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- direct-access fast path, guarded by can_use_direct_file_access(). fclose( $handle ); return $text; @@ -740,6 +741,7 @@ public function export_logs_endpoint( $request ) { header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $this->filepath ) ); + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- streams the log download without loading it into memory. readfile( $this->filepath ); exit; diff --git a/includes/admin/feedzy-rss-feeds-options.php b/includes/admin/feedzy-rss-feeds-options.php index 4abae3a40..d331fcf3d 100644 --- a/includes/admin/feedzy-rss-feeds-options.php +++ b/includes/admin/feedzy-rss-feeds-options.php @@ -9,6 +9,11 @@ * @subpackage feedzy-rss-feeds/includes/admin */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + if ( ! class_exists( 'Feedy_Rss_Feeds_Options' ) ) { /** * Singleton class for options wrapper diff --git a/includes/admin/feedzy-rss-feeds-upgrader.php b/includes/admin/feedzy-rss-feeds-upgrader.php index 7231a7823..62c6b6ce8 100644 --- a/includes/admin/feedzy-rss-feeds-upgrader.php +++ b/includes/admin/feedzy-rss-feeds-upgrader.php @@ -9,6 +9,11 @@ * @subpackage feedzy-rss-feeds/includes/admin */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + if ( ! class_exists( 'Feedzy_Rss_Feeds_Upgrader' ) ) { /** * Class Feedzy_Rss_Feeds_Upgrader for upgrading processes diff --git a/includes/feedzy-rss-feeds-feed-tweaks.php b/includes/feedzy-rss-feeds-feed-tweaks.php index 953dd6bc0..987fe552c 100644 --- a/includes/feedzy-rss-feeds-feed-tweaks.php +++ b/includes/feedzy-rss-feeds-feed-tweaks.php @@ -9,6 +9,11 @@ * @subpackage feedzy-rss-feeds/includes */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + /** * Adds the featured image to the website's RSS feed. * diff --git a/includes/layouts/feedzy-documentation.php b/includes/layouts/feedzy-documentation.php index 82737838b..d23996a9b 100644 --- a/includes/layouts/feedzy-documentation.php +++ b/includes/layouts/feedzy-documentation.php @@ -1,3 +1,8 @@ +