r113475 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113474‎ | r113475 | r113476 >
Date:15:54, 9 March 2012
Author:maxsem
Status:reverted
Tags:gerritmigration 
Comment:
Bug 35083 - OpenSearchXml first sentences extraction produces bad results. Made extracts at least 100 characters long (configurable).
Modified paths:
  • /trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php (modified) (history)
  • /trunk/extensions/OpenSearchXml/OpenSearchXml.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
@@ -275,6 +275,7 @@
276276 * @access private
277277 */
278278 function extractStart( $text ) {
 279+ global $wgOpenSearchDescriptionLength;
279280 $endchars = array(
280281 '([^\d])\.\s', '\!\s', '\?\s', // regular ASCII
281282 '。', // full-width ideographic full-stop
@@ -284,7 +285,7 @@
285286
286287 $endgroup = implode( '|', $endchars );
287288 $end = "(?:$endgroup)";
288 - $sentence = ".*?$end+";
 289+ $sentence = ".{{$wgOpenSearchDescriptionLength},}?$end+";
289290 $firstone = "/^($sentence)/u";
290291 $matches = array();
291292 if( preg_match( $firstone, $text, $matches ) ) {
Index: trunk/extensions/OpenSearchXml/OpenSearchXml.php
@@ -40,6 +40,11 @@
4141 $wgOpenSearchAdvertiseXml = true;
4242
4343 /**
 44+ * Minimum length of extract in <Description>. Actual extracts will last until the end of sentence.
 45+ */
 46+$wgOpenSearchDescriptionLength = 100;
 47+
 48+/**
4449 * @param $urls array
4550 * @return bool
4651 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r114401Revert r113365, r113372, r113395, r113474, r113475: unreviewed revisions in O...catrope20:27, 21 March 2012

Status & tagging log