XF 2.0 Server error: .m-pageWidth troubleshooting

Russ

Well-known member
So I'm getting this error on my styles and I'm a little baffled. I can't reproduce it consistently, it's completely random. I have had the error twice in the past few weeks, another client has the error multiple times today alone.

Code:
Less_Exception_Compiler: .m-pageWidth is undefined in anonymous-file-0.less src/vendor/oyejorge/less.php/lib/Less/Tree/Mixin/Call.php:148
Generated by: Unknown account Nov 30, 2018 at 7:12 AM
Stack trace
#0 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(147): Less_Tree_Mixin_Call->compile(Object(Less_Environment))
#1 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(88): Less_Tree_Ruleset->EvalMixinCalls(Object(Less_Tree_Ruleset), Object(Less_Environment), 2)
#2 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(94): Less_Tree_Ruleset->compile(Object(Less_Environment))
#3 src/vendor/oyejorge/less.php/lib/Less/Parser.php(199): Less_Tree_Ruleset->compile(Object(Less_Environment))
#4 src/XF/CssRenderer.php(363): Less_Parser->getCss()
#5 src/XF/CssRenderer.php(311): XF\CssRenderer->renderToCss('public:xb_foote...', '// Note that th...')
#6 src/XF/CssRenderer.php(235): XF\CssRenderer->renderTemplate('public:xb_foote...', NULL)
#7 src/XF/CssRenderer.php(101): XF\CssRenderer->renderTemplates(Array, Array, Array)
#8 src/XF/CssWriter.php(53): XF\CssRenderer->render(Array)
#9 css.php(30): XF\CssWriter->run(Array, 165, 1, 'f68fcdc4fbe2629...')
#10 {main}

We've edited app.less to include a custom template "xb.less" in which further includes "xb_footer.less" inside of that. In xb_footer.less we have this:

Code:
.p-footer-inner
{
    .m-pageWidth();
}

What would cause .m-pageWidth to show as undefined exactly? This is still intact:

Code:
.m-pageWidth()
{
    max-width: @xf-pageWidthMax;
    padding: 0 @xf-pageEdgeSpacer;
    margin: 0 auto;
}
inside app.less at the default position.
 
What's the full URL that generated the error?

You're depending on this being run with app.less (since the mixin is defined there). If there's ever a situation where you template is compiled without being included into app.less, then this will fail as the mixin won't exist.
 
I suppose I figured app.less was running on every page since the guts of XF css are included in there.

The request state:

Code:
array(4) {
  ["url"] => string(176) "/xf2/css.php?css=public%3Ashare_controls.less%2Cpublic%3Axb.less%2Cpublic%3Axb_footer.less%2Cpublic%3Aextra.less&s=2&l=1&d=1542797199&k=8424fb9b4bee09b4120a9e2ea27f09415f5d8611"
  ["referrer"] => string(31) "https://site.com/xf2/search/"
  ["_GET"] => array(5) {
    ["css"] => string(81) "public:share_controls.less,public:xb.less,public:xb_footer.less,public:extra.less"
    ["s"] => string(1) "2"
    ["l"] => string(1) "1"
    ["d"] => string(10) "1542797199"
    ["k"] => string(40) "8424fb9b4bee09b4120a9e2ea27f09415f5d8611"
  }
  ["_POST"] => array(0) {
  }
}

Code:
array(4) {
  ["url"] => string(185) "/xf2/css.php?css=public%3Anode_list.less%2Cpublic%3Ashare_controls.less%2Cpublic%3Axb_footer.less%2Cpublic%3Aextra.less&s=165&l=1&d=1543518079&k=f68fcdc4fbe262968f36313bffa40b42e4c60b8a"
  ["referrer"] => string(24) "https://site.com/xf2/"
  ["_GET"] => array(5) {
    ["css"] => string(88) "public:node_list.less,public:share_controls.less,public:xb_footer.less,public:extra.less"
    ["s"] => string(3) "165"
    ["l"] => string(1) "1"
    ["d"] => string(10) "1543518079"
    ["k"] => string(40) "f68fcdc4fbe262968f36313bffa40b42e4c60b8a"
  }
  ["_POST"] => array(0) {
  }
}
 
App.less is included in every page, but it's not included in every CSS rendering. If you look at the source of this page, for example, you'll see app.less explicitly named in the first CSS request.

From that URL, you can see xb_footer.less being requested explicitly. This would likely indicate that there's an <xf:css> call for it in a (non-LESS) template somewhere. If it's included in app.less, then you're just including duplicate CSS at that point anyway (notwithstanding the missing mixin).
 
Do you guys have a "best method" for including custom less templates that should load out on every page outside of extra.less as we're wanting to keep that empty?

I'll need to do some digging but that template is only included via this method:
Code:
{{ include('xb_footer.less') }}
inside our xb.less template.
 
@Russ Do you found solution for this issue? I am also getting Server error log after Theme updated for XF 2.0.12


Code:
Less_Exception_Compiler: .m-pageWidth is undefined in anonymous-file-35561.less src/vendor/oyejorge/less.php/lib/Less/Tree/Mixin/Call.php:148

Generated by: Unknown account Dec 15, 2018 at 3:22 AM

Stack trace

#0 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(147): Less_Tree_Mixin_Call->compile(Object(Less_Environment))
#1 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(88): Less_Tree_Ruleset->EvalMixinCalls(Object(Less_Tree_Ruleset), Object(Less_Environment), 2)
#2 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(94): Less_Tree_Ruleset->compile(Object(Less_Environment))
#3 src/vendor/oyejorge/less.php/lib/Less/Parser.php(199): Less_Tree_Ruleset->compile(Object(Less_Environment))
#4 src/XF/CssRenderer.php(363): Less_Parser->getCss()
#5 src/XF/CssRenderer.php(311): XF\CssRenderer->renderToCss('public:xb_foote...', '// Note that th...')
#6 src/XF/CssRenderer.php(235): XF\CssRenderer->renderTemplate('public:xb_foote...', NULL)
#7 src/XF/CssRenderer.php(101): XF\CssRenderer->renderTemplates(Array, Array, Array)
#8 src/XF/CssWriter.php(53): XF\CssRenderer->render(Array)
#9 src/addons/SV/RedisCache/XF/CssWriter.php(23): XF\CssWriter->run(Array, 4, 1, 'e2332072f7c33e3...')
#10 css.php(30): SV\RedisCache\XF\CssWriter->run(Array, 4, 1, 'e2332072f7c33e3...')
#11 {main}

Request state

array(4) {
  ["url"] => string(385) "/css.php?css=public%3Aallm_tag_check_post_links_status.less%2Cpublic%3Amessage.less%2Cpublic%3Anotices.less%2Cpublic%3Ashare_controls.less%2Cpublic%3Asiropu_ads_manager_ad.less%2Cpublic%3Asiropu_ads_manager_slick.less%2Cpublic%3Asnog_flags.less%2Cpublic%3Ath_reactions.less%2Cpublic%3Axb_footer.less%2Cpublic%3Aextra.less&s=4&l=1&d=1522961672&k=e2332072f7c33e3312fbf2ef99a69dc7ce42aaa6"
  ["referrer"] => string(68) "threads/sabrina.1738/page-3"
  ["_GET"] => array(5) {
    ["css"] => string(270) "public:allm_tag_check_post_links_status.less,public:message.less,public:notices.less,public:share_controls.less,public:siropu_ads_manager_ad.less,public:siropu_ads_manager_slick.less,public:snog_flags.less,public:th_reactions.less,public:xb_footer.less,public:extra.less"
    ["s"] => string(1) "4"
    ["l"] => string(1) "1"
    ["d"] => string(10) "1522961672"
    ["k"] => string(40) "e2332072f7c33e3312fbf2ef99a69dc7ce42aaa6"
  }
  ["_POST"] => array(0) {
  }
}


Code:
Less_Exception_Compiler: .m-pageWidth is undefined in anonymous-file-674.less src/vendor/oyejorge/less.php/lib/Less/Tree/Mixin/Call.php:148

Generated by: Unknown account Dec 14, 2018 at 11:42 PM

Stack trace

#0 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(147): Less_Tree_Mixin_Call->compile(Object(Less_Environment))
#1 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(88): Less_Tree_Ruleset->EvalMixinCalls(Object(Less_Tree_Ruleset), Object(Less_Environment), 2)
#2 src/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(94): Less_Tree_Ruleset->compile(Object(Less_Environment))
#3 src/vendor/oyejorge/less.php/lib/Less/Parser.php(199): Less_Tree_Ruleset->compile(Object(Less_Environment))
#4 src/XF/CssRenderer.php(363): Less_Parser->getCss()
#5 src/XF/CssRenderer.php(311): XF\CssRenderer->renderToCss('public:xb_foote...', '// Note that th...')
#6 src/XF/CssRenderer.php(235): XF\CssRenderer->renderTemplate('public:xb_foote...', NULL)
#7 src/XF/CssRenderer.php(101): XF\CssRenderer->renderTemplates(Array, Array, Array)
#8 src/XF/CssWriter.php(53): XF\CssRenderer->render(Array)
#9 src/addons/SV/RedisCache/XF/CssWriter.php(23): XF\CssWriter->run(Array, 4, 1, '787e1625c0c6454...')
#10 css.php(30): SV\RedisCache\XF\CssWriter->run(Array, 4, 1, '787e1625c0c6454...')
#11 {main}

Request state

array(4) {
  ["url"] => string(177) "/css.php?css=public%3Anotices.less%2Cpublic%3Ashare_controls.less%2Cpublic%3Axb_footer.less%2Cpublic%3Aextra.less&s=4&l=1&d=1520171796&k=787e1625c0c645401dcf682f7f7987997f65e745"
  ["referrer"] => string(50) "/members/sheakh.122/trophies"
  ["_GET"] => array(5) {
    ["css"] => string(86) "public:notices.less,public:share_controls.less,public:xb_footer.less,public:extra.less"
    ["s"] => string(1) "4"
    ["l"] => string(1) "1"
    ["d"] => string(10) "1520171796"
    ["k"] => string(40) "787e1625c0c645401dcf682f7f7987997f65e745"
  }
  ["_POST"] => array(0) {
  }
}
 
Since this is a style related issue just go ahead and post on my site for support. For clients experiencing it this is a workaround for the time being:

 
Back
Top Bottom