Fixed various reentrant-unsafe 2D array element unsets (similar to previous commit)

this pattern was used in various places
This commit is contained in:
Dylan K. Taylor
2023-11-01 16:28:59 +00:00
parent abce512860
commit e6e2c54ec9
3 changed files with 25 additions and 16 deletions

View File

@ -1259,9 +1259,10 @@ class Server{
*/
public function unsubscribeFromBroadcastChannel(string $channelId, CommandSender $subscriber) : void{
if(isset($this->broadcastSubscribers[$channelId][spl_object_id($subscriber)])){
unset($this->broadcastSubscribers[$channelId][spl_object_id($subscriber)]);
if(count($this->broadcastSubscribers[$channelId]) === 0){
if(count($this->broadcastSubscribers[$channelId]) === 1){
unset($this->broadcastSubscribers[$channelId]);
}else{
unset($this->broadcastSubscribers[$channelId][spl_object_id($subscriber)]);
}
}
}