1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +02:00

Update to allow for Page objects to load pages (children, parent, etc.) that don't get cached when their load option specified cache=false. Also makes the 'parent' page lazy loading for Page objects, so that it doesn't load the parent Page until a $page->parent() call is requested. Updates for @apeisa / Avoine request.

This commit is contained in:
Ryan Cramer
2016-12-14 11:02:32 -05:00
parent 3821dc2be3
commit 2b9a7adbcb
10 changed files with 343 additions and 181 deletions

View File

@@ -1,5 +1,19 @@
<?php namespace ProcessWire;
/** @var Config $config */
/** @var Pages $pages */
/** @var Sanitizer $sanitizer */
/** @var Session $session */
/** @var WireInput $input */
/** @var Fuel $fuel */
/** @var Modules $modules */
/** @var WireDatabasePDO $database */
/** @var DatabaseMysqli $db */
/** @var User $user */
/** @var Page $page */
/** @var WireCache $cache */
/** @var WireClassLoader $classLoader */
if(!defined("PROCESSWIRE")) die();
$debugToolsLabel = __('Debug Mode Tools', __FILE__);
@@ -19,6 +33,7 @@ $debugToolsLabel = __('Debug Mode Tools', __FILE__);
<?php
$o = '';
$oc = 0;
$oct = $pages->loader()->getTotalPagesLoaded();
foreach($pages->getCache() as $p) {
$oc++;
$parts = explode('/', trim($p->path, '/'));
@@ -30,12 +45,13 @@ $debugToolsLabel = __('Debug Mode Tools', __FILE__);
"<td>$p->id</td>" .
"<td>$path</td>" .
"<td>" . wireClassName($p) . "</td>" .
"<td>$p->_debug_loader</td>" .
($config->debug === Config::debugVerbose ? "<td>" . $sanitizer->entities($p->_debug_loader) . "</td>" : "") .
"</tr>";
}
$occ = $oct > $oc ? "$oc/$oct" : $oc;
?>
<div class="container">
<h3><a href='#'><?php echo __('Pages Loaded', __FILE__) . " <span class='ui-priority-secondary'>($oc)</span>"; ?></a></h3>
<h3><a href='#'><?php echo __('Pages Loaded', __FILE__) . " <span class='ui-priority-secondary'>($occ)</span>"; ?></a></h3>
<div>
<table>
<thead>
@@ -43,11 +59,15 @@ $debugToolsLabel = __('Debug Mode Tools', __FILE__);
<th>ID</th>
<th>Path</th>
<th>Type</th>
<th>Loader</th>
<?php if($config->debug === Config::debugVerbose) echo "<th>Loader</th>"; ?>
</tr>
</thead>
<tbody>
<?php echo $o; unset($o, $oc); ?>
<?php
echo $o;
if($oct > $oc) echo "<p>A total of <strong>$oct</strong> pages were loaded, <strong>$oc</strong> of which are in memory:</p>";
unset($o, $oc, $oct, $occ);
?>
</tbody>
</table>
</div>