User "Tim Starling" posted a comment on MediaWiki.r94502.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94502#c20807
Commit summary:

(bug 30269) Strings like foobar//barfoo are linked to become foobar[//barfoo]

* Introduce a boolean parameter to wfUrlProtocols() which, if set to false, 
will cause '//' to be dropped from the returned regex so it doesn't match 
protocol-relative URLs
* Introduce wfUrlProtocolsWithoutProtRel() as a wrapper for wfUrlProtocols( 
false ). The latter should not be used directly because the former is much 
clearer
* Use this new function in Parser::doMagicLinks() to fix the original bug. Also 
use it in ApiFormatBase::formatHTML() and CodeCommentLinker::link(), which 
probably had similar bugs

Comment:

 static $retval = array( true => null, false => null );

I think you're better off avoiding trying to index arrays with booleans. If 
someone sees you doing it, they might think it actually works as written, and 
they'll get into trouble.

Arrays in PHP have a string index. What's happening here is that the boolean 
values are being converted to integers and then to strings:

<pre>
> $a = array(true => '', false => '' );

> var_dump($a)
array(2) {
  [1]=>
  string(0) ""
  [0]=>
  string(0) ""
}

> unset($a[1]);

> var_dump($a)
array(1) {
  [0]=>
  string(0) ""
}
</pre>

Otherwise OK.

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to