php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50638 User Stream $context is Not Populated
Submitted: 2010-01-02 23:10 UTC Modified: 2010-01-04 14:54 UTC
From: cullin dot wible at cullinwible dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.1 OS: CentOS 5.4 x86_64
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cullin dot wible at cullinwible dot com
New email:
PHP Version: OS:

 

 [2010-01-02 23:10 UTC] cullin dot wible at cullinwible dot com
Description:
------------
When creating a user stream using the streamWrapper format, the $context variable is NOT set during the stream_open method call.


Reproduce code:
---------------
class TestStream {
	public $context;
	
	public function __construct() {
		/* do nothing */
	}
		
	public function stream_open($path, $mode, $options, &$opened_path) {
		echo "Open Context: ";
		var_dump($context);		
		
		return(true);
	}
}

stream_wrapper_register('test, 'TestStream', 0);

$options = array(
	'test' => array(
		'option1' => 'option1_value'));
	
$myContext = stream_context_create($options);

fopen('test://test', 'r', false, $myContext);


Expected result:
----------------
the $this->context variable should equal $myContext.

Actual result:
--------------
The $this->context variable is NULL.

Please NOTE the following:

1. The $context is set on an fread, however, it should be set during the fopen call.

2. If you look at the PHP-c-code, it appears that the userstream.c class is attempting to set the $context property just after class construction and prior to calling stream_open. Also, after modifying the C-code it appears that the context in the C-code is defined and calls the Zend add_property_resource function. However, there is clearly a bug somewhere as the property is still NULL.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-03 00:12 UTC] bjori@php.net
bjori@jessica:~$ php foobar.php 
Open Context: resource(5) of type (stream-context)

Fix your parse error and change $context to $this->context
 [2010-01-04 14:54 UTC] cullin dot wible at cullinwible dot com
You are correct. This is not a bug. Thanks for the follow-up.
 [2011-07-27 00:14 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=313756
Log: - add binary suport, FR #50638, as defined in RFC https://wiki.php.net/rfc/binnotation4ints, patch by Jonah Harris
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 11:01:34 2025 UTC