Clean all values of the current namespace
@return int Number of deleted fields
171346
public function cleanAll(): int
    {
        $cpt = 0;
        $keys = $this->getRedis()->keys($this->namespace . ':*');
        if ($keys) {
            foreach ($keys as $key) {
                $this->getRedis()->del($key);
                $cpt++;
            }
        }
        return $cpt;
    }
593267
public function cleanup()
    {
        $hosts   = $this->redis->smembers(self::redisKey());
        $workers = $this->redis->smembers(Worker::redisKey());
        $cleaned = array('hosts' => array(), 'workers' => array());

        foreach ($hosts as $hostname) {
            $host = new static($hostname);

            if (!$this->redis->exists(self::redisKey($host))) {
                $this->redis->srem(self::redisKey(), (string)$host);
                $cleaned['hosts'][] = (string)$host;
            } else {
                $host_workers = $this->redis->smembers(self::redisKey($host));

                foreach ($host_workers as $host_worker) {
                    if (!in_array($host_worker, $workers)) {
                        $cleaned['workers'][] = $host_worker;

                        $this->redis->srem(self::redisKey($host), $host_worker);
                    }
                }
            }
        }

        return $cleaned;
    }
562947
public function generateRemovedFields()
    {
        foreach ($this->keptModelKeys as $modelName) {
            $oldFieldKeys = $this->oldFieldKeys[$modelName];
            $newFieldKeys = $this->newFieldKeys[$modelName];

            $remFields = array_diff($oldFieldKeys, $newFieldKeys);

            foreach ($remFields as $remField) {
                $this->findRemovedFields($modelName, $remField);
            }
        }
    }
168391
public function isActuallyDirty()
    {
        $values = $this->owner->getDirtyAttributes();
        if (isset($this->fields['modifiedField'])) {
            unset($values[$this->fields['modifiedField']]);
        }
        if (isset($this->fields['modifiedByField'])) {
            unset($values[$this->fields['modifiedByField']]);
        }
        if (isset($this->fields['createdField'])) {
            unset($values[$this->fields['createdField']]);
        }
        if (isset($this->fields['createdByField'])) {
            unset($values[$this->fields['createdByField']]);
        }

        return !empty($values);
    }
864591
protected function clearValues()
    {
        $nPath = $this->getNamespacePath();
        $dp = @opendir($nPath);
        while ($file = @readdir($dp)) {
            if ('.' === $file || '..' === $file) {
                continue;
            }
            $cur_file = "{$nPath}/{$file}";
            if (is_file($cur_file)) {
                @unlink($cur_file);
            }
        }
        @closedir($dp);
        @rmdir($nPath);
        return true;
    }
775059
protected function getNewDeletedAtField()
    {
        $field = current(FieldTransformer::fromString('deleted_at'));
        $field->isDate = true;
        $field->dataType = 'datetime';
        $field->dateFormat = Config::getDateTimeFormat();

        return $field;
    }
467274
private function usesSoftDeletes()
    {
        return (
            (isset($this->forceDeleting) && ! $this->forceDeleting) ||
            (isset($this->softDelete) && ! $this->softDelete)
        );
    }
1282425
public function removeThisAlias()
    {
        if ($this->isExternalLink()) {
            $this->delete();
        } elseif ($this->isAliasPage()) {
            $cIDRedir = $this->getCollectionPointerID();
            $db = Database::connection();

            PageStatistics::decrementParents($this->getCollectionPointerOriginalID());

            $args = [$this->getCollectionPointerOriginalID()];
            $q = 'delete from Pages where cID = ?';
            $db->executeQuery($q, $args);

            $q = 'delete from Collections where cID = ?';
            $db->executeQuery($q, $args);

            $q = 'delete from CollectionVersions where cID = ?';
            $db->executeQuery($q, $args);

            $q = 'delete from PagePaths where cID = ?';
            $db->executeQuery($q, $args);

            return $cIDRedir;
        }
    }
1207105
protected static function cleanFields($fields)
    {
        $new = [];
        $fieldList = explode(',', $fields);
        foreach ($fieldList as $f) {
            if (static::ID_FIELD !== trim(strtolower($f))) {
                $new[] = $f;
            }
        }

        return implode(',', $new);
    }
70361
public static function cleanup() {
        global $CFG, $DB;

        // Delete logs older than the retention period.
        $params = [
            'retentionperiod' => time() - $CFG->task_logretention,
        ];
        $logids = $DB->get_fieldset_select('task_log', 'id', 'timestart < :retentionperiod', $params);
        self::delete_task_logs($logids);

        // Delete logs to retain a minimum number of logs.
        $sql = "SELECT classname FROM {task_log} GROUP BY classname HAVING COUNT(classname) > :retaincount";
        $params = [
            'retaincount' => $CFG->task_logretainruns,
        ];
        $classes = $DB->get_fieldset_sql($sql, $params);

        foreach ($classes as $classname) {
            $notinsql = "";
            $params = [
                'classname' => $classname,
            ];

            $retaincount = (int) $CFG->task_logretainruns;
            if ($retaincount) {
                $keeplogs = $DB->get_records('task_log', [
                        'classname' => $classname,
                    ], 'timestart DESC', 'id', 0, $retaincount);

                if ($keeplogs) {
                    list($notinsql, $params) = $DB->get_in_or_equal(array_keys($keeplogs), SQL_PARAMS_NAMED, 'p', false);
                    $params['classname'] = $classname;
                    $notinsql = " AND id {$notinsql}";
                }
            }

            $logids = $DB->get_fieldset_select('task_log', 'id', "classname = :classname {$notinsql}", $params);
            self::delete_task_logs($logids);
        }
    }
859502
protected function cleanUpValue( $value ) {
		$cleanValue = [];
		if ( !is_array( $value ) ) {
			return $cleanValue;
		}
		foreach ( $value as $singleValue ) {
			$singleValue = parent::cleanUpValue( $singleValue );
			// Remove options that we don't have here
			if ( !isset( $this->fields[ $singleValue ] ) ) {
				continue;
			}
			$cleanValue[] = $singleValue;
		}
		return $cleanValue;
	}
1138657
public function clean()
    {
        $this->removedTags = array();
        $elem = $this->getRealElement();
        if (is_null($elem)) {
            return array();
        }
        $this->cleanNodes($elem, true);
        return $this->removedTags;
    }
1123377
protected function processDeletes() {
    $deletedOids = [];
    $deleteOids = array_keys($this->deletedObjects);
    while (sizeof($deleteOids) > 0) {
      $key = array_shift($deleteOids);
      if (self::$isDebugEnabled) {
        self::$logger->debug("Process delete on object: ".$key);
      }
      $object = $this->deletedObjects[$key];
      $object->getMapper()->delete($object);
      unset($this->deletedObjects[$key]);
      $deletedOids[] = $key;
      $deleteOids = array_keys($this->deletedObjects);
    }
    return $deletedOids;
  }
799684
public function removeAll()
    {
        $classMetaData = $this->entityManager->getClassMetadata($this->getEntityClassName());
        $connection = $this->entityManager->getConnection();
        $databasePlatform = $connection->getDatabasePlatform();
        $truncateTableQuery = $databasePlatform->getTruncateTableSql($classMetaData->getTableName());
        $connection->executeUpdate($truncateTableQuery);
    }
79818
public function clearValues()
    {
        foreach ($this->fields as $name => $field) {
            $field->setValue(null);
        }

        return $this;
    }
621862
protected function removeReservedFields()
    {
        if (!$this->isMode(static::MODE_CREATE)) {
            return;
        }

        $reservedColumns = [
            $this->form->model()->getKeyName(),
            $this->form->model()->getCreatedAtColumn(),
            $this->form->model()->getUpdatedAtColumn(),
        ];

        $this->fields = $this->fields()->reject(function (Field $field) use ($reservedColumns) {
            return in_array($field->column(), $reservedColumns, true);
        });
    }
496445
public static function clearDeletedInstances() {
		if( !isset(static::$instances[static::getClass()]) ) {
			return;
		}
		$instances = &static::$instances[static::getClass()];
		foreach( $instances as $id => $obj ) {
			/* @var static $obj */
			if( $obj->isDeleted() ) {
				unset($instances[$id]);
			}
		}
	}