|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-06-16 12:31 UTC] langemeijer@php.net
-Status: Open
+Status: Feedback
-Type: Bug
+Type: Feature/Change Request
[2012-06-16 12:31 UTC] langemeijer@php.net
[2012-06-22 08:48 UTC] langemeijer@php.net
-Status: Feedback
+Status: Wont fix
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 13:00:01 2025 UTC |
Description: ------------ using the ssh2_sftp() function to create an resource to access an sftp server causes an resource error when using the functions in OOP context and storing the resource handle returned by ssh2_sftp() into an LOCAL var. using class global vars, everything works as expected it seems that the resource reference created by ssh2_sftp() getting closed by the garbage collection when leaving the constructor. it might be an core error into the php garbage collector - it should update references which are used by other variables ::installed SSH2 Extension pecl::ssh2 0.11.3 (beta) ::configure options ./configure --with-freetype-dir=/usr/lib --enable-gd-native-ttf --enable-exif --enable-zip --with-bz2 --with-zlib --enable-ftp --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-mysql=/usr/lib --with-mhash --with-pdo-mysql --with-sqlite --with-openssl --enable-mbstring --enable-debug=no --with-config-file-path=/etc/php --enable-calendar ::php ini changes :::added extension=ssh2.so Test script: --------------- // this code causes the failure class failure{ public $this->resourceIdentifier; public function __construct(){ ... // get sftp con $sftpcon = ssh2_sftp($connection); // set resource handle $this->resourceIdentifier = "ssh2.sftp://$sftpcon"; } public function open(){ // causes an error: Warning: opendir(): 8 is not a valid SSH2 SFTP resource $handle = opendir($this->resourceIdentifier); ... } } // this is a workaround by using a class variable class workaround{ public $this->resourceIdentifier; public function __construct(){ ... // get sftp con -> class global var $this->_sftpcon = ssh2_sftp($connection); // set resource handle $this->resourceIdentifier = "ssh2.sftp://$this->_sftpcon"; } public function open(){ // works fine.. $handle = opendir($this->resourceIdentifier); ... } } Expected result: ---------------- $handle should be an valid directory handle! Actual result: -------------- Warning: opendir(): 8 is not a valid SSH2 SFTP resource