Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128759 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 AA8BF1A00BC for ; Wed, 1 Oct 2025 16:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759334483; bh=GG4sPj8CXb7oKQTPsHWRucw9R1H47p7TvAeV86HIDcE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CXROSQHf9PUs6oV5PDf4q0rns42yhwKcWDuq8L+/VCJdZFF+idofDYYD161MY2Ezu 5he9LFVeFFU4I/mOI3UKjiDKAibFlN+Vdm/il+qUqH1Tgy0v1K/+TMrlWwLeUjFU1T asfq9xRRyTlNqMyl2+s1p7Kg7Im2iwFqxMCxa9Reg5FO7TwL56UGEaDH3ZHAb3R8d6 D1HbbPXTgiVwGp2978Qbp6swyjT7jH7x5HNxukS7bfJNl1PllwgntRte4N14JEwbek vYWyYdkx2eMSmUMFpK85mv2wZVPF00lhV1oQgASWzUEB9Ul/eTI3pY54oNIbEVMfOE 5/PRJkG3OygVA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E16B1801D7 for ; Wed, 1 Oct 2025 16:01:19 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,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-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 16:01:19 +0000 (UTC) Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-6366d48d8ccso124913a12.0 for ; Wed, 01 Oct 2025 09:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759334557; x=1759939357; 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=GG4sPj8CXb7oKQTPsHWRucw9R1H47p7TvAeV86HIDcE=; b=DJq6jTNYVLTp0206qS/wzkz8SeHwlUaaBogvGeimA/n979Z4KiJaH73/1UZd2cXlI2 M2xUwrPxbTzbh3nRWaphonZ1VwSmMTT8SMpwresLm9lwioZly2ywV7ijTodxxOtqZ7Bo mFkKkV7OdWVbbdA0ZNkFj9Ctkrmh4Sa7TRm+EaFKA9HE8YEKq3Vu67J3FbivFKTDge+f mXgB2LTJvweJ0snpwN/ZF4/1AgpSMjZ49KNv71wGhT2ZxKf+6Bm5nKFwd7m5BeW/QNyF 30Zuf2OJ4G46LE3bLU5yWEoBUQGbXIfAMg+4xoYY8EAK3Yzb76Of5PCqlwhXDugR3Omd daTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759334557; x=1759939357; 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=GG4sPj8CXb7oKQTPsHWRucw9R1H47p7TvAeV86HIDcE=; b=FiK9JQce3yj1VTPZrwzBXmTVA9CYtSt61GLX+ZED61LZj9iF/qoT5IAKd0Z4JFbbrs ojodbLjD7f2zuNkY+HH39XDv6If9o6J435pTMj0QxLAtsXMNgr1pbtc7vxphcOZUq4j1 TIa6z4B94GL0cn5ObTIBp1UyTAbpblmkJA+0/Mk/jgD23lNqOQENN7E6WtMDgOQBEXJ7 zmf6GshEzfZpr3QSc8JVXTuCvVhJ0MLbBPT3z2VKBxAJxpYRsfhCQ/Gk+JOxMX8IN4b3 spxdli9h1TgETfTlyWPT+GmAel+rnBPZByDCVvRGd6lwZUmFYSltDFbyFdfu4sbakMj4 V+pw== X-Gm-Message-State: AOJu0YzT1a7r07RA/gRWGiZRWV1a/dXV1Y7n3DFEYcYTZL5kWvJ/D6gQ ju1ZfYuiuD4B0ncEYIUbpH0T7dsXwgMFnR/dWOY73V2WXBzkQkwueKvXZgvWYicMtIIouGP6E0U YbOVgzXhMS+uRWJzzOJkmhIYHfxt0GH5/pUNhcII= X-Gm-Gg: ASbGncvhtmpTc6sekJ68z9Kquf3xBFcedlOyvcspoVfS6ofJgUWMWDXAQseV6zLFpH+ 3E+WJsNHLY95msFWJL9RgTzsgSLBeTh5adrnNHJ5iI4KunXrMklMjlVVO0k4UZRZKFWM1MK2PKv mdubvPmXXxmhPYyKJlECfy/nM5VBijW5yBJtgUkowDsV+ce7wEiqFVptvxN1EXPhi1y3mZpbaaj pY86fYUUpL4I82O1l7BJZ+rHuyhwA== X-Google-Smtp-Source: AGHT+IGeu/rUrogieusV7cI0A8bFEREGRswmEP3q0upz9Xyk4x0DtZj6S6892EyH9JA8La9T9q/EXpcZCdW1iimu8/Q= X-Received: by 2002:a05:6402:1145:b0:62f:b6bd:eff7 with SMTP id 4fb4d7f45d1cf-63678ca5e1fmr3336852a12.38.1759334556487; Wed, 01 Oct 2025 09:02:36 -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: Date: Wed, 1 Oct 2025 12:02:24 -0400 X-Gm-Features: AS18NWDSQ9ZjjeVriViV9Igc3WMdrjYI_nrc7rCz0XorjUMv0vZVsp59txvbPCU Message-ID: Subject: Re: [PHP-DEV] [Discuss] Add PDO disconnect() and isConnected() To: Kamil Tekiela Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000047d62f06401aff72" From: rposky@gmail.com (Robert Wolf) --00000000000047d62f06401aff72 Content-Type: text/plain; charset="UTF-8" > 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. I think this reads too much into the "persistent" language, which does not derive from PDO but rather PHP resources. PDO cannot guarantee a connection always be open, nor should it be defining what connection viability is - it's an application-level concern, and an overreach. > What scenario would necessitate the user to close a connection that should never close? I provided some examples in the thread as to why a user could want to close a connection, maybe unconvincingly. > 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. Thinking along these lines, what could meet this objective and satisfy some of the concerns outlined here, would be an interface to declare the persistent connection as defunct, such that upon subsequent PDO creation, a new connection will be formed, and the former will be closed. This is distinct from a disconnect or reconnect procedure, and similar to failing a "liveness" check upon persistent PDO creation. Users could then effectively replace their persistent PDO in the same manner they would do so for a "regular" PDO. Difficulties in unset($pdo) to force a disconnect are still present though perhaps can be mitigated with the refactoring efforts outlined in "Future Scope" to break apart the mutual PDO and PDO statement references. --00000000000047d62f06401aff72 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> This sounds better, but I would argue that if it'= s a PERSISTENT
> connection, then it should be impossible for the use= r to close it. The
> idea is that the connection should remain open a= fter being established
> and should only close when the server restar= ts.

I think this reads too much into the "persistent" lang= uage, which does not derive from PDO but rather PHP resources. PDO cannot g= uarantee a connection always be open, nor should it be defining what connec= tion viability is - it's an application-level concern, and an overreach= .

> What scenario would necessitate the user to close a connectio= n that should never close?

I provided some examples in the thread as= to why a user could want to close a connection, maybe unconvincingly.
<= br>> What I am trying to say is that there should be no need to ever clo= se
> a persistent connection. If it ever gets messed up, it should be=
> restored to the working state rather than being closed.

Thi= nking along these lines, what could meet this objective and satisfy some of= the concerns outlined here, would be an interface to declare the persisten= t connection as defunct, such that upon subsequent PDO creation, a new conn= ection will be formed, and the former will be closed. This is distinct from= a disconnect or reconnect procedure, and similar to failing a "livene= ss" check upon persistent PDO creation. Users could then effectively r= eplace their persistent PDO in the same manner they would do so for a "= ;regular" PDO.

Difficulties in unset($pdo) to force a disconnec= t are still present though perhaps can be mitigated with the refactoring ef= forts outlined in "Future Scope" to break apart the mutual PDO an= d PDO statement references.
--00000000000047d62f06401aff72--