?
avatar sozzled
sozzled
1 Feb 2018

Steps to reproduce the issue

In J! 3.8.3 the code in the template file editor is hilighted in colour when editing PHP files but in J! 3.8.4 the colour has disappeared. It doesn't make any difference to the actual code. When editing CSS files in J! 3.8.4 the code hilighting is still present.

Expected result

PHP file editing should retain the same code hilighting as for J! 3.8.3

Actual result

Colour code hilighting is absent on J! 3.8.4 when editing some files but the hilighting is retained when editing other files.

System information (as much as possible)

?GeShi

Additional comments

First reported https://forum.joomla.org/viewtopic.php?f=9&t=958741&p=3511589#p3511549

avatar sozzled sozzled - open - 1 Feb 2018
avatar joomla-cms-bot joomla-cms-bot - labeled - 1 Feb 2018
avatar brianteeman
brianteeman - comment - 1 Feb 2018

nothing to do with geshi lol
the editor in use on that page is codemirrror

avatar sozzled sozzled - change - 1 Feb 2018
The description was changed
avatar sozzled sozzled - edited - 1 Feb 2018
avatar Quy
Quy - comment - 1 Feb 2018
avatar okonomiyaki3000
okonomiyaki3000 - comment - 2 Feb 2018

OK, I'll have a look

avatar okonomiyaki3000
okonomiyaki3000 - comment - 2 Feb 2018

Got it. It seems like a bug in the meta.js file that codemirror uses to determine mode.

See, what happens is, we know the "mode" we want by name so we use CodeMirror's findModeByName function to get a mode object based on that. CM keeps a long list of mode objects that look like this:

{
    name: "HTML", 
    mime: "text/html", 
    mode: "htmlmixed", 
    ext: ["html", "htm"], 
    alias: ["xhtml"]
}

Or this:

{
    name: "JavaScript", 
    mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
    mode: "javascript", 
    ext: ["js"], 
    alias: ["ecmascript", "js", "node"]
 }

Spot the difference? OK, so sometimes, there's 'mime' (string) and sometimes 'mimes' (array of strings). In case of 'mimes', CM will just set mime = mimes[0] so we should always have a string 'mime' value. This is useful because then what we do is set the editor's 'mode' option to the value of 'mime' which should be a string. There's a problem with php though. It looks like this:

{
    name: "PHP", 
    mime: ["application/x-httpd-php", "text/x-php"], 
    mode: "php", 
    ext: ["php", "php3", "php4", "php5", "php7", "phtml"]
}

Obviously a typo, 'mime' should be 'mimes' so that CM can set mimes[0] as mime and we can use that value. Instead we're setting an array where we should be setting a string.

So I'll put a workaround for this in our code and I'll also submit a fix to the codemirror project.

Thanks for finding it!

avatar okonomiyaki3000
okonomiyaki3000 - comment - 2 Feb 2018

Ah, seems this is also fixed in the latest version of CodeMirror which was released a few days ago.

avatar Quy Quy - change - 2 Feb 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-02-02 03:36:24
Closed_By Quy
avatar joomla-cms-bot joomla-cms-bot - change - 2 Feb 2018
Closed_By Quy joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 2 Feb 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 2 Feb 2018

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19520

avatar Quy
Quy - comment - 2 Feb 2018

Add a Comment

Login with GitHub to post a comment