Topic on Extension talk:SphinxSearch

Issues with SphinxSearch in 1.39

2
46.31.222.226 (talkcontribs)

We upgrade from the version 1.35.8 LTS to 1.39.1 LTS and we get the following Issues:

1- "connection to localhost:9312 failed (errno=111, msg=Connection refused)"

2- "Interner Fehler: received zero-sized searchd response"


Hier are the fix for this issues:

  • SphinxMWSearchResult:

@@ -20,9 +20,10 @@ class SphinxMWSearchResult extends RevisionSearchResult {

    * @param stdClass $row

    * @param SphinxClient|null $sphinx_client

    */

   public function __construct( $row, $sphinx_client ) {

   public function __construct( $row, $sphinx_client, $terms ) {

       $this->sphinx_client = $sphinx_client;

       $this->initFromTitle( Title::makeTitle( $row->page_namespace, $row->page_title ) );

               $this->terms = $terms;

   }

   /**

@@ -40,9 +41,9 @@ public function getTextSnippet( $terms = [] ) {

       if ( $wgSphinxSearchMWHighlighter ) {

           $h = new SearchHighlighter();

           if ( $wgAdvancedSearchHighlighting ) {

               return $h->highlightText( $this->mText, $terms, $contextlines, $contextchars );

               return $h->highlightText( $this->mText, $this->terms, $contextlines, $contextchars );

           } else {

               return $h->highlightSimple( $this->mText, $terms, $contextlines, $contextchars );

               return $h->highlightSimple( $this->mText, $this->terms, $contextlines, $contextchars );

           }

       }

@@ -57,7 +58,7 @@ public function getTextSnippet( $terms = [] ) {

       $excerpts = $this->sphinx_client->BuildExcerpts(

           [ $this->mText ],

           $wgSphinxSearch_index,

           implode( ' ', $terms ),

           implode( ' ', $this->terms ),

           $excerpts_opt

       );


  • SphinxMWSearchResultSet:

@@ -245,7 +245,7 @@ public function next() {

       if ( isset( $this->mResultSet[$this->mNdx] ) ) {

           $row = $this->mResultSet[$this->mNdx];

           ++$this->mNdx;

           return new SphinxMWSearchResult( $row, $this->sphinx_client );

           return new SphinxMWSearchResult( $row, $this->sphinx_client, $this->mTerms );

       } else {

           return false;

       }

Rrosenfeld (talkcontribs)

Many thanks for this patch! I observed the same issue as you and this patch solved it for me, too. Since something broke the formatting of your patch, here's what I used:

--- SphinxMWSearchResult.php.org	2023-03-14 09:32:43.000000000 +0100
+++ SphinxMWSearchResult.php	2023-06-29 15:47:04.311199198 +0200
@@ -20,9 +20,10 @@
 	 * @param stdClass $row
 	 * @param SphinxClient|null $sphinx_client
 	 */
-	public function __construct( $row, $sphinx_client ) {
+	public function __construct( $row, $sphinx_client, $terms ) {
 		$this->sphinx_client = $sphinx_client;
 		$this->initFromTitle( Title::makeTitle( $row->page_namespace, $row->page_title ) );
+		$this->terms = $terms;
 	}
 
 	/**
@@ -40,9 +41,9 @@
 		if ( $wgSphinxSearchMWHighlighter ) {
 			$h = new SearchHighlighter();
 			if ( $wgAdvancedSearchHighlighting ) {
-				return $h->highlightText( $this->mText, $terms, $contextlines, $contextchars );
+				return $h->highlightText( $this->mText, $this->terms, $contextlines, $contextchars );
 			} else {
-				return $h->highlightSimple( $this->mText, $terms, $contextlines, $contextchars );
+				return $h->highlightSimple( $this->mText, $this->terms, $contextlines, $contextchars );
 			}
 		}
 
@@ -57,7 +58,7 @@
 		$excerpts = $this->sphinx_client->BuildExcerpts(
 			[ $this->mText ],
 			$wgSphinxSearch_index,
-			implode( ' ', $terms ),
+			implode( ' ', $this->terms ),
 			$excerpts_opt
 		);
 
--- SphinxMWSearchResultSet.php.org	2023-03-14 09:32:43.000000000 +0100
+++ SphinxMWSearchResultSet.php	2023-06-29 15:48:16.289051002 +0200
@@ -245,7 +245,7 @@
 		if ( isset( $this->mResultSet[$this->mNdx] ) ) {
 			$row = $this->mResultSet[$this->mNdx];
 			++$this->mNdx;
-			return new SphinxMWSearchResult( $row, $this->sphinx_client );
+			return new SphinxMWSearchResult( $row, $this->sphinx_client, $this->mTerms );
 		} else {
 			return false;
 		}
Reply to "Issues with SphinxSearch in 1.39"