php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42610 $this can be reassigned using references
Submitted: 2007-09-10 12:00 UTC Modified: 2007-09-11 15:54 UTC
From: php dot 20 dot zsh at spamgourmet dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.2.4 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php dot 20 dot zsh at spamgourmet dot com
New email:
PHP Version: OS:

 

 [2007-09-10 12:00 UTC] php dot 20 dot zsh at spamgourmet dot com
Description:
------------
$this can be changed when you use an automagic function.

Reproduce code:
---------------
<?php
function change(&$var, $value) {
	$var = $value;
	return true;
}
class foo {
	function __construct() {
		change($this, false);
		var_dump($this);
	}
}
$foo = new foo;
?>


Expected result:
----------------
HTTP/1.1 500 Internal Server Error

Fatal error: Cannot re-assign $this in %s on line %d


Actual result:
--------------
HTTP/1.1 200 OK

bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-11 15:54 UTC] iliaa@php.net
It is nearly impossible to track back references to this within the code 
to detect attempts to circumvent normal overwrite limits.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 13:01:30 2024 UTC