Skip to content

FOGSSH: null the link on disconnect, and close only a live session - #1998

Merged
mastacontrola merged 1 commit into
working-1.6from
fix/fogssh-reconnect-after-disconnect
Oct 28, 2026
Merged

mastacontrola merged 1 commit into
working-1.6from
fix/fogssh-reconnect-after-disconnect

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Fixes #1997.

Problem

  • Reusing the shared FOGSSH after disconnect() warns Undefined array key "_link" at FOGSSH.php:133.
  • disconnect() without a live session throws a TypeError from ssh2_disconnect().

Change

  • disconnect() sets $_link and $_sftp to null and no longer calls unset() on them.
  • It calls ssh2_disconnect() only when the link is a resource.

Verification

  • New tests/fogssh-reuse-after-disconnect.test.php runs the real class and calls disconnect() twice.
    • On the base it fails with the TypeError.
    • With only the unset() put back, it fails with the _link warning.
    • On this branch both checks pass.
  • fogssh-size and fogssh-delete-terminates still pass.
  • Both phpstan passes are clean.

An rc-1.6.0 port follows.

🤖 Generated with Claude Code

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>
@fog-workflows
fog-workflows Bot enabled auto-merge October 28, 2026 13:45
@mastacontrola
mastacontrola added this pull request to the merge queue Oct 28, 2026
Merged via the queue into working-1.6 with commit ba45f7e Oct 28, 2026
11 checks passed
@mastacontrola
mastacontrola deleted the fix/fogssh-reconnect-after-disconnect branch October 28, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant