From 465fb16d3312b302fdf8fe0ceb8dfa51b6ad239b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 30 Mar 2016 13:45:27 +0300 Subject: [PATCH] remove fetch_file_contents2, use a compat shim instead --- include/functions.php | 41 ++++++++++++++++++++--------------------- include/functions2.php | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/functions.php b/include/functions.php index 6a230a153..0a74db85c 100755 --- a/include/functions.php +++ b/include/functions.php @@ -333,25 +333,9 @@ } } - // TODO: deprecated, remove - function fetch_file_contents($url, $type = false, $login = false, $pass = false, $post_query = false, - $timeout = false, $timestamp = 0, $useragent = false) { - - $options = array( - "url" => $url, - "type" => $type, - "login" => $login, - "pass" => $pass, - "post_query" => $post_query, - "timeout" => $timeout, - "timestamp" => $timestamp, - "useragent" => $useragent - ); - - return fetch_file_contents2($options); - } - - function fetch_file_contents2($options) { + // TODO: multiple-argument way is deprecated, first parameter is a hash now + function fetch_file_contents($options /* previously: 0: $url , 1: $type = false, 2: $login = false, 3: $pass = false, + 4: $post_query = false, 5: $timeout = false, 6: $timestamp = 0, 7: $useragent = false*/) { global $fetch_last_error; global $fetch_last_error_code; @@ -359,15 +343,30 @@ global $fetch_last_content_type; global $fetch_curl_used; + if (!is_array($options) && func_num_args() > 1) { + + // falling back on compatibility shim + $options = array( + "url" => func_get_arg(0), + "type" => @func_get_arg(1), + "login" => @func_get_arg(2), + "pass" => @func_get_arg(3), + "post_query" => @func_get_arg(4), + "timeout" => @func_get_arg(5), + "timestamp" => @func_get_arg(6), + "useragent" => @func_get_arg(7) + ); + } + $url = $options["url"]; $type = isset($options["type"]) ? $options["type"] : false; $login = isset($options["login"]) ? $options["login"] : false; - $pass = isset($options["pass"]) ? $options["pass"] : false; + $pass = isset($options["pass"]) ? $options["pass"] : false; $post_query = isset($options["post_query"]) ? $options["post_query"] : false; $timeout = isset($options["timeout"]) ? $options["timeout"] : false; $timestamp = isset($options["timestamp"]) ? $options["timestamp"] : 0; $useragent = isset($options["useragent"]) ? $options["useragent"] : false; - + $url = ltrim($url, ' '); $url = str_replace(' ', '%20', $url); diff --git a/include/functions2.php b/include/functions2.php index 5fe527b7e..1c2ffb936 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -203,7 +203,7 @@ function check_for_update() { if (defined("GIT_VERSION_TIMESTAMP")) { - $content = @fetch_file_contents2(array("url" => "http://tt-rss.org/version.json", "timeout" => 5)); + $content = @fetch_file_contents(array("url" => "http://tt-rss.org/version.json", "timeout" => 5)); if ($content) { $content = json_decode($content, true);