Merge pull request #6219 from MrPetovan/task/remove-x

Remove x()
This commit is contained in:
Michael Vogel 2018-12-01 23:40:51 +01:00 committed by GitHub
commit 5a3991d4f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
101 changed files with 895 additions and 949 deletions

View file

@ -1061,7 +1061,7 @@ class Contact extends BaseObject
$update_contact = ($contact['avatar-date'] < DateTimeFormat::utc('now -7 days'));
// We force the update if the avatar is empty
if (!x($contact, 'avatar')) {
if (empty($contact['avatar'])) {
$update_contact = true;
}
if (!$update_contact || $no_update) {
@ -1618,7 +1618,7 @@ class Contact extends BaseObject
return $result;
}
if (x($arr['contact'], 'name')) {
if (!empty($arr['contact']['name'])) {
$ret = $arr['contact'];
} else {
$ret = Probe::uri($url, $network, $uid, false);
@ -1664,16 +1664,15 @@ class Contact extends BaseObject
}
// do we have enough information?
if (!((x($ret, 'name')) && (x($ret, 'poll')) && ((x($ret, 'url')) || (x($ret, 'addr'))))) {
if (empty($ret['name']) || empty($ret['poll']) || (empty($ret['url']) && empty($ret['addr']))) {
$result['message'] .= L10n::t('The profile address specified does not provide adequate information.') . EOL;
if (!x($ret, 'poll')) {
if (empty($ret['poll'])) {
$result['message'] .= L10n::t('No compatible communication protocols or feeds were discovered.') . EOL;
}
if (!x($ret, 'name')) {
if (empty($ret['name'])) {
$result['message'] .= L10n::t('An author or name was not found.') . EOL;
}
if (!x($ret, 'url')) {
if (empty($ret['url'])) {
$result['message'] .= L10n::t('No browser URL could be matched to this address.') . EOL;
}
if (strpos($url, '@') !== false) {

View file

@ -276,10 +276,10 @@ class FileTag
}
if ($cat == true) {
$pattern = '<' . self::encode($file) . '>' ;
$pattern = '<' . self::encode($file) . '>';
$termtype = TERM_CATEGORY;
} else {
$pattern = '[' . self::encode($file) . ']' ;
$pattern = '[' . self::encode($file) . ']';
$termtype = TERM_FILE;
}

View file

@ -33,7 +33,7 @@ class Group extends BaseObject
public static function create($uid, $name)
{
$return = false;
if (x($uid) && x($name)) {
if (!empty($uid) && !empty($name)) {
$gid = self::getIdByName($uid, $name); // check for dupes
if ($gid !== false) {
// This could be a problem.
@ -202,7 +202,7 @@ class Group extends BaseObject
*/
public static function removeByName($uid, $name) {
$return = false;
if (x($uid) && x($name)) {
if (!empty($uid) && !empty($name)) {
$gid = self::getIdByName($uid, $name);
$return = self::remove($gid);

View file

@ -1359,15 +1359,15 @@ class Item extends BaseObject
$item['owner-name'] = trim(defaults($item, 'owner-name', ''));
$item['owner-link'] = trim(defaults($item, 'owner-link', ''));
$item['owner-avatar'] = trim(defaults($item, 'owner-avatar', ''));
$item['received'] = ((x($item, 'received') !== false) ? DateTimeFormat::utc($item['received']) : DateTimeFormat::utcNow());
$item['created'] = ((x($item, 'created') !== false) ? DateTimeFormat::utc($item['created']) : $item['received']);
$item['edited'] = ((x($item, 'edited') !== false) ? DateTimeFormat::utc($item['edited']) : $item['created']);
$item['changed'] = ((x($item, 'changed') !== false) ? DateTimeFormat::utc($item['changed']) : $item['created']);
$item['commented'] = ((x($item, 'commented') !== false) ? DateTimeFormat::utc($item['commented']) : $item['created']);
$item['received'] = (isset($item['received']) ? DateTimeFormat::utc($item['received']) : DateTimeFormat::utcNow());
$item['created'] = (isset($item['created']) ? DateTimeFormat::utc($item['created']) : $item['received']);
$item['edited'] = (isset($item['edited']) ? DateTimeFormat::utc($item['edited']) : $item['created']);
$item['changed'] = (isset($item['changed']) ? DateTimeFormat::utc($item['changed']) : $item['created']);
$item['commented'] = (isset($item['commented']) ? DateTimeFormat::utc($item['commented']) : $item['created']);
$item['title'] = trim(defaults($item, 'title', ''));
$item['location'] = trim(defaults($item, 'location', ''));
$item['coord'] = trim(defaults($item, 'coord', ''));
$item['visible'] = ((x($item, 'visible') !== false) ? intval($item['visible']) : 1);
$item['visible'] = (isset($item['visible']) ? intval($item['visible']) : 1);
$item['deleted'] = 0;
$item['parent-uri'] = trim(defaults($item, 'parent-uri', $item['uri']));
$item['post-type'] = defaults($item, 'post-type', self::PT_ARTICLE);
@ -1626,7 +1626,7 @@ class Item extends BaseObject
// It is mainly used in the "post_local" hook.
unset($item['api_source']);
if (x($item, 'cancel')) {
if (!empty($item['cancel'])) {
Logger::log('post cancelled by addon.');
return 0;
}
@ -3443,7 +3443,7 @@ class Item extends BaseObject
$filesubtype = 'unkn';
}
$title = Strings::escapeHtml(trim(!empty($mtch[4]) ? $mtch[4] : $mtch[1]));
$title = Strings::escapeHtml(trim(defaults($mtch, 4, $mtch[1])));
$title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes');
$icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
@ -3455,7 +3455,7 @@ class Item extends BaseObject
}
// Map.
if (strpos($s, '<div class="map">') !== false && x($item, 'coord')) {
if (strpos($s, '<div class="map">') !== false && !empty($item['coord'])) {
$x = Map::byCoordinates(trim($item['coord']));
if ($x) {
$s = preg_replace('/\<div class\=\"map\"\>/', '$0' . $x, $s);

View file

@ -97,7 +97,7 @@ class Photo
$photo = DBA::selectFirst(
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
);
if (x($photo['resource-id'])) {
if (!empty($photo['resource-id'])) {
$hash = $photo['resource-id'];
} else {
$hash = self::newResource();

View file

@ -288,7 +288,7 @@ class Profile
$location = false;
// This function can also use contact information in $profile
$is_contact = x($profile, 'cid');
$is_contact = !empty($profile['cid']);
if (!is_array($profile) && !count($profile)) {
return $o;
@ -357,7 +357,7 @@ class Profile
// See issue https://github.com/friendica/friendica/issues/3838
// Either we remove the message link for remote users or we enable creating messages from remote users
if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
if (remote_user() || (self::getMyURL() && !empty($profile['unkmail']) && ($profile['uid'] != local_user()))) {
$wallmessage = L10n::t('Message');
if (remote_user()) {
@ -424,23 +424,23 @@ class Profile
// Fetch the account type
$account_type = Contact::getAccountType($profile);
if (x($profile, 'address')
|| x($profile, 'location')
|| x($profile, 'locality')
|| x($profile, 'region')
|| x($profile, 'postal-code')
|| x($profile, 'country-name')
if (!empty($profile['address'])
|| !empty($profile['location'])
|| !empty($profile['locality'])
|| !empty($profile['region'])
|| !empty($profile['postal-code'])
|| !empty($profile['country-name'])
) {
$location = L10n::t('Location:');
}
$gender = x($profile, 'gender') ? L10n::t('Gender:') : false;
$marital = x($profile, 'marital') ? L10n::t('Status:') : false;
$homepage = x($profile, 'homepage') ? L10n::t('Homepage:') : false;
$about = x($profile, 'about') ? L10n::t('About:') : false;
$xmpp = x($profile, 'xmpp') ? L10n::t('XMPP:') : false;
$gender = !empty($profile['gender']) ? L10n::t('Gender:') : false;
$marital = !empty($profile['marital']) ? L10n::t('Status:') : false;
$homepage = !empty($profile['homepage']) ? L10n::t('Homepage:') : false;
$about = !empty($profile['about']) ? L10n::t('About:') : false;
$xmpp = !empty($profile['xmpp']) ? L10n::t('XMPP:') : false;
if ((x($profile, 'hidewall') || $block) && !local_user() && !remote_user()) {
if ((!empty($profile['hidewall']) || $block) && !local_user() && !remote_user()) {
$location = $gender = $marital = $homepage = $about = false;
}
@ -448,7 +448,7 @@ class Profile
$firstname = $split_name['first'];
$lastname = $split_name['last'];
if (x($profile, 'guid')) {
if (!empty($profile['guid'])) {
$diaspora = [
'guid' => $profile['guid'],
'podloc' => System::baseUrl(),
@ -890,7 +890,7 @@ class Profile
}
$tab = false;
if (x($_GET, 'tab')) {
if (!empty($_GET['tab'])) {
$tab = Strings::escapeTags(trim($_GET['tab']));
}
@ -1001,7 +1001,7 @@ class Profile
*/
public static function getMyURL()
{
if (x($_SESSION, 'my_url')) {
if (!empty($_SESSION['my_url'])) {
return $_SESSION['my_url'];
}
return null;
@ -1173,7 +1173,7 @@ class Profile
*/
public static function getThemeUid()
{
$uid = ((!empty($_REQUEST['puid'])) ? intval($_REQUEST['puid']) : 0);
$uid = (!empty($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (!$uid))) {
return local_user();
}

View file

@ -412,12 +412,12 @@ class User
$password = !empty($data['password']) ? trim($data['password']) : '';
$password1 = !empty($data['password1']) ? trim($data['password1']) : '';
$confirm = !empty($data['confirm']) ? trim($data['confirm']) : '';
$blocked = !empty($data['blocked']) ? intval($data['blocked']) : 0;
$verified = !empty($data['verified']) ? intval($data['verified']) : 0;
$blocked = !empty($data['blocked']);
$verified = !empty($data['verified']);
$language = !empty($data['language']) ? Strings::escapeTags(trim($data['language'])) : 'en';
$publish = !empty($data['profile_publish_reg']) && intval($data['profile_publish_reg']) ? 1 : 0;
$netpublish = strlen(Config::get('system', 'directory')) ? $publish : 0;
$publish = !empty($data['profile_publish_reg']);
$netpublish = $publish && Config::get('system', 'directory');
if ($password1 != $confirm) {
throw new Exception(L10n::t('Passwords do not match. Password unchanged.'));