Bug #73249 [Ver]: <visibility error> for Exception __construct
| From: | cmb@php.net | Date: | Fri, 21 Oct 2016 14:57:27 +0000 |
| Subject: | Bug #73249 [Ver]: <visibility error> for Exception __construct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204952@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73249&edit=1
ID: 73249
Updated by: cmb@php.net
Reported by: remi@php.net
Summary: <visibility error> for Exception __construct
Status: Verified
Type: Bug
Package: *PDF functions
Operating System: irrevelant
PHP Version: 7.0.11
Assigned To: rjs
Block user comment: N
Private report: N
New Comment:
I'm afraid there is not much documentation available (and I
wouldn't be able to write some). Maybe Julian's blog post about
exceptions is a bit helpful:
<http://jpauli.github.io/2015/04/09/exceptional-php.html>.
Previous Comments:
------------------------------------------------------------------------
[2016-10-20 19:45:22] rjs@php.net
I'm not totally sure, but I think I was inspired by this code when I implemented this some
years ago:
https://github.com/php/php-gtk-src/blob/master/main/phpg_exceptions.c
I understand that this seems to be wrong and I will fix it. cmb@php.net, do you have a source for
(good) documentation/examples on how to do that stuff right, so that I can check the rest of the
implementation.
------------------------------------------------------------------------
[2016-10-05 08:20:37] cmb@php.net
The problem is the following code in pdf.c:
pdflib_exception_class->constructor->common.fn_flags
|= ZEND_ACC_PROTECTED;
This has two issues:
* just adding the protected flags without removing the public
flag creates an unexpected bitmask, because the visibility
flags are supposed to be exclusive
* this changes the flags of the inherited class[1]
Rainer, please have a look at this issue.
[1] <https://github.com/php/php-src/commit/a783891e>
------------------------------------------------------------------------
[2016-10-05 06:58:54] remi@php.net
Reaffecting to PDF as the error only appear when this extension is installed
With pdf => issue
$ php -n -d extension=pdf.so -d extension=json.so -d extension=couchbase.so --re couchbase | grep
__cons
Method [ <internal:Core, inherits Exception, ctor> <visibility error> method
__construct ] {
Without pdf => no issue
$ php -n -d extension=json.so -d extension=couchbase.so --re couchbase | grep __cons
Method [ <internal:Core, inherits Exception, ctor> public method __construct ] {
------------------------------------------------------------------------
[2016-10-05 05:35:07] remi@php.net
Various extensions are affected:
- couchbase
- leveldb
- mongo
- pdflib
- protocolbuffers
- stomp
- strict
- varnish
- xmldiff
- yaf
- yar
- zmq
...
------------------------------------------------------------------------
[2016-10-05 05:32:03] remi@php.net
Description:
------------
Reflection of some extension start reporting <visibility error>
Example:
Class [ <internal:couchbase> class CouchbaseException extends Exception implements Throwable
] {
Method [ <internal:Core, inherits Exception, ctor> <visibility error> method __construct
] {
Reported as https://issues.couchbase.com/browse/PCBC-437
But this class simply extends core Exception.
Test script:
---------------
zend_class_entry cbe;
INIT_CLASS_ENTRY(cbe, "CouchbaseException", NULL);
cb_exception_ce = zap_zend_register_internal_class_ex(&cbe, zend_exception_get_default());
Expected result:
----------------
Method [ <internal:Core, inherits Exception, ctor> public method __construct ] {
Actual result:
--------------
Method [ <internal:Core, inherits Exception, ctor> <visibility error> method __construct
] {
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73249&edit=1