Core: Invalid custom CSS causes forum to 500

Created on 16 Aug 2017  路  3Comments  路  Source: flarum/core

Bug report

  • Version of Flarum: 0.1.0-beta.7
  • Website URL where the bug is visible: Removed
  • The webserver you are running: apache
  • PHP version:
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
  • Hosted environment: vps
  • Hosting provider: KVM VPS provided by ourselves

Flarum info

Flarum core 0.1.0-beta.7
PHP 7.0.22-0ubuntu0.16.04.1
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, pcntl, Reflection, SPL, session, standard, mysqlnd, PDO, xml, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, json, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, Zend OPcache
EXT flarum-approval v0.1.0-beta.7
EXT flarum-bbcode v0.1.0-beta.5
EXT flarum-emoji v0.1.0-beta.6
EXT flarum-english v0.1.0-beta.7
EXT flarum-flags v0.1.0-beta.7
EXT flarum-likes v0.1.0-beta.6
EXT flarum-lock v0.1.0-beta.7
EXT flarum-markdown v0.1.0-beta.5
EXT flarum-mentions v0.1.0-beta.7
EXT flarum-sticky v0.1.0-beta.7
EXT flarum-subscriptions v0.1.0-beta.6
EXT flarum-suspend v0.1.0-beta.7
EXT flarum-tags v0.1.0-beta.8
Base URL: <removed>
Installation path: /srv/forum

Additional comments

Forum displays 500 when CSS with @media is present
Removing the offending CSS in the database makes the forum load correctly.

update frm_settings set value="" where `key`="custom_less";

offending CSS:

/*p {
color:#a8897c;
}

.Button {
color:#a8897c;
}

.IndexPage-newDiscussion {
color:white;
background-color:#a8897c;
}*/

body {
/*background-image:url("<removed>");*/
}

#app {
background-color:rgba(0,0,0,0);
background-image:url("<removed>");
background-repeat: no-repeat;
background-position: 50% -50px;
background-size: 1600px 100%;
}

/*.Button-label, .DiscussionListItem-title, .Dropdown-menu>li>a {
color:black;
}*/

@media {
color:black;
}

.IndexPage-newDiscussion .Button-label {
color:white;
}

Expected behaviour

  • Forum software should not crash
  • Setting "debug mode" should display an error (only way to find the error was the apache logs)

Log files

Apache Error log

[Wed Aug 16 23:01:17.283172 2017] [:error] [pid 8658] [client <REMOVED>] PHP Fatal error:  Uncaught Error: Call to a member function accept() on null in /srv/forum/vendor/oyejorge/less.php/lib/Less/Visitor.php:37\nStack trace:\n
#0 /srv/forum/vendor/oyejorge/less.php/lib/Less/Tree/Media.php(32): Less_Visitor->visitObj(NULL)\n#1 /srv/forum/vendor/oyejorge/less.php/lib/Less/Visitor.php(28): Less_Tree_Media->accept(Object(Less_Visitor_joinSelector))\n
#2 [internal function]: Less_Visitor->visitObj(Object(Less_Tree_Media))\n
#3 /srv/forum/vendor/oyejorge/less.php/lib/Less/Visitor.php(45): array_map(Array, Array)\n
#4 /srv/forum/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(64): Less_Visitor->visitArray(Array)\n
#5 /srv/forum/vendor/oyejorge/less.php/lib/Less/Visitor.php(28): Less_Tree_Ruleset->accept(Object(Less_Visitor_joinSelector))\n
#6 /srv/forum/vendor/oyejorge/less.php/lib/Less/Visitor/joinSelector.php(17): Less_Visitor->visitObj(Object(Less_Tree_Ruleset))\n
#7 /srv/forum/vendor/oyejorge/less.php/lib/Less/Parser.php(420): Less_Visitor_joinSelector->run(Object(Less_Tre in /srv/forum/vendor/oyejorge/less.php/lib/Less/Visitor.php on line 37
typbug

Most helpful comment

Thanks for the report!

IMO, we should verify that the CSS compiles successfully whenever custom CSS is entered in the admin panel. If it is not valid, we should simply not save it. Agreed?

All 3 comments

Thanks for the report!

IMO, we should verify that the CSS compiles successfully whenever custom CSS is entered in the admin panel. If it is not valid, we should simply not save it. Agreed?

Reopening as the PR only partially solves the issue, @franzliedke is correct and we still need the full solution eventually.

This was closed by https://github.com/flarum/core/commit/0e737854980d0ceedc7727509d7429efed7d8494, the merged PR commit description didn鈥檛 include anything past the first line for each commit.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ardacebi picture ardacebi  路  4Comments

tobyzerner picture tobyzerner  路  4Comments

datitisev picture datitisev  路  3Comments

jordanjay29 picture jordanjay29  路  3Comments

tobyzerner picture tobyzerner  路  5Comments