Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 757... Línea 757...
757
                // If the store doesn't support searching we can skip it.
757
                // If the store doesn't support searching we can skip it.
758
                if (!($store instanceof cache_is_searchable)) {
758
                if (!($store instanceof cache_is_searchable)) {
759
                    debugging('Cache stores used for session definitions should ideally be searchable.', DEBUG_DEVELOPER);
759
                    debugging('Cache stores used for session definitions should ideally be searchable.', DEBUG_DEVELOPER);
760
                    continue;
760
                    continue;
761
                }
761
                }
762
                // Get all of the keys.
762
                // Get all of the last access keys.
763
                $keys = $store->find_by_prefix(cache_session::KEY_PREFIX);
763
                $keys = $store->find_by_prefix(cache_session::LASTACCESS);
764
                $todelete = array();
764
                $todelete = [];
765
                foreach ($store->get_many($keys) as $key => $value) {
765
                foreach ($store->get_many($keys) as $key => $value) {
-
 
766
                    $expiresvalue = 0;
-
 
767
                    if ($value instanceof cache_ttl_wrapper) {
-
 
768
                        $expiresvalue = $value->data;
766
                    if (strpos($key, cache_session::KEY_PREFIX) !== 0 || !is_array($value) || !isset($value['lastaccess'])) {
769
                    } else if ($value instanceof cache_cached_object) {
-
 
770
                        $expiresvalue = $value->restore_object();
767
                        continue;
771
                    } else {
-
 
772
                        $expiresvalue = $value;
768
                    }
773
                    }
-
 
774
                    $expires = (int) $expiresvalue;
-
 
775
 
769
                    if ((int)$value['lastaccess'] < $purgetime || true) {
776
                    if ($expires > 0 && $expires < $purgetime) {
-
 
777
                        $prefix = substr($key, strlen(cache_session::LASTACCESS));
770
                        $todelete[] = $key;
778
                        $foundbyprefix = $store->find_by_prefix($prefix);
-
 
779
                        $todelete = array_merge($todelete, [$key], $foundbyprefix);
771
                    }
780
                    }
772
                }
781
                }
773
                if (count($todelete)) {
782
                if ($todelete) {
774
                    $outcome = (int)$store->delete_many($todelete);
783
                    $outcome = (int)$store->delete_many($todelete);
775
                    if ($output) {
784
                    if ($output) {
776
                        $strdef = s($definition->get_id());
785
                        $strdef = s($definition->get_id());
777
                        $strstore = s($store->my_name());
786
                        $strstore = s($store->my_name());
778
                        mtrace("- Removed {$outcome} old {$strdef} sessions from the '{$strstore}' cache store.");
787
                        mtrace("- Removed {$outcome} old {$strdef} sessions from the '{$strstore}' cache store.");