From 3a9a5fcde8a0c7f78a3ec8f4ac6d871bb860e8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 10 May 2018 23:06:25 +0200 Subject: [PATCH] Continued: - x() is deprecated, use proper isset()/empty() (MrPetovan) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- geocoordinates/geocoordinates.php | 3 ++- googlemaps/googlemaps.php | 4 ++-- mailstream/mailstream.php | 12 ++++++++---- openstreetmap/openstreetmap.php | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 065f1b24..51e57636 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -26,8 +26,9 @@ function geocoordinates_uninstall() function geocoordinates_resolve_item(&$item) { - if((!x($item, 'coord')) || (x($item, 'location'))) + if (!isset($item['coord']) || isset($item['location'])) { return; + } $key = Config::get("geocoordinates", "api_key"); diff --git a/googlemaps/googlemaps.php b/googlemaps/googlemaps.php index 7011b935..cc0b2daa 100644 --- a/googlemaps/googlemaps.php +++ b/googlemaps/googlemaps.php @@ -32,13 +32,13 @@ function googlemaps_location(App $a, array &$item) return; } - if (x($item, 'coord')) { + if (isset($item['coord']) { $target = "http://maps.google.com/?q=".urlencode($item['coord']); } else { $target = "http://maps.google.com/?q=".urlencode($item['location']); } - if (x($item, 'location')) { + if (isset($item['location'])) { $title = $item['location']; } else { $title = $item['coord']; diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 1e3e2e47..b6020810 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -104,7 +104,7 @@ function mailstream_post_hook(App $a, array &$item) { return; } - if (!x($item, 'uid') || !x($item, 'contact-id') || !x($item, 'uri')) { + if (!isset($item['uid']) || !isset($item['contact-id']) || !isset($item['uri'])) { return; } @@ -223,9 +223,10 @@ function mailstream_decode_subject($subject) { } function mailstream_subject(array $item) { - if (x($item, 'title')) { + if (isset($item['title'])) { return mailstream_decode_subject($item['title']); } + $parent = $item['thr-parent']; // Don't look more than 100 levels deep for a subject, in case of loops for ($i = 0; ($i < 100) && $parent; $i++) { @@ -267,13 +268,16 @@ function mailstream_subject(array $item) { } function mailstream_send(App $a, $message_id, array $item, $user) { - if (!x($item, 'visible')) { + if (!isset($item['visible'])) { return; } + if (!$message_id) { return; } - require_once(dirname(__file__).'/phpmailer/class.phpmailer.php'); + + // @TODO Isn't there a better way? + require_once dirname(__FILE__) . '/phpmailer/class.phpmailer.php'; $attachments = []; mailstream_do_images($a, $item, $attachments); diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 670ee729..4861c789 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -90,7 +90,7 @@ function openstreetmap_location($a, &$item) $nomserver = OSM_NOM; } - if (x($item, 'coord')) { + if (isset($item['coord'])) { $coords = explode(' ', $item['coord']); if (count($coords) > 1) { $lat = urlencode(round($coords[0], 5)); @@ -107,7 +107,7 @@ function openstreetmap_location($a, &$item) $target = $nomserver.'?q='.urlencode($item['location']); } - if (x($item, 'location')) { + if (isset($item['location'])) { $title = $item['location']; } else { $title = $item['coord'];