mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
CommentParser: Avoid unnecessary reference in foreach()
This is not necessary, and never has been. This variable contains an object and it's never assigned to. Instead, the reference creates hard-to-debug bugs (I've just spent an hour debugging one). When the variable name is reused later in the same function as the loop variable of another foreach() loop (such as in If918bfd5e0), the result is overwriting of the last entry in $this->threadItems with the last entry from the other array. I was questioning everything I know about variables until I noticed. Change-Id: Ibb57f915b39dd4d6d2e744903f9ecadd67b1f52d
This commit is contained in:
parent
a2cf9cc978
commit
88b5be11fd
|
@ -968,7 +968,7 @@ class CommentParser {
|
||||||
$replies = [];
|
$replies = [];
|
||||||
$this->commentsById = [];
|
$this->commentsById = [];
|
||||||
|
|
||||||
foreach ( $this->threadItems as &$threadItem ) {
|
foreach ( $this->threadItems as $threadItem ) {
|
||||||
if ( $threadItem instanceof HeadingItem ) {
|
if ( $threadItem instanceof HeadingItem ) {
|
||||||
// We don't need ids for section headings right now, but we might in the future
|
// We don't need ids for section headings right now, but we might in the future
|
||||||
// e.g. if we allow replying directly to sections (adding top-level comments)
|
// e.g. if we allow replying directly to sections (adding top-level comments)
|
||||||
|
|
Loading…
Reference in a new issue