Commit 1638c464 by Maiyannah Bishop

Merge branch 'cronish-doc' into 'nightly'

Document Cronish

See merge request !46
2 parents 65b16ffc 1de9c9f8
<?php
/****
* postActiv - a fork of the GNU Social microblogging software
* Copyright (C) 2016, Maiyannah Bishop
/* ============================================================================
* Title: CronishPlugin
* postActiv cronish plugin, to imitate cron actions
*
* postActiv:
* the micro-blogging software
*
* Copyright:
* Copyright (C) 2016-2017, Maiyannah Bishop
*
* Derived from code copyright various sources:
* GNU Social (C) 2013-2016, Free Software Foundation, Inc
* StatusNet (C) 2008-2011, StatusNet, Inc
* o GNU Social (C) 2013-2016, Free Software Foundation, Inc
* o StatusNet (C) 2008-2012, StatusNet, Inc
* ----------------------------------------------------------------------------
* License:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* GNU social cronish plugin, to imitate cron actions
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Cron
* @package GNUsocial
* @author Mikael Nordfeldth <mmn@hethane.se>
* @copyright 2013 Free Software Foundation, Inc.
* @license https://www.gnu.org/licenses/agpl.html
* @link http://gnu.io/social/
* <https://www.gnu.org/licenses/agpl.html>
* ----------------------------------------------------------------------------
* About:
* Plugin that emulates cron actions by performing them on pageload.
*
* PHP version:
* Tested with PHP 7
* ----------------------------------------------------------------------------
* File Authors:
* o Maiyannah Bishop <maiyannah.bishop@postactiv.com>
* o Mikael Nordfeldth <mmn@hethane.se>
*
* Web:
* o postActiv <http://www.postactiv.com>
* o GNU social <https://www.gnu.org/s/social/>
* ============================================================================
*/
// This file is formatted so that it provides useful documentation output in
// NaturalDocs. Please be considerate of this before changing formatting.
if (!defined('GNUSOCIAL')) { exit(1); }
// ----------------------------------------------------------------------------
// Class: CronishPlugin
// Base class for the Cronish plugin
class CronishPlugin extends Plugin {
// ------------------------------------------------------------------------
// Function: onCronMinutely
// Print to log that a near-minutely cron job is being performed.
public function onCronMinutely()
{
common_debug('CRON: Running near-minutely cron job!');
}
// ------------------------------------------------------------------------
// Function: onCronHourly
// Print to log that a near-hourly cron job is being performed.
public function onCronHourly()
{
common_debug('CRON: Running near-hourly cron job!');
}
// ------------------------------------------------------------------------
// Function: onCronDaily
// Print to log that a near-daily cron job is being performed.
public function onCronDaily()
{
common_debug('CRON: Running near-daily cron job!');
}
// ------------------------------------------------------------------------
// Function: onCronWeekly
// Print to log that a near-weekly cron job is being performed.
public function onCronWeekly()
{
common_debug('CRON: Running near-weekly cron job!');
}
/**
* When the page has finished rendering, let's do some cron jobs
* if we have the time.
*/
// ------------------------------------------------------------------------
// Function: onEndActionExecute
// When the page has finished rendering, let's do some cron jobs
// if we have the time.
//
// Parameters:
// o Action $action - Action to execute
//
// Returns:
// o bool true
public function onEndActionExecute(Action $action)
{
$cron = new Cronish();
......@@ -51,6 +105,15 @@ class CronishPlugin extends Plugin {
return true;
}
// ------------------------------------------------------------------------
// Function: onPluginVersion
// Modify a versions array to provide the plugin version info.
//
// Parameters:
// o array $versions - versions array to modify
//
// Returns:
// o bool true
public function onPluginVersion(array &$versions)
{
$versions[] = array('name' => 'Cronish',
......@@ -63,3 +126,5 @@ class CronishPlugin extends Plugin {
return true;
}
}
// END OF FILE
// ============================================================================
<?php
/**
* postActiv - a fork of the GNU Social microblogging software
* Copyright (C) 2016, Maiyannah Bishop
/* ============================================================================
* Title: cronish
* postActiv cron-on-visit class
*
* postActiv:
* the micro-blogging software
*
* Copyright:
* Copyright (C) 2016-2017, Maiyannah Bishop
*
* Derived from code copyright various sources:
* GNU Social (C) 2013-2016, Free Software Foundation, Inc
* StatusNet (C) 2008-2011, StatusNet, Inc
* o GNU Social (C) 2013-2016, Free Software Foundation, Inc
* o StatusNet (C) 2008-2012, StatusNet, Inc
* ----------------------------------------------------------------------------
* License:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNU social cron-on-visit class
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* Keeps track, through Config dataobject class, of relative time since the
* last run in order to to run event handlers with certain intervals.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Cron
* @package GNUsocial
* @author Mikael Nordfeldth <mmn@hethane.se>
* @copyright 2013 Free Software Foundation, Inc.
* @license https://www.gnu.org/licenses/agpl.html
* @link http://status.net/
* <https://www.gnu.org/licenses/agpl.html>
* ----------------------------------------------------------------------------
* About:
* Uses page visits as a timer for cron jobs. Most effective when there's
* sufficient traffic to the site.
*
* PHP version:
* Tested with PHP 7
* ----------------------------------------------------------------------------
* File Authors:
* o Maiyannah Bishop <maiyannah.bishop@postactiv.com>
* o Mikael Nordfeldth <mmn@hethane.se>
* Web:
* o postActiv <http://www.postactiv.com>
* o GNU social <https://www.gnu.org/s/social/>
* ============================================================================
*/
// This file is formatted so that it provides useful documentation output in
// NaturalDocs. Please be considerate of this before changing formatting.
// ----------------------------------------------------------------------------
// Class: Cronish
// Cron-on-visit class
class Cronish
{
/**
* Will call events as close as it gets to one hour. Event handlers
* which use this MUST be as quick as possible, maybe only adding a
* queue item to be handled later or something. Otherwise execution
* will timeout for PHP - or at least cause unnecessary delays for
* the unlucky user who visits the site exactly at one of these events.
*/
// ------------------------------------------------------------------------
// Function: callTimedEvents
// Will call events as close as it gets to one hour. Event handlers
// which use this MUST be as quick as possible, maybe only adding a
// queue item to be handled later or something. Otherwise execution
// will timeout for PHP - or at least cause unnecessary delays for
// the unlucky user who visits the site exactly at one of these events.
public function callTimedEvents()
{
$timers = array('minutely' => 60, // this is NOT guaranteed to run every minute (only on busy sites)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!