Elegance - 404 error font-awesome after theme update

Elegance - 404 error font-awesome after theme update

by Ella S. -
Number of replies: 13

Hello. Moodle 2.9 and 3.0.1. (Windows Server 2012 R2, IIS, MSSQL)

After update theme Elegance to version 3.0.0 (2015111500) the fonts (fontawesome) were lost. I get the 404 errors (in console):


load elegance js

http://my.domain.ru/theme/font.php?theme=elegance&component=theme&rev=1451982023&font=fontawesome-webfont.woff2?v=4.4.0

Failed to load resource: the server responded with a status of 404 (not found)

http://my.domain.ru/theme/font.php?theme=elegance&component=theme&rev=1451982023&font=fontawesome-webfont.woff?v=4.4.0

Failed to load resource: the server responded with a status of 404 (not found)

http://my.domain.ru/theme/font.php?theme=elegance&component=theme&rev=1451982023&font=fontawesome-webfont.ttf?v=4.4.0

Failed to load resource: the server responded with a status of 404 (not found)

 

Before update, font worked fine.  What can I do to fix this?


Attachment elegance-font-error.png
Average of ratings: -
In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Ella S. -

There are font files in theme folder:

Attachment elegance-font.png
In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Check permissions on the folder to make sure they can be accessed by the webpage

In reply to Richard Oelmann

Re: Elegance - 404 error font-awesome after theme update

by Ella S. -
Check permissions on the folder to make sure they can be accessed by the webpage


I re-cheked all permission, they are OK. Also users IUSR and IIS_IUSRS have "modify"-rights on theme folder. But don't helps.

In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Ella,
try to put the URL straight on your browser and read there the reason for the 404: it could be a permissions issue or something that depends on Moodle.
Please, activate the debugging at DEVELOPER level before testing the URL.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Elegance - 404 error font-awesome after theme update

by Ella S. -

try to put the URL straight on your browser and read there the reason for the 404: it could be a permissions issue or something that depends on Moodle. Please, activate the debugging at DEVELOPER level before testing the URL.

I'll tried to do as you write.

The direct URL writes: 404. Font was not found.

BUT if I remove "?v=4.4.0" from original URL (http://my.domain.ru/theme/font.php?theme=elegance&component=theme&rev=1451982023&font=fontawesome-webfont.woff?v=4.4.0), then I normally get font file by URL http://my.domain.ru/theme/font.php?theme=elegance&component=theme&rev=1451982023&font=fontawesome-webfont.woff

What is the string "?v=4.4.0"? Can I somehow remove it from theme? Where? Is theme bug or moodle bug?

In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Ella,
I didn't notice it before, at the time of my post: yes, that piece of HTTP GET breaks the URL since it should be &v=4.4.0!

I do not run Elegance but sounds a theme bug when Moodle is deployed with slash arguments set to off. Is there any reason why you're not using slash arguments?

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Re: Elegance - 404 error font-awesome after theme update

by Ella S. -

Thank you, Matteo.

Yes, slash arguments was set to off some years ago because IIS has some problems with it (with russian symbols in file names). But thanks to your advice, I again looked at this manual and found that it is possible to make URL Rewrite rule, which allows IIS to work with slasharguments.

After enable slasharguments, font works.

In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I'm sure I posted ages ago about font.php not supporting the '?v=' syntax.  Can't find a tracker issue though.

In reply to Gareth J Barnard

Re: Elegance - 404 error font-awesome after theme update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gareth,
that syntax is used here: https://github.com/bmbrands/moodle-theme_elegance/blob/master/less/fontawesome/path.less being fa-version defined in https://github.com/bmbrands/moodle-theme_elegance/blob/master/less/fontawesome/variables.less#L9.

IMHO there is room for an improvement in Moodle for the work done in MDL-23493 BUT you know that Slash arguments set to On will be the default settings starting from 3.1 so I guess that this improvement will never land.

It could be coded directly into Elegance via theme_elegance_process_css() being declared as $THEME->csspostprocess (twice, a trivial bug): there it should be tested the Slash arguments setting and replaced accordingly the "?v="- I know you're not the maintainer just free discussion wink -, something like the patch below (untested):

diff --git a/lib.php b/lib.php
index ebfb973..ed6c05a 100644
--- a/lib.php
+++ b/lib.php
@@ -150,6 +150,16 @@ function theme_elegance_less_variables($theme) {
 }

 function theme_elegance_process_css($css, $theme) {
+    global $CFG;
+
+    // Fix the version used as a cache killer.
+    if (!$CFG->slasharguments) {
+        $css = str_replace(
+            array('?v=', '?#iefix'),
+            array('&v=', '&#iefix',
+            $css
+        );
+    }

     // Set the background image for the logo.

HTH,
Matteo

In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Ella,
glad to read it!

BTW you can get rid of the URL Rewrite approach if you stick with FastCGI and follow https://docs.moodle.org/29/en/Internet_Information_Services#Slasharguments and https://docs.moodle.org/29/en/Internet_Information_Services#Optional_UTF-8_file_name_fix.
Tested on both IIS 7.5 (2008 R2) and 8.5 (2012 R2).

If you want to give it a chance, please do it in a test environment first wink.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Ella S.

Re: Elegance - 404 error font-awesome after theme update

by Usman Asar -
Picture of Plugin developers Picture of Testers
Worked fine for me on IIS, Had  you upgraded your bootstrap as well? though shouldn't directly be linked to BS's update, but just in case.
Try deleting cache for theme and see if works.
In reply to Usman Asar

Re: Elegance - 404 error font-awesome after theme update

by Ella S. -

Had  you upgraded your bootstrap as well?

Yes. Bootstrap was updated before update Elegance.