[wp-trac] [WordPress Trac] #60579: Notice: Undefined index: name in /wp-includes/class-wp-roles.php on line 293
WordPress Trac
noreply at wordpress.org
Tue Feb 20 09:56:45 UTC 2024
#60579: Notice: Undefined index: name in /wp-includes/class-wp-roles.php on line
293
--------------------------+-----------------------------
Reporter: mrsize | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.4.3
Severity: minor | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
[[Image(http://servtest.ovh/notice-wp.jpg)]]
I have some notices on my dashboard, and fix the bug by modifying the
function in core file, line 279 :
{{{#!php
<?php
/**
* Initializes all of the available roles.
*
* @since 4.9.0
*/
public function init_roles() {
if ( empty( $this->roles ) ) {
return;
}
$this->role_objects = array();
$this->role_names = array();
foreach ( array_keys( $this->roles ) as $role ) {
// Vérifier si 'name' est défini pour le rôle actuel
if ( isset( $this->roles[ $role ]['name'] ) ) {
$this->role_objects[ $role ] = new WP_Role( $role,
$this->roles[ $role ]['capabilities'] );
$this->role_names[ $role ] = $this->roles[ $role ]['name'];
} else {
// Gérer le cas où 'name' n'est pas défini (éventuellement
définir une valeur par défaut)
$this->role_objects[ $role ] = new WP_Role( $role,
$this->roles[ $role ]['capabilities'] );
$this->role_names[ $role ] = 'Nom par défaut';
}
}
/**
* Fires after the roles have been initialized, allowing plugins to
add their own roles.
*
* @since 4.7.0
*
* @param WP_Roles $wp_roles A reference to the WP_Roles object.
*/
do_action( 'wp_roles_init', $this );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60579>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list