New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.4] Remove unsed variable messages from enqueue messages #42948
base: 4.4-dev
Are you sure you want to change the base?
Conversation
This should be properly tested as the function getMessageQueue initializes $this->messageQueue which is used later down. I don't think so we can remove that line. Perhaps the returned $messages variable should be used instead of $this->messageQueue. |
Then we let it as is. Just looks weird in the IDE. |
What you can remove is |
shouldn't it be |
Better remove the line as you did here, and replace next line with if (!\in_array($message, $this->getMessageQueue())) {
// Enqueue the message.
$this->messageQueue[] = $message;
}
|
@joomdonation I think with this changes we losing the context, I would suggest to keep that comment and the logic. Kind of: // For empty queue, if messages exists in the session, enqueue them first.
$this->getMessageQueue();
if (!\in_array($message, $this->messageQueue)) {
// Enqueue the message.
$this->messageQueue[] = $message;
} |
@chmst @Fedik That also works, but it is also a bit confusing when calling method returns data but we do not use that returned data for any thing. Honestly, I don't know what's better, but I would also not complain if your code is used. The most important thing is get rid of unused variable so that the code is not being removed by mistake in the future. |
Agree with @joomdonation |
The problem, that in future, someone may refactor that code, and just replace Because, why not? But it is important to call It can stay as you made, but then please add a comment with explanation. |
@Fedik what about that comment? |
Good enough, thanks 😉 |
I wouldn't do this in 4.4 and move it 5.2 since it doesn't solve a bug. |
Pull Request for Issue # .
Summary of Changes
As title says, there is an unused variable.
Testing Instructions
Test different situations where messages are sent and also enqueued, like here
All messages must be the same before and after patch