1
1
Fork 0

Merge pull request #3633 from annando/dba-bugfix

Further database corrections
This commit is contained in:
Tobias Diekershoff 2017-08-15 13:30:34 +02:00 committed by GitHub
commit 0abdb26507
3 changed files with 11 additions and 12 deletions

View file

@ -3,6 +3,8 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Config; use Friendica\Core\Config;
require_once 'include/contact_selectors.php';
function follow_widget($value = "") { function follow_widget($value = "") {
return replace_macros(get_markup_template('follow.tpl'), array( return replace_macros(get_markup_template('follow.tpl'), array(
@ -113,16 +115,13 @@ function networks_widget($baseurl, $selected = '') {
); );
$nets = array(); $nets = array();
if (dbm::is_result($r)) { while ($rr = dba::fetch($r)) {
require_once 'include/contact_selectors.php'; /// @TODO If 'network' is not there, this triggers an E_NOTICE
while ($rr = dba::fetch($r)) { if ($rr['network']) {
/// @TODO If 'network' is not there, this triggers an E_NOTICE $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
if ($rr['network']) {
$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
}
} }
dba::close($r);
} }
dba::close($r);
if (count($nets) < 2) { if (count($nets) < 2) {
return ''; return '';

View file

@ -41,7 +41,7 @@ class dbm {
* Checks if $array is a filled array with at least one entry. * Checks if $array is a filled array with at least one entry.
* *
* @param $array mixed A filled array with at least one entry * @param $array mixed A filled array with at least one entry
* @return Whether $array is a filled array * @return Whether $array is a filled array or an object with rows
*/ */
public static function is_result($array) { public static function is_result($array) {
// It could be a return value from an update statement // It could be a return value from an update statement
@ -50,10 +50,10 @@ class dbm {
} }
if (is_object($array)) { if (is_object($array)) {
return true; return dba::num_rows($array) > 0;
} }
return (is_array($array) && count($array) > 0); return (is_array($array) && (count($array) > 0));
} }
/** /**

View file

@ -43,11 +43,11 @@ class PConfig {
$a->config[$uid][$family][$k] = $rr['v']; $a->config[$uid][$family][$k] = $rr['v'];
self::$in_db[$uid][$family][$k] = true; self::$in_db[$uid][$family][$k] = true;
} }
dba::close($r);
} else if ($family != 'config') { } else if ($family != 'config') {
// Negative caching // Negative caching
$a->config[$uid][$family] = "!<unset>!"; $a->config[$uid][$family] = "!<unset>!";
} }
dba::close($r);
} }
/** /**