Last modified: 2010-06-04 13:33:08 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 T25791, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 23791 - SelectCategory removes Category assignments within <pre>- and <nowiki> -tags
SelectCategory removes Category assignments within <pre>- and <nowiki> -tags
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
SelectCategory (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Leon Weber
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-04 13:18 UTC by Tommi Tuura
Modified: 2010-06-04 13:33 UTC (History)
0 users

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


Attachments

Description Tommi Tuura 2010-06-04 13:18:49 UTC
When an article (that has <pre> / <nowiki> -tags which include category assignments) is opened for editing, SelectCategory takes those category assignments out. Those categories are also not included in the categories the page is in. Thus, when the page is subsequently saved, the category assingments have disappeared.

Clearly, the category assignments within <pre>- and <nowiki>-tags should be left as they are, since the point of <pre> and <nowiki> tags includes the idea of excluding wiki markup altogether. 

...For our internal mediawiki installation, I have actually made an (quite ugly) hack that makes it so that lines that include those tags (or are between the start/end tags of those elements) are not cleaned from category assignments. It seems to work so far, however no real testing has happened with this hack. My hack seems to be (so far) adequate for the needs of my organization, but having this issue fixed in main version would be much preferred, for obvious reasons.
Comment 1 Tommi Tuura 2010-06-04 13:32:01 UTC
Here's my hack: in SelectCategoryFunctions.php, lines 260-280:

  # Check linewise for category links:
  $m_isWithinPre = false; # For hack to make this ignore lines including and between <pre> / <nowiki> tags
  foreach( explode( "\n", $m_pageText ) as $m_textLine ) {
    if (stristr($m_textLine, "<pre>") || stristr($m_textLine, "<nowiki>")) { # hack
       $m_isWithinPre = true;
    }
    if (!$m_isWithinPre) { # original code
       # Filter line through pattern and store the result:
       $m_cleanText .= preg_replace( "/{$m_pattern}/i", "", $m_textLine ) . "\n";
       # Check if we have found a category, else proceed with next line:
                   if( !preg_match( "/{$m_pattern}/i", $m_textLine) ) continue;
       # Get the category link from the original text and store it in our list:
       $m_catLinks[ str_replace( ' ', '_', preg_replace( "/.*{$m_pattern}/i", $m_replace, $m_textLine ) ) ] = true;
    } else { # hack
       $m_cleanText .= $m_textLine . "\n";
    }
    if (stristr($m_textLine, "</pre>") || stristr($m_textLine, "</nowiki>")) { # hack
       $m_isWithinPre = false;
       
    }
  }
Comment 2 Tommi Tuura 2010-06-04 13:33:08 UTC
Here's my hack: in SelectCategoryFunctions.php, lines 260-280:

  # Check linewise for category links:
  $m_isWithinPre = false; # For hack to make this ignore lines including and between <pre> / <nowiki> tags
  foreach( explode( "\n", $m_pageText ) as $m_textLine ) {
    if (stristr($m_textLine, "<pre>") || stristr($m_textLine, "<nowiki>")) { # hack
       $m_isWithinPre = true;
    }
    if (!$m_isWithinPre) { # original code
       # Filter line through pattern and store the result:
       $m_cleanText .= preg_replace( "/{$m_pattern}/i", "", $m_textLine ) . "\n";
       # Check if we have found a category, else proceed with next line:
                   if( !preg_match( "/{$m_pattern}/i", $m_textLine) ) continue;
       # Get the category link from the original text and store it in our list:
       $m_catLinks[ str_replace( ' ', '_', preg_replace( "/.*{$m_pattern}/i", $m_replace, $m_textLine ) ) ] = true;
    } else { # hack
       $m_cleanText .= $m_textLine . "\n";
    }
    if (stristr($m_textLine, "</pre>") || stristr($m_textLine, "</nowiki>")) { # hack
       $m_isWithinPre = false;
       
    }
  }

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


Navigation
Links