Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111189 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98882 invoked from network); 26 Jul 2020 05:27:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Jul 2020 05:27:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A5FD818050B for ; Sat, 25 Jul 2020 21:22:43 -0700 (PDT) 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,FREEMAIL_FROM,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-Virus: No X-Envelope-From: Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 ; Sat, 25 Jul 2020 21:22:39 -0700 (PDT) Received: by mail-oi1-f169.google.com with SMTP id u24so1696914oiv.7 for ; Sat, 25 Jul 2020 21:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=FYT5km41+y2MLDmTlgm5m2AVLSrgh6WZTOnQazwRoII=; b=P/VUcqETRXRSPIxi0xcgAN0aq2dBK7rHkS0JdahdtTkD9Y8gvMfbA73DqxM/7b9V0F IM920QeU0MIrPLMgViBIOYMYqVu+ZjBVN4F3Fega/JzU0sBojoddr5Jd1jSCgvyaZwS1 Bjv9AcHkLranJwtjmI6uvkKTlGGUnGYsQvOvF4KHgpWbuAKROyDGaFHR4SALCMDq7Vlx jEw6+rMPQIMECGK4ZBIDSH8AQA6tm1KsP2JO+uSFNAp94KoOBhhsjFsQYInTROXvjzvj C5Gjukz0zirwEIjytrVnbwa1ekay2PlcAS4JENRf2a9/vDeaUGK35xMaycwvS6vNh95d RLLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=FYT5km41+y2MLDmTlgm5m2AVLSrgh6WZTOnQazwRoII=; b=cg81FBph9SXdO63xYjUHh6YISvLg7hHKcwc5ApHMR7EJqPhmQtMQT6mUpzmjSTmyMA u2QabmsH7lDd+qkDjhwZNU0/DHjAApSChsFrZBqynfhKrV/cYm1sVEzbBjG+So30RuhK UgT0BtNkRXlCwPYU2J7Xo+hMFfiveA66zbC3HAL/XMjmMUTgoZP75Gb0u8ofBMH0Kj0+ SmyPRKCfzjgnATvRi/0GO7SlZgWhxa4G9ZgKCswRL8qGBzjE/MVDT4aZXh/5Bw6xJmdN qn5AE6LvWERwAalD40rVPM+tXIcnHhQDOJn1El1qy/VWwuhjVnyNLhPt5hKQa2/hJQ/B Qu/A== X-Gm-Message-State: AOAM532t5LR+DuYLSJ6PWyqOes3O7gthbP7J49IZhDPc5Q3eGJ/Lwop+ pYrKJEAM3bdUWBc/qjTD/rSho3YLLUWF4NwcCu5Th+mQ X-Google-Smtp-Source: ABdhPJy1mpyqFFI/nI5JO7s9/Rt1qDTT+mTDmj3BSk27GGNOrOEOuPEbN1vCExBCordVW2jzkwvQK7nA61VXeVtk2tM= X-Received: by 2002:aca:1e04:: with SMTP id m4mr13251560oic.76.1595737358857; Sat, 25 Jul 2020 21:22:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 25 Jul 2020 23:22:27 -0500 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000006dfd0805ab508e59" Subject: Re: [PHP-DEV] Proposal: php.ini environment variable fallback value From: tendoaki@gmail.com (Michael Morris) --0000000000006dfd0805ab508e59 Content-Type: text/plain; charset="UTF-8" PHP's ini values are already a bit of a mess. You have a global php.ini file, and then most PHP ini directives can be set per directory using the .htaccess file. About a third can be set at runtime. This makes tracking down where a setting came from a bit of a headache unless care is taken. This proposal promises to make the situation even more complicated. Also, what would this solve that using .htaccess files to override the default values not solve aside from the rare settings that cannot be set per directory? On Fri, Jul 24, 2020 at 3:54 PM Derek Bonner wrote: > Currently an environment variable can be specified in the php.ini file. > This is useful if you want tune one or two settings in your runtime > environment. Where this runs into issues is if you want to do something > similar to Juan Terminio[1][2]. > > I'm proposing a change the php.ini parser that would allow for an extended > syntax for environment variables in the php.ini. In this syntax when > checking for an environment variable if it is empty the fallback value > would be used instead. The original environment variable syntax would > remain valid as well. > > Possible syntax options. I currently do not have a very deep understanding > of the current .ini parser so this may make invalid assumptions. > > * memory_limit = ${PHP_MEMORY_LIMIT:-"default value"} > * memory_limit = ${PHP_MEMORY_LIMIT::"default value"} > * memory_limit = ${PHP_MEMORY_LIMIT:="default value"} > * memory_limit = ${PHP_MEMORY_LIMIT=="default value"} > > * Potential issue: Adopting a bash-ism > > This type of environment fallback is common in bash. If adopted it could > lead users to think other bash features are also available. To dissuade > this I would suggest that the fallback value syntax not appear in any of > the default php.ini files. Users must read the documentation and decide if > it works for them and add it in their php.ini file. > > Changes needed in the code > > Digging through the code I find that two sections would need to be changed, > both in Zend/zend_ini_parser.y. I hope to be able to write this code myself > but would gladly accept some guidance. > > 1. cfg_var_ref: Currently TC_DOLLAR_CURLY TC_VARNAME '} would need to be > changed to something like TC_DOLLAR_CURLY TC_VARNAME ':-' TC_FALLBACK '}' > 2. zend_ini_get_var: I imagine this would require adding a third parameter > to the function signature that would be used in the event of a null value > when checking the environment. > > [1] > https://jtreminio.com/blog/php-modules-toggled-via-environment-variables/ > [2] > > https://jtreminio.com/blog/docker-php/php-fpm-configuration-via-environment-variables/ > > I look forward to your feedback. > > Derek > --0000000000006dfd0805ab508e59--