taches_generales_cron

This pipeline is used to declare functions that will be periodically executed by SPIP. It is called in the ecrire/inc/genie.php file by the taches_generales function, accepting a parameter and returning output of a keyed array, using function names as the key and the time between execution runs as the value.

return pipeline('taches_generales_cron', $taches_generales);

Please read the section on the Wizard for further information.

Example

Any plugin whatsoever could declare a cleaning function to be run every week:

function carte_postale_taches_generales_cron($taches){
	$taches['nettoyer_cartes_postales'] = 7*24*3600; // every week
	return $taches;
}

This function is contained in the genie/nettoyer_cartes_postales.php file. It deletes all the files in a given directory that are older than 30 days, by using the purger_repertoire function:

function genie_nettoyer_cartes_postales_dist($t){
	// Purge postcards that are older than 30 days
	include_spip('inc/invalideur');
	purger_repertoire(_DIR_IMG . 'cartes_postales/', array(
		'atime' => (time() - (30 * 24 * 3600)),
	));
	return 1;
}

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français