Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107360 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33178 invoked from network); 1 Oct 2019 23:58:49 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 1 Oct 2019 23:58:49 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 2200C2D1F9D for ; Tue, 1 Oct 2019 14:39:33 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: ** X-Spam-Status: No, score=3.0 required=5.0 tests=BAYES_00, CK_HELO_DYNAMIC_SPLIT_IP,HELO_DYNAMIC_SPLIT_IP,RDNS_DYNAMIC, SPF_HELO_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS16276 149.56.0.0/16 X-Spam-Virus: No Received: from 28.ip-149-56-142.net (28.ip-149-56-142.net [149.56.142.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Tue, 1 Oct 2019 14:39:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: thruska@cubiclesoft.com) with ESMTPSA id 78B053E8C6 To: Rasmus Lerdorf , Benjamin Morel Cc: PHP Internals References: Message-ID: <866ac36c-ddb5-80db-1ac2-56ff3f49cd81@cubiclesoft.com> Date: Tue, 1 Oct 2019 14:39:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Envelope-From: Subject: Re: [PHP-DEV] Error when POST / upload limits are exceeded From: thruska@cubiclesoft.com (Thomas Hruska) On 10/1/2019 1:26 PM, Rasmus Lerdorf wrote: > On Tue, Oct 1, 2019 at 8:25 AM Benjamin Morel > wrote: > >>> Perhaps a more generic $_SERVER['PHP_REQUEST_STATUS'] or something along >> those lines where you'd put the error message from >> https://www.php.net/manual/en/features.file-upload.errors.php as well. >> And add new states for these exceeded limits that aren't caught there. It >> would be nice if you just needed a single check instead of having to look >> for multiple things. >> >> Those are per-file error codes, that belong in each $_FILES entry, while >> the errors I'm talking about affect the whole request, so I'm afraid you >> cannot put these errors in the same place, nor can you extend the existing >> error codes, as they do not have the same scope! >> > > I know they are per-file errors. I wrote that code :) > > But you could still have a global status that specifies whether an error > occurred or not. Then you can go look for which file it occurred on in the > $_FILES array. The idea is to have a single check that tells you if > everything was fine on the request. > > -Rasmus I agree this is needed. The problem I've encountered is that if there are any more variables after a limit is hit, then some of the submitted vars don't exist in the superglobals. Specifically, the variables before the limit do exist while the ones after don't. There's a LOT of userland code that *assumes* all expected non-file POST vars exist and then DO things with the non-existent variables in this scenario. Is it poorly written, lazy userland code? Sure, but it's certainly unexpected. In the past, I've seen all kinds of weird behaviors happen due to missing vars in userland ranging from looping, WSODs, and altering PHP sessions. The data gets submitted to the server but the PHP input parser ignores it once a limit is reached. One of the first things I do on a new system is to bump up the default limits considerably to avoid hitting the limits. The ability to globally detect that processing of input variables was early-terminated by the parser would allow userland startup sequences to detect the problem globally and cleanly terminate the request BEFORE the core application logic is encountered. This shouldn't just be for files, it should be for any time the parser early-terminates input processing but then proceeds to start executing userland code as if nothing is wrong. -- Thomas Hruska CubicleSoft President I've got great, time saving software that you will find useful. http://cubiclesoft.com/ And once you find my software useful: http://cubiclesoft.com/donate/