]> git.mxchange.org Git - friendica.git/commitdiff
The "scrape" bugfix lead to partly damaged encodings. This is fixed now.
authorMichael Vogel <icarus@dabo.de>
Sun, 4 Jan 2015 10:56:41 +0000 (11:56 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 4 Jan 2015 10:56:41 +0000 (11:56 +0100)
boot.php
include/dbstructure.php
include/lock.php
library/HTML5/Parser.php
update.php

index 34836a97aa6c570839577375abab5e455bea2d42..7ba74c4f6f67da372497150e7ae9292cbcbe52a9 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 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' );
 
index 66e67c0a9aaf977ca68f0086360fa955d26ca60e..469ae1003085257e222abff719e8779f89d14781 100644 (file)
@@ -823,6 +823,7 @@ function db_definition() {
                                        "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"),
index caf1f855ab98264d7b02aee6152bc213f2b981cb..70cf4b787b439dbf25c5c135965cd0b3b4bfad24 100644 (file)
@@ -11,20 +11,22 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
        $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;
                }
@@ -37,7 +39,7 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
        } 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;
 }}
 
@@ -65,7 +67,7 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
 
 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)
             );
 
index c7faf875ad326304c44f65aa3f64ff63b07924c6..e101d3e545ad5e1f7245fba9be5b5b6c3663de86 100644 (file)
@@ -20,7 +20,12 @@ class HTML5_Parser
 
        // 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);
index 10195c1baa39414e56eea937f6861fd8a0c7a895..97b0bd58dcb1188d7485dd1bf8e2e4b6646c749d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1175 );
+define( 'UPDATE_VERSION' , 1176 );
 
 /**
  *