Some more replaced old database functions
This commit is contained in:
parent
663c38afed
commit
7c3fd2adb5
10 changed files with 65 additions and 107 deletions
|
@ -1016,16 +1016,12 @@ class dba {
|
||||||
public static function update($table, $fields, $condition, $old_fields = array()) {
|
public static function update($table, $fields, $condition, $old_fields = array()) {
|
||||||
$table = self::escape($table);
|
$table = self::escape($table);
|
||||||
|
|
||||||
if (count($condition) > 0) {
|
$array_element = each($condition);
|
||||||
$array_element = each($condition);
|
$array_key = $array_element['key'];
|
||||||
$array_key = $array_element['key'];
|
if (is_int($array_key)) {
|
||||||
if (is_int($array_key)) {
|
$condition_string = " WHERE ".array_shift($condition);
|
||||||
$condition_string = " WHERE ".array_shift($condition);
|
|
||||||
} else {
|
|
||||||
$condition_string = " WHERE `".implode("` = ? AND `", array_keys($condition))."` = ?";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$condition_string = "";
|
$condition_string = " WHERE `".implode("` = ? AND `", array_keys($condition))."` = ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_bool($old_fields)) {
|
if (is_bool($old_fields)) {
|
||||||
|
|
|
@ -216,7 +216,7 @@ function event_delete($event_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q("DELETE FROM `event` WHERE `id` = %d", intval($event_id));
|
dba::delete('event', array('id' => $event_id));
|
||||||
logger("Deleted event ".$event_id, LOGGER_DEBUG);
|
logger("Deleted event ".$event_id, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2122,7 +2122,7 @@ function drop_item($id, $interactive = true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((local_user() == $item['uid']) || ($contact_id) || (! $interactive)) {
|
if ((local_user() == $item['uid']) || $contact_id || !$interactive) {
|
||||||
|
|
||||||
// Check if we should do HTML-based delete confirmation
|
// Check if we should do HTML-based delete confirmation
|
||||||
if ($_REQUEST['confirm']) {
|
if ($_REQUEST['confirm']) {
|
||||||
|
@ -2189,30 +2189,18 @@ function drop_item($id, $interactive = true) {
|
||||||
* generate a resource-id and therefore aren't intimately linked to the item.
|
* generate a resource-id and therefore aren't intimately linked to the item.
|
||||||
*/
|
*/
|
||||||
if (strlen($item['resource-id'])) {
|
if (strlen($item['resource-id'])) {
|
||||||
q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ",
|
dba::delete('photo', array('resource-id' => $item['resource-id'], 'uid' => $item['uid']));
|
||||||
dbesc($item['resource-id']),
|
|
||||||
intval($item['uid'])
|
|
||||||
);
|
|
||||||
// ignore the result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If item is a link to an event, nuke the event record.
|
// If item is a link to an event, nuke the event record.
|
||||||
if (intval($item['event-id'])) {
|
if (intval($item['event-id'])) {
|
||||||
q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d",
|
dba::delete('event', array('id' => $item['event-id'], 'uid' => $item['uid']));
|
||||||
intval($item['event-id']),
|
|
||||||
intval($item['uid'])
|
|
||||||
);
|
|
||||||
// ignore the result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If item has attachments, drop them
|
// If item has attachments, drop them
|
||||||
foreach (explode(", ", $item['attach']) as $attach) {
|
foreach (explode(", ", $item['attach']) as $attach) {
|
||||||
preg_match("|attach/(\d+)|", $attach, $matches);
|
preg_match("|attach/(\d+)|", $attach, $matches);
|
||||||
q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d",
|
dba::delete('attach', array('id' => $matches[1], 'uid' => $item['uid']));
|
||||||
intval($matches[1]),
|
|
||||||
local_user()
|
|
||||||
);
|
|
||||||
// ignore the result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The new code splits the queries since the mysql optimizer really has bad problems with subqueries
|
// The new code splits the queries since the mysql optimizer really has bad problems with subqueries
|
||||||
|
|
|
@ -163,9 +163,7 @@ function do_like($item_id, $verb) {
|
||||||
// Clean up the Diaspora signatures for this like
|
// Clean up the Diaspora signatures for this like
|
||||||
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
|
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
|
||||||
// if it had been enabled in the past
|
// if it had been enabled in the past
|
||||||
q("DELETE FROM `sign` WHERE `iid` = %d",
|
dba::delete('sign', array('iid' => $like_item['id']));
|
||||||
intval($like_item['id'])
|
|
||||||
);
|
|
||||||
|
|
||||||
$like_item_id = $like_item['id'];
|
$like_item_id = $like_item['id'];
|
||||||
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id);
|
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id);
|
||||||
|
|
|
@ -113,7 +113,7 @@ class FKOAuthDataStore extends OAuthDataStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
q("DELETE FROM tokens WHERE id='%s'", $token->key);
|
dba::delete('tokens', array('id' => $token->key));
|
||||||
|
|
||||||
|
|
||||||
if (!is_null($ret) && $uverifier!==false){
|
if (!is_null($ret) && $uverifier!==false){
|
||||||
|
|
|
@ -28,17 +28,17 @@ function oembed_replacecb($matches){
|
||||||
* @return bool|object Returns object with embed content or false if no embedable
|
* @return bool|object Returns object with embed content or false if no embedable
|
||||||
* content exists
|
* content exists
|
||||||
*/
|
*/
|
||||||
function oembed_fetch_url($embedurl, $no_rich_type = false){
|
function oembed_fetch_url($embedurl, $no_rich_type = false) {
|
||||||
$embedurl = trim($embedurl, "'");
|
$embedurl = trim($embedurl, "'");
|
||||||
$embedurl = trim($embedurl, '"');
|
$embedurl = trim($embedurl, '"');
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$r = q("SELECT * FROM `oembed` WHERE `url` = '%s'",
|
$condition = array('url' => normalise_link($embedurl));
|
||||||
dbesc(normalise_link($embedurl)));
|
$r = dba::select('oembed', array('content'), $condition, array('limit' => 1));
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$txt = $r[0]["content"];
|
$txt = $r["content"];
|
||||||
} else {
|
} else {
|
||||||
$txt = Cache::get($a->videowidth . $embedurl);
|
$txt = Cache::get($a->videowidth . $embedurl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,16 @@ use Friendica\Database\DBM;
|
||||||
* @param string $plugin name of the addon
|
* @param string $plugin name of the addon
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
if (! function_exists('uninstall_plugin')){
|
function uninstall_plugin($plugin) {
|
||||||
function uninstall_plugin($plugin){
|
|
||||||
logger("Addons: uninstalling " . $plugin);
|
logger("Addons: uninstalling " . $plugin);
|
||||||
q("DELETE FROM `addon` WHERE `name` = '%s' ",
|
dba::delete('addon', array('name' => $plugin));
|
||||||
dbesc($plugin)
|
|
||||||
);
|
|
||||||
|
|
||||||
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
|
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
|
||||||
if (function_exists($plugin . '_uninstall')) {
|
if (function_exists($plugin . '_uninstall')) {
|
||||||
$func = $plugin . '_uninstall';
|
$func = $plugin . '_uninstall';
|
||||||
$func();
|
$func();
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief installs an addon.
|
* @brief installs an addon.
|
||||||
|
@ -36,12 +33,12 @@ function uninstall_plugin($plugin){
|
||||||
* @param string $plugin name of the addon
|
* @param string $plugin name of the addon
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
if (! function_exists('install_plugin')){
|
|
||||||
function install_plugin($plugin) {
|
function install_plugin($plugin) {
|
||||||
// silently fail if plugin was removed
|
// silently fail if plugin was removed
|
||||||
|
|
||||||
if (! file_exists('addon/' . $plugin . '/' . $plugin . '.php'))
|
if (!file_exists('addon/' . $plugin . '/' . $plugin . '.php')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
logger("Addons: installing " . $plugin);
|
logger("Addons: installing " . $plugin);
|
||||||
$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
|
$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
|
||||||
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
|
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
|
||||||
|
@ -62,26 +59,24 @@ function install_plugin($plugin) {
|
||||||
dba::update('addon', array('hidden' => true), array('name' => $plugin));
|
dba::update('addon', array('hidden' => true), array('name' => $plugin));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
logger("Addons: FAILED installing " . $plugin);
|
logger("Addons: FAILED installing " . $plugin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}}
|
|
||||||
|
|
||||||
// reload all updated plugins
|
// reload all updated plugins
|
||||||
|
|
||||||
if (! function_exists('reload_plugins')) {
|
|
||||||
function reload_plugins() {
|
function reload_plugins() {
|
||||||
$plugins = Config::get('system','addon');
|
$plugins = Config::get('system', 'addon');
|
||||||
if (strlen($plugins)) {
|
if (strlen($plugins)) {
|
||||||
|
|
||||||
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
|
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
|
||||||
if (DBM::is_result($r))
|
if (DBM::is_result($r)) {
|
||||||
$installed = $r;
|
$installed = $r;
|
||||||
else
|
} else {
|
||||||
$installed = array();
|
$installed = array();
|
||||||
|
}
|
||||||
|
|
||||||
$parr = explode(',',$plugins);
|
$parr = explode(',',$plugins);
|
||||||
|
|
||||||
|
@ -115,7 +110,7 @@ function reload_plugins() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief check if addon is enabled
|
* @brief check if addon is enabled
|
||||||
|
@ -137,21 +132,17 @@ function plugin_enabled($plugin) {
|
||||||
* @param int $priority A priority (defaults to 0)
|
* @param int $priority A priority (defaults to 0)
|
||||||
* @return mixed|bool
|
* @return mixed|bool
|
||||||
*/
|
*/
|
||||||
if (! function_exists('register_hook')) {
|
function register_hook($hook, $file, $function, $priority=0) {
|
||||||
function register_hook($hook,$file,$function,$priority=0) {
|
$condition = array('hook' => $hook, 'file' => $file, 'function' => $function);
|
||||||
|
$exists = dba::exists('hook', $condition);
|
||||||
$r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
|
if ($exists) {
|
||||||
dbesc($hook),
|
|
||||||
dbesc($file),
|
|
||||||
dbesc($function)
|
|
||||||
);
|
|
||||||
if (DBM::is_result($r))
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority));
|
$r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority));
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief unregisters a hook.
|
* @brief unregisters a hook.
|
||||||
|
@ -161,16 +152,11 @@ function register_hook($hook,$file,$function,$priority=0) {
|
||||||
* @param string $function the name of the function that the hook called
|
* @param string $function the name of the function that the hook called
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
if (! function_exists('unregister_hook')) {
|
function unregister_hook($hook, $file, $function) {
|
||||||
function unregister_hook($hook,$file,$function) {
|
$condition = array('hook' => $hook, 'file' => $file, 'function' => $function);
|
||||||
|
$r = dba::delete('hook', $condition);
|
||||||
$r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'",
|
|
||||||
dbesc($hook),
|
|
||||||
dbesc($file),
|
|
||||||
dbesc($function)
|
|
||||||
);
|
|
||||||
return $r;
|
return $r;
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
function load_hooks() {
|
function load_hooks() {
|
||||||
|
@ -224,17 +210,13 @@ function call_single_hook($a, $name, $hook, &$data = null) {
|
||||||
$func($a, $data);
|
$func($a, $data);
|
||||||
} else {
|
} else {
|
||||||
// remove orphan hooks
|
// remove orphan hooks
|
||||||
q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'",
|
$condition = array('hook' => $name, 'file' => $hook[0], 'function' => $hook[1]);
|
||||||
dbesc($name),
|
dba::delete('hook', $condition);
|
||||||
dbesc($hook[0]),
|
|
||||||
dbesc($hook[1])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if an app_menu hook exist for plugin $name.
|
//check if an app_menu hook exist for plugin $name.
|
||||||
//Return true if the plugin is an app
|
//Return true if the plugin is an app
|
||||||
if (! function_exists('plugin_is_app')) {
|
|
||||||
function plugin_is_app($name) {
|
function plugin_is_app($name) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
@ -246,7 +228,7 @@ function plugin_is_app($name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parse plugin comment in search of plugin infos.
|
* @brief Parse plugin comment in search of plugin infos.
|
||||||
|
@ -264,8 +246,7 @@ function plugin_is_app($name) {
|
||||||
* @return array with the plugin information
|
* @return array with the plugin information
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! function_exists('get_plugin_info')){
|
function get_plugin_info($plugin) {
|
||||||
function get_plugin_info($plugin){
|
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
@ -285,14 +266,14 @@ function get_plugin_info($plugin){
|
||||||
|
|
||||||
$r = preg_match("|/\*.*\*/|msU", $f, $m);
|
$r = preg_match("|/\*.*\*/|msU", $f, $m);
|
||||||
|
|
||||||
if ($r){
|
if ($r) {
|
||||||
$ll = explode("\n", $m[0]);
|
$ll = explode("\n", $m[0]);
|
||||||
foreach ( $ll as $l ) {
|
foreach ( $ll as $l ) {
|
||||||
$l = trim($l,"\t\n\r */");
|
$l = trim($l,"\t\n\r */");
|
||||||
if ($l!=""){
|
if ($l != "") {
|
||||||
list($k,$v) = array_map("trim", explode(":",$l,2));
|
list($k,$v) = array_map("trim", explode(":",$l,2));
|
||||||
$k= strtolower($k);
|
$k= strtolower($k);
|
||||||
if ($k=="author"){
|
if ($k == "author") {
|
||||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
||||||
|
@ -300,7 +281,7 @@ function get_plugin_info($plugin){
|
||||||
$info['author'][] = array('name'=>$v);
|
$info['author'][] = array('name'=>$v);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (array_key_exists($k,$info)){
|
if (array_key_exists($k,$info)) {
|
||||||
$info[$k]=$v;
|
$info[$k]=$v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +291,7 @@ function get_plugin_info($plugin){
|
||||||
|
|
||||||
}
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,8 +310,7 @@ function get_plugin_info($plugin){
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! function_exists('get_theme_info')){
|
function get_theme_info($theme) {
|
||||||
function get_theme_info($theme){
|
|
||||||
$info=Array(
|
$info=Array(
|
||||||
'name' => $theme,
|
'name' => $theme,
|
||||||
'description' => "",
|
'description' => "",
|
||||||
|
@ -356,14 +336,14 @@ function get_theme_info($theme){
|
||||||
|
|
||||||
$r = preg_match("|/\*.*\*/|msU", $f, $m);
|
$r = preg_match("|/\*.*\*/|msU", $f, $m);
|
||||||
|
|
||||||
if ($r){
|
if ($r) {
|
||||||
$ll = explode("\n", $m[0]);
|
$ll = explode("\n", $m[0]);
|
||||||
foreach ( $ll as $l ) {
|
foreach ( $ll as $l ) {
|
||||||
$l = trim($l,"\t\n\r */");
|
$l = trim($l,"\t\n\r */");
|
||||||
if ($l!=""){
|
if ($l != "") {
|
||||||
list($k,$v) = array_map("trim", explode(":",$l,2));
|
list($k,$v) = array_map("trim", explode(":",$l,2));
|
||||||
$k= strtolower($k);
|
$k= strtolower($k);
|
||||||
if ($k=="author"){
|
if ($k == "author") {
|
||||||
|
|
||||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
|
@ -371,8 +351,7 @@ function get_theme_info($theme){
|
||||||
} else {
|
} else {
|
||||||
$info['author'][] = array('name'=>$v);
|
$info['author'][] = array('name'=>$v);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($k == "maintainer") {
|
||||||
elseif ($k=="maintainer"){
|
|
||||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$info['maintainer'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
$info['maintainer'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
||||||
|
@ -380,7 +359,7 @@ function get_theme_info($theme){
|
||||||
$info['maintainer'][] = array('name'=>$v);
|
$info['maintainer'][] = array('name'=>$v);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (array_key_exists($k,$info)){
|
if (array_key_exists($k,$info)) {
|
||||||
$info[$k]=$v;
|
$info[$k]=$v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,7 +369,7 @@ function get_theme_info($theme){
|
||||||
|
|
||||||
}
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the theme's screenshot.
|
* @brief Returns the theme's screenshot.
|
||||||
|
@ -411,8 +390,7 @@ function get_theme_screenshot($theme) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// install and uninstall theme
|
// install and uninstall theme
|
||||||
if (! function_exists('uninstall_theme')){
|
function uninstall_theme($theme) {
|
||||||
function uninstall_theme($theme){
|
|
||||||
logger("Addons: uninstalling theme " . $theme);
|
logger("Addons: uninstalling theme " . $theme);
|
||||||
|
|
||||||
include_once("view/theme/$theme/theme.php");
|
include_once("view/theme/$theme/theme.php");
|
||||||
|
@ -420,9 +398,8 @@ function uninstall_theme($theme){
|
||||||
$func = "{$theme}_uninstall";
|
$func = "{$theme}_uninstall";
|
||||||
$func();
|
$func();
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
if (! function_exists('install_theme')){
|
|
||||||
function install_theme($theme) {
|
function install_theme($theme) {
|
||||||
// silently fail if theme was removed
|
// silently fail if theme was removed
|
||||||
|
|
||||||
|
@ -443,7 +420,7 @@ function install_theme($theme) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the full path to relevant theme files by filename
|
* @brief Get the full path to relevant theme files by filename
|
||||||
|
|
|
@ -13,9 +13,7 @@ function update_queue_time($id) {
|
||||||
|
|
||||||
function remove_queue_item($id) {
|
function remove_queue_item($id) {
|
||||||
logger('queue: remove queue item ' . $id);
|
logger('queue: remove queue item ' . $id);
|
||||||
q("DELETE FROM `queue` WHERE `id` = %d",
|
dba::delete('queue', array('id' => $id));
|
||||||
intval($id)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -251,7 +251,7 @@ function delete_thread($itemid, $itemuri = "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using dba::delete at this time could delete the associated item entries
|
// Using dba::delete at this time could delete the associated item entries
|
||||||
$result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid));
|
$result = dba::e("DELETE FROM `thread` WHERE `iid` = ?", $itemid);
|
||||||
|
|
||||||
logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
|
|
|
@ -155,14 +155,15 @@ class CronJobs {
|
||||||
if (!$cachetime) {
|
if (!$cachetime) {
|
||||||
$cachetime = PROXY_DEFAULT_TIME;
|
$cachetime = PROXY_DEFAULT_TIME;
|
||||||
}
|
}
|
||||||
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
|
$condition = array('`uid` = 0 AND `resource-id` LIKE "pic:%" AND `created` < NOW() - INTERVAL ? SECOND', $cachetime);
|
||||||
|
dba::delete('photo', $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the cached OEmbed entries that are older than one year
|
// Delete the cached OEmbed entries that are older than three month
|
||||||
q("DELETE FROM `oembed` WHERE `created` < NOW() - INTERVAL 3 MONTH");
|
dba::delete('oembed', array("`created` < NOW() - INTERVAL 3 MONTH"));
|
||||||
|
|
||||||
// Delete the cached "parse_url" entries that are older than one year
|
// Delete the cached "parse_url" entries that are older than three month
|
||||||
q("DELETE FROM `parsed_url` WHERE `created` < NOW() - INTERVAL 3 MONTH");
|
dba::delete('parsed_url', array("`created` < NOW() - INTERVAL 3 MONTH"));
|
||||||
|
|
||||||
// Maximum table size in megabyte
|
// Maximum table size in megabyte
|
||||||
$max_tablesize = intval(Config::get('system','optimize_max_tablesize')) * 1000000;
|
$max_tablesize = intval(Config::get('system','optimize_max_tablesize')) * 1000000;
|
||||||
|
|
Loading…
Reference in a new issue