Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.
/ core Public archive

Comments

PHP 5.4 problems (repository catalog + manager, ...) #4087

Closed
ghost wants to merge 2 commits into2.11.xfrom
unknown repository
Closed

PHP 5.4 problems (repository catalog + manager, ...) #4087
ghost wants to merge 2 commits into2.11.xfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Mar 16, 2012

Contao 2.11.2 does not proper work with new PHP 5.4.

Repository catalog and manager do not work for me! Got a warning and an error twice, for the repository_catalog and repository_manager:

Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in /var/www/virtual/####/html/system/modules/rep_client/RepositoryBackendModule.php on line 217

Fatal error: Uncaught exception SoapFault with message SoapClient::__doRequest() returned non string value thrown in /var/www/virtual/####/html/system/modules/rep_client/RepositoryBackendModule.php on line 217

The Zlib warning is caused due to the new constants introduced by PHP 5.4. (BTW, found the old constant FORCE_GZIP in tiny_mce_gzip.php, line 209.)

For the SoapFault exception I have no idea, but I think it's definitely associated to the warning.

@SunBlack
Copy link

Discussion for this problem see hier.

Current solution: remove compression level (| 1) from SoapClient

@ghost
Copy link
Author

ghost commented Mar 16, 2012

Ok, it works with PHP 5.4 and also PHP 5.3.10. But it seems to load slower!?!

@SunBlack
Copy link

This is possible. The default compression level for gzip compression is -1. And if -1 is used, the default compression of the zlib library is used which is 6 (see here).

How is the performance, if you add SOAP_COMPRESSION_DEFLATE?

And yeah, currently no idea, how to send the compression level for gzip :(

@ghost
Copy link
Author

ghost commented Mar 16, 2012

Seems to be faster!

…flate) in SoapClient constructor call.

Tested with PHP 5.4.0 and PHP 5.3.10.
@ghost
Copy link
Author

ghost commented Mar 17, 2012

Seems to be a bug in SOAP, caused by the new Zlib constants.
For SOAP_COMPRESSION_GZIP with level > 0 gzencode(DATA, level, 1) will be called, but it should be gzencode(DATA, level, ZLIB_ENCODING_GZIP[=31]).

BTW, the compression level (1..9) has to be set otherwise no compression will be applied.

Note, the compression level (0..9) has to be set greater 0 otherwise no compression for SOAP requests will be applied.
@ghost
Copy link
Author

ghost commented Mar 17, 2012

borrible13th: "[...] The Zlib warning is caused due to the new constants introduced by PHP 5.4. (BTW, found the old constant FORCE_GZIP in tiny_mce_gzip.php, line 209.) [...]"

It's not a problem because FORCE_GZIP is defined as ZLIB_ENCODING_GZIP and FORCE_DEFLATE as ZLIB_ENCODING_DEFLATE in PHP 5.4.

@ghost
Copy link
Author

ghost commented Mar 17, 2012

Reported it as SOAP related here: https://bugs.php.net/bug.php?id=61423.

At the moment with PHP 5.4 you should use SOAP_COMPRESSION_DEFLATE. For that see my pull-request.

@ghost ghost closed this Mar 17, 2012
@ghost
Copy link
Author

ghost commented Mar 22, 2012

Ok, SOAP related bug seemed to be fixed (https://bugs.php.net/bug.php?id=61423). Hopefully, we'll see it in PHP 5.4.1.

(Unfortunately, the suggested bugfix is also applied on the branch for PHP-5.3.)

@dominikzogg
Copy link

Contao: 2.11.3
PHP: 5.4.3

Got the same error

@ghost
Copy link
Author

ghost commented Jun 8, 2012

Unfortunately, the bug isn't fixed yet.

Look at the current commits, Leo has added a patch.

@ghost
Copy link
Author

ghost commented Jun 8, 2012

5d3dd72

@dominikzogg
Copy link

Thats what his done at the conference ;-9

@ghost
Copy link
Author

ghost commented Jul 7, 2012

It's solved in PHP-5.4.4.


About Leo's patch:

Leo defines "missing" ZLIB_ENCODING_GZIP as SOAP_COMPRESSION_GZIP for older PHP versions than 5.4 and calls the SoapClient constructor with this "compression value":

..., 'compression' => SOAP_COMPRESSION_ACCEPT | ZLIB_ENCODING_GZIP | 1, ...

instead of:

..., 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 1, ...

Let's look at the magic numbers:
In ext/soap/php_soap.h (PHP 5.3 + 5.4) are defined:

SOAP_COMPRESSION_ACCEPT  0x20
SOAP_COMPRESSION_GZIP    0x00
SOAP_COMPRESSION_DEFLATE 0x10

and in ext/zlib/php_zlib.h:

for PHP 5.3:

CODING_GZIP 1 (registered as "FORCE_GZIP")
CODING_DEFLATE 2 (registered as "FORCE_DEFLATE")

for PHP 5.4:

PHP_ZLIB_ENCODING_RAW -0xf (registered as "ZLIB_ENCODING_RAW")
PHP_ZLIB_ENCODING_GZIP 0x1f (registered as "ZLIB_ENCODING_GZIP" and "FORCE_GZIP")
PHP_ZLIB_ENCODING_DEFLATE 0x0f (registered as "ZLIB_ENCODING_DEFLATE" and "FORCE_DEFLATE")
[PHP_ZLIB_ENCODING_ANY 0x2f]

Therefore the "compression value" is:

  • for PHP 5.3:

    0x20 | 0x00 | 1 = 0x21

  • for PHP 5.4:

    0x20 | 0x1f | 1 = 0x3f

This value is parsed in the function

int make_http_soap_request(...) {...}

in ext/soap/php_http.c:

  • for PHP 5.3:

    level = 0x21 & 0x0f = 0x01 = 1
    kind = 0x21 & SOAP_COMPRESSION_DEFLATE = 0x21 & 0x10 = 0x00

    ==> GZIP with level 1

  • for PHP 5.4:

    level = 0x3f & 0x0f = 0x01 = 1
    kind = 0x3f & SOAP_COMPRESSION_DEFLATE = 0x3f & 0x10 = 0x10

    ==> DEFLATE with level 1

So, Leo uses SOAP_COMPRESSION_DEFLATE for PHP 5.4 like I suggested. What was his intention here?

Why not check against the PHP version?

...
// workaround for PHP 5.4.0-5.4.3
if (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<'))
{
    // buggy gzencode call in function "int make_http_soap_request(...) {...}" in ext/soap/php_http.c
    define('COMPRESSION_KIND', SOAP_COMPRESSION_DEFLATE);
} else {
    // use gzip as previously done
    define('COMPRESSION_KIND', SOAP_COMPRESSION_GZIP);
}
...
'compression' => SOAP_COMPRESSION_ACCEPT | COMPRESSION_KIND | 1,
...

@leofeyer
Copy link
Member

Fixed in 588c6a5. Thanks a lot for tracking this down.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants