Skip to:
Content

BuddyPress.org

Changeset 13495


Ignore:
Timestamp:
06/02/2023 02:05:08 AM (9 months ago)
Author:
imath
Message:

Prevent potential issues with late_includes() in Component classes

Use require_once instead of require to load action & screen files.

See #4954
Fixes #8910
Closes https://github.com/buddypress/buddypress/pull/112

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-component.php

    r13492 r13495  
    122122                in_array( bp_current_action(), array( 'delete', 'spam', 'post', 'reply', 'favorite', 'unfavorite' ), true )
    123123            ) {
    124                 require $this->path . 'bp-activity/actions/' . bp_current_action() . '.php';
     124                require_once $this->path . 'bp-activity/actions/' . bp_current_action() . '.php';
    125125            }
    126126
    127127            // RSS feeds.
    128128            if ( bp_is_current_action( 'feed' ) || bp_is_action_variable( 'feed', 0 ) ) {
    129                 require $this->path . 'bp-activity/actions/feeds.php';
     129                require_once $this->path . 'bp-activity/actions/feeds.php';
    130130            }
    131131
    132132            // Screens - Directory.
    133133            if ( bp_is_activity_directory() ) {
    134                 require $this->path . 'bp-activity/screens/directory.php';
     134                require_once $this->path . 'bp-activity/screens/directory.php';
    135135            }
    136136
    137137            // Screens - User main nav.
    138138            if ( bp_is_user() ) {
    139                 require $this->path . 'bp-activity/screens/just-me.php';
     139                require_once $this->path . 'bp-activity/screens/just-me.php';
    140140            }
    141141
     
    163163
    164164            if ( bp_is_user() && isset( $filenames[ $slug ] ) ) {
    165                 require $this->path . 'bp-activity/screens/' . $filenames[ $slug ] . '.php';
     165                require_once $this->path . 'bp-activity/screens/' . $filenames[ $slug ] . '.php';
    166166            }
    167167
    168168            // Screens - Single permalink.
    169169            if ( bp_is_current_action( 'p' ) || is_numeric( bp_current_action() ) ) {
    170                 require $this->path . 'bp-activity/screens/permalink.php';
     170                require_once $this->path . 'bp-activity/screens/permalink.php';
    171171            }
    172172
  • trunk/src/bp-blogs/classes/class-bp-blogs-component.php

    r13492 r13495  
    177177        // Actions.
    178178        if ( isset( $_GET['random-blog'] ) ) {
    179             require $this->path . 'bp-blogs/actions/random.php';
     179            require_once $this->path . 'bp-blogs/actions/random.php';
    180180        }
    181181
    182182        // Screens.
    183183        if ( bp_is_user() ) {
    184             require $this->path . 'bp-blogs/screens/my-blogs.php';
     184            require_once $this->path . 'bp-blogs/screens/my-blogs.php';
    185185        } else {
    186186            if ( bp_is_blogs_directory() ) {
    187                 require $this->path . 'bp-blogs/screens/directory.php';
     187                require_once $this->path . 'bp-blogs/screens/directory.php';
    188188            }
    189189
    190190            if ( is_user_logged_in() && bp_is_current_action( 'create' ) ) {
    191                 require $this->path . 'bp-blogs/screens/create.php';
     191                require_once $this->path . 'bp-blogs/screens/create.php';
    192192            }
    193193
  • trunk/src/bp-friends/classes/class-bp-friends-component.php

    r13481 r13495  
    8686                in_array( bp_current_action(), array( 'add-friend', 'remove-friend' ), true )
    8787            ) {
    88                 require $this->path . 'bp-friends/actions/' . bp_current_action() . '.php';
     88                require_once $this->path . 'bp-friends/actions/' . bp_current_action() . '.php';
    8989            }
    9090
    9191            // User nav.
    92             require $this->path . 'bp-friends/screens/my-friends.php';
     92            require_once $this->path . 'bp-friends/screens/my-friends.php';
    9393            if ( is_user_logged_in() && bp_is_user_friend_requests() ) {
    94                 require $this->path . 'bp-friends/screens/requests.php';
     94                require_once $this->path . 'bp-friends/screens/requests.php';
    9595            }
    9696        }
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r13492 r13495  
    152152            // Actions - Random member handler.
    153153            if ( isset( $_GET['random-member'] ) ) {
    154                 require $this->path . 'bp-members/actions/random.php';
     154                require_once $this->path . 'bp-members/actions/random.php';
    155155            }
    156156
    157157            // Screens - Directory.
    158158            if ( bp_is_members_directory() ) {
    159                 require $this->path . 'bp-members/screens/directory.php';
     159                require_once $this->path . 'bp-members/screens/directory.php';
    160160            }
    161161        }
     
    163163        // Members - User main nav screen.
    164164        if ( bp_is_user() ) {
    165             require $this->path . 'bp-members/screens/profile.php';
     165            require_once $this->path . 'bp-members/screens/profile.php';
    166166
    167167            // Action - Delete avatar.
    168168            if ( is_user_logged_in()&& bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) {
    169                 require $this->path . 'bp-members/actions/delete-avatar.php';
     169                require_once $this->path . 'bp-members/actions/delete-avatar.php';
    170170            }
    171171
     
    174174                in_array( bp_current_action(), array( 'change-avatar', 'change-cover-image' ), true )
    175175            ) {
    176                 require $this->path . 'bp-members/screens/' . bp_current_action() . '.php';
     176                require_once $this->path . 'bp-members/screens/' . bp_current_action() . '.php';
    177177            }
    178178        }
     
    186186        if ( bp_is_register_page() || bp_is_activation_page() ) {
    187187            if ( bp_is_register_page() ) {
    188                 require $this->path . 'bp-members/screens/register.php';
     188                require_once $this->path . 'bp-members/screens/register.php';
    189189            } else {
    190                 require $this->path . 'bp-members/screens/activate.php';
     190                require_once $this->path . 'bp-members/screens/activate.php';
    191191            }
    192192
     
    199199            // Actions.
    200200            if ( isset( $_POST['members_invitations'] ) ) {
    201                 require $this->path . 'bp-members/actions/invitations-bulk-manage.php';
     201                require_once $this->path . 'bp-members/actions/invitations-bulk-manage.php';
    202202            }
    203203
    204204            // Screens.
    205             require $this->path . 'bp-members/screens/invitations.php';
     205            require_once $this->path . 'bp-members/screens/invitations.php';
    206206        }
    207207    }
  • trunk/src/bp-messages/classes/class-bp-messages-component.php

    r13481 r13495  
    9898                in_array( bp_current_action(), array( 'compose', 'notices', 'view' ), true )
    9999            ) {
    100                 require $this->path . 'bp-messages/actions/' . bp_current_action() . '.php';
     100                require_once $this->path . 'bp-messages/actions/' . bp_current_action() . '.php';
    101101            }
    102102
     
    105105                in_array( bp_action_variable( 0 ), array( 'delete', 'read', 'unread', 'bulk-manage', 'bulk-delete', 'exit' ), true )
    106106            ) {
    107                 require $this->path . 'bp-messages/actions/' . bp_action_variable( 0 ) . '.php';
     107                require_once $this->path . 'bp-messages/actions/' . bp_action_variable( 0 ) . '.php';
    108108            }
    109109
     
    112112                // Single action.
    113113                if ( in_array( bp_current_action(), array( 'star', 'unstar' ), true ) ) {
    114                     require $this->path . 'bp-messages/actions/star.php';
     114                    require_once $this->path . 'bp-messages/actions/star.php';
    115115                }
    116116
    117117                // Bulk-manage.
    118118                if ( bp_is_action_variable( 'bulk-manage' ) ) {
    119                     require $this->path . 'bp-messages/actions/bulk-manage-star.php';
     119                    require_once $this->path . 'bp-messages/actions/bulk-manage-star.php';
    120120                }
    121121            }
     
    123123            // Screens - User profile integration.
    124124            if ( bp_is_user() ) {
    125                 require $this->path . 'bp-messages/screens/inbox.php';
     125                require_once $this->path . 'bp-messages/screens/inbox.php';
    126126
    127127                /*
     
    131131                 */
    132132                if ( bp_is_user_messages() && in_array( bp_current_action(), array( 'sentbox', 'compose', 'notices', 'view' ), true ) ) {
    133                     require $this->path . 'bp-messages/screens/' . bp_current_action() . '.php';
     133                    require_once $this->path . 'bp-messages/screens/' . bp_current_action() . '.php';
    134134                }
    135135
    136136                // Nav item - Starred.
    137137                if ( bp_is_active( $this->id, 'star' ) && bp_is_current_action( bp_get_messages_starred_slug() ) ) {
    138                     require $this->path . 'bp-messages/screens/starred.php';
     138                    require_once $this->path . 'bp-messages/screens/starred.php';
    139139                }
    140140            }
  • trunk/src/bp-notifications/classes/class-bp-notifications-component.php

    r13450 r13495  
    7878        // Actions.
    7979        if ( bp_is_post_request() ) {
    80             require $this->path . 'bp-notifications/actions/bulk-manage.php';
     80            require_once $this->path . 'bp-notifications/actions/bulk-manage.php';
    8181        } elseif ( bp_is_get_request() ) {
    82             require $this->path . 'bp-notifications/actions/delete.php';
     82            require_once $this->path . 'bp-notifications/actions/delete.php';
    8383        }
    8484
    8585        // Screens.
    86         require $this->path . 'bp-notifications/screens/unread.php';
     86        require_once $this->path . 'bp-notifications/screens/unread.php';
    8787        if ( bp_is_current_action( 'read' ) ) {
    88             require $this->path . 'bp-notifications/screens/read.php';
     88            require_once $this->path . 'bp-notifications/screens/read.php';
    8989        }
    9090    }
  • trunk/src/bp-settings/classes/class-bp-settings-component.php

    r13450 r13495  
    7373        if ( is_user_logged_in() ) {
    7474            if ( ! bp_current_action() || bp_is_current_action( 'general' ) ) {
    75                 require $this->path . 'bp-settings/actions/general.php';
     75                require_once $this->path . 'bp-settings/actions/general.php';
    7676
    7777            // Specific to post requests.
    7878            } elseif ( bp_is_post_request() && in_array( bp_current_action(), $actions, true ) ) {
    79                 require $this->path . 'bp-settings/actions/' . bp_current_action() . '.php';
     79                require_once $this->path . 'bp-settings/actions/' . bp_current_action() . '.php';
    8080            }
    8181        }
     
    8383        // Screens - User profile integration.
    8484        if ( bp_is_user() ) {
    85             require $this->path . 'bp-settings/screens/general.php';
     85            require_once $this->path . 'bp-settings/screens/general.php';
    8686
    8787            // Sub-nav items.
    8888            if ( in_array( bp_current_action(), $actions, true ) ) {
    89                 require $this->path . 'bp-settings/screens/' . bp_current_action() . '.php';
     89                require_once $this->path . 'bp-settings/screens/' . bp_current_action() . '.php';
    9090            }
    9191        }
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-component.php

    r13450 r13495  
    112112        // User nav.
    113113        if ( bp_is_profile_component() ) {
    114             require $this->path . 'bp-xprofile/screens/public.php';
     114            require_once $this->path . 'bp-xprofile/screens/public.php';
    115115
    116116            // Sub-nav items.
    117117            if ( is_user_logged_in() && 'edit' === bp_current_action() ) {
    118                 require $this->path . 'bp-xprofile/screens/edit.php';
     118                require_once $this->path . 'bp-xprofile/screens/edit.php';
    119119            }
    120120        }
     
    122122        // Settings.
    123123        if ( is_user_logged_in() && bp_is_user_settings_profile() ) {
    124             require $this->path . 'bp-xprofile/screens/settings-profile.php';
     124            require_once $this->path . 'bp-xprofile/screens/settings-profile.php';
    125125        }
    126126    }
Note: See TracChangeset for help on using the changeset viewer.