From ca6e4777016a71a3d3621ff3cbdc4cee8717a6b9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 9 Jan 2018 22:27:30 -0500 Subject: [PATCH 1/3] Replace dba::select(limit => 1) by dba::selectOne() --- buffer/buffer.php | 2 +- diaspora/diaspora.php | 2 +- ifttt/ifttt.php | 2 +- libertree/libertree.php | 2 +- pumpio/pumpio.php | 2 +- statusnet/statusnet.php | 2 +- tumblr/tumblr.php | 2 +- twitter/twitter.php | 2 +- windowsphonepush/windowsphonepush.php | 2 +- wppost/wppost.php | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 97373f30..6ecfb189 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -250,7 +250,7 @@ function buffer_send(App $a, &$b) // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 04ed24ca..d2e2961d 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -286,7 +286,7 @@ function diaspora_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 384b955c..ad7a367b 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -97,7 +97,7 @@ function ifttt_post(App $a) $nickname = $a->argv[1]; - $user = dba::select('user', ['uid'], ['nickname' => $nickname], ['limit' => 1]); + $user = dba::selectOne('user', ['uid'], ['nickname' => $nickname]); if (!DBM::is_result($user)) { logger('User ' . $nickname . ' not found.', LOGGER_DEBUG); return; diff --git a/libertree/libertree.php b/libertree/libertree.php index 95def07a..f942bed3 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -166,7 +166,7 @@ function libertree_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index f5bf6496..52a48ae2 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -418,7 +418,7 @@ function pumpio_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 659ddaef..814722f4 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -580,7 +580,7 @@ function statusnet_post_hook(App $a, &$b) // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 77d98aca..674093ed 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -327,7 +327,7 @@ function tumblr_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/twitter/twitter.php b/twitter/twitter.php index 43aee0fe..e501a344 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -468,7 +468,7 @@ function twitter_post_hook(App $a, &$b) // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index baa4c656..c9d58bd7 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -458,7 +458,7 @@ function windowsphonepush_login(App $a) $user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW'])); if ($user_id) { - $record = dba::select('user', [], ['uid' => $user_id], ['limit' => 1]); + $record = dba::selectOne('user', [], ['uid' => $user_id]); } else { logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); diff --git a/wppost/wppost.php b/wppost/wppost.php index ea26ae45..d6daa8c0 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -202,7 +202,7 @@ function wppost_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } From 3e141d268e10a10e2c7a69782fdd6378f0804368 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 9 Jan 2018 22:27:40 -0500 Subject: [PATCH 2/3] Fix formatting --- buffer/buffer.php | 9 ++++++--- diaspora/diaspora.php | 9 ++++++--- libertree/libertree.php | 9 ++++++--- pumpio/pumpio.php | 3 ++- statusnet/statusnet.php | 6 ++++-- tumblr/tumblr.php | 9 ++++++--- wppost/wppost.php | 9 ++++++--- 7 files changed, 36 insertions(+), 18 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 6ecfb189..a85e843a 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -239,14 +239,17 @@ function buffer_post_local(&$a,&$b) { function buffer_send(App $a, &$b) { - if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; + } - if(! strstr($b['postopts'],'buffer')) + if(! strstr($b['postopts'],'buffer')) { return; + } - if($b['parent'] != $b['id']) + if($b['parent'] != $b['id']) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index d2e2961d..6f54f442 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -275,14 +275,17 @@ function diaspora_send(&$a,&$b) { logger('diaspora_send: invoked'); - if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; + } - if(! strstr($b['postopts'],'diaspora')) + if(! strstr($b['postopts'],'diaspora')) { return; + } - if($b['parent'] != $b['id']) + if($b['parent'] != $b['id']) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings diff --git a/libertree/libertree.php b/libertree/libertree.php index f942bed3..c421d076 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -155,14 +155,17 @@ function libertree_send(&$a,&$b) { logger('libertree_send: invoked'); - if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; + } - if (! strstr($b['postopts'],'libertree')) + if (! strstr($b['postopts'],'libertree')) { return; + } - if ($b['parent'] != $b['id']) + if ($b['parent'] != $b['id']) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 52a48ae2..af932180 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -413,8 +413,9 @@ function pumpio_send(&$a,&$b) { logger("pumpio_send: receiver ".print_r($receiver, true)); - if (!count($receiver) && ($b['private'] || !strstr($b['postopts'],'pumpio'))) + if (!count($receiver) && ($b['private'] || !strstr($b['postopts'],'pumpio'))) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 814722f4..084b233d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -568,15 +568,17 @@ function statusnet_post_hook(App $a, &$b) $nicknameplain = "@" . $nick; logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); - if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) + if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) { $b["body"] = $nickname . " " . $b["body"]; + } logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); } else { $iscomment = false; - if ($b['private'] || !strstr($b['postopts'], 'statusnet')) + if ($b['private'] || !strstr($b['postopts'], 'statusnet')) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 674093ed..c255f5a4 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -316,14 +316,17 @@ function tumblr_post_local(&$a, &$b) { function tumblr_send(&$a,&$b) { - if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; + } - if(! strstr($b['postopts'],'tumblr')) + if(! strstr($b['postopts'],'tumblr')) { return; + } - if($b['parent'] != $b['id']) + if($b['parent'] != $b['id']) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings diff --git a/wppost/wppost.php b/wppost/wppost.php index d6daa8c0..96e95979 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -191,14 +191,17 @@ function wppost_post_local(&$a, &$b) { function wppost_send(&$a,&$b) { - if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; + } - if(! strstr($b['postopts'],'wppost')) + if(! strstr($b['postopts'],'wppost')) { return; + } - if($b['parent'] != $b['id']) + if($b['parent'] != $b['id']) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings From a66a4959f5de35d5a82094ffa40b846c865deac9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 10 Jan 2018 08:37:11 -0500 Subject: [PATCH 3/3] Rename selectOne to selectFirst --- buffer/buffer.php | 2 +- diaspora/diaspora.php | 2 +- ifttt/ifttt.php | 2 +- libertree/libertree.php | 2 +- pumpio/pumpio.php | 2 +- statusnet/statusnet.php | 2 +- tumblr/tumblr.php | 2 +- twitter/twitter.php | 2 +- windowsphonepush/windowsphonepush.php | 2 +- wppost/wppost.php | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index a85e843a..932789da 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -253,7 +253,7 @@ function buffer_send(App $a, &$b) // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 6f54f442..db4cc46e 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -289,7 +289,7 @@ function diaspora_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index ad7a367b..199aace4 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -97,7 +97,7 @@ function ifttt_post(App $a) $nickname = $a->argv[1]; - $user = dba::selectOne('user', ['uid'], ['nickname' => $nickname]); + $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]); if (!DBM::is_result($user)) { logger('User ' . $nickname . ' not found.', LOGGER_DEBUG); return; diff --git a/libertree/libertree.php b/libertree/libertree.php index c421d076..f5a157ec 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -169,7 +169,7 @@ function libertree_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index af932180..3f6f8a87 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -419,7 +419,7 @@ function pumpio_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 084b233d..34bbf20c 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -582,7 +582,7 @@ function statusnet_post_hook(App $a, &$b) // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index c255f5a4..78c12a5f 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -330,7 +330,7 @@ function tumblr_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/twitter/twitter.php b/twitter/twitter.php index e501a344..ccfdeb1f 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -468,7 +468,7 @@ function twitter_post_hook(App $a, &$b) // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index c9d58bd7..ca615205 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -458,7 +458,7 @@ function windowsphonepush_login(App $a) $user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW'])); if ($user_id) { - $record = dba::selectOne('user', [], ['uid' => $user_id]); + $record = dba::selectFirst('user', [], ['uid' => $user_id]); } else { logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); diff --git a/wppost/wppost.php b/wppost/wppost.php index 96e95979..323fcef0 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -205,7 +205,7 @@ function wppost_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectOne('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; }