Skip to content

__destruct() access class properties already destroyed #56

@fiSCIENCES

Description

@fiSCIENCES

Hello Romain,

Luckily, this was working for years.
I changed the if() line a little bit to make it as a patch. But I'm sure you can work it out more robustly.
See below.

Thank you.

    /**
     * @throws FileMakerException
     */
    public function __destruct()
    {
        // Logout dataAPI session if the token cannot be saved to be reused in next query (cli mode or no active session)
        // If a session handler is set, we assume the token has been saved (session may have been closed before destruct was called)
// Patch by MPLT 07-03-2025 because properties are already destroyed!
        if((!session_id() || php_sapi_name() === 'cli') && $this->token && $this->useDataApi && !$this->sessionHandler) {
//        if ($this->token && $this->useDataApi && !$this->sessionHandler && !session_id() || php_sapi_name() === 'cli') {
            $this->dataApiLogout();
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions