From fd7da77f25a1aa21dd226dcc970a3834c9584c10 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Wed, 5 Aug 2026 11:53:35 -0500 Subject: [PATCH] Plugin Directory: Emit a PHP warning when a ZIP fails to build. Previously a failed ZIP build was silently swallowed in two places: the per-version catch in Zip\Builder::build() skips the version, and Import::rebuild_affected_zips() catches the Builder exception and returns false. In both cases the import reports success and nothing reaches the error log, so build outages go unnoticed. Trigger an E_USER_WARNING with the slug, version(s), and underlying error in both spots, and record the failure in the import warnings so it also lands in the _import_warnings post meta and the wporg_plugins_imported action. Co-Authored-By: Claude Fable 5 --- .../wp-content/plugins/plugin-directory/cli/class-import.php | 5 +++++ .../plugins/plugin-directory/zip/class-builder.php | 3 +++ 2 files changed, 8 insertions(+) diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php index 3a1785c472..81b3291f56 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php @@ -661,6 +661,11 @@ protected function rebuild_affected_zips( $plugin_slug, $stable_tag, $current_st $stable_tag ); } catch ( Exception $e ) { + $this->warnings['zip_build_failed'] = $e->getMessage(); + + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Routed to the error log via E_USER_WARNING; raw is fine. + trigger_error( sprintf( '%s: ZIP build failed for %s: %s', $plugin_slug, implode( ', ', array_unique( $versions_to_build ) ), $e->getMessage() ), E_USER_WARNING ); + return false; } diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php index 89ec3724b0..2eb663df32 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php @@ -128,6 +128,9 @@ public function build( $slug, $versions, $context = '', $stable_tag = '' ) { } catch ( Exception $e ) { // In event of error, skip this file this time. + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Routed to the error log via E_USER_WARNING; raw is fine. + trigger_error( sprintf( 'ZIP build failed for %s %s: %s', $this->slug, $version, $e->getMessage() ), E_USER_WARNING ); + $this->cleanup_plugin_tmp(); // Perform an SVN up to revert any changes made.