Removes FINISHED processes rows from the db (in one db call)
method self-manages the removal, based on the defined cleanupInterval and cleanupAgeLimit

@return void
346533
private function cleanupFinishedProcesses()
    {
        if ( time() < ( $this->cleanupLastTime + $this->cleanupInterval ) )
        {
            return;
        }

        $processes = count( ezpContentPublishingProcess::fetchProcesses( ezpContentPublishingProcess::STATUS_FINISHED ) );
        if ( $processes > 0 )
        {
            //Remove all objects at once
            // this is required as the MySQL connection might be closed anytime by a fork
            try
            {
                eZDebug::writeNotice( "ASYNC:: removing processes entries marked as STATUS_FINISHED in database.");
                $db = eZDB::instance();
                eZDB::setInstance( null );
                $deleteBefore = time() - $this->cleanupAgeLimit;
                $definition = ezpContentPublishingProcess::definition();
                $processTable = $definition['name'];
                $db->query( "DELETE from ". $processTable. " WHERE status =".  ezpContentPublishingProcess::STATUS_FINISHED. " AND finished < ". $deleteBefore );
                $this->cleanupLastTime = time();
            }
            catch( eZDBException $e ) 
            {
                // Do nothing, this will be retried until the DB is back up
            }
        }
    }
747576
public function cleanup(): void
    {
        foreach ($this->getStore() as $key => $value)
        {
            $this->remove($key);
        }
    }
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);
        }
    }
1086352
public function uninstall_cleanup() {
        global $DB, $CFG;

        $DB->delete_records('filter_active', array('filter' => $this->name));
        $DB->delete_records('filter_config', array('filter' => $this->name));

        if (empty($CFG->filterall)) {
            $stringfilters = array();
        } else if (!empty($CFG->stringfilters)) {
            $stringfilters = explode(',', $CFG->stringfilters);
            $stringfilters = array_combine($stringfilters, $stringfilters);
        } else {
            $stringfilters = array();
        }

        unset($stringfilters[$this->name]);

        set_config('stringfilters', implode(',', $stringfilters));
        set_config('filterall', !empty($stringfilters));

        parent::uninstall_cleanup();
    }
346069
public function truncate()
    {
        foreach ($this->tables as $table) {
            $this->db->query("DELETE FROM $table");
        }

        $this->tables = array();
    }
544196
public function clean() {
		if (!Configure::read('Queue.cleanuptimeout')) {
			$this->abort('You disabled cleanuptimout in config. Aborting.');
		}

		$this->out('Deleting old jobs, that have finished before ' . date('Y-m-d H:i:s', time() - (int)Configure::read('Queue.cleanuptimeout')));
		$this->QueuedJobs->cleanOldJobs();
		$this->QueueProcesses->cleanEndedProcesses();
	}
227202
protected function cleanupAction()
    {
        $days = 2;
        $date = new \DateTime();
        $date->modify("-$days day");

        $filter = array("before" => $date->format("Y-m-d"),
                        "isDraft" => 1);
        
        $applications    = $this->fetchApplications($filter);
        $documentManager = $this->documentManager;

        $count = count($applications);
        $i=0;

        echo  $count . " applications in Draft Mode and older than " . $days . " days will be deleted\n";

        $progress = new ProgressBar($count);

        foreach ($applications as $application) {
            $progress->update($i++, 'Application ' . $i . ' / ' . $count);
            try {
                $documentManager->remove($application);
            } catch (\Exception $e) {
                // log something
                $e->getCode();
            }
        }
        $progress->update($i, 'clean up database');
        $documentManager->flush();
        $progress->finish();
    }
102512
public function onFinish()
    {
        foreach ($this->cursors as $curId => $cur) {
            if ($cur instanceof Cursor) {
                $cur->destroy(true);
            }
        }
        $this->cursors = null;
        $this->requests = null;
        parent::onFinish();
    }
871255
public function cleanUp()
    {
        // create a separate queue for each priority
        foreach (PriorityKeys::getAll() as $priorityKey) {
            $this->workers[$this->uniqueWorkerName($priorityKey)]->stop();
        }
    }
54709
public function cleanup()
    {
        foreach ($this->workerList as $worker) {
            if (!$worker->isValid()) {
                $this->removeWorker($worker);
            }
        }

        return $this;
    }
1210629
public function cleanup()
    {
        if ($this->option('force')) {
            $this->deleteDirs();
        } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) {
            $this->deleteDirs();
        }
    }
20190
public function cleanup()
	{
		$conn = $this->_dbm->acquire( $this->_dbname );

		try
		{
			$date = date( 'Y-m-d H:i:00' );
			$search = new MW_Common_Criteria_SQL( $conn );
			$search->setConditions( $search->compare( '<', $this->_searchConfig['cache.expire']['code'], $date ) );

			$types = $this->_getSearchTypes( $this->_searchConfig );
			$translations = $this->_getSearchTranslations( $this->_searchConfig );
			$conditions = $search->getConditionString( $types, $translations );

			$stmt = $conn->create( str_replace( ':cond', $conditions, $this->_sql['delete'] ) );
			$stmt->bind( 1, $this->_siteid, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->execute()->finish();

			$this->_dbm->release( $conn, $this->_dbname );
		}
		catch( Exception $e )
		{
			$this->_dbm->release( $conn, $this->_dbname );
			throw $e;
		}
	}
263101
protected function clear()
    {
        $this->sql      = null;
        $this->start    = null;
        $this->from     = null;
        $this->join     = null;
        $this->set      = null;
        $this->where    = null;
        $this->groupby  = null;
        $this->orderby  = null;
        $this->limit    = null;
        $this->offset   = null;
    }
174568
private function cleanup(): void
    {

        CharacterBlueprint::where('character_id', $this->getCharacterId())
            ->whereNotIn('item_id', $this->cleanup_ids->flatten()->unique()->all())
            ->delete();
    }
504116
public function cleanup()
    {
        try {
            foreach ($this->locks as $lock) {
                $lock->release();
            }
        } catch (LockReleasingException $e) {
            // noop
        } finally {
            $this->locks = [];
        }
    }
299556
public static function cleanup_instances() {
        global $DB;
        self::init_levels();

        $sqls = array();
        foreach (self::$alllevels as $level=>$classname) {
            $sqls[] = $classname::get_cleanup_sql();
        }

        $sql = implode(" UNION ", $sqls);

        // it is probably better to use transactions, it might be faster too
        $transaction = $DB->start_delegated_transaction();

        $rs = $DB->get_recordset_sql($sql);
        foreach ($rs as $record) {
            $context = context::create_instance_from_record($record);
            $context->delete();
        }
        $rs->close();

        $transaction->allow_commit();
    }
287510
protected function flushDeletes()
    {
        if ( ! $this->deleteTarget) {
            return;
        }

        foreach ($this->queuedForDelete as $variant) {
            $this->handler->deleteVariant($this->deleteTarget, $variant);
        }

        $this->queuedForDelete = [];
    }