apps/files_versions/lib/Expiration.php
/**
	* Read versions_retention_obligation, validate it 
	* and set private members accordingly
	*/
Read versions_retention_obligation, validate it
and set private members accordingly
Read versions_retention_obligation validate it and set private members accordingly
private function parseRetentionObligation(){
		$splitValues = explode(',', $this->retentionObligation);
		if (!isset($splitValues[0])) {
			$minValue = 'auto';
		} else {
			$minValue = trim($splitValues[0]);
		}
		if (!isset($splitValues[1])) {
			$maxValue = 'auto';
		} else {
			$maxValue = trim($splitValues[1]);
		}
		$isValid = true;
		if (!ctype_digit($minValue) && $minValue !== 'auto') {
			$isValid = false;
			\OC::$server->getLogger()->warning(
					$minValue . ' is not a valid value for minimal versions retention obligation. Check versions_retention_obligation in your config.php. Falling back to auto.',
					['app'=>'files_versions']
			);
		}
		if (!ctype_digit($maxValue) && $maxValue !== 'auto') {
			$isValid = false;
			\OC::$server->getLogger()->warning(
					$maxValue . ' is not a valid value for maximal versions retention obligation. Check versions_retention_obligation in your config.php. Falling back to auto.',
					['app'=>'files_versions']
			);
		}
		if (!$isValid){
			$minValue = 'auto';
			$maxValue = 'auto';
		}
		if ($minValue === 'auto' && $maxValue === 'auto') {
			$this->minAge = self::NO_OBLIGATION;
			$this->maxAge = self::NO_OBLIGATION;
			$this->canPurgeToSaveSpace = true;
		} elseif ($minValue !== 'auto' && $maxValue === 'auto') {
			$this->minAge = intval($minValue);
			$this->maxAge = self::NO_OBLIGATION;
			$this->canPurgeToSaveSpace = true;
		} elseif ($minValue === 'auto' && $maxValue !== 'auto') {
			$this->minAge = self::NO_OBLIGATION;
			$this->maxAge = intval($maxValue);
			$this->canPurgeToSaveSpace = true;
		} elseif ($minValue !== 'auto' && $maxValue !== 'auto') {
			if ($maxValue < $minValue) {
				$maxValue = $minValue;
			}
			$this->minAge = intval($minValue);
			$this->maxAge = intval($maxValue);
			$this->canPurgeToSaveSpace = false;
		}
	}
private function parseRetentionObligation ( ) { $ splitValues = explode ( ',' , $ this -> retentionObligation ) ; if ( ! isset ( $ splitValues [ 0 ] ) ) { $ minValue = 'auto' ; } else { $ minValue = trim ( $ splitValues [ 0 ] ) ; } if ( ! isset ( $ splitValues [ 1 ] ) ) { $ maxValue = 'auto' ; } else { $ maxValue = trim ( $ splitValues [ 1 ] ) ; } $ isValid = true ; if ( ! ctype_digit ( $ minValue ) && $ minValue !== 'auto' ) { $ isValid = false ; \ OC :: $ server -> getLogger ( ) -> warning ( $ minValue . ' is not a valid value for minimal versions retention obligation. Check versions_retention_obligation in your config.php. Falling back to auto.' , [ 'app' => 'files_versions' ] ) ; } if ( ! ctype_digit ( $ maxValue ) && $ maxValue !== 'auto' ) { $ isValid = false ; \ OC :: $ server -> getLogger ( ) -> warning ( $ maxValue . ' is not a valid value for maximal versions retention obligation. Check versions_retention_obligation in your config.php. Falling back to auto.' , [ 'app' => 'files_versions' ] ) ; } if ( ! $ isValid ) { $ minValue = 'auto' ; $ maxValue = 'auto' ; } if ( $ minValue === 'auto' && $ maxValue === 'auto' ) { $ this -> minAge = self :: NO_OBLIGATION ; $ this -> maxAge = self :: NO_OBLIGATION ; $ this -> canPurgeToSaveSpace = true ; } elseif ( $ minValue !== 'auto' && $ maxValue === 'auto' ) { $ this -> minAge = intval ( $ minValue ) ; $ this -> maxAge = self :: NO_OBLIGATION ; $ this -> canPurgeToSaveSpace = true ; } elseif ( $ minValue === 'auto' && $ maxValue !== 'auto' ) { $ this -> minAge = self :: NO_OBLIGATION ; $ this -> maxAge = intval ( $ maxValue ) ; $ this -> canPurgeToSaveSpace = true ; } elseif ( $ minValue !== 'auto' && $ maxValue !== 'auto' ) { if ( $ maxValue < $ minValue ) { $ maxValue = $ minValue ; } $ this -> minAge = intval ( $ minValue ) ; $ this -> maxAge = intval ( $ maxValue ) ; $ this -> canPurgeToSaveSpace = false ; } }
Read versions_retention_obligation, validate it
 and set private members accordingly
Read versions_retention_obligation validate it and set private members accordingly
// Validate // Default: Delete anytime if space needed // Keep for X days but delete anytime if space needed // Delete anytime if space needed, Delete all older than max automatically // Delete all older than max OR older than min if space needed // Max < Min as per https://github.com/owncloud/core/issues/16301