Files
oc-server3/htdocs/util/publish_caches/run_publish.php
following 252019f52d fixed another trigger recursion when updating a cache record
function touchCache() in lib/clicompatbase.inc.php updated e.g. cache_desc.last_modified
in the same statement with an access to caches table. As the cacheDescAfterUpdate trigger
updates caches.listing_last_modified, the read & write access to caches table collided.

function touchCache() is obsolete, as touching on status change is done by triggers
for all depending tables (via SQL function sp_touch_cache).
2013-03-22 10:24:04 +01:00

60 lines
1.7 KiB
PHP

#!/usr/local/bin/php -q
<?php
/***************************************************************************
./util/publish_caches/run_publish.php
-------------------
begin : Sat September 2 2006
For license information see doc/license.txt
****************************************************************************/
/***************************************************************************
Unicode Reminder メモ
Ggf. muss die Location des php-Binaries angepasst werden.
Prueft auf wartende Caches, deren Veröffentlichungszeitpunkt
gekommen ist und veröffentlicht sie.
***************************************************************************/
$rootpath = '../../';
// chdir to proper directory (needed for cronjobs)
chdir(substr(realpath($_SERVER['PHP_SELF']), 0, strrpos(realpath($_SERVER['PHP_SELF']), '/')));
require_once($rootpath . 'lib/clicompatbase.inc.php');
require_once('settings.inc.php');
require_once($rootpath . 'lib/eventhandler.inc.php');
/* begin db connect */
db_connect();
if ($dblink === false)
{
echo 'Unable to connect to database';
exit;
}
/* end db connect */
$rsPublish = sql(" SELECT `cache_id`, `user_id`
FROM `caches`
WHERE `status` = 5
AND `date_activate` <= NOW()");
while($rPublish = sql_fetch_array($rsPublish))
{
$userid = $rPublish['user_id'];
$cacheid = $rPublish['cache_id'];
// update cache status to active
// will touch the last_modified date of all depending records
sql("UPDATE `caches` SET `status`=1, `date_activate`=NULL WHERE `cache_id`='&1'", $cacheid);
// send events
event_new_cache($userid);
event_notify_new_cache($cacheid);
}
mysql_free_result($rsPublish);
?>