Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colour hilighting absent in J! 3.8.4 when editing PHP files #19520

Closed
sozzled opened this issue Feb 1, 2018 · 7 comments
Closed

Colour hilighting absent in J! 3.8.4 when editing PHP files #19520

sozzled opened this issue Feb 1, 2018 · 7 comments

Comments

@sozzled
Copy link

sozzled commented Feb 1, 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

@brianteeman
Copy link
Contributor

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

@Quy
Copy link
Contributor

Quy commented Feb 1, 2018

cc @okonomiyaki3000

@okonomiyaki3000
Copy link
Contributor

OK, I'll have a look

@okonomiyaki3000
Copy link
Contributor

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!

@okonomiyaki3000
Copy link
Contributor

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

@joomla-cms-bot
Copy link

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

@Quy
Copy link
Contributor

Quy commented Feb 2, 2018

See #19522 #19524


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19520.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants