Last modified: 2010-06-04 13:33:08 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.
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; } }