define ( 'FRIENDICA_CODENAME', 'Ginger');
define ( 'FRIENDICA_VERSION', '3.3.2' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1175 );
+define ( 'DB_UPDATE_VERSION', 1176 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
"locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
+ "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
),
"indexes" => array(
"PRIMARY" => array("id"),
$start = time();
do {
- q("LOCK TABLE locks WRITE");
- $r = q("SELECT locked FROM locks WHERE name = '%s' LIMIT 1",
+ q("LOCK TABLE `locks` WRITE");
+ $r = q("SELECT `locked`, `created` FROM `locks` WHERE `name` = '%s' LIMIT 1",
dbesc($fn_name)
);
- if((count($r)) && (! $r[0]['locked'])) {
- q("UPDATE locks SET locked = 1 WHERE name = '%s'",
+ if((count($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
+ q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'",
+ dbesc(datetime_convert()),
dbesc($fn_name)
);
$got_lock = true;
}
elseif(! $r) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
- q("INSERT INTO locks ( name, locked ) VALUES ( '%s', 1 )",
- dbesc($fn_name)
+ q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
+ dbesc($fn_name),
+ dbesc(datetime_convert())
);
$got_lock = true;
}
} while(($block) && (! $got_lock) && ((time() - $start) < $timeout));
logger('lock_function: function ' . $fn_name . ' with blocking = ' . $block . ' got_lock = ' . $got_lock . ' time = ' . (time() - $start), LOGGER_DEBUG);
-
+
return $got_lock;
}}
if(! function_exists('unlock_function')) {
function unlock_function($fn_name) {
- $r = q("UPDATE locks SET locked = 0 WHERE name = '%s'",
+ $r = q("UPDATE `locks` SET `locked` = 0, `created` = '0000-00-00 00:00:00' WHERE `name` = '%s'",
dbesc($fn_name)
);
// Cleanup invalid HTML
$doc = new DOMDocument();
- @$doc->loadHTML($text);
+
+ if (mb_detect_encoding($text, "UTF-8", true) == "UTF-8")
+ @$doc->loadHTML('<?xml encoding="UTF-8" ?>'.$text);
+ else
+ @$doc->loadHTML($text);
+
$text = $doc->saveHTML();
$tokenizer = new HTML5_Tokenizer($text, $builder);
<?php
-define( 'UPDATE_VERSION' , 1175 );
+define( 'UPDATE_VERSION' , 1176 );
/**
*