Closed meskarune closed 6 years ago
Hello there. Chyrp Lite will use gzip or deflate compression where it detects this is available and not already enabled. You can see the logic here. If the content is compressed, an appropriate header will be outputted here.
I was able to fetch your page using a little PHP script, and all looks well if I supply no Accept-Encoding
header. If I supply the request header Accept-Encoding: gzip
the content returned from your site is gzip encoded but the Content-Encoding: gzip
response header is not sent by your server. Chyrp Lite sets this header if it is responsible for the encoding so it seems the header is being stripped before the response is sent, presumably by lighttpd.
A simple way to test this would be to add the following at the top of the file includes/common.php:
define('USE_ZLIB', false);
This definition will prevent Chyrp Lite from trying to do content compression. Once this is set, if your site looks ok then the problem is with lighttpd. You can either try to fix it or leave it as is – Chyrp Lite will work just fine without it.
Correction: I am seeing the correct headers from your server, but something is wrong with the encoding. Please try the test described above and let me know what happens.
After poking around a bit more, it seems your server is assuming that all PHP scripts will serve HTML content, and something is injecting top level HTML tags into the content if those tags are not already present. This causes pages served with gzip compression to be fubar, but it also screws up dynamically generated JavaScript.
I have no idea how this server behaviour has been configured, but that's the source of your problem.
The tag injection is done regardless of what Content-Type
header is set. At the application level, Chyrp Lite appears to be working correctly. Preventing Chyrp Lite from compressing pages should get you up and running, but other things will remain broken unless you track down the source of this behaviour.
Thanks for getting back to me. I added the define('USE_ZLIB', false);
as a test and indeed the site loaded, but with a messages "You are not allowed to view this site." even after logging in that is the only content I can see.
For lighttpd I have the following modules enabled: mod_access, mod_auth, mod_fastcgi
Access and auth are for server side handling of password protected directories, and fastcgi is support for php-fpm.
Other than configuring fastcgi/php-fpm the server is basically running default settings. I will investigate further and reach out to the lighttpd folks to try and figure this out.
edit: I ran the following command:
file -b --mime-type /usr/local/www/vhosts/doloresportalatin.info/public/test.php
And got this result: text/html
I am on freebsd version 11.2 (the latest release)
I tried adding ".php" => "text/x-php; charset=utf-8",
to the server's mimetype list, but still no change in chyrp. In the server's mimetype list it also has ".gz" => "application/gzip",
in the mimetype list as well as a large number of other compression formats.
Just to give you an update. I talked with the lighttpd folks and they seemed to think it might be my server's php configuration. So I uninstalled php, deleted all config files and reinstalled with everything completely default. I had recently upgraded the system to the latest version of freebsd and it automatically merged php configs, so I am guessing something with that could have been the problem.
Anyways, I reinstalled php and then uncommented the needed modules for chryp, and now the content encoding is just fine.
I have a totally different (unrelated) error message which I think is due to php version 7.2 changes - https://wiki.php.net/rfc/counting_non_countables
Error count(): Parameter must be an array or an object that implements Countable
Current headers:
HTTP/1.0 500 Internal Server Error =>
X-Powered-By => PHP/7.2.8
Set-Cookie => ChyrpSession=dh1951rvduar9gh2l1dg4h9d14; expires=Tue, 18-Sep-2018 20:53:08 GMT; Max-Age=2592000; path=/; domain=doloresportalatin.info; HttpOnly
Pragma => no-cache
Referrer-Policy => strict-origin-when-cross-origin
Vary => Accept-Encoding, Cookie
X-Pingback => http://doloresportalatin.info/includes/rpc.php
Content-Type => text/html; charset=UTF-8
Cache-Control => no-cache, must-revalidate
Expires => Mon, 03 Jun 1991 05:30:00 GMT
Content-Length => 6280
Connection => close
Date => Sun, 19 Aug 2018 20:53:08 GMT
Server => lighttpd/1.4.49
I have compression enabled right now and things are looking good. (the line define('USE_ZLIB', false);
is not in common.php)
Should I close this issue and open a new issue for the php 7.2 bug?
I'm glad to have one problem solved. =)
My own Chyrp Lite blog is running on PHP 7.2.8 without issues so I think this error is being triggered by something out of the ordinary. You mentioned also that login is not behaving as expected – perhaps the previous PHP weirdness has caused the database to be improperly configured during the installation process.
Could you try a fresh install of Chyrp Lite? If the error persists please do open a new issue for it and I will investigate. Enabling DEBUG mode will provide a more helpful error message if you need to open an issue.
I did a full reinstall of the app as well as deleting the old database and making a new database/user. I was able to install and also login and create a post: http://doloresportalatin.info/?action=index
But when I click on the post I get the count() error, for example: http://doloresportalatin.info/?action=view&url=test-page (I have debug turned on)
Error
count(): Parameter must be an array or an object that implements Countable
Backtrace
includes/controller/Main.php on line 331
includes/class/Route.php on line 130
includes/class/Route.php on line 130
Thanks for the backtrace. I see the problem and I should be able to get a simple fix committed today.
The problem will only occur when running on 7.2 with Chyrp Lite’s clean URLs setting not enabled, which is why I haven’t run into it until now.
I've just committed a fix for the count problem. It requires a couple of small changes to two files, which you can reproduce yourself or patch from the develop branch.
Sweet, thanks for fixing that so fast. I patched the files and the site is working as you'd expect: http://doloresportalatin.info/?action=view&url=test-page
I'll go ahead and close this issue :smile:
I installed chyrp-lite on my freebsd server and the install was successful, however when I try to load the page I get an error, "Content encoding error, the page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression". I am using lighttpd + php-fpm and do not have compression enabled on them currently. My other php sites/scripts work, and the web server has no errors so I think it is the chyrp app that is the issue as it returns some html and then gzipped data mixed in, but either not sending the right headers or not doing something that is required for the server to serve pagers propertly.
I have the chyrp install at http://doloresportalatin.info and a test php page at http://doloresportalatin.info/test.php so you can see that php is working.
If you could let me know how to further debug this I would be happy to help.