Permalink
Browse files

Remove workaround for PHP bug #49692

PHP bug #49692 [1] affects only PHP 5.3.0 and was fixed in PHP 5.3.1.
I think it is time to remove the workaround as PHP version 5.3.0 is
end-of-life for a long time now and even Debian old-stable comes with
PHP 5.3.3.

[1] <http://bugs.php.net/bug.php?id=49692>
  • Loading branch information...
andreashaerter committed Feb 8, 2014
1 parent 284378d commit 9de085038adfb3a54ab3b9d01901144099091f00
Showing with 5 additions and 161 deletions.
  1. +0 −8 README
  2. +0 −120 bug49642.php
  3. +5 −14 main.php
  4. +0 −9 mediamanager.php
  5. +0 −10 style.ini
View
8 README
@@ -24,16 +24,8 @@
See the monobook template website for update instructions [2].
NOTE: If everything will be displayed unformatted, your PHP environment is
probably affected by PHP bug #49692 [3]. You may find errors like
"syntax error, unexpected '/' in ../../lib/tpl/monobook/style.ini on
line XX" in your PHP logs when this is the case. monobook provides a
workaround for this, simply delete monobook's "style.ini" to trigger
the template to use it.
[1] <https://www.dokuwiki.org/template>
[2] <https://www.dokuwiki.org/template:monobook#update>
[3] <http://bugs.php.net/bug.php?id=49692>
View
@@ -1,120 +0,0 @@
<?php
/**
* Helper to provide a workaround for PHP bug #49692
*
* Some PHP versions are not able to parse INI-files if "/" is used for INI
* keynames (known as bug #49692, see <http://bugs.php.net/bug.php?id=49692>).
* Therefore, DokuWiki is not able to parse monobook's style.ini and users don't
* get the needed CSS (but errors like "syntax error, unexpected '/' in
* ../../lib/tpl/monobook/style.ini on line XX" instead). To get things work in
* such environments, simply delete the "style.ini". Then the template uses
* this helper to get the CSS.
*
* Known disadvantages: A little bit more traffic compared to an environment
* without this bug and DokuWiki's "compress" feature enabled (cause this
* feature does not have any effect on monobook's CSS files when using this
* workaround, and therefore non-minimized and uncompressed CSS will be
* delivered).
*
*
* LICENSE: This file is open source software (OSS) and may be copied under
* certain conditions. See COPYING file for details or try to contact
* the author(s) of this file in doubt.
*
* @license GPLv2 (http://www.gnu.org/licenses/gpl2.html)
* @author ARSAVA <dokuwiki@dev.arsava.com>
* @link http://bugs.php.net/bug.php?id=49692
* @link https://forum.dokuwiki.org/thread/4827
* @link https://www.dokuwiki.org/template:monobook
* @link https://www.dokuwiki.org/devel:style.ini
*/
//workaround for PHP Bug #49692
//If you are affected, simply delete monobook's style.ini to trigger the
//template to use this workaround.
//we are rebuilding a CSS file, send needed headers (otherwise, the browser
//would interpret this as text/plain or XHTML)
header("Content-Type: text/css");
//define placeholders as they are known out of the style.ini
$placeholder_names = array(//main text and background colors
"__text__",
"__background__",
//alternative text and background colors
"__text_alt__",
"__background_alt__",
//neutral text and background colors
"__text_neu__",
"__background_neu__",
//border color
"__border__",
//these are used for links
"__existing__",
"__missing__",
//highlighting search snippets
"__highlight__");
$placeholder_values = array(//main text and background colors
"#000",
"#fff",
//alternative text and background colors
"#000",
"#dee7ec",
//neutral text and background colors
"#000",
"#fff",
//border color
"#8cacbb",
//these are used for links
"#002bb8",
"#ba0000",
//highlighting search snippets
"#ff9");
//get needed file contents: screen media CSS
$interim = trim(file_get_contents("./static/3rd/dokuwiki/_imgdetail.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_media_popup.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_media_fullscreen.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_fileuploader.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_tabs.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_links.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_toc.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_footnotes.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_search.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_recent.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_diff.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_edit.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_modal.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_forms.css"))."\n"
.trim(file_get_contents("./static/3rd/dokuwiki/_admin.css"))."\n"
.trim(file_get_contents("./static/3rd/monobook/main.css"))."\n"
.trim(file_get_contents("./static/css/screen.css"))."\n"
.trim(file_get_contents("./user/screen.css"))."\n";
if (!empty($_GET["langdir"]) &&
$_GET["langdir"] === "rtl"){
$interim .= trim(file_get_contents("./static/3rd/monobook/rtl.css"))."\n"
.trim(file_get_contents("./user/rtl.css"))."\n";
}
//replace the placeholders with the corresponding values and send the needed CSS
echo "@media screen {\n".str_replace(//search
$placeholder_names,
//replace
$placeholder_values,
//haystack
$interim)."\n}\n\n";
//get needed file contents: print media CSS
$interim = trim(file_get_contents("./static/3rd/dokuwiki/print.css"))."\n"
.trim(file_get_contents("./static/3rd/wikipedia/commonPrint.css"))."\n"
.trim(file_get_contents("./static/css/print.css"))."\n"
.trim(file_get_contents("./user/print.css"))."\n";
//replace the placeholders with the corresponding values and send the needed CSS
echo "@media print {\n".str_replace(//search
$placeholder_names,
//replace
$placeholder_values,
//haystack
$interim)."\n}\n\n";
View
@@ -140,8 +140,8 @@
* NOTE: This function is heavily inspired by "writeMBPortlet(), context.php" of
* the "Monobook for Dokuwiki" template by Terence J. Grant.
*
* @param array The tab data to render within the snippet. Each element
* is represented through a subarray:
* @param array The tab data to render within the snippet. Each element is
* represented by a subarray:
* $array = array("tab1" => array("text" => "hello world!",
* "href" => "http://www.example.com"
* "nofollow" => true),
@@ -281,7 +281,7 @@ function _monobook_renderTabs($arr)
* the "Monobook for Dokuwiki" template by Terence J. Grant.
*
* @param array The box data to render within the snippet. Each box is
* represented through a subarray:
* represented by a subarray:
* $array = array("box-id1" => array("headline" => "hello world!",
* "xhtml" => "I am <i>here</i>."));
* Available keys within the subarrays:
@@ -361,8 +361,8 @@ function _monobook_renderBoxes($arr)
/**
* Helper to render the footer buttons (like a dynamic XHTML snippet)
*
* @param array The button data to render within the snippet. Each element
* is represented through a subarray:
* @param array The button data to render within the snippet. Each element is
* represented by a subarray:
* $array = array("btn1" => array("img" => DOKU_TPL."static/img/button-monobook.png",
* "href" => "https://andreashaerter.com/",
* "width" => 80,
@@ -473,15 +473,6 @@ function _monobook_renderButtons($arr)
tpl_metaheaders();
echo "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />";
//manually load needed CSS? this is a workaround for PHP Bug #49642. In some
//version/os combinations PHP is not able to parse INI-file entries if there
//are slashes "/" used for the keynames (see bugreport for more information:
//<http://bugs.php.net/bug.php?id=49692>). to trigger this workaround, simply
//delete/rename monobook's style.ini.
if (!file_exists(DOKU_TPLINC."style.ini")){
echo "<link rel=\"stylesheet\" media=\"all\" type=\"text/css\" href=\"".DOKU_TPL."bug49642.php".((!empty($lang["direction"]) && $lang["direction"] === "rtl") ? "?langdir=rtl" : "")."\" />\n"; //var comes from DokuWiki core
}
//include default or userdefined favicon
//
//note: since 2011-04-22 "Rincewind RC1", there is a core function named
View
@@ -33,15 +33,6 @@
tpl_metaheaders();
echo "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />";
//manually load needed CSS? this is a workaround for PHP Bug #49642. In some
//version/os combinations PHP is not able to parse INI-file entries if there
//are slashes "/" used for the keynames (see bugreport for more information:
//<http://bugs.php.net/bug.php?id=49692>). to trigger this workaround, simply
//delete/rename monobook's style.ini.
if (!file_exists(DOKU_TPLINC."style.ini")){
echo "<link rel=\"stylesheet\" media=\"all\" type=\"text/css\" href=\"".DOKU_TPL."bug49642.php".((!empty($lang["direction"]) && $lang["direction"] === "rtl") ? "?langdir=rtl" : "")."\" />\n"; //var comes from DokuWiki core
}
//include default or userdefined favicon
//
//note: since 2011-04-22 "Rincewind RC1", there is a core function named
View
@@ -27,8 +27,6 @@
[stylesheets]
; screen
; note to myself: don't forget to respect the workaround within "bug49642.php"
; when adding new screen styles.
; load the DokuWiki styles. See <http://j.mp/eq8zSo> why I am doing this.
static/3rd/dokuwiki/_imgdetail.css = screen
static/3rd/dokuwiki/_media_popup.css = screen
@@ -60,8 +58,6 @@ user/screen.css = screen
; I think this function is silly (cause therefore we got
; different "media" but some people *always* searching for such
; print version links). Good text about this: <http://j.mp/6r3Kgf>
; note to myself: don't forget to respect the workaround within "bug49642.php"
; when adding new print styles.
; load the DokuWiki styles. See <http://j.mp/eq8zSo> why I am doing this.
static/3rd/dokuwiki/print.css = print
@@ -74,9 +70,6 @@ user/print.css = print
; right-to-left
; note to myself: don't forget to respect the workaround within "bug49642.php"
; when adding new rtl styles.
; load the most important MediaWiki monobook styles
static/3rd/monobook/rtl.css = rtl
@@ -95,9 +88,6 @@ user/rtl.css = rtl
;--------------------------------------------------------------------------
;------ guaranteed dokuwiki color placeholders that every plugin can use
; main text and background colors
;
;note to myself: don't forget to respect the workaround within "bug49642.php"
; when changing values in here.
__text__ = "#000"
__background__ = "#fff"
; alternative text and background colors

0 comments on commit 9de0850

Please sign in to comment.