php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71047 file_exists seems to be broken in php7
Submitted: 2015-12-07 07:36 UTC Modified: 2017-11-05 04:22 UTC
Votes:17
Avg. Score:4.5 ± 0.6
Reproduced:16 of 17 (94.1%)
Same Version:11 (68.8%)
Same OS:9 (56.2%)
From: mmucklo at gmail dot com Assigned: langemeijer (profile)
Status: No Feedback Package: ssh2 (PECL)
PHP Version: 7.0.0 OS: Ubuntu 15.10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-12-07 07:36 UTC] mmucklo at gmail dot com
Description:
------------
I've tried to use this plugin on PHP7 (compiling from trunk / master).

It compiles and installs.  I can connect fine.

However it seems the file_exists function no longer reports true when using an ssh2_sftp resource handle.



Test script:
---------------
<?php
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at server1.example.com on port 22
if(!($con = ssh2_connect("wherever", 22))){
    echo "fail: unable to establish connection\n";
} else {
    // try to authenticate with username root, password secretpassword
    if(!ssh2_auth_pubkey_file($con, "someuser", "/path/to/.ssh/id_rsa.pub", "/path/to/.ssh/id_rsa")) {
        echo "fail: unable to authenticate\n";
    } else {
        // allright, we're in!
        echo "okay: logged in...\n";

        // execute a command
        if (!($stream = ssh2_exec($con, "ls -al" ))) {
            echo "fail: unable to execute command\n";
        } else {
            echo "what came back from command:\n";
            // collect returning data from command
            stream_set_blocking($stream, true);
            $data = "";
            while ($buf = fread($stream,4096)) {
                $data .= $buf;
            }
            fclose($stream);
            echo $data;
            $sftp = ssh2_sftp($con);
            echo "\n";
            $result = file_exists("ssh2.sftp://$sftp/path/to/somefile");
            echo "\n";
            echo "\n";
            echo "\n";
            echo "file_exists: " . ($result ? "yes" : "no ");
            echo "\n";
        }
    }
}

Expected result:
----------------
....

file_exists: yes

Actual result:
--------------
....

file_exists: no

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-14 08:18 UTC] fashionretailshop01 at gmail dot com
http://www.fakesunglasseswholesale.com/tag.php?Fake_ray_ban_sunglasses/ - fake  ray ban sunglasses
http://www.fakesunglasseswholesale.com/tag.php?Wholesale_ray_ban_sunglasses/ - wholesale ray ban sunglasses
http://www.shoesbootscheap.com/ - shoes
http://www.shoesbootscheap.com/sitemap.php - ShoesBootsCheap Sitemap
 [2016-10-14 08:19 UTC] fashionretailshop01 at gmail dot com
http://www.wholesalecheapjerseysonline.com/Home - Cheap NFL Jerseys
http://www.wholesalecheapjerseysonline.com/ContactUS - Cheap Jerseys Free shipping
http://www.wholesalecheapjerseysonline.com/Custom - Custom NFL Jerseys
http://www.wholesalecheapjerseysonline.com/Discount - Discount NFL Jerseys
 [2016-12-01 14:28 UTC] hranicka at outlook dot com
ssh2_* functions requires SSH2 extension.

For PHP 7, you need PECL SSH2 v1.0.0 or greather.

It was not exist at 2015-12-07 but now is available.

I've found this issue because of I've used PECL extension until today. For PHP 7.0.12 worked fine, but in 7.0.13 is broken. And I've has the same problem.

Solution: Compile latest versions where the bug with newest version is fixed: https://github.com/php/pecl-networking-ssh2/commit/17680cf039f0cfac53b5a2531fdb715b95e9cc42
 [2017-02-06 19:39 UTC] langemeijer@php.net
This might well be fixed with this commit:

https://github.com/php/pecl-networking-ssh2/commit/17680cf039f0cfac53b5a2531fdb715b95e9cc42

Could you try current master and see if the problem is solved?
 [2017-02-06 19:57 UTC] langemeijer@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: langemeijer
 [2017-03-29 02:23 UTC] james at james dot tl
I was having this problem with pecl-ssh2 1.0.0 and php 7.0.15, but I am not having it anymore with pecl-ssh master.
 [2017-10-24 06:49 UTC] kalle@php.net
-Status: Assigned +Status: Feedback
 [2017-11-05 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC