Created
October 16, 2019 20:35
-
-
Save matdave/e8bed147b9d22c23c85c0bddf3528d40 to your computer and use it in GitHub Desktop.
Delay Clearing Cache on Resource Save
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
switch ($modx->event->name) { | |
case 'OnBeforeDocFormSave': | |
$now = mktime(); | |
$lastcache = $modx->cacheManager->get('delaycache'); | |
if(!empty($lastcache) && ($now - $lastcache) < 300){ | |
$_POST['syncsite'] = 0; | |
} | |
return; | |
break; | |
case 'OnDocFormSave': | |
$now = mktime(); | |
$lastcache = $modx->cacheManager->get('delaycache'); | |
if(empty($lastcache)){ | |
$modx->cacheManager->set('delaycache', $now, 300); | |
} | |
return; | |
break; | |
default: | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment