r1371 implements this efficiently and in a backwards compatible way.
Usage:
if ( is_callable( array( 'CBuser', 'advanceNoticeOfUsersNeeded' ) ) {
CBuser::advanceNoticeOfUsersNeeded( array( 63, 64, 65 ) );
CBuser::advanceNoticeOfUsersNeeded( array( 66, 67, 65 ) );
}
echo CBuser::getUserDataInstance( 64 )->id; // echo's 64
if ( is_callable( array( 'CBuser', 'advanceNoticeOfUsersNeeded' ) ) {
CBuser::advanceNoticeOfUsersNeeded( array( 68, 67, 69, 71 ) );
}
echo CBuser::getUserDataInstance( 67 )->id; // echos 67
echo CBuser::getUserDataInstance( 69 )->username; // echos username of user id 69
API:
/**
* Sets an additional list of user records to also load and cache with next SQL query
* e.g.:
* CBuser::advanceNoticeOfUsersNeeded( array( 66, 67, 65 ) ); // just remembers
* CBuser::advanceNoticeOfUsersNeeded( array( 64, 65 ) ); // just remembers
* echo CBuser::getUserDataInstance( 64 )->id; // echo's 64 // and loads 64-67
* CBuser::advanceNoticeOfUsersNeeded( array( 68, 67, 69, 71 ) ); // just remembers
* echo CBuser::getUserDataInstance( 67 )->id; // echos 67 // and doesn't load
* echo CBuser::getUserDataInstance( 69 )->username; // echos // and loads 68,69,71
*
* @param array of int $usersIds
*/
public static function advanceNoticeOfUsersNeeded( $usersIds );