close

Making WordPress.org

Changeset 14699


Ignore:
Timestamp:
03/12/2026 03:25:55 AM (41 hours ago)
Author:
dd32
Message:

Plugin Directory: Guard SVN credential constants behind defined() checks.

Avoid fatal errors when PLUGIN_SVN_MANAGEMENT_USER is not defined by checking before use, and returning early with an error when no credentials are available.

Additionally, a quickfix for a potential fatal in svn ls XML parsing.

See https://github.com/WordPress/wordpress.org/pull/555

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php

    r14414 r14699  
    2525
    2626        $options[]   = 'non-interactive';
    27         if ( empty( $options['username'] ) ) {
     27        if ( empty( $options['username'] ) && defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) ) {
    2828            $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
    2929            $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     
    7575        $options[] = 'non-interactive';
    7676        $options['m'] = $message;
    77         if ( empty( $options['username'] ) ) {
     77        if ( empty( $options['username'] ) && defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) ) {
    7878            $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
    7979            $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     80        }
     81
     82        if ( empty( $options['username'] ) ) {
     83            return [
     84                'result'   => false,
     85                'revision' => false,
     86                'errors'   => [ 'No SVN credentials configured.' ],
     87            ];
    8088        }
    8189
     
    250258        $options[] = 'non-interactive';
    251259        $options['m'] = $message;
    252         if ( empty( $options['username'] ) ) {
     260        if ( empty( $options['username'] ) && defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) ) {
    253261            $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
    254262            $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     263        }
     264
     265        if ( empty( $options['username'] ) ) {
     266            return [
     267                'result'   => false,
     268                'revision' => false,
     269                'errors'   => [ 'No SVN credentials configured.' ],
     270            ];
    255271        }
    256272
     
    290306        $options[] = 'non-interactive';
    291307        $options['m'] = $message;
    292         if ( empty( $options['username'] ) ) {
     308        if ( empty( $options['username'] ) && defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) ) {
    293309            $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
    294310            $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     311        }
     312
     313        if ( empty( $options['username'] ) ) {
     314            return [
     315                'result'   => false,
     316                'revision' => false,
     317                'errors'   => [ 'No SVN credentials configured.' ],
     318            ];
    295319        }
    296320
     
    342366        $xml    = simplexml_load_string( $output );
    343367        libxml_use_internal_errors( $errors );
     368
     369        if ( ! $xml || ! isset( $xml->list ) ) {
     370            return false;
     371        }
    344372
    345373        $files = [];
     
    496524            }
    497525
    498             if ( empty( $options['username'] ) ) {
     526            if ( empty( $options['username'] ) && defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) ) {
    499527                $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
    500528                $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     529            }
     530
     531            if ( empty( $options['username'] ) ) {
     532                return [
     533                    'result'   => false,
     534                    'revision' => false,
     535                    'errors'   => [ 'No SVN credentials configured.' ],
     536                ];
    501537            }
    502538        }
Note: See TracChangeset for help on using the changeset viewer.