viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]
diff --git a/src/configs/Config.php b/src/configs/Config.php index f98e92d2a..92298f9e6 100755 --- a/src/configs/Config.php +++ b/src/configs/Config.php @@ -77,6 +77,52 @@ if (file_exists(__DIR__."/../../vendor/autoload.php")) { } }); } +/** + * User defined function to perform error handling for yioop if + * the error box was checked in the configure menu. + * + * @param int $errno the level of the error raised, as an integer + * @param string $errstr the error message + * @param string $errfile the filename the error occurred in + * @param int $errline the line number of the error + * @param array $errcontext the context (variables and their values) + * at the point the error occurred + */ +function yioop_error_handler($errno, $errstr, $errfile, $errline, + $errcontext) +{ + $num_lines_of_backtrace = 5; + $error_types = [ + E_NOTICE => 'NOTICE:', E_WARNING => 'WARNING:']; + $type = (isset($error_types[$errno])) ? $error_types[$errno]: + "PHP OTHER ERROR"; + echo "<pre>\n"; + echo "$type $errstr at line $errline in $errfile\n"; + $backtrace = debug_backtrace(); + array_shift($backtrace); + $i = 0; + $in_or_called = "in"; + foreach ($backtrace as $call) { + $function = ""; + if (isset($call['class'])) { + $function .= $call['class']."->"; + } + if (isset($call['function'])) { + $function .= $call['function']; + } + $line = (isset($call['line'])) ? $call['line'] : ""; + $file = (isset($call['file'])) ? $call['file'] : ""; + echo " $in_or_called $function, line $line". + " in $file \n"; + $in_or_called = "called from"; + $i++; + if ($i >= $num_lines_of_backtrace) {break; } + } + if (count($backtrace) > $num_lines_of_backtrace) { + echo "...\n"; + } + echo "</pre>"; +} /** * Define a constant in the Yioop configs namespace (seekquarry\yioop) * @param string $constant the name of the constant to define @@ -594,7 +640,7 @@ function defineMemoryProfile() } else if (stristr(PHP_OS, "LINUX")) { set_error_handler(null); $mem_data = @file_get_contents("/proc/meminfo"); - set_error_handler(NS_LIB . "yioop_error_handler"); + set_error_handler(NS_CONFIGS . "yioop_error_handler"); if (!empty($mem_data)) { $data = preg_split("/\s+/", $mem_data); $memory = 1024 * intval($data[1]); diff --git a/src/controllers/ResourceController.php b/src/controllers/ResourceController.php index 50a8d5d80..bfec9f1cc 100644 --- a/src/controllers/ResourceController.php +++ b/src/controllers/ResourceController.php @@ -132,7 +132,7 @@ class ResourceController extends Controller implements CrawlConstants $image_page = FetchUrl::getPage($image_url); set_error_handler(null); $image = @imagecreatefromstring($image_page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $thumb = ImageProcessor::createThumb($image); if (!empty($thumb)) { $this->web_site->filePutContents($path, $thumb); diff --git a/src/controllers/SearchController.php b/src/controllers/SearchController.php index b9cc09243..1a559f396 100755 --- a/src/controllers/SearchController.php +++ b/src/controllers/SearchController.php @@ -1587,7 +1587,7 @@ class SearchController extends Controller implements CrawlConstants $dom = new \DOMDocument(); @$dom->loadHTML($cache_file); } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $body = $dom->getElementsByTagName('body')->item(0); if (!$body) { return $cache_file; diff --git a/src/controllers/components/CrawlComponent.php b/src/controllers/components/CrawlComponent.php index 6e104724b..e0c19db5d 100644 --- a/src/controllers/components/CrawlComponent.php +++ b/src/controllers/components/CrawlComponent.php @@ -704,7 +704,7 @@ class CrawlComponent extends Component implements CrawlConstants if (!empty($_REQUEST['recompute'])) { set_error_handler(null); @unlink($stats_file); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } if (!file_exists($stats_file)) { $info = $crawl_model->getInfoTimestamp($data['its'], @@ -1468,7 +1468,7 @@ class CrawlComponent extends Component implements CrawlConstants $doc_info = $page_processor->handle( substr($_REQUEST['TESTPAGE'], 0, $data["PAGE_RANGE_REQUEST"]), $site[self::URL]); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (!$doc_info) { $data["AFTER_PAGE_PROCESS"] = ""; $data["AFTER_RULE_PROCESS"] = ""; diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php index da3738873..84b947170 100644 --- a/src/controllers/components/SocialComponent.php +++ b/src/controllers/components/SocialComponent.php @@ -980,7 +980,7 @@ class SocialComponent extends Component implements CrawlConstants strtotime($item['pubdate'], 0) : $i; $items[$pos] = $item; } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); ksort($items); $threads = []; foreach ($items as $item) { @@ -2603,7 +2603,7 @@ class SocialComponent extends Component implements CrawlConstants set_error_handler(null); $page_data = @unserialize(base64_decode( $data['PAGE'])); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (is_array($page_data)) { foreach ($page_data as $page_key => $page_value) { @@ -2743,7 +2743,7 @@ EOD; $page_data = @unserialize(base64_decode(substr( $data['PAGE'], strlen('<div>'), -strlen('</div>')))); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (is_array($page_data)) { foreach ($page_data as $page_key => $page_value) { @@ -2896,7 +2896,7 @@ EOD; } set_error_handler(null); $sort_map = @unserialize(L\webdecode($data["HEAD"]['sort'])); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $sort_key = (empty($data['SUB_PATH'])) ? "." : $data['SUB_PATH']; $sort_key = rtrim($sort_key, '/'); if (empty($sort_map[$sort_key])) { diff --git a/src/executables/Fetcher.php b/src/executables/Fetcher.php index 257a660f9..d62360916 100755 --- a/src/executables/Fetcher.php +++ b/src/executables/Fetcher.php @@ -1764,7 +1764,7 @@ class Fetcher implements CrawlConstants @mb_convert_encoding($site[self::PAGE], "UTF-8", $site[self::ENCODING]); } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } $page_processor = get_class($processor); L\crawlLog(" Using Processor..." . substr($page_processor, diff --git a/src/executables/QueueServer.php b/src/executables/QueueServer.php index 7a39879d4..694e97745 100755 --- a/src/executables/QueueServer.php +++ b/src/executables/QueueServer.php @@ -712,7 +712,7 @@ class QueueServer implements CrawlConstants, Join set_error_handler(null); $decode = @gzuncompress($decode); $sites = @unserialize($decode); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $sites; } /** diff --git a/src/index.php b/src/index.php index e4f51cc2e..68efc0d16 100644 --- a/src/index.php +++ b/src/index.php @@ -72,7 +72,7 @@ function bootstrap($web_site = null, $start_new_session = true) */ configureRewrites($web_site); if ((C\DEBUG_LEVEL & C\ERROR_INFO) == C\ERROR_INFO) { - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } /** * Load global functions related to localization diff --git a/src/library/FetchUrl.php b/src/library/FetchUrl.php index 0f030e194..d11e4555f 100755 --- a/src/library/FetchUrl.php +++ b/src/library/FetchUrl.php @@ -233,7 +233,7 @@ class FetchUrl implements CrawlConstants } } while (memory_get_usage() < $memory_limit && $mrc == $mrc_check && time() - $start < C\PAGE_TIMEOUT && $running > 0); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (time() - $start > C\PAGE_TIMEOUT && $timer) { crawlLog(" TIMED OUT!!!"); } diff --git a/src/library/ScraperManager.php b/src/library/ScraperManager.php index c8edce208..17777d9e6 100644 --- a/src/library/ScraperManager.php +++ b/src/library/ScraperManager.php @@ -123,7 +123,7 @@ class ScraperManager $results = $xpath->query($signature); } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return !empty($results->length) && $results->length > 0; } else { return (mb_ereg($signature, $page) !== false); @@ -148,7 +148,7 @@ class ScraperManager $result = $dom->saveHTML($xpath_result->item(0)); } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $result; } /** @@ -179,7 +179,7 @@ class ScraperManager $result = $dom->saveHTML(); } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $result; } } \ No newline at end of file diff --git a/src/library/UpgradeFunctions.php b/src/library/UpgradeFunctions.php index 4c579024f..f8e699e5a 100644 --- a/src/library/UpgradeFunctions.php +++ b/src/library/UpgradeFunctions.php @@ -140,7 +140,7 @@ function upgradeDatabaseWorkDirectoryCheck() } sleep(3); } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); webExit(); } /** @@ -166,7 +166,7 @@ function upgradeDatabaseWorkDirectory() } else { webExit(); // maybe someone else has locked DB, so bail } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $result = null; //don't lock db if sqlite $versions = range(1, C\YIOOP_VERSION); $key = array_search($current_version, $versions); diff --git a/src/library/Utility.php b/src/library/Utility.php index 33558500d..d78e02197 100755 --- a/src/library/Utility.php +++ b/src/library/Utility.php @@ -37,52 +37,6 @@ use seekquarry\yioop\configs as C; /** For Yioop global defines */ require_once __DIR__."/../configs/Config.php"; -/** - * User defined function to perform error handling for yioop if - * the error box was checked in the configure menu. - * - * @param int $errno the level of the error raised, as an integer - * @param string $errstr the error message - * @param string $errfile the filename the error occurred in - * @param int $errline the line number of the error - * @param array $errcontext the context (variables and their values) - * at the point the error occurred - */ -function yioop_error_handler($errno, $errstr, $errfile, $errline, - $errcontext) -{ - $num_lines_of_backtrace = 5; - $error_types = [ - E_NOTICE => 'NOTICE:', E_WARNING => 'WARNING:']; - $type = (isset($error_types[$errno])) ? $error_types[$errno]: - "PHP OTHER ERROR"; - echo "<pre>\n"; - echo "$type $errstr at line $errline in $errfile\n"; - $backtrace = debug_backtrace(); - array_shift($backtrace); - $i = 0; - $in_or_called = "in"; - foreach ($backtrace as $call) { - $function = ""; - if (isset($call['class'])) { - $function .= $call['class']."->"; - } - if (isset($call['function'])) { - $function .= $call['function']; - } - $line = (isset($call['line'])) ? $call['line'] : ""; - $file = (isset($call['file'])) ? $call['file'] : ""; - echo " $in_or_called $function, line $line". - " in $file \n"; - $in_or_called = "called from"; - $i++; - if ($i >= $num_lines_of_backtrace) {break; } - } - if (count($backtrace) > $num_lines_of_backtrace) { - echo "...\n"; - } - echo "</pre>"; -} /** * Adds delimiters to a regex that may or may not have them * @@ -1742,7 +1696,7 @@ function setWorldPermissions($file) } set_error_handler(null); chmod($file, 0777); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } /** * This is a callback function used in the process of recursively calculating diff --git a/src/library/WebArchive.php b/src/library/WebArchive.php index 7522ce788..5fc1e9725 100755 --- a/src/library/WebArchive.php +++ b/src/library/WebArchive.php @@ -342,7 +342,7 @@ class WebArchive set_error_handler(null); $file = $this->compressor->uncompress($compressed_file); $object = @unserialize($file); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $offset += $compressed_int_len + $len; $objects[] = [$offset, $object]; } else { diff --git a/src/library/WebSite.php b/src/library/WebSite.php index 59e4c760e..3bdc8a1e0 100644 --- a/src/library/WebSite.php +++ b/src/library/WebSite.php @@ -350,7 +350,7 @@ class WebSite $out_cookie .= "; Expires=" . @gmdate("D, d M Y H:i:s", $expire) . " GMT"; set_error_handler( - "seekquarry\\yioop\\library\\yioop_error_handler"); + "seekquarry\\yioop\\configs\\yioop_error_handler"); } if ($path != "") { $out_cookie .= "; Path=$path"; @@ -1470,7 +1470,7 @@ class WebSite @stream_socket_shutdown($this->in_streams[self::CONNECTION][$key], STREAM_SHUT_RDWR); set_error_handler( - "seekquarry\\yioop\\library\\yioop_error_handler"); + "seekquarry\\yioop\\configs\\yioop_error_handler"); } unset($this->in_streams[self::CONNECTION][$key], $this->in_streams[self::CONTEXT][$key], diff --git a/src/library/archive_bundle_iterators/MediaWikiArchiveBundleIterator.php b/src/library/archive_bundle_iterators/MediaWikiArchiveBundleIterator.php index 721ca3882..9ac75dda4 100644 --- a/src/library/archive_bundle_iterators/MediaWikiArchiveBundleIterator.php +++ b/src/library/archive_bundle_iterators/MediaWikiArchiveBundleIterator.php @@ -145,7 +145,7 @@ EOD; strrpos($pre_host_name, "/") + 1); set_error_handler(null); $url_parts = @parse_url($this->header['base_address']); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $this->header['ip_address'] = gethostbyname($url_parts['host']); return true; } @@ -255,7 +255,7 @@ EOD; $dom = new \DOMDocument(); set_error_handler(null); @$dom->loadXML($page_info); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $site = []; $pre_url = $this->getTextContent($dom, "/page/title"); $pre_url = str_replace(" ", "_", $pre_url); diff --git a/src/library/index_bundle_iterators/NetworkIterator.php b/src/library/index_bundle_iterators/NetworkIterator.php index f7c63fb68..9fd657bb0 100644 --- a/src/library/index_bundle_iterators/NetworkIterator.php +++ b/src/library/index_bundle_iterators/NetworkIterator.php @@ -241,7 +241,7 @@ class NetworkIterator extends IndexBundleIterator if (isset($download[self::PAGE]) && $download[self::PAGE]) { set_error_handler(null); $pre_result = @unserialize($download[self::PAGE]); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (!isset($pre_result["TOTAL_ROWS"]) || $pre_result["TOTAL_ROWS"] < $this->results_per_block) { $this->more_flags[$lookup[$j]] = false; diff --git a/src/library/indexing_plugins/RecipePlugin.php b/src/library/indexing_plugins/RecipePlugin.php index ff7d28dcd..102d01620 100644 --- a/src/library/indexing_plugins/RecipePlugin.php +++ b/src/library/indexing_plugins/RecipePlugin.php @@ -225,7 +225,7 @@ class RecipePlugin extends IndexingPlugin implements CrawlConstants $more_docs = false; } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); L\crawlLog("...Clustering from $up_to_last_shard_num to "); $up_to_last_shard_num += self::NUM_RECIPES_PER_SHARD; L\crawlLog("...to $up_to_last_shard_num"); diff --git a/src/library/media_jobs/FeedsUpdateJob.php b/src/library/media_jobs/FeedsUpdateJob.php index f9bc39947..38f433393 100644 --- a/src/library/media_jobs/FeedsUpdateJob.php +++ b/src/library/media_jobs/FeedsUpdateJob.php @@ -584,7 +584,7 @@ class FeedsUpdateJob extends MediaJob @chmod($feed_shard_name, 0777); @rename($prune_shard_name, $feed_shard_name); @chmod($feed_shard_name, 0777); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); L\crawlLog("----..deleting old feed items"); $sql = "DELETE FROM FEED_ITEM WHERE PUBDATE < ?"; $db->execute($sql, [$too_old]); diff --git a/src/library/media_jobs/VideoConvertJob.php b/src/library/media_jobs/VideoConvertJob.php index 89b31eeb0..911873cbd 100644 --- a/src/library/media_jobs/VideoConvertJob.php +++ b/src/library/media_jobs/VideoConvertJob.php @@ -100,7 +100,7 @@ class VideoConvertJob extends MediaJob if (!file_exists($convert_folder)) { set_error_handler(null); @mkdir($convert_folder); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (!file_exists($convert_folder)) { L\crawlLog("----Unable to create $convert_folder. Bailing!"); return; diff --git a/src/library/processors/DocxProcessor.php b/src/library/processors/DocxProcessor.php index 18fa5403f..479da1983 100644 --- a/src/library/processors/DocxProcessor.php +++ b/src/library/processors/DocxProcessor.php @@ -162,7 +162,7 @@ class DocxProcessor extends TextProcessor $dom = new \DOMDocument(); set_error_handler(null); @$dom->loadXML($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $dom; } /** diff --git a/src/library/processors/GifProcessor.php b/src/library/processors/GifProcessor.php index 00818ce71..e7274b65c 100755 --- a/src/library/processors/GifProcessor.php +++ b/src/library/processors/GifProcessor.php @@ -76,7 +76,7 @@ class GifProcessor extends ImageProcessor if (is_string($page)) { set_error_handler(null); $image = @imagecreatefromstring($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $thumb_string = self::createThumb($image); $summary[self::TITLE] = ""; $summary[self::DESCRIPTION] = diff --git a/src/library/processors/HtmlProcessor.php b/src/library/processors/HtmlProcessor.php index a96fc4ef5..675574272 100755 --- a/src/library/processors/HtmlProcessor.php +++ b/src/library/processors/HtmlProcessor.php @@ -213,7 +213,7 @@ class HtmlProcessor extends TextProcessor //this hack modified from php.net set_error_handler(null); @$dom->loadHTML('<?xml encoding="UTF-8">' . $page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); foreach ($dom->childNodes as $item) { if (isset($item->nodeType) && $item->nodeType == XML_PI_NODE) { $dom->removeChild($item); // remove hack diff --git a/src/library/processors/ImageProcessor.php b/src/library/processors/ImageProcessor.php index 7322f6e07..72dd4622f 100755 --- a/src/library/processors/ImageProcessor.php +++ b/src/library/processors/ImageProcessor.php @@ -74,7 +74,7 @@ class ImageProcessor extends PageProcessor set_error_handler(null); @imagecopyresampled($thumb, $image, 0,0, 0,0, C\THUMB_DIM, C\THUMB_DIM, $size_x, $size_y); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); imagedestroy($image); } ob_start(); diff --git a/src/library/processors/JpgProcessor.php b/src/library/processors/JpgProcessor.php index 71d6d4fc3..95b70c1dd 100755 --- a/src/library/processors/JpgProcessor.php +++ b/src/library/processors/JpgProcessor.php @@ -79,7 +79,7 @@ class JpgProcessor extends ImageProcessor if (is_string($page)) { set_error_handler(null); $image = @imagecreatefromstring($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $thumb_string = self::createThumb($image); $summary[self::TITLE] = ""; $summary[self::DESCRIPTION] = "Image of ". diff --git a/src/library/processors/PdfProcessor.php b/src/library/processors/PdfProcessor.php index 03e3dfb02..4fccdf38c 100755 --- a/src/library/processors/PdfProcessor.php +++ b/src/library/processors/PdfProcessor.php @@ -124,7 +124,7 @@ class PdfProcessor extends TextProcessor } } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $font_pos = strpos($out, "PS-AdobeFont"); if (!$font_pos) { $font_pos = strlen($out); diff --git a/src/library/processors/PngProcessor.php b/src/library/processors/PngProcessor.php index 582571d04..f2372a5b3 100755 --- a/src/library/processors/PngProcessor.php +++ b/src/library/processors/PngProcessor.php @@ -76,7 +76,7 @@ class PngProcessor extends ImageProcessor if (is_string($page)) { set_error_handler(null); $image = @imagecreatefromstring($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); $thumb_string = self::createThumb($image); $summary[self::TITLE] = ""; $summary[self::DESCRIPTION] = "Image of ". diff --git a/src/library/processors/PptxProcessor.php b/src/library/processors/PptxProcessor.php index c63b6bdde..129158873 100644 --- a/src/library/processors/PptxProcessor.php +++ b/src/library/processors/PptxProcessor.php @@ -180,7 +180,7 @@ class PptxProcessor extends TextProcessor $dom = new \DOMDocument(); set_error_handler(null); @$dom->loadXML($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $dom; } /** diff --git a/src/library/processors/SvgProcessor.php b/src/library/processors/SvgProcessor.php index a3ef3cf20..390ce1c0a 100644 --- a/src/library/processors/SvgProcessor.php +++ b/src/library/processors/SvgProcessor.php @@ -146,7 +146,7 @@ class SvgProcessor extends TextProcessor $dom = new \DOMDocument(); set_error_handler(null); @$dom->loadXML($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $dom; } /** diff --git a/src/library/processors/TextProcessor.php b/src/library/processors/TextProcessor.php index 6a2bf5028..4c7c6e041 100755 --- a/src/library/processors/TextProcessor.php +++ b/src/library/processors/TextProcessor.php @@ -252,7 +252,7 @@ class TextProcessor extends PageProcessor } } $dom->encoding = "UTF-8"; // insert proper - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $dom; } } diff --git a/src/library/processors/XlsxProcessor.php b/src/library/processors/XlsxProcessor.php index ba28edb1d..1c2227460 100644 --- a/src/library/processors/XlsxProcessor.php +++ b/src/library/processors/XlsxProcessor.php @@ -133,7 +133,7 @@ class XlsxProcessor extends TextProcessor $dom = new \DOMDocument(); set_error_handler(null); @$dom->loadXML($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $dom; } /** diff --git a/src/library/processors/XmlProcessor.php b/src/library/processors/XmlProcessor.php index 896102492..e11534fec 100644 --- a/src/library/processors/XmlProcessor.php +++ b/src/library/processors/XmlProcessor.php @@ -111,7 +111,7 @@ class XmlProcessor extends TextProcessor set_error_handler(null); $dom = new \DOMDocument(); @$dom->loadXML($page); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $dom; } } diff --git a/src/library/summarizers/CentroidSummarizer.php b/src/library/summarizers/CentroidSummarizer.php index 54c1c0561..355ac8077 100644 --- a/src/library/summarizers/CentroidSummarizer.php +++ b/src/library/summarizers/CentroidSummarizer.php @@ -164,7 +164,7 @@ class CentroidSummarizer extends Summarizer $wc[$j] = 0; } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); /* Calculate centroid */ arsort($wc); $centroid = array_slice($wc, 0, self::CENTROID_COMPONENTS, true); diff --git a/src/library/summarizers/CentroidWeightedSummarizer.php b/src/library/summarizers/CentroidWeightedSummarizer.php index d31a251e9..fa4dd92d6 100644 --- a/src/library/summarizers/CentroidWeightedSummarizer.php +++ b/src/library/summarizers/CentroidWeightedSummarizer.php @@ -164,7 +164,7 @@ class CentroidWeightedSummarizer extends Summarizer $wc[$j] = 0; } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); /* Calculate centroid */ arsort($wc); $centroid = array_slice($wc, 0, self::CENTROID_COMPONENTS, true); diff --git a/src/models/CrawlModel.php b/src/models/CrawlModel.php index d8c8eecb1..b37bb1655 100755 --- a/src/models/CrawlModel.php +++ b/src/models/CrawlModel.php @@ -823,7 +823,7 @@ EOT; $a_info['COUNT']; } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); file_put_contents($cache_file, serialize($info)); return $info; } @@ -1064,7 +1064,7 @@ EOT; if (isset($info['DESCRIPTION'])) { set_error_handler(null); $index_info = @unserialize($info['DESCRIPTION']); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } else { $index_info = []; $index_info['DESCRIPTION'] = "ERROR!! $dir<br />" . @@ -1184,7 +1184,7 @@ EOT; } } $list = array_values($pre_list); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $list; } /** @@ -1253,7 +1253,7 @@ EOT; break; } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $result; } /** @@ -1384,7 +1384,7 @@ EOT; max($status[$field], $a_status[$field]); } } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return $status; } /** diff --git a/src/models/CronModel.php b/src/models/CronModel.php index 21a612d73..a2fbcaf15 100644 --- a/src/models/CronModel.php +++ b/src/models/CronModel.php @@ -118,7 +118,7 @@ class CronModel extends Model file_put_contents($this->cron_file, serialize($this->cron_table)); set_error_handler(null); @chmod($this->cron_file, 0777); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } } /** @@ -129,6 +129,6 @@ class CronModel extends Model file_put_contents($this->cron_file, serialize($this->cron_table)); set_error_handler(null); @chmod($this->cron_file, 0777); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } } diff --git a/src/models/GroupModel.php b/src/models/GroupModel.php index e513d46c8..6f4403e5e 100644 --- a/src/models/GroupModel.php +++ b/src/models/GroupModel.php @@ -3086,7 +3086,7 @@ class GroupModel extends Model implements MediaConstants ob_start(); $exif = @exif_read_data("$folder/$file_name"); ob_end_clean(); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 8: diff --git a/src/models/ParallelModel.php b/src/models/ParallelModel.php index 02e78ce6e..3757f368b 100755 --- a/src/models/ParallelModel.php +++ b/src/models/ParallelModel.php @@ -166,7 +166,7 @@ class ParallelModel extends Model $description_hash = []; set_error_handler(null); $result = @unserialize(L\webdecode($elt[self::PAGE])); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if (!is_array($result)) { $elapsed_times[] = 0; continue; diff --git a/src/models/ProfileModel.php b/src/models/ProfileModel.php index abb8cd07b..6b214620f 100755 --- a/src/models/ProfileModel.php +++ b/src/models/ProfileModel.php @@ -616,7 +616,7 @@ EOT; $new_profile_data['AUXILIARY_CSS']); @chmod($css_file, 0777); } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); return true; } return false; @@ -636,7 +636,7 @@ EOT; set_error_handler(null); @mkdir($directory); @chmod($directory, 0777); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } if (file_exists($directory)) { return 1; @@ -813,7 +813,7 @@ EOT; */ $sql = "SELECT LOCALE_ID FROM LOCALE"; $result = $test_dbm->execute($sql); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); if ($result !== false && $test_dbm->fetchArray($result) !== false) { return true; } diff --git a/src/models/datasources/PdoManager.php b/src/models/datasources/PdoManager.php index 3f680bb3d..3e55cfa7f 100644 --- a/src/models/datasources/PdoManager.php +++ b/src/models/datasources/PdoManager.php @@ -112,8 +112,11 @@ class PdoManager extends DatasourceManager if ($last_sql != $sql) { $statement = null;//garbage collect so don't sqlite lock } + if (empty($this->pdo)) { + return false; + } if ($params) { - if (!$statement && !empty($this->pdo)) { + if (!$statement) { $statement = $this->pdo->prepare($sql); } if (!$statement) { diff --git a/tests/HashTableTest.php b/tests/HashTableTest.php index 9583cdf7b..18d8cb42b 100755 --- a/tests/HashTableTest.php +++ b/tests/HashTableTest.php @@ -65,7 +65,7 @@ class HashTableTest extends UnitTest set_error_handler(null); @unlink(C\WORK_DIRECTORY."/hash1.txt"); @unlink(C\WORK_DIRECTORY."/hash2.txt"); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } /** * Check if for the big hash table we insert something then later look it diff --git a/tests/IndexShardTest.php b/tests/IndexShardTest.php index 9a58e7b88..53198f7da 100644 --- a/tests/IndexShardTest.php +++ b/tests/IndexShardTest.php @@ -66,7 +66,7 @@ class IndexShardTest extends UnitTest @unlink(C\WORK_DIRECTORY."/shard.txt"); @unlink(C\WORK_DIRECTORY."/shard2.txt"); @unlink(C\WORK_DIRECTORY."/shard3.txt"); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } /** * Check if can store documents into an index shard and retrieve them diff --git a/tests/PriorityQueueTest.php b/tests/PriorityQueueTest.php index 7f77abbbf..2f1683e4d 100755 --- a/tests/PriorityQueueTest.php +++ b/tests/PriorityQueueTest.php @@ -65,7 +65,7 @@ class PriorityQueueTest extends UnitTest set_error_handler(null); @unlink(C\WORK_DIRECTORY."/queue1.txt"); @unlink(C\WORK_DIRECTORY."/queue2.txt"); - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } /** * Insert five items into a priority queue. Checks that the resulting heap diff --git a/tests/StringArrayTest.php b/tests/StringArrayTest.php index a940c0006..4d77fc78f 100644 --- a/tests/StringArrayTest.php +++ b/tests/StringArrayTest.php @@ -62,7 +62,7 @@ class StringArrayTest extends UnitTest if (file_exists(C\WORK_DIRECTORY . "/array.txt")) { @unlink(C\WORK_DIRECTORY . "/array.txt"); } - set_error_handler(C\NS_LIB . "yioop_error_handler"); + set_error_handler(C\NS_CONFIGS . "yioop_error_handler"); } /** * Check if can put objects into string array and retrieve them