[MediaWiki-commits] [Gerrit] Add debuging functionality - change (mediawiki...Math)

2014-11-18 Thread Physikerwelt (Code Review)
Physikerwelt has uploaded a new change for review.

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

Change subject: Add debuging functionality
..

Add debuging functionality

Write debug log to database
for if $wgMathDebug is enabled.

Change-Id: I7ddd297b3ab0e3ec8b46faf55a466fc2ae6f5a9a
---
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
M tests/MathMathMLTest.php
M tests/MathRendererTest.php
5 files changed, 116 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/41/174141/1

diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index b9d7f86..24b424d 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -109,7 +109,9 @@
$post = preg_replace( '/tex=/' , 'tex=literal:', 
$post , 1);
}
$this-lastError = '';
+   if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this-makeRequest( $host, $post, $res, 
$this-lastError );
+   if( $wgMathDebug ) { $this-setRenderingTime( microtime( true ) 
- $renderingStart ); }
if ( $requestResult ) {
$jsonResult = json_decode( $res );
if ( $jsonResult  json_last_error() === 
JSON_ERROR_NONE ) {
@@ -117,7 +119,9 @@
$this-setMathml( $jsonResult-result );
if ( $wgMathDebug ) {
$this-setLog( $jsonResult-log 
);
+   $this-setPostData( $post );
$this-setStatusCode( 
$jsonResult-status_code );
+   $this-write
}
return true;
} else {
diff --git a/MathMathML.php b/MathMathML.php
index 63f2b26..6cc8b5e 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -236,7 +236,9 @@
$host = self::pickHost();
$post = $this-getPostData();
$this-lastError = '';
+   if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this-makeRequest( $host, $post, $res, 
$this-lastError );
+   if( $wgMathDebug ) { $this-setRenderingTime( microtime( true ) 
- $renderingStart ); }
if ( $requestResult ) {
$jsonResult = json_decode( $res );
if ( $jsonResult  json_last_error() === 
JSON_ERROR_NONE ) {
@@ -253,6 +255,8 @@
}
if ( $wgMathDebug ) {
$this-setLog( 
$jsonResult-log );
+   $this-setPostData( 
$post );
+   $this-writeDebugLog();
}
if ( $this-getMode() != 
MW_MATH_LATEXML  $this-inputType != 'pmml') {
$this-setMathml( 
$jsonResult-mml );
@@ -469,4 +473,5 @@
parent::initializeFromDatabaseRow( $rpage );
 
}
+
 }
diff --git a/MathRenderer.php b/MathRenderer.php
index 6784ff4..72e2a6d 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -47,6 +47,10 @@
protected $timestamp;
/** @var log messages generated during conversion of mathematical 
content */
protected $log = '';
+   /** @var time used for rendering in ms */
+   protected $renderingTime = 0;
+   /** @var post request sent to rendering server (if applicable) */
+   protected $postData = '';
 
// STATE OF THE CLASS INSTANCE
/** @var boolean has variable tex been security-checked */
@@ -685,4 +689,70 @@
$names = MathHooks::getMathNames();
return $names[ $this-getMode() ];
}
+
+   /**
+* @return string
+*/
+   public function getPostData() {
+   return $this-postData;
+   }
+
+   /**
+* @param string $postData
+*/
+   public function setPostData( $postData ) {
+   $this-postData = $postData;
+   }
+
+   /**
+* @return int time in ms
+*/
+   public function getRenderingTime() {
+   return $this-renderingTime;
+   }
+
+   /**
+* @param int|long $renderingTime either in ms or as in seconds as long
+* @throws MWException
+*/
+   public function setRenderingTime( $renderingTime ) {
+   $type = gettype($renderingTime);
+   switch ( $type ) {
+   case double:
+   case float:
+

[MediaWiki-commits] [Gerrit] Add debuging functionality - change (mediawiki...Math)

2014-11-18 Thread Physikerwelt (Code Review)
Physikerwelt has uploaded a new change for review.

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

Change subject: Add debuging functionality
..

Add debuging functionality

Write debug log to database if $wgMathDebug is enabled.

Change-Id: I7ddd297b3ab0e3ec8b46faf55a466fc2ae6f5a9a
---
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
M tests/MathMathMLTest.php
M tests/MathRendererTest.php
5 files changed, 116 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/56/174156/1

diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index 4915058..4f40474 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -109,7 +109,9 @@
$post = preg_replace( '/tex=/' , 'tex=literal:', 
$post , 1);
}
$this-lastError = '';
+   if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this-makeRequest( $host, $post, $res, 
$this-lastError );
+   if( $wgMathDebug ) { $this-setRenderingTime( microtime( true ) 
- $renderingStart ); }
if ( $requestResult ) {
$jsonResult = json_decode( $res );
if ( $jsonResult  json_last_error() === 
JSON_ERROR_NONE ) {
@@ -117,7 +119,9 @@
$this-setMathml( $jsonResult-result );
if ( $wgMathDebug ) {
$this-setLog( $jsonResult-log 
);
+   $this-setPostData( $post );
$this-setStatusCode( 
$jsonResult-status_code );
+   $this-writeDebugLog();
}
return true;
} else {
diff --git a/MathMathML.php b/MathMathML.php
index 6707059..d7dd222 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -236,7 +236,9 @@
$host = self::pickHost();
$post = $this-getPostData();
$this-lastError = '';
+   if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this-makeRequest( $host, $post, $res, 
$this-lastError );
+   if( $wgMathDebug ) { $this-setRenderingTime( microtime( true ) 
- $renderingStart ); }
if ( $requestResult ) {
$jsonResult = json_decode( $res );
if ( $jsonResult  json_last_error() === 
JSON_ERROR_NONE ) {
@@ -253,6 +255,8 @@
}
if ( $wgMathDebug ) {
$this-setLog( 
$jsonResult-log );
+   $this-setPostData( 
$post );
+   $this-writeDebugLog();
}
if ( $this-getMode() != 
MW_MATH_LATEXML  $this-inputType != 'pmml') {
$this-setMathml( 
$jsonResult-mml );
@@ -469,4 +473,5 @@
parent::initializeFromDatabaseRow( $rpage );
 
}
+
 }
diff --git a/MathRenderer.php b/MathRenderer.php
index 6784ff4..72e2a6d 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -47,6 +47,10 @@
protected $timestamp;
/** @var log messages generated during conversion of mathematical 
content */
protected $log = '';
+   /** @var time used for rendering in ms */
+   protected $renderingTime = 0;
+   /** @var post request sent to rendering server (if applicable) */
+   protected $postData = '';
 
// STATE OF THE CLASS INSTANCE
/** @var boolean has variable tex been security-checked */
@@ -685,4 +689,70 @@
$names = MathHooks::getMathNames();
return $names[ $this-getMode() ];
}
+
+   /**
+* @return string
+*/
+   public function getPostData() {
+   return $this-postData;
+   }
+
+   /**
+* @param string $postData
+*/
+   public function setPostData( $postData ) {
+   $this-postData = $postData;
+   }
+
+   /**
+* @return int time in ms
+*/
+   public function getRenderingTime() {
+   return $this-renderingTime;
+   }
+
+   /**
+* @param int|long $renderingTime either in ms or as in seconds as long
+* @throws MWException
+*/
+   public function setRenderingTime( $renderingTime ) {
+   $type = gettype($renderingTime);
+   switch ( $type ) {
+   case double:
+   case float:
+ 

[MediaWiki-commits] [Gerrit] Add debuging functionality - change (mediawiki...Math)

2014-11-18 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add debuging functionality
..


Add debuging functionality

Write debug log to database if $wgMathDebug is enabled.

Change-Id: I7ddd297b3ab0e3ec8b46faf55a466fc2ae6f5a9a
---
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
M tests/MathMathMLTest.php
M tests/MathRendererTest.php
5 files changed, 116 insertions(+), 0 deletions(-)

Approvals:
  Physikerwelt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index 4915058..4f40474 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -109,7 +109,9 @@
$post = preg_replace( '/tex=/' , 'tex=literal:', 
$post , 1);
}
$this-lastError = '';
+   if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this-makeRequest( $host, $post, $res, 
$this-lastError );
+   if( $wgMathDebug ) { $this-setRenderingTime( microtime( true ) 
- $renderingStart ); }
if ( $requestResult ) {
$jsonResult = json_decode( $res );
if ( $jsonResult  json_last_error() === 
JSON_ERROR_NONE ) {
@@ -117,7 +119,9 @@
$this-setMathml( $jsonResult-result );
if ( $wgMathDebug ) {
$this-setLog( $jsonResult-log 
);
+   $this-setPostData( $post );
$this-setStatusCode( 
$jsonResult-status_code );
+   $this-writeDebugLog();
}
return true;
} else {
diff --git a/MathMathML.php b/MathMathML.php
index 6707059..d7dd222 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -236,7 +236,9 @@
$host = self::pickHost();
$post = $this-getPostData();
$this-lastError = '';
+   if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this-makeRequest( $host, $post, $res, 
$this-lastError );
+   if( $wgMathDebug ) { $this-setRenderingTime( microtime( true ) 
- $renderingStart ); }
if ( $requestResult ) {
$jsonResult = json_decode( $res );
if ( $jsonResult  json_last_error() === 
JSON_ERROR_NONE ) {
@@ -253,6 +255,8 @@
}
if ( $wgMathDebug ) {
$this-setLog( 
$jsonResult-log );
+   $this-setPostData( 
$post );
+   $this-writeDebugLog();
}
if ( $this-getMode() != 
MW_MATH_LATEXML  $this-inputType != 'pmml') {
$this-setMathml( 
$jsonResult-mml );
@@ -469,4 +473,5 @@
parent::initializeFromDatabaseRow( $rpage );
 
}
+
 }
diff --git a/MathRenderer.php b/MathRenderer.php
index 6784ff4..72e2a6d 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -47,6 +47,10 @@
protected $timestamp;
/** @var log messages generated during conversion of mathematical 
content */
protected $log = '';
+   /** @var time used for rendering in ms */
+   protected $renderingTime = 0;
+   /** @var post request sent to rendering server (if applicable) */
+   protected $postData = '';
 
// STATE OF THE CLASS INSTANCE
/** @var boolean has variable tex been security-checked */
@@ -685,4 +689,70 @@
$names = MathHooks::getMathNames();
return $names[ $this-getMode() ];
}
+
+   /**
+* @return string
+*/
+   public function getPostData() {
+   return $this-postData;
+   }
+
+   /**
+* @param string $postData
+*/
+   public function setPostData( $postData ) {
+   $this-postData = $postData;
+   }
+
+   /**
+* @return int time in ms
+*/
+   public function getRenderingTime() {
+   return $this-renderingTime;
+   }
+
+   /**
+* @param int|long $renderingTime either in ms or as in seconds as long
+* @throws MWException
+*/
+   public function setRenderingTime( $renderingTime ) {
+   $type = gettype($renderingTime);
+   switch ( $type ) {
+   case double:
+   case float:
+   $this-renderingTime = (int)