Skip to content

Commit

Permalink
Upgrade core to have lazy-loading option for Fields, Templates, Field…
Browse files Browse the repository at this point in the history
…groups. Collaboration with @thetuningspoon for boot performance improvement on installations with large quantities of fields/templates/fieldgroups. Lazy loading option is enabled by default but can be disabled by setting $config->useLazyLoading=false; in your /site/config.php file.

Co-authored-by: thetuningspoon <mspooner@hey.com>
  • Loading branch information
ryancramerdesign and thetuningspoon committed Feb 4, 2022
1 parent 9a1cf64 commit a5c70a4
Show file tree
Hide file tree
Showing 16 changed files with 1,229 additions and 326 deletions.
24 changes: 22 additions & 2 deletions wire/config.php
Expand Up @@ -12,7 +12,7 @@
* You may also make up your own configuration options by assigning them
* in /site/config.php
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
*
Expand Down Expand Up @@ -76,12 +76,15 @@
/**
* Tools, and their order, to show in debug mode (admin)
*
* Options include: pages, api, session, modules, hooks, database, db, timers, user, input, cache, autoload
* Options include: pages, api, session, modules, hooks, database, db, timers, user, input, cache, autoload, lazyload
*
* Note: when used, lazyload option should be placed first beause its results can be affected by later debug tools.
*
* @var array
*
*/
$config->debugTools = array(
//'lazyload',
'pages',
'api',
'session',
Expand Down Expand Up @@ -194,6 +197,23 @@
*/
$config->usePageClasses = false;

/**
* Use lazy loading of fields (plus templates and fieldgroups) for faster boot times?
*
* This delays loading of fields, templates and fieldgroups until they are requested.
* This can improve performance on systems with hundreds of fields or templates, as
* individual fields, templates/fieldgroups won't get constructed until they are needed.
*
* Specify `true` to use lazy loading for all types, `false` to disable all lazy loading,
* or specify array with one or more of the following for lazy loading only certain types:
* `[ 'fields', 'templates', 'fieldgroups' ]`
*
* @var bool|array
* @since 3.0.194
*
*/
$config->useLazyLoading = true;

/**
* Disable all HTTPS requirements?
*
Expand Down
1 change: 1 addition & 0 deletions wire/core/Config.php
Expand Up @@ -148,6 +148,7 @@
* @property bool $usePoweredBy Use the x-powered-by header? Set to false to disable. #pw-group-system
* @property bool $useFunctionsAPI Allow most API variables to be accessed as functions? (see /wire/core/FunctionsAPI.php) #pw-group-system
* @property bool $useMarkupRegions Enable support for front-end markup regions? #pw-group-system
* @property bool|array $useLazyLoading Delay loading of fields (and templates/fieldgroups) till requested? Can improve performance on systems with lots of fields or templates. #pw-group-system @since 3.0.193
* @property bool $usePageClasses Use custom Page classes in `/site/classes/[TemplateName]Page.php`? #pw-group-system @since 3.0.152
* @property int $lazyPageChunkSize Chunk size for for $pages->findMany() calls. #pw-group-system
*
Expand Down

1 comment on commit a5c70a4

@adrianbj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really excited by this. Thank you both!

Please sign in to comment.