diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index 4cfa3570..f66a535a 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -216,7 +216,7 @@ class Net_SCP $sent+= strlen($temp); if (is_callable($callback)) { - $callback($sent); + call_user_func($callback, $sent); } } $this->_close(); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 2fddb68a..d3bc7c60 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2258,7 +2258,7 @@ class Net_SSH2 return false; default: if (is_callable($callback)) { - $callback($temp); + call_user_func($callback, $temp); } else { $output.= $temp; } diff --git a/tests/Net/SSH2FunctionalTest.php b/tests/Net/SSH2FunctionalTest.php index 34a9377b..3078bd40 100644 --- a/tests/Net/SSH2FunctionalTest.php +++ b/tests/Net/SSH2FunctionalTest.php @@ -41,5 +41,21 @@ class Net_SSH2FunctionalTest extends PhpseclibFunctionalTestCase $ssh->login($username, $password), 'SSH2 login using password failed.' ); + + return $ssh; + } + + /** + * @depends testPasswordLogin + * @group bug280 + */ + public function testExecWithMethodCallback($ssh) + { + $callbackObject = $this->getMock('stdClass', array('callbackMethod')); + $callbackObject + ->expects($this->atLeastOnce()) + ->method('callbackMethod') + ->will($this->returnValue(true)); + $ssh->exec('ls', array($callbackObject, 'callbackMethod')); } }