function subsite_manager_upgrade_system_handler($event, $type, $entity) { if (get_input("all") == "true") { // find subsites and do stuff $options = array("type" => "site", "subtype" => Subsite::SUBTYPE, "limit" => false); // this could take a while set_time_limit(0); $batch = new ElggBatch("elgg_get_entities", $options); $viewtypes = elgg_get_config("view_types"); $dataroot = elgg_get_config("dataroot"); foreach ($batch as $subsite) { // clear simplecache $dir = $dataroot . "views_simplecache/" . $subsite->getGUID() . "/"; if (file_exists($dir) && ($handle = opendir($dir))) { // remove files while (false !== ($file = readdir($handle))) { if (!is_dir($dir . $file)) { unlink($dir . $file); } } closedir($handle); } if (!empty($viewtypes) && is_array($viewtypes)) { foreach ($viewtypes as $viewtype) { datalist_set("sc_lastupdate_" . $viewtype . "_" . $subsite->getGUID(), 0); datalist_set("sc_lastcached_" . $viewtype . "_" . $subsite->getGUID(), 0); } } // clear system cache $system_cache = new ElggFileCache($dataroot . "system_cache/" . $subsite->getGUID() . "/"); $system_cache->clear(); // cleanup cron cache $cron_cache = $dataroot . "subsite_manager/" . $subsite->getGUID() . "/cron_cache.json"; if (file_exists($cron_cache)) { unlink($cron_cache); } // reset translation editor cache // can't use remove_private_setting because of 'name like' not 'name =' $sql = "DELETE FROM " . get_config("dbprefix") . "private_settings"; $sql .= " WHERE name LIKE 'te_last_update_%'"; $sql .= " AND entity_guid = " . $subsite->getGUID(); delete_data($sql); } } }