|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66466 Derived classes get wong context
Submitted: 2014-01-11 16:59 UTC Modified: 2014-01-11 18:49 UTC
From: post-christian at freenet dot de Assigned: krakjoe (profile)
Status: Closed Package: pthreads (PECL)
PHP Version: 5.5.8 OS: openSUSE 11.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
8 + 46 = ?
Subscribe to this entry?

 [2014-01-11 16:59 UTC] post-christian at freenet dot de
Derived classes get wrong context inside the thread. Please see example below.

Test script:
abstract class Animal
	protected abstract function getName();
	public function printName()
		echo __CLASS__ . " -> " . $this->getName() . "\n";

class Bird extends Animal
	protected function getName()
		return "Bird";

$bird = new Bird();

class MyThread extends Thread
	private $animal;
	public function __construct( $animal )
		$this->animal = $animal;
	public function run()

$thread = new MyThread( $bird );

Expected result:
The protected function of the derived class should be called like outside the thread.

Actual result:
Normal PHP:
Animal -> Bird

Inside Thread:
PHP Fatal error:  Call to protected method Bird::getName() from context 'Animal' in thread_test.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-11 18:49 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2014-01-11 18:49 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

This is fixed in git master.

A release is coming, soon ...
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 12:01:23 2020 UTC