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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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: Fri Apr 19 01:01:28 2024 UTC