Repository navigation
FOGSSH: null the link on disconnect, and close only a live session - #1998
Merged
Merged
Conversation
disconnect() unset() the declared $_link and $_sftp. PHP routes the next read of an unset declared property to __get(), which looks it up in $data, so every reuse of the shared instance warned 'Undefined array key "_link"' at FOGSSH.php:133. Set them to null instead. disconnect() also handed a false or null link to ssh2_disconnect(). On PHP 8 that is a TypeError, which @ does not suppress, so disconnect() after a failed connect() or a second disconnect() was fatal. Close only a resource. tests/fogssh-reuse-after-disconnect.test.php drives disconnect() twice on the real class. Each check fails on its own defect: the TypeError on the base, and the warning with only the unset() put back. Fixes #1997 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1997.
Problem
FOGSSHafterdisconnect()warnsUndefined array key "_link"atFOGSSH.php:133.disconnect()without a live session throws aTypeErrorfromssh2_disconnect().Change
disconnect()sets$_linkand$_sftptonulland no longer callsunset()on them.ssh2_disconnect()only when the link is a resource.Verification
tests/fogssh-reuse-after-disconnect.test.phpruns the real class and callsdisconnect()twice.TypeError.unset()put back, it fails with the_linkwarning.fogssh-sizeandfogssh-delete-terminatesstill pass.An
rc-1.6.0port follows.🤖 Generated with Claude Code