# PHP 5.3.1 reference parameter regression

- Thread: https://externals.io/message/46389
- Original archive: https://news-web.php.net/php.internals/46389
- Started by Tim Starling on 2009-12-09T22:43:11+00:00
- Messages: 11
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #46389 — Tim Starling — 2009-12-09T22:43:11+00:00

URL: https://externals.io/message/46389#46389

Since 5.3.1 it's impossible to have a reference parameter passed to a
__call() function. This is apparently due to the bugfix committed by
stas as shown here:

<http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/Zend/zend_execute_API.c?r1=287466&r2=287465&pathrev=287466>

Test cases can be found here: <http://bugs.php.net/bug.php?id=50394>. It
seems to me that a special case would be needed to restore the behaviour
seen in PHP 5.3.0.

This change causes bugs in MediaWiki, where an attempt by a proxy object
to pass a call through to a function that accepts reference parameters
will always fail, due to the exacerbating change made to reference
argument semantics in PHP 5.3.0.

If we want MediaWiki to support PHP 5.3.1, we'll have to do some major
changes, like abandoning __call entirely, or rewriting all the relevant
interfaces to not use reference parameters. I'm not too keen about doing
this without getting some indication from the PHP dev team as to whether
this change is permanent or whether it will be fixed in an imminent PHP
5.3.2 release. If it's going to be fixed soon, we can just blacklist PHP
5.3.1 in our installer.

I've tried emailing stas but I didn't get a reply.

-- Tim Starling

---

## #46392 — Stanislav Malyshev — 2009-12-09T23:12:32+00:00

URL: https://externals.io/message/46389#46392 · In reply to: #46389

Hi!

> Test cases can be found here:<http://bugs.php.net/bug.php?id=50394>. It
> seems to me that a special case would be needed to restore the behaviour
> seen in PHP 5.3.0.

I'll check it out, seems to be valid use case, we should find some 
solution for that.

> I've tried emailing stas but I didn't get a reply.

Sorry, I didn't see any email from you.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #46403 — Keisial — 2009-12-12T17:08:44+00:00

URL: https://externals.io/message/46389#46403 · In reply to: #46389

Tim Starling wrote:
> Since 5.3.1 it's impossible to have a reference parameter passed to a
> __call() function. 

> This change causes bugs in MediaWiki, where an attempt by a proxy object
> to pass a call through to a function that accepts reference parameters
> will always fail, due to the exacerbating change made to reference
> argument semantics in PHP 5.3.0.
>
> If we want MediaWiki to support PHP 5.3.1, we'll have to do some major
> changes, like abandoning __call entirely, or rewriting all the relevant
> interfaces to not use reference parameters. I'm not too keen about doing
> this without getting some indication from the PHP dev team as to whether
> this change is permanent or whether it will be fixed in an imminent PHP
> 5.3.2 release. If it's going to be fixed soon, we can just blacklist PHP
> 5.3.1 in our installer.
>
> I've tried emailing stas but I didn't get a reply.
>
> -- Tim Starling
It's also broken in PHP 5.2.11 and 5.2.12 RC4. Works in 5.2.10 and
5.2.11RC1.
Whatever change broke it, was backported and got into 5.2.11RC2.

PS: Did mediawiki opt-out for release candidate announcements? It didn't
receive emails about RCs
for 5.2.12 branch.

---

## #46453 — Tim Starling — 2009-12-17T02:46:47+00:00

URL: https://externals.io/message/46389#46453 · In reply to: #46392

Stanislav Malyshev wrote:
> Hi!
>
> > […]
>
> I'll check it out, seems to be valid use case, we should find some
> solution for that.
>

There seems to have been no progress on this. Is there anything I can do
to help?

-- Tim Starling

---

## #46454 — Stefan Esser — 2009-12-17T06:37:43+00:00

URL: https://externals.io/message/46389#46454 · In reply to: #46453

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Tim,
> > […]
just for the record: why does MediaWiki rely on a feature
"Call-Time-Pass-By-Reference" that is deprecated since PHP 4.0.0 <-
Yes exactly 4.0.0

What happened between 5.3.0 and 5.3.1 is that stas killed that feature
for internal functions to work around a big security problem in the
design of the Zend Engine.
Considering the fact that the feature is DEPRECATED since 4.0.0 it
would even be okay to kill it for all functions.

Stefan Esser

- --
SektionEins GmbH                      stefan.esser@sektioneins.de
Eupener Straße 150                           Tel: 0221 / 29282931
50933 Köln                                   Fax: 0221 / 29282935
http://SektionEins.de/                     

Firmensitz          Eupener Straße 150       50933 Köln
Registergericht     Amtsgericht Köln         HRB 59950
Geschäftsführer     Johann-Peter Hartmann
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksp0bcACgkQSuF5XhWr2nhdwQCggzxIUz8N7ZlRLWWklTqJBnPO
BSoAniiOqs2JXyh4iNwRtp9FiGRIy/16
=q9+2
-----END PGP SIGNATURE

---

## #46455 — Ferenc Kovacs — 2009-12-17T08:44:29+00:00

URL: https://externals.io/message/46389#46455 · In reply to: #46454

I agree that this feature should be avoided in userland, but I think
that it would be terrible, if this "bugfix" would stay this way,
because this breaks backward compatibility -without notification- with
a minor version update both in 5.3 and 5.2 branch.

Tyrael

On Thu, Dec 17, 2009 at 7:37 AM, Stefan Esser
<stefan.esser@sektioneins.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello Tim,
> > […]
> just for the record: why does MediaWiki rely on a feature
> "Call-Time-Pass-By-Reference" that is deprecated since PHP 4.0.0 <-
> Yes exactly 4.0.0
>
> What happened between 5.3.0 and 5.3.1 is that stas killed that feature
> for internal functions to work around a big security problem in the
> design of the Zend Engine.
> Considering the fact that the feature is DEPRECATED since 4.0.0 it
> would even be okay to kill it for all functions.
>
> Stefan Esser
>
> - --
> SektionEins GmbH                      stefan.esser@sektioneins.de
> Eupener Straße 150                           Tel: 0221 / 29282931
> 50933 Köln                                   Fax: 0221 / 29282935
> http://SektionEins.de/
>
> Firmensitz          Eupener Straße 150       50933 Köln
> Registergericht     Amtsgericht Köln         HRB 59950
> Geschäftsführer     Johann-Peter Hartmann
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAksp0bcACgkQSuF5XhWr2nhdwQCggzxIUz8N7ZlRLWWklTqJBnPO
> BSoAniiOqs2JXyh4iNwRtp9FiGRIy/16
> =q9+2
> -----END PGP SIGNATURE

---

## #46456 — Stefan Esser — 2009-12-17T08:54:49+00:00

URL: https://externals.io/message/46389#46456 · In reply to: #46455

Hi,

> because this breaks backward compatibility -without notification- with
> a minor version update both in 5.3 and 5.2 branch.
well actually the bug was that `call_user_func_array()` did not trigger
the "what you do is deprecated warning".
Calling the function directly would have resulted in a "this is
deprecated" warning anyway.

Stefan Esser

-- 
SektionEins GmbH                      stefan.esser@sektioneins.de
Eupener Straße 150                           Tel: 0221 / 29282931
50933 Köln                                   Fax: 0221 / 29282935
http://SektionEins.de/                       

Firmensitz          Eupener Straße 150       50933 Köln
Registergericht     Amtsgericht Köln         HRB 59950
Geschäftsführer     Johann-Peter Hartmann

---

## #46457 — Ferenc Kovacs — 2009-12-17T09:00:32+00:00

URL: https://externals.io/message/46389#46457 · In reply to: #46456

As tsarling stated in the bugreport:
http://bugs.php.net/bug.php?id=50394

"I'm not complaining about the
warning, which I just added to demonstrate the problem. I'm not
complaining about the new behaviour of zend_call_function() as of PHP
5.3.0, I'm complaining about the lost reference in __call in PHP 5.3.1."

Tyrael

On Thu, Dec 17, 2009 at 9:54 AM, Stefan Esser
<stefan.esser@sektioneins.de> wrote:
> Hi,
>
> > […]
> well actually the bug was that `call_user_func_array()` did not trigger
> the "what you do is deprecated warning".
> Calling the function directly would have resulted in a "this is
> deprecated" warning anyway.
>
> Stefan Esser
>
> --
> SektionEins GmbH                      stefan.esser@sektioneins.de
> Eupener Straße 150                           Tel: 0221 / 29282931
> 50933 Köln                                   Fax: 0221 / 29282935
> http://SektionEins.de/
>
> Firmensitz          Eupener Straße 150       50933 Köln
> Registergericht     Amtsgericht Köln         HRB 59950
> Geschäftsführer     Johann-Peter Hartmann

---

## #46462 — Stanislav Malyshev — 2009-12-17T19:28:29+00:00

URL: https://externals.io/message/46389#46462 · In reply to: #46453

Hi!

> > […]
>
> There seems to have been no progress on this. Is there anything I can do
> to help?

Tim, could you check if the attached patch solves your problem?

-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #46465 — Tim Starling — 2009-12-18T01:50:26+00:00

URL: https://externals.io/message/46389#46465 · In reply to: #46462

Stanislav Malyshev wrote:
>
> Tim, could you check if the attached patch solves your problem?
>

Yes, it works for me, in both the isolated test case and the original MW
bug.

MW's parser test suite shows 4 failing tests in 5.3.1, all fixed with
this patch and no new regressions.


Stefan Esser wrote:
> just for the record: why does MediaWiki rely on a feature
> "Call-Time-Pass-By-Reference" that is deprecated since PHP 4.0.0 <-
> Yes exactly 4.0.0

The underlying functions are declared with reference parameters, and we
call them with `call_user_func_array()` so explicitly creating references
on the caller side is required. If you have a better method for calling
arbitrary functions that accept reference parameters, let me know.

Lots of MediaWiki functions are declared with reference parameters for
objects when they aren't really needed, because that was the required
convention in PHP 4, and we never made a concerted effort to remove all
the ampersands. It's too late to fix it now, in many cases, because many
extensions declare hook functions with reference parameters, following
the caller and documentation that dates from PHP 4, and so we have to
keep passing them reference parameters to avoid breaking them in PHP
5.3+. So the window for easy migration to value parameters has closed.

-- Tim Starling

---

## #46466 — Stanislav Malyshev — 2009-12-18T02:01:07+00:00

URL: https://externals.io/message/46389#46466 · In reply to: #46465

Hi!

> Yes, it works for me, in both the isolated test case and the original MW
> bug.
>
> MW's parser test suite shows 4 failing tests in 5.3.1, all fixed with
> this patch and no new regressions.

Great, will commit the patch tomorrow then to all branches.

> The underlying functions are declared with reference parameters, and we
> call them with `call_user_func_array()` so explicitly creating references
> on the caller side is required. If you have a better method for calling
> arbitrary functions that accept reference parameters, let me know.

 `call_user_func_array()` wasn't a problem in this particular case, __call 
was (see the bug), because internally it's user function call simulated 
by internal function call, so it needed some special check.

> Lots of MediaWiki functions are declared with reference parameters for
> objects when they aren't really needed, because that was the required

Entirely unrelated to this bug, passing objects by-ref is not the best 
idea in PHP 5.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com
