From 674249ccfcb668eb5991ee3e2ebf1ae14cac0398 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 3 Oct 2021 20:58:52 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Hypolite Petovan --- pumpio/pumpio.php | 12 ++++-------- windowsphonepush/windowsphonepush.php | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 5f63284ee..a29402a25 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -687,11 +687,9 @@ function pumpio_sync(App $a) Logger::notice('pumpio: cron_start'); $pconfigs = DBA::selectToArray('pconfig', ['cat' => 'pumpio', 'k' => 'mirror', 'v' => '1']); - if (DBA::isResult($pconfigs)) { - foreach ($pconfigs as $rr) { - Logger::notice('pumpio: mirroring user '.$rr['uid']); - pumpio_fetchtimeline($a, $rr['uid']); - } + foreach ($pconfigs as $rr) { + Logger::notice('pumpio: mirroring user '.$rr['uid']); + pumpio_fetchtimeline($a, $rr['uid']); } $abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); @@ -702,8 +700,7 @@ function pumpio_sync(App $a) $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $pconfigs = DBA::selectToArray('pconfig', ['cat' => 'pumpio', 'k' => 'import', 'v' => '1']); - if (DBA::isResult($pconfigs)) { - foreach ($pconfigs as $rr) { + foreach ($pconfigs as $rr) { if ($abandon_days != 0) { if (DBA::exists('user', ["uid = ? AND `login_date` >= ?", $rr['uid'], $abandon_limit])) { Logger::notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported'); @@ -726,7 +723,6 @@ function pumpio_sync(App $a) pumpio_getallusers($a, $rr["uid"]); DI::pConfig()->set($rr['uid'], 'pumpio', 'contact_check', time()); } - } } Logger::notice('pumpio: cron_end'); diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index cba706170..acaa027cd 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -135,7 +135,7 @@ function windowsphonepush_settings(&$a, &$s) function windowsphonepush_cron() { // retrieve all UID's for which the addon windowsphonepush is enabled and loop through every user - $pconfigs = DBA::selectToArray('pconfig', ['cat' => 'windowsphonepush', 'k' => 'enable', 'v' => true]); + $pconfigs = DBA::selectToArray('pconfig', ['uid'], ['cat' => 'windowsphonepush', 'k' => 'enable', 'v' => true]); foreach ($pconfigs as $rr) { // load stored information for the user-id of the current loop $device_url = DI::pConfig()->get($rr['uid'], 'windowsphonepush', 'device_url'); @@ -399,7 +399,7 @@ function windowsphonepush_updatesettings() // the user on the Windows Phone device and that device url is no longer true for the other user, so we // et the device_url for the OTHER user blank (should normally not occur as App should include User/server // in url request to Microsoft Push Notification server) - $pconfigs = DBA::selectToArray('pconfig', ["`uid` != ? AND `cat` = ? AND `k` = ? AND `v` = ?", local_user(), 'windowsphonepush', 'device_url', $device_url]); + $pconfigs = DBA::selectToArray('pconfig', ['uid'], ["`uid` != ? AND `cat` = ? AND `k` = ? AND `v` = ?", local_user(), 'windowsphonepush', 'device_url', $device_url]); foreach ($pconfigs as $rr) { DI::pConfig()->set($rr['uid'], 'windowsphonepush', 'device_url', ''); Logger::notice("WARN: the sent URL was already registered with user '" . $rr['uid'] . "'. Deleted for this user as we expect to be correct now for user '" . local_user() . "'.");