Make WordPress Core

Changeset 50263


Ignore:
Timestamp:
02/09/2021 12:04:01 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Site Health: Clarify the recommendation in file uploads test when post_max_size is defined as 0.

This adds a more descriptive text in scenarios where post_max_size and upload_max_filesize differ, and post_max_size is set to a value of 0.

In some scenarios, PHP may read 0 as a literal zero size, and not as unlimited, which it also means in other scenarios.

See https://www.php.net/manual/en/ini.core.php#ini.post-max-size for details, as PHP 5.3.4 introduced this behavior for literal zero interpretation when the content type of a request is application/x-www-form-urlencoded or is not registered with PHP.

Props Clorith, pixolin, helen, ratneshk.
Fixes #51466.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r50131 r50263  
    21772177                'upload_max_filesize'
    21782178            );
    2179             $result['status']      = 'recommended';
    2180             $result['description'] = sprintf(
    2181                 '<p>%s</p>',
    2182                 sprintf(
    2183                     /* translators: 1: post_max_size, 2: upload_max_filesize */
    2184                     __( 'The setting for %1$s is smaller than %2$s, this could cause some problems when trying to upload files.' ),
    2185                     '<code>post_max_size</code>',
    2186                     '<code>upload_max_filesize</code>'
    2187                 )
    2188             );
     2179            $result['status'] = 'recommended';
     2180
     2181            if ( 0 === wp_convert_hr_to_bytes( $post_max_size ) ) {
     2182                $result['description'] = sprintf(
     2183                    '<p>%s</p>',
     2184                    sprintf(
     2185                        /* translators: 1: post_max_size, 2: upload_max_filesize */
     2186                        __( 'The setting for %1$s is currently configured as 0, this could cause some problems when trying to upload files through plugin or theme features that rely on various upload methods. It is recommended to configure this setting to a fixed value, ideally matching the value of %2$s, as some upload methods read the value 0 as either unlimited, or disabled.' ),
     2187                        '<code>post_max_size</code>',
     2188                        '<code>upload_max_filesize</code>'
     2189                    )
     2190                );
     2191            } else {
     2192                $result['description'] = sprintf(
     2193                    '<p>%s</p>',
     2194                    sprintf(
     2195                        /* translators: 1: post_max_size, 2: upload_max_filesize */
     2196                        __( 'The setting for %1$s is smaller than %2$s, this could cause some problems when trying to upload files.' ),
     2197                        '<code>post_max_size</code>',
     2198                        '<code>upload_max_filesize</code>'
     2199                    )
     2200                );
     2201            }
     2202
    21892203            return $result;
    21902204        }
Note: See TracChangeset for help on using the changeset viewer.