Kaldari has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/72121


Change subject: Adding the page ID to the debugging output
......................................................................

Adding the page ID to the debugging output

Bug: 46581
Change-Id: Ifab643922937dfe2f6882ed91c95f022ff000f55
---
M includes/api/ApiQueryExtracts.php
1 file changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/21/72121/1

diff --git a/includes/api/ApiQueryExtracts.php 
b/includes/api/ApiQueryExtracts.php
index da5f711..6c575f9 100644
--- a/includes/api/ApiQueryExtracts.php
+++ b/includes/api/ApiQueryExtracts.php
@@ -45,7 +45,7 @@
                                break;
                        }
                        $text = $this->getExtract( $t );
-                       $text = $this->truncate( $text );
+                       $text = $this->truncate( $text, $id );
                        if ( $this->params['plaintext'] ) {
                                $text = $this->doSections( $text );
                        }
@@ -204,11 +204,17 @@
                return trim( $text );
        }
 
-       private function truncate( $text ) {
+       /**
+        * Truncate the given text to a certain number of characters or 
sentences
+        * @param string $text The text to truncate
+        * @param int $pageId ID of the page (for debugging)
+        * @return string
+        */
+       private function truncate( $text, $pageId ) {
                if ( $this->params['chars'] ) {
                        return $this->getFirstChars( $text, 
$this->params['chars'] );
                } elseif ( $this->params['sentences'] ) {
-                       return $this->getFirstSentences( $text, 
$this->params['sentences'] );
+                       return $this->getFirstSentences( $text, 
$this->params['sentences'], $pageId );
                }
                return $text;
        }
@@ -240,9 +246,10 @@
         *
         * @param string $text
         * @param int $requestedSentenceCount
+        * @param int $pageId ID of the page (for debugging)
         * @return string
         */
-       private function getFirstSentences( $text, $requestedSentenceCount ) {
+       private function getFirstSentences( $text, $requestedSentenceCount, 
$pageId ) {
                wfProfileIn( __METHOD__ );
                // Based on code from OpenSearchXml by Brion Vibber
                $endchars = array(
@@ -262,7 +269,7 @@
                        $text = $matches[0];
                } else {
                        if ( $res === false ) {
-                               wfDebugLog( 'mobile', "Invalid regular 
expression: $regexp" );
+                               wfDebugLog( 'mobile', "Page ID: $pageId; 
Invalid regular expression: $regexp" );
                        }
                        // Just return the first line
                        $lines = explode( "\n", $text );
@@ -440,4 +447,4 @@
                wfProfileOut( __METHOD__ );
                return $html;
        }
-}
\ No newline at end of file
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/72121
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifab643922937dfe2f6882ed91c95f022ff000f55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to