Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128762 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 34EB91A00BC for ; Wed, 1 Oct 2025 18:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759342019; bh=DntfQPBO6AC510k1TJ8syS7xFhZwl2KqZA3vftTDUdo=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=SnGLA9LIAAFCuS3RiqVNenYojXVztLOC0/fzMOi3MYPc9Rkxx0cnJ/BjpERisG4hR QSag8GFFCZVIst6QQWiTSHaNvlxCUgSrdk3IDIsak+qQ6FmkI3YzsNuaEBBrDQLqW+ DA1nn4oVMUZjMwsHfG0FAqQGpqLOu+tgtaaKCFhls57+yONlGr7YjYcBmmwTFncH7E mSJva4FlKv2yCOSc12C2iTe2viUyu7XpCJ7MU3o12AhkMshn0xzHGbsE6p2pxOSOdT noxi+guUG0CnELhuzlLJrcJuIN1KnJkcS/Yl5bEm/V4gMYGgpk9JZxFjaT280eL2r3 KrU/vAIZgF8LA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9593180081 for ; Wed, 1 Oct 2025 18:06:58 +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.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 18:06:58 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id EC0A47A0428; Wed, 1 Oct 2025 14:08:15 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-05.internal (MEProxy); Wed, 01 Oct 2025 14:08:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1759342095; x= 1759428495; bh=DntfQPBO6AC510k1TJ8syS7xFhZwl2KqZA3vftTDUdo=; b=F EOyjV7oEw8+xKx/U9cCt+DYNCg+UV3dEL8PvjQ9Wk75i/2p6O7lgmPeE1mqac64/ yJTyWyXqQNEqS0yMIMOPSLjTBNblsh2UhnZ+6wEieJa75N+uKx6G1hcCvflakHra pls+U2/xrr/EndVsN0IHEw7VWwN4xAXGFebmqEsRpVypDgEhGcBFqsLboqbfL5Zm xCKbra4U4x1rezlgF/OUtCBmmUP216UAJIH/YDVxguh+qZzvwTo5xtJBeapVPi88 V6YSw11BWhweCi+loNhta9k6k6qDJGCBMjTTAb4lDB+vSjo9OJ5MEp2cn2WjRiva TXTkWif0kieFpHPQ23Row== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1759342095; x=1759428495; bh=DntfQPBO6AC510k1TJ8syS7xFhZwl2KqZA3 vftTDUdo=; b=dHJhGvKgZuT/vf8B9AdT4pcKJ5v3F/m8GR6rQoakqfP75+hWF0j ARdzUIKgzit6N/nTRhzU5NaaSoQO7dxfahkAqHM2xeWCYBZLvHquEOGGctaIDqNF AcWxsbwLI2ezMTbo6hlfQpQoxyOk9nR2AAU/G6DsnotC7uSf4uNHu3TtRjRYo/tU I/PjOvLdDLoT5VHHXHGtFQukjsfnER+oymxq6uBJ9A6UMn/O63o/PmxHhVblqpoo B1OLLGptpkbc7HTn+onKppG8nH88lZeMHYxY0j97dIsbEGVpFYccqSol76KDp8GF zKpy0/8iZfAh6bf02P6q0vNCw3b1hR6LOHw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdekfeekvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvvefkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgr nhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvg hrnhepieeuteehvddvfeejhffgieehleehhedthfefkeejffelgfevvdekudetjeejtddt necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosg essghothhtlhgvugdrtghouggvshdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhht phhouhhtpdhrtghpthhtoheptghlrghuuggvrdhprggthhgvsehgmhgrihhlrdgtohhmpd hrtghpthhtoheprhhpohhskhihsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthgvkhhi vghlrgdvgeeisehgmhgrihhlrdgtohhmpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 55A9B182007A; Wed, 1 Oct 2025 14:08:15 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: A8cBfPafW5yB Date: Wed, 01 Oct 2025 20:07:55 +0200 To: "Kamil Tekiela" , "Robert Wolf" Cc: "Claude Pache" , "PHP internals" Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] [Discuss] Add PDO disconnect() and isConnected() Content-Type: multipart/alternative; boundary=be16756372bd4010a764f57589cc91bc From: rob@bottled.codes ("Rob Landers") --be16756372bd4010a764f57589cc91bc Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Oct 1, 2025, at 15:55, Kamil Tekiela wrote: > On Wed, 1 Oct 2025 at 14:45, Robert Wolf wrote: > > > > > I generally agree that there's little value to a disconnect() acti= on; unset($pdo) is already sufficient. > > > > See the point again about persistent connections. The user has no me= ans to disconnect in that case. > > > > > I recommend to use a name that deters users from using it in norma= l operations, e.g. pdo->debug_manual_disconnect(). > > > > Considering the above as well, a possible stance to take could be to= introduce it as persistent_disconnect(). We could then decide whether i= t should function on "regular" connections as well. >=20 > This sounds better, but I would argue that if it's a PERSISTENT > connection, then it should be impossible for the user to close it. The > idea is that the connection should remain open after being established > and should only close when the server restarts. What scenario would > necessitate the user to close a connection that should never close? Off the top of my head (and it depends on the actual database on the oth= er end of the pipe): 1. After grant/role revocation, password rotation, or a switch from rea= d/write replicas. Existing sessions usually keep there their privileges = in a lot of databases. So, you could argue this is a security issue for = long-lived applications. 2. Perhaps you want to free any and all advisory locks? 3. Sometimes the handle is alive, but the network connection is dead (t= his is argued elsewhere though). 4. I've had some fun bugs in the past with prepared statements crashing= a db server (putting it in maintenance mode and serving no traffic) bei= ng shared between requests. If I could have slapped a "just close it unt= il we figure out what is going on" statement in there, I would have. 5. Replica promotion, primary failover, blue/green cutovers, firewall c= hanges ... all these need new connections. Right now, you have to jump through a number of hoops to do these types = of operations. =E2=80=94 Rob --be16756372bd4010a764f57589cc91bc Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Oct = 1, 2025, at 15:55, Kamil Tekiela wrote:
On Wed, 1 Oct 2025 at 14:45, Robert Wolf <rposky@gmail.com> wrote:
<= div>>
> > I generally agree that there's little value= to a disconnect() action; unset($pdo) is already sufficient.
= >
> See the point again about persistent connections. Th= e user has no means to disconnect in that case.
>
> > I recommend to use a name that deters users from using it in = normal operations, e.g. pdo->debug_manual_disconnect().
>= ;
> Considering the above as well, a possible stance to tak= e could be to introduce it as persistent_disconnect(). We could then dec= ide whether it should function on "regular" connections as well.

This sounds better, but I would argue that if it's a P= ERSISTENT
connection, then it should be impossible for the use= r to close it. The
idea is that the connection should remain o= pen after being established
and should only close when the ser= ver restarts. What scenario would
necessitate the user to clos= e a connection that should never close?

Off the top of my head (and it depends on the actual database on t= he other end of the pipe):
  1. After grant/role revocation,= password rotation, or a switch from read/write replicas. Existing sessi= ons usually keep there their privileges in a lot of databases. So, you c= ould argue this is a security issue for long-lived applications.
  2. Perhaps you want to free any and all advisory locks?
  3. Sometimes = the handle is alive, but the network connection is dead (this is argued = elsewhere though).
  4. I've had some fun bugs in the past with prepa= red statements crashing a db server (putting it in maintenance mode and = serving no traffic) being shared between requests. If I could have slapp= ed a "just close it until we figure out what is going on" statement in t= here, I would have.
  5. Replica promotion, primary failover, blue/gr= een cutovers, firewall changes ... all these need new connections.
  6. <= /ol>
    Right now, you have to jump through a number of hoops to do the= se types of operations.

    =E2= =80=94 Rob
    --be16756372bd4010a764f57589cc91bc--