Skip to content

FOGSSH::disconnect(): 'Undefined array key "_link"' warning on reuse, TypeError without a live session #1997

Closed

Description

@mastacontrola

Problem

  • Services write PHP Warning: Undefined array key "_link" in src/Net/FOGSSH.php on line 133 to servicemaster.log. This box logged 285 of them.
  • FOGSSH::disconnect() without a live SSH session throws TypeError: ssh2_disconnect(): Argument #1 ($session) must be of type resource. That happens after a failed connect() (link is false) or after an earlier disconnect() (link is null).

Cause

  • disconnect() calls unset($this->_link) and unset($this->_sftp). PHP routes the next read of an unset declared property to __get(). __get() reads $this->data['_link'], which does not exist. FOGSSH is one shared instance, so the next connect() or disconnect() warns.
  • disconnect() passes the link to ssh2_disconnect() without checking it. On PHP 8, a non-resource argument is a TypeError, and @ does not suppress it.

Fix

  • Set both properties to null. Do not unset() them.
  • Call ssh2_disconnect() only when the link is a resource.

Affects working-1.6 and rc-1.6.0, including RC18.

Activity

  1. mastacontrola commented on Oct 28, 2026

    @mastacontrola
    MemberAuthor

    Fixed on working-1.6 in #1998 and on rc-1.6.0 in #1999. RC18 still has the bug. The fix ships in the next RC.

  2. mastacontrola commented on Oct 28, 2026

    @mastacontrola
    MemberAuthor

    The fix is in 1.6.0-RC-19: https://github.com/FOGProject/fogproject/releases/tag/1.6.0-RC-19 . Update with bin/updatefog.sh --channel rc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions