PCRE Tweaks

If you have pages of given length and saving them raises 500 AJAX error, this is most probably you reached limits of Perl-Compatible Regular Expressions library, which Wikidot uses massively.

You'll need to recompile the libpcre and raise limits for recursion in php.ini

Recompile libpcre

Instructions for Debian, Ubuntu and other Debian derivatives

apt-get install build-essential fakeroot
mkdir /usr/src/debian
mkdir /usr/src/debian/pcre
cd /usr/src/debian/pcre
apt-get -y source libpcre3
apt-get -y build-dep libpcre3
cd pcre3-*/
sed -i 's/--enable-utf8 --enable-unicode-properties/--enable-utf8 --disable-stack-for-recursion --enable-unicode-properties/' debian/rules
fakeroot debian/rules binary
dpkg -i ../*.deb
pcretest -C | grep 'Match recursion'

The last command should say: Match recursion uses heap (not stack)

Other distributions

It's probably best to just compile the library from source (standard ./configure -> make -> make install process).

If you want to compile from source, just be sure to add --disable-stack-for-recursion option to ./configure.

Raise limits in php.ini

Edit php.ini (for Debian/Ubuntu it is located in /etc/php5/cgi/php.ini). Locate:

[Pcre]
;PCRE library backtracking limit.
;pcre.backtrack_limit=100000

;PCRE library recursion limit. 
;Please note that if you set this value to a high number you may consume all 
;the available process stack and eventually crash PHP (due to reaching the 
;stack size limit imposed by the Operating System).
;pcre.recursion_limit=100000

Change to:

[Pcre]
;PCRE library backtracking limit.
pcre.backtrack_limit=100000

;PCRE library recursion limit. 
;Please note that if you set this value to a high number you may consume all 
;the available process stack and eventually crash PHP (due to reaching the 
;stack size limit imposed by the Operating System).
pcre.recursion_limit=100000

(Which means just removing comment marks from lines setting PCRE limits to high)

Then restart wikidot:

./wikidotctl restart

Things should work now.

Handy thing

If you get pages giving you something like blank page or 500 error (not an AJAX one), you can append /norender/true to the URL address. This would cause Wikidot not render the pages and thus not trigger the error. Everything else like sidebar, footer, custom CSS works.

Examples:

for page http://mywiki.somewhere.com:8080/blank-page
use http://mywiki.somewhere.com:8080/blank-page/norender/true

for page http://mywiki.somewhere.com:8080/
use http://mywiki.somewhere.com:8080/start/norender/true

(you need to point actual page name using norender).

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License