Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116560 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9837 invoked from network); 2 Dec 2021 16:29:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Dec 2021 16:29:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 93C501804E3 for ; Thu, 2 Dec 2021 09:28:58 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.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 ; Thu, 2 Dec 2021 09:28:58 -0800 (PST) Received: by mail-lf1-f49.google.com with SMTP id b1so139190lfs.13 for ; Thu, 02 Dec 2021 09:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craigfrancis.co.uk; s=default; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FTYlvw48qpPWkoL+b8fSi4HEmYZMavbtVL80sezXGsM=; b=c8N1qvQ3ZnbqTK+sYga83DF5YdJnwh6lQUe6cuhUtUe2mJSKW9rKkoll4aBhXjqE8F Rp7V+Br2mTGg7kBFbBxRP8JVvoMlHYdfXBvGsVmYqLGhZ8Mm/yY0f+QghlO6OKkTQc7I EKWdCyUHH3U61ZeEDxhik1BXRTUHFVQsLnPDE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FTYlvw48qpPWkoL+b8fSi4HEmYZMavbtVL80sezXGsM=; b=rWEhxcTi8lcb1BCyE6jucxGpwk/keQDoUSGrJQg5XQQnpRk6LGL/ka2uI2zpL3K/Wo 3WmPpKblZyP+0u4EX5tDGPt7cKqDM6RmnhvqtxifHCYzDA+FI7Joe8+JGcuHW2KoErLn E3BlBzQFsn2V05bUaLJhTMdsOtVb4629UehLntV10BmeEhAAfg1DR3DS8zXBtuEnZ37y z8ugaquVA4wUNc3n5l1fvUNdM4qs6N7CKHRNNa8YqV50NQ7LxtW89UCp6FX3kdGGQ+AG 72kqLy4HAVvD+smjzkQYNh7UI+QhPqjXI7zhDgCc9H8VqxEGoIh0mrPp7bK5K2e4UWVu CTiQ== X-Gm-Message-State: AOAM5322FsGLGtrWyCQVYWKhv4MhG6c2oHWNrEi3WPVDhkdXZQdc7Reu g7dyOKxI19vDOi50myGzbLYnI+X4wlqX7FV2xAH7OdDxDfQ= X-Google-Smtp-Source: ABdhPJy052OhUoMZkkrpEZnsOpdPdBD3N018jxAXsosXN6Aw/PXjFvqgx/DY9p3uLU0EZ6KGCJHy8XWKnk7hhg93Fzs= X-Received: by 2002:a05:6512:3d94:: with SMTP id k20mr13642423lfv.116.1638466136062; Thu, 02 Dec 2021 09:28:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 2 Dec 2021 17:28:45 +0000 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000045ae905d22d2085" Subject: Re: [PHP-DEV] Allowing NULL for some internal functions From: craig@craigfrancis.co.uk (Craig Francis) --000000000000045ae905d22d2085 Content-Type: text/plain; charset="UTF-8" On Thu, 2 Dec 2021 at 15:19, Sara Golemon wrote: > I'm not hard against this idea. The interpretation of null in these > contexts as being equivalent to empty string isn't unreasonable. I guess > the only objection I could have would be an academic one and I can't really > defend that. So yeah, sure... why not? > Thanks, I'll start by creating a list of functions I think apply (anyone who has any suggestions, please let me know... I'm just going to look at some log files to get started... or try to work out if `Z_PARAM_STRING_OR_NULL` vs `Z_PARAM_STR` / `Z_PARAM_STRING` can give me a list of functions to look though). I would say that such applications should consider unifying their own > types. $a = $_GET['q'] ?? ''; Is there a place in the application where > empty string and null would have been distinct? i.e. Is a search for > nothing different from not searching? > While I think unifying can help in some cases, there is a lot of existing code where developers have used the null coalesce operator to return NULL (either out of habit, or because they need to determine the difference between an empty string vs an unset value)... the main source being the functions frameworks have provided to return GPC values, e.g. - Laravel: $request->input('name'); - Symfony: $request->get('name'); - CakePHP: $this->request->getQuery('name'); - CodeIgniter: $request->getGet('name'); As to the search example... I've seen one project where the search pages would only show the form at first (when null); then, when the user did a search, it showed the search form again, the results table (where an empty string would show all records, useful to see the total number of records), and present additional filtering fields (done like this for performance reasons). That's not to say all of these examples can't be updated to work, but there will be a lot to change... like one project which had simply used `trim()` to remove whitespace from some user inputs, where the fields/values are normally present, but because NULL can happen (even via odd things, like the user being on a slow connection and the form not loading completely), it's now a problem. Thanks again, Craig --000000000000045ae905d22d2085--