Skip to content

Commit

Permalink
profile_is_global() now calls profile_get_row_direct()
Browse files Browse the repository at this point in the history
This allows triggering an error when checking on an invalid Profile ID
instead of returning false (which could be interpreted as if it were a
valid User profile)

Fixes #27258
  • Loading branch information
dregad committed Sep 18, 2020
1 parent fc5ad9a commit 2fc662f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions account_prof_edit_page.php
Expand Up @@ -61,6 +61,7 @@
$f_profile_id = gpc_get_int( 'profile_id' );
$f_redirect_page = gpc_get_string( 'redirect', 'account_prof_menu_page.php' );

/** @noinspection PhpUnhandledExceptionInspection */
$t_global_profile = profile_is_global( $f_profile_id );
if( $t_global_profile ) {
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );
Expand Down
6 changes: 3 additions & 3 deletions core/profile_api.php
Expand Up @@ -312,9 +312,9 @@ function profile_get_default( $p_user_id ) {
* Returns whether the specified profile is global
* @param integer $p_profile_id A valid profile identifier.
* @return boolean
* @throws ClientException if the profile ID does not exist
*/
function profile_is_global( $p_profile_id ) {
$t_row = profile_get_row( ALL_USERS, $p_profile_id );
return( $t_row !== false );
$t_row = profile_get_row_direct( $p_profile_id );
return $t_row['user_id'] == ALL_USERS;
}

0 comments on commit 2fc662f

Please sign in to comment.