Math safe mode

De WikiLICC
Revisão de 13h03min de 21 de abril de 2009 por Dago (Discussão | contribs) (Nova página: Mediawiki <math> support with PHP safe_mode =========================================== Author: Mattias Guns <tias@ulyssis.org> http://xylofaan.ulyssis.org/patch/mediawiki/math_safe_m...)
(dif) ← Edição anterior | ver versão atual (dif) | Versão posterior → (dif)
Ir para: navegação, pesquisa

Mediawiki <math> support with PHP safe_mode

===============================

Author: Mattias Guns <tias@ulyssis.org> http://xylofaan.ulyssis.org/patch/mediawiki/math_safe_mode/

These are the steps I had to take to get <math> support working an a box that uses PHP safe_mode.

1) safe_mode_exec_dir


First off, check what the value of the PHP setting `safe_mode_exec_dir` is.

  • No safe_mode_exec_dir
 Edit the apache config of your virtual host, and set
 it to the math directory of your mediawiki installation:

php_admin_value safe_mode_exec_dir /srv/www/wiki/math/

  • safe_mode_exec_dir is set to some directory
 Make sure you can add something in it.

2) patch includes/Math.php


It uses backticks ` ` to execute the command, this doesn't work in safe mode, apply the patch named:

includes_Math.php_safemode.patch

It uses exec() but also drops the escaping which, for some reason, is necessary. It also ignores checking if the created file exists, which is necessary if you don't want (or can't) add that directory to `safe_mode_include_dir`.

3) copy the texvc-wrapper script


Because the data is not escaped, spaces in the latex code confuse texvc. I have written a wrapper that fixes this by grouping the arguments the right way, copy this wrapper script `texvc-wrapper` to the directory set in the PHP value `safe_mode_exec_dir`. Next, edit the wrapper script so that the `TEXVC` points to the texfc executable of your installation. Don't forget to make the wrapper executable ; )

4) edit your LocalSettings.php


Lastly, edit your LocalSettings.php:

  1. Of course, enable <math> support

$wgUseTeX = true;

  1. enable the features provided by the patch

define('FIX_TEX_SAFE_MODE', 1);

  1. point the Texvc var to the wrapper script

$wgTexvc = "{$IP}/math/texvc-wrapper";