Make WordPress Core

Changeset 56370


Ignore:
Timestamp:
08/07/2023 07:31:13 PM (16 months ago)
Author:
flixos90
Message:

Options, Meta APIs: Expand $autoload parameter documentation.

This changeset expands documentation of the $autoload parameter of the add_option() and update_option() functions, in order to provide more context on what autoloading is and which considerations should go into the decision whether to autoload an option.

Excessive autoloading of options can lead to severe performance problems on some sites, and lack of documentation is a partial cause for the issue.

Props rajinsharwar.
Fixes #58963.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r56333 r56370  
    429429 * @param string|bool $autoload Optional. Whether to load the option when WordPress starts up. For existing options,
    430430 *                              `$autoload` can only be updated using `update_option()` if `$value` is also changed.
    431  *                              Accepts 'yes'|true to enable or 'no'|false to disable. For non-existent options,
    432  *                              the default value is 'yes'. Default null.
     431 *                              Accepts 'yes'|true to enable or 'no'|false to disable.
     432 *                              Autoloading too many options can lead to performance problems, especially if the
     433 *                              options are not frequently used. For options which are accessed across several places
     434 *                              in the frontend, it is recommended to autoload them, by using 'yes'|true.
     435 *                              For options which are accessed only on few specific URLs, it is recommended
     436 *                              to not autoload them, by using 'no'|false. For non-existent options, the default value
     437 *                              is 'yes'. Default null.
    433438 * @return bool True if the value was updated, false otherwise.
    434439 */
     
    616621 * @param string      $deprecated Optional. Description. Not used anymore.
    617622 * @param string|bool $autoload   Optional. Whether to load the option when WordPress starts up.
    618  *                                Default is enabled. Accepts 'no' to disable for legacy reasons.
     623 *                                Accepts 'yes'|true to enable or 'no'|false to disable.
     624 *                                Autoloading too many options can lead to performance problems, especially if the
     625 *                                options are not frequently used. For options which are accessed across several places
     626 *                                in the frontend, it is recommended to autoload them, by using 'yes'|true.
     627 *                                For options which are accessed only on few specific URLs, it is recommended
     628 *                                to not autoload them, by using 'no'|false. Default 'yes'.
    619629 * @return bool True if the option was added, false otherwise.
    620630 */
Note: See TracChangeset for help on using the changeset viewer.