Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128758 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 3611B1A00BC for ; Wed, 1 Oct 2025 15:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759333761; bh=M+XpPey65J1xk8LijPmWiwCzU8biuQvWSwX4Em6YVcw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OPZ2xmkVRfCybe2m6CweaZCJXGYqAkADUBpNxmYCq3tOJxKoAwgl8zPoNOXLix5jr Pfw69C3NAkZ2V1qMpNKY31FtlPDRPFWy4hF34n87Gq53cFksdTm7TeGBum9u/2b38u r9Rnumu4B+4kajToWJBxItWYa1A+P0/TmqV11AsuftaEcOJ+3E+FjQ7om1nziz5LvT lXVBb6bgK1/Kd8PHRKnawxTRDIXXoB07nUbCMtRwztpD/nN8SUJoKAVB+jiq7Gj8SP mRDWbaA+lbsBMk8M/S8jA8tF0fsJ40/v+CXTeKZixJ6yBHaOzQHxD7ttuoUI9VOaj0 tQd96Z+Tt38fA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0E8EB18007E for ; Wed, 1 Oct 2025 15:49:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 1 Oct 2025 15:49:17 +0000 (UTC) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-36c0b946cb5so59994531fa.3 for ; Wed, 01 Oct 2025 08:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759333835; x=1759938635; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=M+XpPey65J1xk8LijPmWiwCzU8biuQvWSwX4Em6YVcw=; b=EJwtO8kTb9Ec6F6GRo9lKa7AlWVI4SUxPV+5qmcvV9KGrzGxVNgjKBdhccj1bEFLW3 u7nSx6FN/9g5hKsxXnHMhhEpTlklng4Z5zf8K9BynodYHYPb1AWcIuPvYmuWTYmgg73J 5xWtTaA8n+Opy5sb+UxRcMcS9VBN/MYrydO0YEly4yb8Tnz8K+eEciOaKZvew44UfZnO uieLM65Tjrgywp78wOUH3PsmLTtAnOgkaUq5HyTwsSP0c24mmuT1PQu9Nchg3qZEEtZg DibXC/zDYBQzy85JlRHxmeMsKimCZ4EXGDn0cdVkPX92UmwcDY/87ktXo6JnjdZr9ydO +5JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759333835; x=1759938635; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M+XpPey65J1xk8LijPmWiwCzU8biuQvWSwX4Em6YVcw=; b=g5EaAmWgZubhaIM5nUTfD2Gm0+mpcaO94FH5ipLE6ZOoP3odQ+JX9jnPec3Nq3cUGy ihxfvMtDBWcy6vHeMEiFY8xCX83fkWtK6hSA9hQMN1esKku4YcHVD5SI8do6h8qrdIiZ n+ajPI3OH6+fWoyJkuvS1RDmt05nBPnU1eMksV/oKC/SNSJnAD9WhTnVgu5ipK5Z3D1N yGUHw1qfRsjCZ2ewBlxE8itzIJsILL2pqRAhFaFy0raw9MO3R6aqWV9frBd0AaJ+3c20 FBOHgbUXafxFcKXKY6Yk/kcRNhp6Prjjx3q5y2lWAMirAzQFvnh/PbQDRBkAkfJQh1ny A5gQ== X-Forwarded-Encrypted: i=1; AJvYcCUtj578gSaBTcC7r91Wtgxl+ARK4HBGWrHRHPjYooS5BtE8/xZzm7/HIUcxZNc6qiW+iG866e1AJKI=@lists.php.net X-Gm-Message-State: AOJu0YyJCyBD0jo6xjV/bM+ujJEPwTxmvhug5TqW9k59R1QtlwYxszWa BcG7FlWBqwj6Q/BmNEkgyyufF9iBTxeWvQ4VaDzc/n3usfB6ArtriIaI2volxQi2dZD8No+8gst uQcXN1I3rhSBnh7iv0thu2IKJmho2Lng= X-Gm-Gg: ASbGncsB3lOzH6egxtLR8uTyKozlMjYm5qba+dmDdv5A+CEUGOZJuzMRoKVQcAj3xDI R5wuwjv/VO2/77na0mIl7Pk1z4dFh4Xp/quHkjIaP25n/mThEwPnGq9wtvwwi3hZt9Cnu2HIBdy Bqeow7fhPAJPK7XM87V+dZbor5b/JwqXMBPuHcXEAhyW2XiTWATYco1EmfdgeQ53UePkUqWRQxq n9kCOP4FB0EFLZ4yHkrsc2tr3Gi/5w= X-Google-Smtp-Source: AGHT+IEjq7LdozoO5Wp3O6bVPnX6l1Cz1855Qukvfg9dfftxp8nFM1u83F+mu+BWglG17nSz5kWLds634FKv08N2nuw= X-Received: by 2002:a05:651c:1547:b0:36e:4481:9eaf with SMTP id 38308e7fff4ca-373a73b4868mr9675891fa.15.1759333834841; Wed, 01 Oct 2025 08:50:34 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <7b1f853f-1bb0-4d84-975b-164a71e092cc@allenjb.me.uk> In-Reply-To: <7b1f853f-1bb0-4d84-975b-164a71e092cc@allenjb.me.uk> Date: Wed, 1 Oct 2025 16:50:24 +0100 X-Gm-Features: AS18NWAv0wW8T067fSKx6Mjb2JOLfPpYU541Jcps7NHN1vlurQVxIocdyxT6U1c Message-ID: Subject: Re: [PHP-DEV] [Discuss] Add PDO disconnect() and isConnected() To: AllenJB Cc: Robert Wolf , Claude Pache , PHP internals Content-Type: text/plain; charset="UTF-8" From: tekiela246@gmail.com (Kamil Tekiela) On Wed, 1 Oct 2025 at 15:45, AllenJB wrote: > As I understand it, at least in the case of MySQL, the state of > persistent connections is not managed by MySQL, but by the client (PHP). > This means that it's (at least theoretically) possible for a connection > to end up in an undesirable state, in which case there should be a way > to close it so it's not reused. You are correct, and I can see this as a justification for adding a dangerous function; however, the circumstances you describe are very vague. What is this undesirable state, and how would someone be able to determine in code that the connection is in an undesirable state? More importantly, why would they need to close the connection when it happens instead of restoring it to a working state? The most common way I can imagine is if you acquire a lock on a table and then PHP script gets aborted due to an unhandled exception from something else (e.g. HTTP network request which failed due to outside reasons). But in that case, the persistent connection should be cleaned up by the custom error handler on the script's termination. Currently, there is no way to do that other than manually trying to release all locks/transactions/tables. A disconnect method would solve that, but so would a method to trigger COM_CHANGE_USER, which is still a worse solution than a simple function to reset the connection. If borked persistent connections are a real problem that needs solving, then I support adding a function to PDO to reset persistent connections. In MySQL, it would trigger COM_RESET_CONNECTION, and in other drivers an analogous solution would need to be found. This avoids the problem of having the PDO instance in a borked state. What I am trying to say is that there should be no need to ever close a persistent connection. If it ever gets messed up, it should be restored to the working state rather than being closed.