Continued:

- SQL keywords must be all-uppercase (MrPetovan)
- used empty(), not isset() (annando)
- used more DBM::is_result()

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2018-05-10 23:44:22 +02:00
parent ed59c29484
commit 249a8ac6fc
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
5 changed files with 29 additions and 19 deletions

View file

@ -13,6 +13,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -170,11 +171,13 @@ function dwpost_send(App $a, array &$b) {
$tz = 'UTC'; $tz = 'UTC';
$x = q("select timezone from user where uid = %d limit 1", $x = q("SELECT `timezone` FROM `user` WHERE `uid`=%d LIMIT 1",
intval($b['uid']) intval($b['uid'])
); );
if($x && strlen($x[0]['timezone']))
if (DBM::is_result($x) && strlen($x[0]['timezone'])) {
$tz = $x[0]['timezone']; $tz = $x[0]['timezone'];
}
$dw_username = PConfig::get($b['uid'],'dwpost','dw_username'); $dw_username = PConfig::get($b['uid'],'dwpost','dw_username');
$dw_password = PConfig::get($b['uid'],'dwpost','dw_password'); $dw_password = PConfig::get($b['uid'],'dwpost','dw_password');

View file

@ -28,7 +28,7 @@ function geocoordinates_uninstall()
function geocoordinates_resolve_item(array &$item) function geocoordinates_resolve_item(array &$item)
{ {
if (!isset($item['coord']) || isset($item['location'])) { if (empty($item['coord']) || !empty($item['location'])) {
return; return;
} }
@ -38,7 +38,7 @@ function geocoordinates_resolve_item(array &$item)
return; return;
} }
$language = Config::get("geocoordinates", "language"); $language = Config::get("geocoordinates", "language", "de");
if ($language == "") { if ($language == "") {
$language = "de"; $language = "de";
@ -62,7 +62,7 @@ function geocoordinates_resolve_item(array &$item)
$s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); $s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language);
if ($s === FALSE) { if ($s === FALSE || empty($s)) {
logger("API could not be queried", LOGGER_DEBUG); logger("API could not be queried", LOGGER_DEBUG);
return; return;
} }
@ -83,9 +83,10 @@ function geocoordinates_resolve_item(array &$item)
logger("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG); logger("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG);
if ($item["location"] != "") if ($item["location"] != "") {
Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]); Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
} }
}
function geocoordinates_post_hook(App $a, array &$item) function geocoordinates_post_hook(App $a, array &$item)
{ {

View file

@ -13,6 +13,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -168,11 +169,13 @@ function ijpost_send(App $a, array &$b) {
$tz = 'UTC'; $tz = 'UTC';
$x = q("select timezone from user where uid = %d limit 1", $x = q("SELECT `timezone` FROM `user` WHERE `uid`=%d LIMIT 1",
intval($b['uid']) intval($b['uid'])
); );
if($x && strlen($x[0]['timezone']))
if (DBM::is_result($x) && strlen($x[0]['timezone'])) {
$tz = $x[0]['timezone']; $tz = $x[0]['timezone'];
}
$ij_username = PConfig::get($b['uid'],'ijpost','ij_username'); $ij_username = PConfig::get($b['uid'],'ijpost','ij_username');
$ij_password = PConfig::get($b['uid'],'ijpost','ij_password'); $ij_password = PConfig::get($b['uid'],'ijpost','ij_password');

View file

@ -13,6 +13,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -163,11 +164,13 @@ function ljpost_send(App $a, array &$b) {
$tz = 'UTC'; $tz = 'UTC';
$x = q("select timezone from user where uid = %d limit 1", $x = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($b['uid']) intval($b['uid'])
); );
if($x && strlen($x[0]['timezone']))
if (DBM::is_result($x) && strlen($x[0]['timezone'])) {
$tz = $x[0]['timezone']; $tz = $x[0]['timezone'];
}
$lj_username = xmlify(PConfig::get($b['uid'],'ljpost','lj_username')); $lj_username = xmlify(PConfig::get($b['uid'],'ljpost','lj_username'));
$lj_password = xmlify(PConfig::get($b['uid'],'ljpost','lj_password')); $lj_password = xmlify(PConfig::get($b['uid'],'ljpost','lj_password'));
@ -176,8 +179,9 @@ function ljpost_send(App $a, array &$b) {
// $lj_journal = $lj_username; // $lj_journal = $lj_username;
$lj_blog = xmlify(PConfig::get($b['uid'],'ljpost','lj_blog')); $lj_blog = xmlify(PConfig::get($b['uid'],'ljpost','lj_blog'));
if(! strlen($lj_blog)) if (! strlen($lj_blog)) {
$lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc'); $lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc');
}
if ($lj_username && $lj_password && $lj_blog) { if ($lj_username && $lj_password && $lj_blog) {
$title = xmlify($b['title']); $title = xmlify($b['title']);

View file

@ -63,8 +63,8 @@ function testdrive_register_account($a,$b) {
function testdrive_cron($a,$b) { function testdrive_cron($a,$b) {
require_once('include/enotify.php'); require_once('include/enotify.php');
$r = q("select * from user where account_expires_on < UTC_TIMESTAMP() + INTERVAL 5 DAY and $r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
expire_notification_sent = '0000-00-00 00:00:00' "); `expire_notification_sent` = '0000-00-00 00:00:00'");
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
@ -80,15 +80,14 @@ function testdrive_cron($a,$b) {
'source_photo' => $a->get_baseurl() . '/images/person-80.jpg', 'source_photo' => $a->get_baseurl() . '/images/person-80.jpg',
]); ]);
q("update user set expire_notification_sent = '%s' where uid = %d", q("UPDATE `user` SET `expire_notification_sent`='%s' WHERE `uid`=%d",
dbesc(DateTimeFormat::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval($rr['uid']) intval($rr['uid'])
); );
} }
} }
$r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY "); $r = q("SELECT * FROM `user` WHERE `account_expired`=1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 5 DAY");
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {