- Affected version
- 2.2.1
The call sites for
But in
This is fetching any moderated changes and then expires duplicates, that makes sense. Except the callback registered in
I'm fairly sure
Even then,
Also shouldn't this function call
clearPendingUsernameChanges
have comments suggesting the cleanup is triggered/done by the function.
PHP:
class User {
...
// if user has a pending username change then handle them
$usernameChangeRepo->clearPendingUsernameChanges($this);
PHP:
class UsernameChange {
...
// remove/reject any other pending changes
$this->getUsernameChangeRepo()->clearPendingUsernameChanges($this->User, $this);
But in
clearPendingUsernameChanges()
PHP:
public function clearPendingUsernameChanges(
\XF\Entity\User $user, \XF\Entity\UsernameChange $skipChange = null, \XF\Entity\User $moderator = null
)
{
...
$pendingChanges = $this->finder('XF:UsernameChange')->where([
'user_id' => $user->user_id,
'change_state' => 'moderated'
]);
if ($skipChange)
{
$pendingChanges->where('change_id', '!=', $skipChange->change_id);
}
foreach ($pendingChanges->fetch() AS $pendingChange)
{
$pendingChange->whenSaveable(function(\XF\Entity\UsernameChange $pendingChange) use ($user, $moderator)
{
...
});
}
}
This is fetching any moderated changes and then expires duplicates, that makes sense. Except the callback registered in
whenSaveable
doesn't look to be very called as these are never registered with the calling entity in any way.I'm fairly sure
$pendingChange->whenSaveable
should be $user->whenSaveable
.Even then,
UsernameChange::_postSave()
doesn't modify the $user
entity so that isn't going to reliably work either. I'm struggling to see how whenSaveable
would be used in this function.Also shouldn't this function call
$user->clearCache('PendingUsernameChange')
to ensure a non-cached value is used later?