|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50526 stat() needs Context parameter
Submitted: 2009-12-18 21:36 UTC Modified: 2016-07-31 04:25 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: codeslinger at compsalot dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 5.2.12 OS: any
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
33 + 49 = ?
Subscribe to this entry?

 [2009-12-18 21:36 UTC] codeslinger at compsalot dot com
Feature Request:

the stream wrapper functions are *totally awesome*  :-)  !!!

but the "stat" family of functions is limited by the lack of a "context" param.

For instance I need to be able to provide a user name and password for a particular connection.  for opendir mkdir fopen etc.  I am able to pass a context with that info and everything works.  But then when I try to do a "stat" or "fstat"  it fails because there is no way to pass the $context.

Thank you for making PHP such a fantastic programming language!

Reproduce code:
From manual page:

Actual result:
also see related 
Bug #42965  	copy() should support context parameters for URLs


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-21 22:37 UTC]
For stream_wrappers, by calling fopen() with a context parameter and then fstat() on the opened stream, you should be able to pass a context (the ->context attribute in the wrapper's instance).
 [2010-08-16 23:58 UTC]
-Status: Open +Status: Assigned -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: kalle
 [2013-10-04 13:00 UTC] matti dot jarvinen at nitroid dot fi
And it seems that StreamWrapper stat doesn't use default context either.

$options = array('testfs'=> array(

$defaultContext = stream_context_get_options(stream_context_get_default());

$newContext = array_replace_recursive($defaultContext, $options);


stream_wrapper_register('testfs', 'Test_StreamWrapper');

class Test_StreamWrapper
  public $context;

  public function url_stat()
    if($this->context === null)
       print 'No Context!';   
    return false;



No Context!
 [2016-07-31 04:25 UTC]
-Status: Assigned +Status: Open -Assigned To: kalle +Assigned To:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jun 21 19:01:26 2021 UTC