Last modified: 2011-03-13 18:05:54 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T17566, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 15566 - weird code for onlyinclude
weird code for onlyinclude
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Lowest trivial (vote)
: ---
Assigned To: Nobody - You can work on this!
http://svn.wikimedia.org/doc/
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-11 19:57 UTC by Christopher Yeleighton
Modified: 2011-03-13 18:05 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Christopher Yeleighton 2008-09-11 19:57:31 UTC
This is not a bug report but rather a code review remark.  Preprocessor_Hash::preprocessToObj says:

00075                         if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
00076                                 $enableOnlyinclude = true;
00077                         }

that means "</onlyinclude><onlyinclude>" is covered by the case.
Whas that intended?  
I suppose it was not 
and this is only some heuristic 
to detect "<onlyinclude>…</onlyinclude>"; 
however, an obvious improvement seems to exist.

I would rather say this

if(
 ($oip = strpos($text, '<onlyinclude>')) !== false && 
 strpos($text, '</onlyinclude>', $oip + strlen('<onlyinclude>')) 
 != false)
Comment 1 Roan Kattouw 2008-09-11 21:33:31 UTC
Regexes, anyone?
Comment 2 Max Semenik 2008-09-12 17:39:53 UTC
Regexes are needlessly slow, you just need to compare those two strpos'es.
Comment 3 Aaron Schulz 2009-01-02 17:24:14 UTC
This isn't really worth adding code complexity and overhead for this case.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links