Fix some undefined variable/index notices in tests
This commit is contained in:
parent
28741c8366
commit
6776c4e3f9
5 changed files with 29 additions and 21 deletions
|
@ -90,11 +90,15 @@ function api_source()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support for known clients that doesn't send a source name
|
// Support for known clients that doesn't send a source name
|
||||||
if (strpos($_SERVER['HTTP_USER_AGENT'], "Twidere") !== false) {
|
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
if(strpos($_SERVER['HTTP_USER_AGENT'], "Twidere") !== false) {
|
||||||
return "Twidere";
|
return "Twidere";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG);
|
logger("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger("Empty user-agent", LOGGER_DEBUG);
|
||||||
|
|
||||||
return "api";
|
return "api";
|
||||||
}
|
}
|
||||||
|
@ -193,8 +197,8 @@ function api_login(App $a)
|
||||||
throw new UnauthorizedException("This API requires login");
|
throw new UnauthorizedException("This API requires login");
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $_SERVER['PHP_AUTH_USER'];
|
$user = defaults($_SERVER, 'PHP_AUTH_USER', '');
|
||||||
$password = $_SERVER['PHP_AUTH_PW'];
|
$password = defaults($_SERVER, 'PHP_AUTH_PW', '');
|
||||||
|
|
||||||
// allow "user@server" login (but ignore 'server' part)
|
// allow "user@server" login (but ignore 'server' part)
|
||||||
$at = strstr($user, "@", true);
|
$at = strstr($user, "@", true);
|
||||||
|
@ -258,7 +262,7 @@ function api_check_method($method)
|
||||||
if ($method == "*") {
|
if ($method == "*") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (strpos($method, $_SERVER['REQUEST_METHOD']) !== false);
|
return (stripos($method, defaults($_SERVER, 'REQUEST_METHOD', 'GET')) !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,7 +302,7 @@ function api_call(App $a)
|
||||||
//unset($_SERVER['PHP_AUTH_USER']);
|
//unset($_SERVER['PHP_AUTH_USER']);
|
||||||
|
|
||||||
/// @TODO should be "true ==[=] $info['auth']", if you miss only one = character, you assign a variable (only with ==). Let's make all this even.
|
/// @TODO should be "true ==[=] $info['auth']", if you miss only one = character, you assign a variable (only with ==). Let's make all this even.
|
||||||
if ($info['auth'] === true && api_user() === false) {
|
if (!empty($info['auth']) && api_user() === false) {
|
||||||
api_login($a);
|
api_login($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +663,7 @@ function api_get_user(App $a, $contact_id = null)
|
||||||
'geo_enabled' => false,
|
'geo_enabled' => false,
|
||||||
'verified' => false,
|
'verified' => false,
|
||||||
'statuses_count' => 0,
|
'statuses_count' => 0,
|
||||||
'lang' => '',
|
'language' => '',
|
||||||
'contributors_enabled' => false,
|
'contributors_enabled' => false,
|
||||||
'is_translator' => false,
|
'is_translator' => false,
|
||||||
'is_translation_enabled' => false,
|
'is_translation_enabled' => false,
|
||||||
|
@ -740,7 +744,7 @@ function api_get_user(App $a, $contact_id = null)
|
||||||
'geo_enabled' => false,
|
'geo_enabled' => false,
|
||||||
'verified' => true,
|
'verified' => true,
|
||||||
'statuses_count' => intval($countitems),
|
'statuses_count' => intval($countitems),
|
||||||
'lang' => '',
|
'language' => '',
|
||||||
'contributors_enabled' => false,
|
'contributors_enabled' => false,
|
||||||
'is_translator' => false,
|
'is_translator' => false,
|
||||||
'is_translation_enabled' => false,
|
'is_translation_enabled' => false,
|
||||||
|
@ -773,13 +777,13 @@ function api_get_user(App $a, $contact_id = null)
|
||||||
$link_color = PConfig::get($ret['uid'], 'frio', 'link_color');
|
$link_color = PConfig::get($ret['uid'], 'frio', 'link_color');
|
||||||
$bgcolor = PConfig::get($ret['uid'], 'frio', 'background_color');
|
$bgcolor = PConfig::get($ret['uid'], 'frio', 'background_color');
|
||||||
}
|
}
|
||||||
if (!$nav_bg) {
|
if (empty($nav_bg)) {
|
||||||
$nav_bg = "#708fa0";
|
$nav_bg = "#708fa0";
|
||||||
}
|
}
|
||||||
if (!$link_color) {
|
if (empty($link_color)) {
|
||||||
$link_color = "#6fdbe8";
|
$link_color = "#6fdbe8";
|
||||||
}
|
}
|
||||||
if (!$bgcolor) {
|
if (empty($bgcolor)) {
|
||||||
$bgcolor = "#ededed";
|
$bgcolor = "#ededed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,12 +805,12 @@ function api_get_user(App $a, $contact_id = null)
|
||||||
*/
|
*/
|
||||||
function api_item_get_user(App $a, $item)
|
function api_item_get_user(App $a, $item)
|
||||||
{
|
{
|
||||||
$status_user = api_get_user($a, $item["author-id"]);
|
$status_user = api_get_user($a, defaults($item, 'author-id', null));
|
||||||
|
|
||||||
$status_user["protected"] = $item["private"];
|
$status_user["protected"] = defaults($item, 'private', 0);
|
||||||
|
|
||||||
if ($item['thr-parent'] == $item['uri']) {
|
if (defaults($item, 'thr-parent', '') == defaults($item, 'uri', '')) {
|
||||||
$owner_user = api_get_user($a, $item["owner-id"]);
|
$owner_user = api_get_user($a, defaults($item, 'author-id', null));
|
||||||
} else {
|
} else {
|
||||||
$owner_user = $status_user;
|
$owner_user = $status_user;
|
||||||
}
|
}
|
||||||
|
@ -1308,7 +1312,7 @@ function api_status_show($type)
|
||||||
'favorited' => $lastwall['starred'] ? true : false,
|
'favorited' => $lastwall['starred'] ? true : false,
|
||||||
'retweeted' => false,
|
'retweeted' => false,
|
||||||
'possibly_sensitive' => false,
|
'possibly_sensitive' => false,
|
||||||
'lang' => "",
|
'language' => "",
|
||||||
'statusnet_html' => $converted["html"],
|
'statusnet_html' => $converted["html"],
|
||||||
'statusnet_conversation_id' => $lastwall['parent'],
|
'statusnet_conversation_id' => $lastwall['parent'],
|
||||||
'external_url' => System::baseUrl() . "/display/" . $lastwall['guid'],
|
'external_url' => System::baseUrl() . "/display/" . $lastwall['guid'],
|
||||||
|
@ -2205,7 +2209,7 @@ function api_favorites_create_destroy($type)
|
||||||
// for versioned api.
|
// for versioned api.
|
||||||
/// @TODO We need a better global soluton
|
/// @TODO We need a better global soluton
|
||||||
$action_argv_id = 2;
|
$action_argv_id = 2;
|
||||||
if ($a->argv[1] == "1.1") {
|
if (count($a->argv) > 1 && $a->argv[1] == "1.1") {
|
||||||
$action_argv_id = 3;
|
$action_argv_id = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ function new_cookie($time, $user = [])
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$value = json_encode(["uid" => $user["uid"],
|
$value = json_encode(["uid" => $user["uid"],
|
||||||
"hash" => cookie_hash($user),
|
"hash" => cookie_hash($user),
|
||||||
"ip" => $_SERVER['REMOTE_ADDR']]);
|
"ip" => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')]);
|
||||||
} else {
|
} else {
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
||||||
$_SESSION['page_flags'] = $user_record['page-flags'];
|
$_SESSION['page_flags'] = $user_record['page-flags'];
|
||||||
$_SESSION['my_url'] = System::baseUrl() . '/profile/' . $user_record['nickname'];
|
$_SESSION['my_url'] = System::baseUrl() . '/profile/' . $user_record['nickname'];
|
||||||
$_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
|
$_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
|
||||||
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
|
$_SESSION['addr'] = defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0');
|
||||||
|
|
||||||
$a->user = $user_record;
|
$a->user = $user_record;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ class System extends BaseObject
|
||||||
}
|
}
|
||||||
} elseif (!in_array($func['function'], $ignore)) {
|
} elseif (!in_array($func['function'], $ignore)) {
|
||||||
$callstack[] = $func['function'];
|
$callstack[] = $func['function'];
|
||||||
|
$func['class'] = '';
|
||||||
$previous = $func;
|
$previous = $func;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ class Probe
|
||||||
$redirects = 0;
|
$redirects = 0;
|
||||||
|
|
||||||
logger("Probing for ".$host, LOGGER_DEBUG);
|
logger("Probing for ".$host, LOGGER_DEBUG);
|
||||||
|
$xrd = null;
|
||||||
|
|
||||||
$ret = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
$ret = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||||
if ($ret['success']) {
|
if ($ret['success']) {
|
||||||
|
@ -1510,6 +1511,7 @@ class Probe
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$feed = $ret['body'];
|
$feed = $ret['body'];
|
||||||
|
$dummy1 = $dummy2 = $dummy3 = null;
|
||||||
$feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);
|
$feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);
|
||||||
|
|
||||||
if (!$feed_data) {
|
if (!$feed_data) {
|
||||||
|
|
|
@ -629,7 +629,7 @@ class ApiTest extends DatabaseTest
|
||||||
*/
|
*/
|
||||||
public function testApiRssExtra()
|
public function testApiRssExtra()
|
||||||
{
|
{
|
||||||
$user_info = ['url' => 'user_url'];
|
$user_info = ['url' => 'user_url', 'language' => 'en'];
|
||||||
$result = api_rss_extra($this->app, [], $user_info);
|
$result = api_rss_extra($this->app, [], $user_info);
|
||||||
$this->assertEquals($user_info, $result['$user']);
|
$this->assertEquals($user_info, $result['$user']);
|
||||||
$this->assertEquals($user_info['url'], $result['$rss']['alternate']);
|
$this->assertEquals($user_info['url'], $result['$rss']['alternate']);
|
||||||
|
@ -1073,6 +1073,7 @@ class ApiTest extends DatabaseTest
|
||||||
'width' => 666,
|
'width' => 666,
|
||||||
'height' => 666,
|
'height' => 666,
|
||||||
'tmp_name' => $this->getTempImage(),
|
'tmp_name' => $this->getTempImage(),
|
||||||
|
'name' => 'spacer.png',
|
||||||
'type' => 'image/png'
|
'type' => 'image/png'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue