some poller optimisations and a fix for undefined (empty) dbtype which shows up as a mysql error that 'rand' isn't found.
This commit is contained in:
parent
7e58bfe931
commit
1c249a5b06
1
boot.php
1
boot.php
@ -567,6 +567,7 @@ define ( 'ITEM_VERIFIED', 0x2000); // Signature verification was success
|
|||||||
define ( 'ITEM_RETAINED', 0x4000); // We looked at this item once to decide whether or not to expire it, and decided not to.
|
define ( 'ITEM_RETAINED', 0x4000); // We looked at this item once to decide whether or not to expire it, and decided not to.
|
||||||
define ( 'ITEM_RSS', 0x8000); // Item comes from a feed. Use this to decide whether to link the title
|
define ( 'ITEM_RSS', 0x8000); // Item comes from a feed. Use this to decide whether to link the title
|
||||||
// Don't make us evaluate this same item again.
|
// Don't make us evaluate this same item again.
|
||||||
|
|
||||||
define ( 'DBTYPE_MYSQL', 0 );
|
define ( 'DBTYPE_MYSQL', 0 );
|
||||||
define ( 'DBTYPE_POSTGRES', 1 );
|
define ( 'DBTYPE_POSTGRES', 1 );
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@
|
|||||||
function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
|
function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
|
||||||
$dba = null;
|
$dba = null;
|
||||||
|
|
||||||
if($dbtype == 1) {
|
|
||||||
|
$dbtype = intval($dbtype);
|
||||||
|
|
||||||
|
if($dbtype == DBTYPE_POSTGRES) {
|
||||||
require_once('include/dba/dba_postgres.php');
|
require_once('include/dba/dba_postgres.php');
|
||||||
if(is_null($port)) $port = 5432;
|
if(is_null($port)) $port = 5432;
|
||||||
$dba = new dba_postgres($server, $port, $user, $pass, $db, $install);
|
$dba = new dba_postgres($server, $port, $user, $pass, $db, $install);
|
||||||
@ -39,6 +42,7 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
|
|||||||
$dba = new dba_mysql($server, $port,$user,$pass,$db,$install);
|
$dba = new dba_mysql($server, $port,$user,$pass,$db,$install);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
define('NULL_DATE', $dba->get_null_date());
|
define('NULL_DATE', $dba->get_null_date());
|
||||||
define('ACTIVE_DBTYPE', $dbtype);
|
define('ACTIVE_DBTYPE', $dbtype);
|
||||||
return $dba;
|
return $dba;
|
||||||
@ -371,7 +375,7 @@ function db_getfunc($f) {
|
|||||||
if(isset($lookup[$f]) && isset($lookup[$f][ACTIVE_DBTYPE]))
|
if(isset($lookup[$f]) && isset($lookup[$f][ACTIVE_DBTYPE]))
|
||||||
return $lookup[$f][ACTIVE_DBTYPE];
|
return $lookup[$f][ACTIVE_DBTYPE];
|
||||||
|
|
||||||
logger('Unable to abstract DB function "'. $f . '"', LOG_DEBUG);
|
logger('Unable to abstract DB function "'. $f . '" for dbtype ' . ACTIVE_DBTYPE, LOGGER_DEBUG);
|
||||||
return $f;
|
return $f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ function externals_run($argv, $argc){
|
|||||||
$total = 0;
|
$total = 0;
|
||||||
$attempts = 0;
|
$attempts = 0;
|
||||||
|
|
||||||
|
logger('externals: startup', LOGGER_DEBUG);
|
||||||
|
|
||||||
// pull in some public posts
|
// pull in some public posts
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ function poller_run($argv, $argc){
|
|||||||
|
|
||||||
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
|
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
|
||||||
$lockfile = 'store/[data]/poller';
|
$lockfile = 'store/[data]/poller';
|
||||||
if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))) {
|
if((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
|
||||||
|
&& (! get_config('system','override_poll_lockfile'))) {
|
||||||
logger("poller: Already running");
|
logger("poller: Already running");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,7 +53,7 @@ function poller_run($argv, $argc){
|
|||||||
// expire any expired items
|
// expire any expired items
|
||||||
|
|
||||||
$r = q("select id from item where expires != '%s' and expires < %s
|
$r = q("select id from item where expires != '%s' and expires < %s
|
||||||
and not ( item_restrict & %d )>0 ",
|
and ( item_restrict & %d ) = 0 ",
|
||||||
dbesc(NULL_DATE),
|
dbesc(NULL_DATE),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
intval(ITEM_DELETED)
|
intval(ITEM_DELETED)
|
||||||
@ -69,7 +70,8 @@ function poller_run($argv, $argc){
|
|||||||
// or dead entries.
|
// or dead entries.
|
||||||
|
|
||||||
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s",
|
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s",
|
||||||
db_utcnow(), db_quoteinterval('30 DAY')
|
db_utcnow(),
|
||||||
|
db_quoteinterval('30 DAY')
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
@ -207,7 +209,8 @@ function poller_run($argv, $argc){
|
|||||||
|
|
||||||
$r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = ''
|
$r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = ''
|
||||||
and xchan_photo_date < %s - INTERVAL %s",
|
and xchan_photo_date < %s - INTERVAL %s",
|
||||||
db_utcnow(), db_quoteinterval('1 DAY')
|
db_utcnow(),
|
||||||
|
db_quoteinterval('1 DAY')
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
require_once('include/photo/photo_driver.php');
|
require_once('include/photo/photo_driver.php');
|
||||||
@ -253,7 +256,7 @@ function poller_run($argv, $argc){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql_extra = (($manual_id) ? " AND abook_id = $manual_id " : "");
|
$sql_extra = (($manual_id) ? " AND abook_id = " . intval($manual_id) . " " : "");
|
||||||
|
|
||||||
reload_plugins();
|
reload_plugins();
|
||||||
|
|
||||||
@ -271,10 +274,10 @@ function poller_run($argv, $argc){
|
|||||||
: ''
|
: ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$randfunc = (ACTIVE_DBTYPE == DBTYPE_POSTGRES) ? 'RANDOM()' : 'RAND()';
|
$randfunc = db_getfunc('RAND');
|
||||||
|
|
||||||
$contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_xchan, abook_channel
|
$contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_xchan, abook_channel, xchan_network
|
||||||
FROM abook LEFT JOIN account on abook_account = account_id
|
FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash LEFT JOIN account on abook_account = account_id
|
||||||
$sql_extra
|
$sql_extra
|
||||||
AND (( abook_flags & %d ) > 0 OR ( abook_flags = %d ))
|
AND (( abook_flags & %d ) > 0 OR ( abook_flags = %d ))
|
||||||
AND (( account_flags = %d ) OR ( account_flags = %d )) $abandon_sql ORDER BY $randfunc",
|
AND (( account_flags = %d ) OR ( account_flags = %d )) $abandon_sql ORDER BY $randfunc",
|
||||||
@ -289,6 +292,9 @@ function poller_run($argv, $argc){
|
|||||||
|
|
||||||
foreach($contacts as $contact) {
|
foreach($contacts as $contact) {
|
||||||
|
|
||||||
|
if($contact['abook_flags'] & ABOOK_FLAG_SELF)
|
||||||
|
continue;
|
||||||
|
|
||||||
$update = false;
|
$update = false;
|
||||||
|
|
||||||
$t = $contact['abook_updated'];
|
$t = $contact['abook_updated'];
|
||||||
@ -310,6 +316,9 @@ function poller_run($argv, $argc){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($contact['xchan_network'] !== 'zot')
|
||||||
|
continue;
|
||||||
|
|
||||||
if($c == $t) {
|
if($c == $t) {
|
||||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
|
||||||
$update = true;
|
$update = true;
|
||||||
@ -330,10 +339,6 @@ function poller_run($argv, $argc){
|
|||||||
// He's dead, Jim
|
// He's dead, Jim
|
||||||
|
|
||||||
if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) {
|
if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) {
|
||||||
$n = q("select xchan_network from xchan where xchan_hash = '%s' limit 1",
|
|
||||||
dbesc($contact['abook_xchan'])
|
|
||||||
);
|
|
||||||
if($n && $n[0]['xchan_network'] == 'zot') {
|
|
||||||
$r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d",
|
$r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d",
|
||||||
intval(ABOOK_FLAG_ARCHIVED),
|
intval(ABOOK_FLAG_ARCHIVED),
|
||||||
intval($contact['abook_id'])
|
intval($contact['abook_id'])
|
||||||
@ -341,7 +346,6 @@ function poller_run($argv, $argc){
|
|||||||
$update = false;
|
$update = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) {
|
if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) {
|
||||||
$update = false;
|
$update = false;
|
||||||
@ -364,6 +368,9 @@ function poller_run($argv, $argc){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($contact['abook_flags'] & (ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_IGNORED))
|
||||||
|
continue;
|
||||||
|
|
||||||
if((! $update) && (! $force))
|
if((! $update) && (! $force))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -375,7 +382,7 @@ function poller_run($argv, $argc){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
|
if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
|
||||||
$r = q("select distinct ud_addr, updates.* from updates where not ( ud_flags & %d )>0 and ud_addr != '' and ( ud_last = '%s' OR ud_last > %s - INTERVAL %s ) group by ud_addr ",
|
$r = q("select distinct ud_addr, updates.* from updates where ( ud_flags & %d ) = 0 and ud_addr != '' and ( ud_last = '%s' OR ud_last > %s - INTERVAL %s ) group by ud_addr ",
|
||||||
intval(UPDATE_FLAGS_UPDATED),
|
intval(UPDATE_FLAGS_UPDATED),
|
||||||
dbesc(NULL_DATE),
|
dbesc(NULL_DATE),
|
||||||
db_utcnow(), db_quoteinterval('7 DAY')
|
db_utcnow(), db_quoteinterval('7 DAY')
|
||||||
|
@ -1 +1 @@
|
|||||||
2014-11-15.860
|
2014-11-16.861
|
||||||
|
Reference in New Issue
Block a user