ProcessWire icon indicating copy to clipboard operation
ProcessWire copied to clipboard

php-xml package required for PNGs to work

Open thetuningspoon opened this issue 8 years ago • 4 comments

I ran into an issue where my php7 installation didn't have php-xml installed, which caused the following error if I tried to output a PNG file into my template from a file field:

Fatal error: Uncaught Error: Call to undefined function ProcessWire\utf8_encode() in /.../wire/core/PWPNG.php:117

I don't remember php-xml being noted as a required package during the PW installation.

PW 3.0.29

thetuningspoon avatar Aug 31 '16 16:08 thetuningspoon

This is one of the features that seem to be, as far as I can tell, disabled by default as of PHP 7. In other words: before PHP 7 they were always available (or at least enabled by default), while in PHP 7 the php-xml package is indeed required.

For the record, I can't think of any sane reason to bundle utf8_encode() with the languages XML features (php-xml), but I guess that's just how PHP is :)

Here's one thread discussing the issue: http://stackoverflow.com/questions/35701730/utf8-endecode-removed-from-php7.

teppokoivula avatar Sep 02 '16 06:09 teppokoivula

@horst-n since this is in the PWPNG class you made, I wanted to ask if this utf8_encode() is something that we need at all? I see it's creating a $this->info['palette'] property, but can't find any code that is actually using it. As a result, I'm wondering if maybe we can just delete this line to solve the problem?

ryancramerdesign avatar Sep 05 '16 12:09 ryancramerdesign

Came across this issue as well, but with PHP 5.6. Might be related to the fact that I am using a Docker image (centos6), that may have a different default configuration than other variants.

For now, I just commented out line 117 of PWPNG.php to solve the problem.

This is with the 3.0.57 of PW from the dev branch.

evanmcd avatar Mar 26 '17 18:03 evanmcd

Hey @ryancramerdesign and @horst-n, I (well, my client) ran into the same issue with this utf8_encode() and couldn't edit the affected page anymore due to the fatal error.

I "deleted" the utf8_encode() call in line 117 and reloaded the corresponding "/page/edit?id=1234" in the PW backend. Then I changed the line back again because I didn't knew what I was doing there in this core module - not a good feeling

Can you please fix this? My client wasn't able to edit his page anymore. Meanwhile I try to contact the sysadmin to install the module php xml. but I bet others will run into this issue aswell.

here is the full error code:

Fatal Error: Uncaught Error: Call to undefined function ProcessWire\utf8_encode() in /var/www/a.secret.domain.de/www2/htdocs/wire/core/PWPNG.php:117
Stack trace: #0 /var/www/a.secret.domain.de/www2/htdocs/wire/core/PWPNG.php(31): ProcessWire\PWPNG->_parsepngstream(Resource id #57, 'file-name...')
#1 /var/www/a.secret.domain.de/www2/htdocs/wire/core/ImageInspector.php(209): ProcessWire\PWPNG->loadFile('/var/www/a.secret.domain.de...')
#2 /var/www/a.secret.domain.de/www2/htdocs/wire/core/ImageInspector.php(129): ProcessWire\ImageInspector->loadImageInfoPng()
#3 /var/www/a.secret.domain.de/www2/htdocs/wire/core/ImageSizer.php(445): ProcessWire\ImageInspector->inspect('/var/www/a.secret.domain.de...', true)
#4 /var/www/a.secret.domain.de/www2/htdocs/wire/core/Pageimage.php(839): ProcessWire\ImageSizer->getEngine()
#5 /var/www/a.secret.domain.de/www2/htdocs/wire/core/Pageimage.php(646): ProcessWire\Pageimage->___size(0, 260, Array)
#6 /var/www/a.secret.domain.de/www2/htdocs/wire/core/Pageimage.php(1045): ProcessWire\Pageimage->size(0, 260, Array)
#7 /var/www/a.secret.domain.de/www2/htdocs/wire/modules/Inputfield/InputfieldI (line 117 of /var/www/a.secret.domain.de/www2/htdocs/wire/core/PWPNG.php)

PW: 3.0.138 Linux a.secret.domain.de 3.16.0-7-amd64 #1 SMP Debian 3.16.59-1 (2018-10-03) x86_64 PHP Version 7.0.33-1~dotdeb+8.1

thank you so much for your support.

kbreynck avatar Oct 04 '19 17:10 kbreynck