Skip to content

Commit f844d4b

Browse files
committed
Plugin Directory: Fix PHP warnings when building plugin ZIPs and checking block plugins.
When an SVN export fails but the error details aren't available, the code tried to read them anyway, triggering warnings. Add a fallback so a generic message is used instead. Also fixes a typo in a constant name that would have caused a fatal error when a plugin directory turned out to be empty. git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14773 74240141-8908-4e6f-9713-ba540dce6ec7
1 parent 63a36c0 commit f844d4b

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-block-plugin-checker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ function export_plugin( $svn_url ) {
248248
$this->record_result(
249249
__FUNCTION__,
250250
'error',
251-
sprintf( __( 'Error fetching repository %s: %s', 'wporg-plugins' ), $svn_url, $export['errors'][0]['error_code'] ),
252-
$export['errors']
251+
sprintf( __( 'Error fetching repository %s: %s', 'wporg-plugins' ), $svn_url, $export['errors'][0]['error_code'] ?? 'unknown error' ),
252+
$export['errors'] ?? array()
253253
);
254254
return false;
255255
}

wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,15 @@ protected function export_plugin() {
395395
$res = SVN::export( $this->plugin_version_svn_url, $build_dir, $svn_params );
396396
}
397397
if ( ! $res['result'] ) {
398-
throw new Exception( __METHOD__ . ': ' . $res['errors'][0]['error_message'], 404 );
398+
throw new Exception( __METHOD__ . ': ' . ( $res['errors'][0]['error_message'] ?? 'unknown error' ), 404 );
399399
}
400400

401401
// Store the SVN revision that's been used for the ZIP in a property for later.
402402
$this->plugins_revision = $res['revision'];
403403

404404
// Verify that the specified plugin zip will contain files.
405405
if ( ! array_diff( scandir( $this->tmp_build_dir ), array( '.', '..' ) ) ) {
406-
throw new Exception( ___METHOD__ . ': No files exist in the plugin directory', 404 );
406+
throw new Exception( __METHOD__ . ': No files exist in the plugin directory', 404 );
407407
}
408408

409409
// Cleanup any symlinks that shouldn't be there

0 commit comments

Comments
 (0)