Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113156 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93666 invoked from network); 12 Feb 2021 16:31:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Feb 2021 16:31:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 772651804DC for ; Fri, 12 Feb 2021 08:16:56 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 12 Feb 2021 08:16:55 -0800 (PST) Received: by mail-wr1-f49.google.com with SMTP id u14so8838730wri.3 for ; Fri, 12 Feb 2021 08:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craigfrancis.co.uk; s=default; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2hA0CfaxzRvgkn5nbiF3KlSdRm5h/hHuehJe0VzRO5Q=; b=ZkPlqjEwB84XjI8lHmjSb0nKNtuBbZ51AXp+5vN7kfC/uxQWJHlXAe4tuJKmk8PI44 OSNm7b5AZHxEbSSLrRzpFl1YvwdkATVEgMsQ0NPeeqDEwt2C/hoJ72tLf0aRReU9f5yG eEqDYvInENjE2BLzdp9M/A4lEXyGdDGsMhfVs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2hA0CfaxzRvgkn5nbiF3KlSdRm5h/hHuehJe0VzRO5Q=; b=GGb4O43b87iUVAqYj9xKUBNwweNEocUDTZ2uCKoL8M4BE5l4/vvg+BBWKZB4IS7rFO oWVST1uahpAacel75Rpt9L2Fj3PeEJETpczL8XuHZuQJ49mk9f0fBxs9V79/s1V9ug7i uSyC5+0JXIQmurjml3TrYuCSWUxfTE66GyhLEBJqwDfiUW0J0CyqkRkfsM0Z+fVjQbZP Wk+V7dkUupTmWXCMpZa0BjQrZIleHRIjYPzT5JDPa/TMyskuXStrJ7SFT3OLI4Fc4xjd 13J75fupiN+g+mW92/qUwxiv2RKO2ARHWVEuuftmDRt6uHtJ8f7WBXNKYGy1VxzpbKtA 2KEA== X-Gm-Message-State: AOAM5310yGuNP/IVThC8KbHYeWG7Qpxyp71lt6DmUmJBIyWPtxLEfMnv t/s+1JyBfoa85N7JgBmWaoEIS50bSpV3k7mh X-Google-Smtp-Source: ABdhPJwPXG7VH+B3BYJY90QTyKzxuxlAeJa6SHWxWOogxC+yKXmQSeezM6XXF9dSXe9YfERREKTpSw== X-Received: by 2002:adf:b749:: with SMTP id n9mr4292120wre.267.1613146614786; Fri, 12 Feb 2021 08:16:54 -0800 (PST) Received: from [192.168.1.10] ([92.237.247.170]) by smtp.gmail.com with ESMTPSA id m5sm12288370wmc.25.2021.02.12.08.16.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Feb 2021 08:16:54 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) In-Reply-To: <303C832F-CAE7-44F4-B879-33C054825953@cschneid.com> Date: Fri, 12 Feb 2021 16:16:53 +0000 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <5D0AC588-7BBC-419D-BFEA-06E2E112D3F8@cschneid.com> <303C832F-CAE7-44F4-B879-33C054825953@cschneid.com> To: Christian Schneider X-Mailer: Apple Mail (2.3654.60.0.2.21) Subject: Re: [PHP-DEV] [VOTE]: Change Default mysqli Error Mode From: craig@craigfrancis.co.uk (Craig Francis) On 12 Feb 2021, at 15:17, Christian Schneider = wrote: >=20 > Am 12.02.2021 um 15:30 schrieb Craig Francis = : >> Switching the default from `OFF` to `ERROR` to `ERROR | STRICT` isn't = an obvious step, as that still means you're still having a single step = to change from error reporting to exceptions. >=20 > It is the usual step for (almost) all BC breaking changes in PHP: Warn = first (leaving time to find and adapt code), explode later. > The question is not *if* the change has to be made (or how big it is) = but *when* (and how to find places to be changed). Oh, I completely agree, but Nikita's solution gives a better warning = about the change to using exceptions. As in, it would warn that mysqli_report() needs to be used, to specify = the reporting mode you want, before the default changes. Going via `MYSQLI_REPORT_ERROR` first, well, it doesn't exactly warn = about that (it kinda moves forward a bit, but it doesn't warn that = exceptions will be the new default in 8.2). Craig I know you know this already, I'm only including this as a note to self, = to check how these changes will affect this example code: $db =3D new mysqli('localhost', 'user', 'password', 'db'); $result =3D $db->query('SELECT COUNT(id) FROM invalid_table'); if ($result) { print_r(mysqli_fetch_assoc($result)); } else { print_r('Error'); } Currently this just prints 'Error'. Step 1) Using `MYSQLI_REPORT_ERROR` would add a warning; and then = continue to print 'Error' - it's not really that different, maybe more = error messages are shown or logged, but it still works in the same way. Step 2) Using `MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT` is the = big-ish change, because it will now throw an exception, and the error = (which ideally won't happen in the first place) needs to be handled in a = completely different way. That said, we are talking about what happens when something goes wrong, = and generally speaking, that shouldn't happen on an already running = system... which is why I'm fairly happy with the change that Kamil is = proposing. And I should note, maybe phpMyAdmin is an oddity here, because I will = make typos, and those need to be handled properly, and, erm, phpMyAdmin = doesn't currently use mysqli_report().