Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions textpattern/lib/txplib_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ function safe_query($q = '', $debug = false, $unbuf = false)
if ($production_status !== 'live') {
$trace->start("[SQL: $q ]", true);
}

$result = mysqli_query($DB->link, $q, $method);

if ($production_status !== 'live') {
$trace->stop();
}
Expand Down Expand Up @@ -509,6 +509,7 @@ function safe_upsert($table, $set, $where, $debug = false)
if ($r and (mysqli_affected_rows($DB->link) or safe_count($table, $where, $debug))) {
return $r;
} else {
$where = implode(', ', (preg_split( "/ (AND|OR) /", $where)));
return safe_insert($table, join(', ', array($where, $set)), $debug);
}
}
Expand Down Expand Up @@ -1452,7 +1453,7 @@ function db_down()
* the txp_file table.
*
* @param string $type Column name, lower case (one of 'posted', 'expires', 'created')
* @param bool $update Force update
* @param bool $update Force update
* @return string SQL query string partial
*/

Expand All @@ -1478,7 +1479,7 @@ function now($type, $update = false) {
$table = ($type === 'created') ? 'txp_file' : 'textpattern';
$where = '1=1 having utime > '.$time.' order by utime asc limit 1';
$now = safe_field('unix_timestamp('.$type.') as utime', $table, $where);
$now = ($now === false) ? 2147483647 : intval($now) - 1;
$now = ($now === false) ? 2147483647 : intval($now) - 1;
update_pref($pref, $now);
$nows[$type] = $now;
}
Expand Down