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

Wrong variable type in css.php for $less->importDir[] #1777

Closed
nevotheless opened this issue Dec 12, 2016 · 14 comments
Closed

Wrong variable type in css.php for $less->importDir[] #1777

nevotheless opened this issue Dec 12, 2016 · 14 comments

Comments

@nevotheless
Copy link

Hi there,

i think a found a bug (i absolutely cannot reproduce this on non docker environments, but it is definitely there) related to the used type of $less->importDir[]...

i don't think it should be an array.

This causes my css.php to fail: output of the file is just

<br />
<b>Fatal error</b>:  Uncaught Error: [] operator not supported for strings in /var/www/html/lib/exe/css.php:169
Stack trace:
#0 /var/www/html/lib/exe/css.php(140): css_parseless('@ini_text: #333...')
#1 /var/www/html/lib/exe/css.php(18): css_out()
#2 {main}
  thrown in <b>/var/www/html/lib/exe/css.php</b> on line <b>169</b><br />

Removing [] made it work for me.

I tested this with
Apache/2.4.10 (Debian) PHP/7.1.0
Apache/2.4.10 (Debian) PHP/7.0
Apache/2.4.10 (Debian) PHP/5.6
I had the issue on every containerized environment.
(I'm using this dockerfile)

@splitbrain
Copy link
Collaborator

I am not sure why, but the linked docker file replaces lib/exe/css.php with their own version. That's probably the reason why it behaves differently only in docker.

@nevotheless
Copy link
Author

That's the fix for the dockerfile. I simply added a corrected version of the css.php so that the container will actually work as intended.

@splitbrain
Copy link
Collaborator

I didn't notice that this seems to be your Docker image.

lessc.inc.php declares $importDir as string|string[] and indeed uses it as (array)$this->importDir.

However I guess the problem might be that it is never initialized as an array. Though I wonder why this doesn't throw any problems outside your docker image. Actually I think this should be a notice not an error...

@nevotheless
Copy link
Author

Yeah that's quite interesting indeed. We also use a non-docker productive dokuwiki and there is no issue with that as well. 😲

@nevotheless
Copy link
Author

http://i.imgur.com/s9JTJSX.png that's what i see btw. with the $less->importDir[] version.

@splitbrain
Copy link
Collaborator

I pushed a fix. Could it be that the PHP image you use for some reason sets a config option or something that converts warnings to exceptions?

@nevotheless
Copy link
Author

That is highly unlikely i guess. The base image is the offical php:7.1-apache image but i cannot find weird stuff there right now nor can i say anything definite about config options that would convert warnings. It's pretty basic afaik.

@lifehome
Copy link

lifehome commented Feb 1, 2017

I think this should be pushed as a hotfix, since the stable release with PHP7 is crashing like the imgur picture @ununseptium provided.

@mikeploeger
Copy link

Iam using PHP 7.1.1 and [] worked for me as well.
Otherwise the layout got messed up and things got broken.

@snassar
Copy link

snassar commented Feb 12, 2017

I am testing Dokuwiki with Apache 2.4.25 and PHP 7.1.1 and I had to change:

function css_parseless($css) {
    global $conf;

    $less = new lessc();
    $less->importDir[] = DOKU_INC;
    $less->setPreserveComments(!$conf['compress']);

to

function css_parseless($css) {
    global $conf;

    $less = new lessc();
    $less->importDir = DOKU_INC;
    $less->setPreserveComments(!$conf['compress']);

to get stylesheets to work.

@rivthor
Copy link

rivthor commented Aug 17, 2018

Can verify that this is indeed an issue on Ubuntu 18.04.1 LTS as well, importDir[] should be importDir for templates to work (otherwise there's a 500 error thrown by apache and :

[Fri Aug 17 10:23:07.956448 2018] [php7:error] [pid 20149] [client 157.157.42.1:41810] PHP Fatal error: Uncaught Error: [] operator not supported for strings in /usr/share/dokuwiki/lib/exe/css.php:169\nStack trace:\n#0 /usr/share/dokuwiki/lib/exe/css.php(140): css_parseless('@ini_text: #333...')\n#1 /usr/share/dokuwiki/lib/exe/css.php(18): css_out()\n#2 {main}\n thrown in /usr/share/dokuwiki/lib/exe/css.php on line 169, referer: https://localhost/doku.php

@splitbrain
Copy link
Collaborator

This has been fixed since years! Update your DokuWiki.

@rivthor
Copy link

rivthor commented Aug 17, 2018

This is in the latest version that installs with Ubuntu 18.04 LTS.

Me complaining to Canonical does nothing. If someone authoritative for the software points it out, it might help.

@splitbrain
Copy link
Collaborator

Don't install the debian package. It's notoriously outdated. Just download the official package and follow the installation instructions.

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

No branches or pull requests

6 participants