close

Making WordPress.org

Changeset 14698


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

Plugin Directory: Gate 2FA-related calls behind class_exists/function_exists checks to prevent fatal errors when Two_Factor plugin is not active.

  • Skip 2FA revalidation in release confirmation API when Two_Factor_Core class is unavailable
  • Wrap Two_Factor_Core::is_user_using_two_factor() calls in release confirmation shortcode
  • Guard user_requires_2fa() and is_email_address_unsafe() calls in upload shortcode

This allows for the plugin directory to be used in a local environment.

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

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-release-confirmation.php

    r14503 r14698  
    118118        }
    119119
     120        if ( ! class_exists( 'Two_Factor_Core' ) ) {
     121            return true;
     122        }
     123
    120124        // Check to see if they've confirmed their 2FA status recently..
    121125        $status = get_revalidation_status();
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-release-confirmation.php

    r14697 r14698  
    6969
    7070        // If the user is not using 2FA, show a notice.
    71         if ( ! Two_Factor_Core::is_user_using_two_factor( get_current_user_id() ) ) {
     71        if (
     72            class_exists( 'Two_Factor_Core' ) &&
     73            ! Two_Factor_Core::is_user_using_two_factor( get_current_user_id() )
     74        ) {
    7275            printf(
    7376                '<div class="plugin-notice notice notice-error notice-alt"><p>%s</p></div>',
     
    283286        if (
    284287            ! is_user_logged_in() ||
    285             ! Two_Factor_Core::is_user_using_two_factor( get_current_user_id() ) ||
    286288            ! current_user_can( 'plugin_manage_releases', $plugin  ) ||
     289            ( class_exists( 'Two_Factor_Core' ) && ! Two_Factor_Core::is_user_using_two_factor( get_current_user_id() ) ) ||
    287290
    288291            // No need to show actions if the release can't be confirmed, or is already confirmed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r14697 r14698  
    6565        // Require 2FA for plugin authors on upload.
    6666        if (
     67            function_exists( 'WordPressdotorg\Two_Factor\user_requires_2fa' ) &&
     68            class_exists( 'Two_Factor_Core' ) &&
    6769            user_requires_2fa( wp_get_current_user() ) &&
    6870            ! Two_Factor_Core::is_user_using_two_factor( get_current_user_id() )
     
    394396                )
    395397            );
    396         } else if ( is_email_address_unsafe( wp_get_current_user()->user_email ) ) {
     398        } else if ( function_exists( 'is_email_address_unsafe' ) /* multisite-only */ && is_email_address_unsafe( wp_get_current_user()->user_email ) ) {
    397399            echo '<div class="notice notice-error notice-alt"><p>' .
    398400                sprintf(
Note: See TracChangeset for help on using the changeset viewer.