Physikerwelt has submitted this change and it was merged.

Change subject: Fixing problem in the LaTeXMLImage class
......................................................................


Fixing problem in the LaTeXMLImage class

Change-Id: I13e4fbd1c3a8afd788bed6bd2351a0c23379fa7a
---
M .gitattributes
M MathLaTeXMLImages.php
2 files changed, 16 insertions(+), 80 deletions(-)

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



diff --git a/.gitattributes b/.gitattributes
index 5a43e73..8f237dc 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,3 +2,5 @@
 *.png binary
 *.ico binary
 *.ppk binary
+*.eot binary
+*.woff binary
diff --git a/MathLaTeXMLImages.php b/MathLaTeXMLImages.php
index 4a7524c..3e62e8c 100644
--- a/MathLaTeXMLImages.php
+++ b/MathLaTeXMLImages.php
@@ -61,7 +61,7 @@
                $url = $this->mathImageUrl();
 
                return Xml::element( 'img',
-                               $this->getAttribs(
+                               $this->getAttributes(
                                                'img',
                                                array(
                                                                'class' => 
'tex',
@@ -73,12 +73,16 @@
                                )
                );
        }
+       private function getMd5(){
+               return md5( $this->tex );
+       }
        function callTexvc() {
                $tmpDir = wfTempDir();
                global $wgTmpDirectory;
                global $wgLaTeXML, $wgTexvcBackgroundColor, $wgUseSquid;
                if ( !is_executable( $wgLaTeXML ) ) {
-                       return $this->error( 'math_notexvc' );
+                       wfDebugLog("Math", "$wgLaTeXML seems to be no 
executable");
+                       return $this->getError( 'math_notexvc' );
                }
                $cmd = $wgLaTeXML . ' --preload=amsmath  --preload=amssymb'.
                                ' --preload=amsfonts --preload=cancel 
--preload=color --preload=upgreek --verbose'.
@@ -99,90 +103,16 @@
                wfDebugLog( 'Math', "TeX: $cmd\n" );
                $contents = wfShellExec( $cmd);
                wfDebugLog( 'Math', "TeX output:\n $contents\n---\n" );
-               /*              if ( strlen( $contents ) == 0 ) {
-                       if ( !file_exists( $tmpDir ) || !is_writable( $tmpDir ) 
) {
-               return $this->error( 'math_bad_tmpdir' );
-               } else {
-               return $this->error( 'math_unknown_error' );
-               }
-               }*/
 
                $tempFsFile = new TempFSFile( "$tmpDir/{$this->hash}.png" );
                $tempFsFile->autocollect(); // destroy file when $tempFsFile 
leaves scope
-               /*
-                $retval = substr( $contents, 0, 1 );
-               $errmsg = '';
-               if ( ( $retval == 'C' ) || ( $retval == 'M' ) || ( $retval == 
'L' ) ) {
-               if ( $retval == 'C' ) {
-               $this->conservativeness = 2;
-               } elseif ( $retval == 'M' ) {
-               $this->conservativeness = 1;
-               } else {
-               $this->conservativeness = 0;
-               }
-               $outdata = substr( $contents, 33 );
-
-               $i = strpos( $outdata, "\000" );
-
-               $this->html = substr( $outdata, 0, $i );
-               $this->mathml = substr( $outdata, $i + 1 );
-               } elseif ( ( $retval == 'c' ) || ( $retval == 'm' ) || ( 
$retval == 'l' ) ) {
-               $this->html = substr( $contents, 33 );
-               if ( $retval == 'c' ) {
-               $this->conservativeness = 2;
-               } elseif ( $retval == 'm' ) {
-               $this->conservativeness = 1;
-               } else {
-               $this->conservativeness = 0;
-               }
-               $this->mathml = null;
-               } elseif ( $retval == 'X' ) {
-               $this->html = null;
-               $this->mathml = substr( $contents, 33 );
-               $this->conservativeness = 0;
-               } elseif ( $retval == '+' ) {
-               $this->html = null;
-               $this->mathml = null;
-               $this->conservativeness = 0;
-               } else {
-               $errbit = htmlspecialchars( substr( $contents, 1 ) );
-               switch( $retval ) {
-               case 'E':
-               $errmsg = $this->error( 'math_lexing_error', $errbit );
-               break;
-               case 'S':
-               $errmsg = $this->error( 'math_syntax_error', $errbit );
-               break;
-               case 'F':
-               $errmsg = $this->error( 'math_unknown_function', $errbit );
-               break;
-               default:
-               $errmsg = $this->error( 'math_unknown_error', $errbit );
-               }
-               }
-
-               if ( !$errmsg ) {
-               $this->hash = substr( $contents, 1, 32 );
-               }*/
-
-               /*wfRunHooks( 'MathAfterTexvc', array( &$this, &$errmsg ) );
-
-               if ( $errmsg ) {
-               return $errmsg;
-               } elseif ( !preg_match( "/^[a-f0-9]{32}$/",  ) ) {
-               return $this->error( 'math_unknown_error' );
-               } elseif ( !file_exists( "$tmpDir/{}.png" ) ) {
-               return $this->error( 'math_image_error' );
-               } elseif ( filesize( "$tmpDir/{}.png" ) == 0 ) {
-               return $this->error( 'math_image_error' );
-               }*/
 
                $hashpath = $this->getHashPath(); // final storage directory
 
                $backend = $this->getBackend();
                # Create any containers/directories as needed...
                if ( !$backend->prepare( array( 'dir' => $hashpath ) )->isOK() 
) {
-                       return $this->error( 'math_output_error' );
+                       return $this->getError( 'math_output_error' );
                }
                // Store the file at the final storage path...
                $fResult= $backend->quickStore( array(
@@ -192,7 +122,7 @@
                if ( !$fResult->isOK()
                ) {
                        wfDebugLog("Math", 'error moving 
file:'.var_export($fResult,true));
-                       return $this->error( 'math_output_error' );
+                       return $this->getError( 'math_output_error' );
                }
                return MW_TEXVC_SUCCESS;
 
@@ -221,7 +151,7 @@
        function doRender() {
                if ( $this->mode == MW_MATH_MATHML && $this->mathml != '' ) {
                        return Xml::tags( 'math',
-                                       $this->getAttribs( 'math',
+                                       $this->getAttributes( 'math',
                                                        array( 'xmlns' => 
'http://www.w3.org/1998/Math/MathML' ) ),
                                        $this->mathml );
                }
@@ -233,7 +163,7 @@
                        return $this->linkToMathImage();
                } else {
                        return Xml::tags( 'span',
-                                       $this->getAttribs( 'span',
+                                       $this->getAttributes( 'span',
                                                        array( 'class' => 
'texhtml',
                                                                        'dir' 
=> 'ltr'
                                                        ) ),
@@ -261,6 +191,9 @@
                // Short-circuit the file existence & migration checks
                return true;
                }*/
+               if($this->isPurge()){
+                       return false;
+               }
                $filename = $this->getHashPath() . "/{$this->getMd5()}.png"; // 
final storage path
                $backend = $this->getBackend();
                if ( $backend->fileExists( array( 'src' => $filename ) ) ) {
@@ -272,6 +205,7 @@
                        }
                        //}
                }
+               return false;
        }
 
 }
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I13e4fbd1c3a8afd788bed6bd2351a0c23379fa7a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: dev
Gerrit-Owner: Physikerwelt <w...@physikerwelt.de>
Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to