Commit 86affb18 authored by walper's avatar walper

[FIX] Codemirror modes were not restored properly on cache deletes, thus...

[FIX] Codemirror modes were not restored properly on cache deletes, thus codemirror was not working when minify was active (due to codemirror modes did not exist). Removed unused parameter and renamed function to a more meaningful name.
parent b065814c
......@@ -5,7 +5,11 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function codemirrorModes($minify = true)
/**
* Create codemirror modes in temp - put wiki language upfront.
*/
function createCodemirrorModes()
{
global $prefs, $tikidomainslash;
$js = '';
......@@ -42,12 +46,10 @@ test = { mode: function () {}, indentation: function() {} }
$css .= @file_get_contents($cssFile);
}
// race condition when minify is active and cache was just cleared - need to set exclusive access
file_put_contents($jsModes, $js, LOCK_EX);
file_put_contents($jsModes, $js);
chmod($jsModes, 0644);
// race condition when minify is active and cache was just cleared - need to set exclusive access
file_put_contents($cssModes, $css, LOCK_EX);
file_put_contents($cssModes, $css);
chmod($cssModes, 0644);
}
......
......@@ -8,6 +8,12 @@
//this script may only be included - so its better to die if called directly.
$access->check_script($_SERVER['SCRIPT_NAME'], basename(__FILE__));
// need to rebuild because they were created in tiki-setup and just removed due to clear cache
// we need to create upfront in case codemirror is used later on.
require_once("lib/codemirror_tiki/tiki_codemirror.php");
createCodemirrorModes();
// Javascript auto-detection
// (to be able to generate non-javascript code if there is no javascript, when noscript tag is not useful enough)
// It uses cookies instead of session vars to keep the correct value after a session timeout
......@@ -202,7 +208,7 @@ var syntaxHighlighter = {
}
$headerlib->add_js($js);
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
$smarty->assign('ie6', true);
......
......@@ -27,6 +27,10 @@ if (isset($_GET['do'])) {
include('lib/setup/javascript.php');
include('lib/setup/theme.php');
}
// codemirror modes are created in /temp/public -- need to restore them
if ($_GET['do'] === 'temp_public') {
include('lib/setup/javascript.php');
}
}
if (isset($_GET['compiletemplates'])) {
$ctempl = 'templates';
......
......@@ -398,7 +398,7 @@ if ($prefs['feature_syntax_highlighter'] == 'y') {
->add_jsfile('lib/codemirror_tiki/codemirror_tiki.js', 5);
require_once("lib/codemirror_tiki/tiki_codemirror.php");
codemirrorModes($prefs['tiki_minify_javascript'] === 'y');
createCodemirrorModes();
}
if ($prefs['feature_wikilingo'] == 'y') {
$headerlib
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment