Tex filter not working on 1.9.7??

Tex filter not working on 1.9.7??

by A. H. -
Number of replies: 20
Hello,

I am running moodle 1.9.5 and 1.9.7 on the same machine.(RHEL5,php5.3)

The LaTeX renderer Settings are correct (installed) and the paths:

/usr/bin/latex
/usr/bin/dvips
/usr/bin/convert


Its working fine on 1.9.5 but on 1.9.7 it shows the correct link but not the image.

All permissions are identical for both instances.

The same server have two moodle versions: 1.9.5 and 1.9.7. Currently LaTex is working fine on Moodle 1.9.5, but the problem is on version 1.9.7. It shows the correct link but not the image.

We test the output of Tex on moodle using texdebug.php.
we got the error: The image “http://ourdomain/filter/tex/texdebug.php?tex=%5Crho&action=ShowImageMimetex” cannot be displayed, because it contains errors.

Folder and file permissions are the same on both instances.

Any hints?Is there a bug on 1.9.7?

regards,
amer
Average of ratings: -
In reply to A. H.

Re: Tex filter not working on 1.9.7??

by Mauno Korpelainen -

Option 3 in texdebugging.php - Show a graphic image of the algebraic expression rendered with mimetex - is using code

if ($action=='ShowImageMimetex') {
        tex2image($texexp);
    }

and it tries to use executable mimetex file from folder filter/tex (or if you have created a symbolic link from executable mimetex some local version of mimetex elsewhere)

Option 4 - Show a graphic image of the algebraic expression rendered with Tex/Ghostscript - is using
if ($action=='ShowImageTex') {
        TexOutput($texexp, true);
        exit;
    }
and it tries to render tex image with local binaries you mentioned but f(x)=\Bigint_{-\infty}^x~e^{-t^2}dt should not be used because \Bigint is mimetex syntax...

If tex filter does not seem to work at all and permissions of executable files are correct doublecheck the settings from Administration > Modules > Filters > TeX Notation or try to re-upload files of folder filter/tex - some file might be corrupted.

Attachment tex.gif
In reply to Mauno Korpelainen

Re: Tex filter not working on 1.9.7??

by A. H. -
Hello Mauno,

I appreciate your reply!

All i did, was unzip moodle 1.9.7 on a server which already has 1.9.5 running very well.

File permission: -rwxr-xr-x 1 root root 812K Jul 16 2009 mimetex.linux

Latex Renderer settings are exactly same as the snapshot you attached.



When i check moodle data folder/filter/tex, i see the pictures are already created there. I deleted them too, and are re-created.

So whats going wrong then?

thnx!
amer
In reply to Mauno Korpelainen

Re: Tex filter not working on 1.9.7??

by A. H. -
I am attaching the pic generated for the character"$$\rho$$"

This shows, that the pictures are being generated.
Permissions on their folder is 777

What might be the cause?

amer
Attachment d2606be4e0cd2c9a6179c8f2e3547a85.gif
In reply to Mauno Korpelainen

Re: Tex filter not working on 1.9.7??

by A. H. -
I upgraded the 1.9.7 version to 1.9.8, same problem...pictures not displaying...

On same machine the 195 is working!!!

regards,
amer
In reply to A. H.

Re: Tex filter not working on 1.9.7??

by Mauno Korpelainen -

I don't know for sure any good explanation.

It might have something to do with version of php - since moodle 1.9.5 some security fixes were added to tex filter but my test sites have had no such problems with tex filter. Or some kind of a server cache issue (image is created but not found when moodle is trying to render it using possibly wrong/cached path???)

I could try to test a fresh local XAMPP install with php 5.3.1 during this weekend and check if some 1.9.7/8 tex filter commands are incompatible with php 5.3 - other people have reported before that moodle 1.9.7 is not fully compatible with php 5.3 (elsewhere)

In reply to A. H.

Re: Tex filter not working on 1.9.7??

by Mauno Korpelainen -
The problem seems to be that some functions like eregi are depreciated in php 5.3 and in this case tex filter created the gif image but moodle can't render it obviously because filelib.php does not recognize the mime type of created files... I was able to reproduce your problem with the XAMPP 1.7.3 and PHP 5.3.1 - and with XAMPP 1.7.1 together with PHP 5.2.9 all images were created correct. It may take some time before developers have time to check all php 5.3 compatibility issues so the best solution might be to downgrade php to some 5.2.X version.
In reply to Mauno Korpelainen

Re: Tex filter not working on 1.9.7??

by A. H. -
Mauno!

i really appreciate your help and your investigation. Thankyou for giving this issue some of your time!

i cant downgrade to php 5.2.x because of many security breaches found in that version. i recommend to upgrade php asap.

Meanwhile, i will use an alternative method to write these "roman characters", using html entities rather than tex.

I hope this gets the attention of the related developers and get it solved soon.

regards,
amer
In reply to A. H.

Re: Tex filter not working on 1.9.7 or 1.9.8 with php 5.3.X

by Mauno Korpelainen -

Because Petr said that they are definitely NOT going to do any changes like this (ereg-preg changes) in STABLE branch I tested a quick fix that seems to get tex notations back on my test moodle 1.9.8 with php 5.3.1 (XAMPP):

In filelib.php

line 499

    if (eregi('\.([a-z0-9]+)$', $filename, $match)) {
 
can be changed for example to

    if (preg_match('/\.([a-z0-9]+)$/', $filename, $match)) {
 
or if you want to use tildes instead of slashes try
 
 if (preg_match('~\.([a-z0-9]+)$~', $filename, $match)) {
 
and the same way in moodlelib.php

lines 467 to 470 from

            $param = ereg_replace(':cntrl:|[<>"`\|\':]', '', $param);
            $param = ereg_replace('\.\.+', '', $param);
            $param = ereg_replace('//+', '/', $param);
            return ereg_replace('/(\./)+', '/', $param);

to

            $param = preg_replace('~:cntrl:|[&<>"`\|\':]~', '', $param);
            $param = preg_replace('~\.\.+~', '', $param);
            $param = preg_replace('~//+~', '/', $param);
            return preg_replace('~/(\./)+~', '/', $param);
   
Note - when you edit moodlelib.php use only such text editor that does not change UTF-8 coding of moodlelib.php and does not add BOMs to moodlelib.php...

In reply to Mauno Korpelainen

Re: Tex filter not working on 1.9.7 or 1.9.8 with php 5.3.X

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
hmm, I do not see any issue number mentioned here, is this already reported in tracker?

Btw I just said we are not going to change all eregs to pregs only to eliminate some warnings, but if some of them cause problems I agree we need to fix them in 1.9.8+ asap.
In reply to Petr Skoda

Re: Tex filter not working on 1.9.7 or 1.9.8 with php 5.3.X

by Mauno Korpelainen -

Well, in a way it is a new issue (or old issue) but there is another fix too - like you suggested in that other post changing the error_reporting in filter/tex/pix.php and then those previous tags can stay as they are.

So if line 29 is changed from

    error_reporting(E_ALL);

to

 error_reporting(E_ALL & ~E_DEPRECATED);

php 5.3 does not show the deprecated functions warnings that otherwise would prevent showing of tex images.

In the long run all deprecated features of php 5.3.X should be fixed in core code like suggested in php.net/manual/en/migration53.deprecated.php because those deprecated features won't work at all in php 6 (will be removed for ever) but that's not necessary today or before moodle 2.0 is released... wink

In reply to Mauno Korpelainen

Trả lời: Re: Tex filter not working on 1.9.7??

by Quách Nhị -

I try it in localhost and very ok but when i upload to website and i don't show math.

Cant u help me.

In reply to Quách Nhị

Re: Trả lời: Re: Tex filter not working on 1.9.7??

by Ken Task -
Picture of Particularly helpful Moodlers

Sounds like localhost version you are running has supports for Math and server does not.

Remotely hosted?  Check with hosting provider.

Operating system?  Makes a difference installing supports needed for TeX Notation - ie the Math app that draws graphics of the text representations of math.

Site Admin Mehu
Modules
Filders
Manage Filters - TeX Notation ON (little eye icon is open)

Settings:
On a CentOS/RedHat standalone (not shared) server path to latex library is:
/usr/bin/latex
Path to dvips library is
/usr/bin/dvips
Path to convert library is
/usr/bin/convert
** NOTE: no trailing slash in above as they are pointers to 'executables'.

Moodle 2.2.2
Site Admin
Plugins
Filters
Manage Filters
TeX Notation ON.
Settings almost same as version 1.9

version 1.9.x and 2.x of Moodle
http://yoursite/[moodle]/filter/tex/texdebug.php
and
http://yoursite/[moodle]/filter/tex/texdebug.php#help


If remotely hosted, contact your hosting provider to check on supports (latex, dvips, and convert) installation and paths.

'spirit of sharing', Ken

In reply to A. H.

Re: Tex filter not working on 1.9.7??

by William Felton -
This seemed like the correct place to post this. After upgrading from 1.9.5 to 1.9.9 my tex filter stopped working in a glorious fashion. There were so many errors in the text debug, I would not put them all here. The most notable of them were that /latex /dvips and /convert were not readable.
I tried the fix mentioned in this thread and there was no "E_ALL" error function on page 29 (I assume it was changed on 1.9.9)
I made a directory comparison between my 1.9.9 /filter/tex/ directories and found around 150 differences. No wanting to make so many tweaks I simply copied my old tex directory into my current moodle install and it now works perfectly.
Not sure why or if this is related to the php incompatibilities but there is a fix for anyone who is stuck.
In reply to William Felton

Re: Tex filter not working on 1.9.7??

by Mauno Korpelainen -
The most common reason for such problems is that when you upgrade you forget to change permissions of executable mimetex files in folder filter/tex ... upgrading might have changed those permissions to non executable.
In reply to Mauno Korpelainen

Re: Tex filter not working on 1.9.7??

by Marc Grober -
But, that would not account for the Tex binaries failing (if they in fact were working prior to upgrade.....) Nor would copying old moodle files to new moodle fix the operation of the tex binaries (unless the old files were patched.)

I would certainly not recommend the OP's action as a fix, and arguably the action taken now precludes further troubleshooting.
In reply to William Felton

Re: Tex filter not working on 1.9.7??

by Caroline Moore -
William, thank you for posting this! I just upgraded to 1.9.9 and had the same problem with TeX not processing new equations. I swapped in the /filter/tex directory from 1.9.5, and it works like a charm.

Is there a tracker item for this issue yet?
In reply to Caroline Moore

Re: Tex filter not working on 1.9.7??

by Marc Grober -
Without information as to why you experienced this issue it would be difficult to resolve the issue. Once again, the "solution" offered prevents any debugging and mixes version code and will undoubtedly create additional woes in the future.
In reply to Caroline Moore

Re: Tex filter not working on 1.9.7??

by oniciuc grigoruta -

I install for the first time 1.9.9 on my computer. The tex filter not working and /latex is not readable.
Were is in pix.php line 29 ? ochii larg deschiși

Have you any suggestion ?