From ac6d30832befe3466e39077e85d170892b8dccc5 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Mon, 17 Oct 2005 13:04:11 +0000 Subject: [PATCH] * Fix some dreaded "only variables can be returned by referenced" PHP 4.4 notices on some minor occasions (garvinhicking) M trunk/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php M trunk/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php M trunk/include/db/sqlite.inc.php M trunk/include/db/mysql.inc.php M trunk/include/db/postgres.inc.php M trunk/include/db/mysqli.inc.php M trunk/include/plugin_api.inc.php M trunk/include/admin/import.inc.php M trunk/include/functions_permalinks.inc.php M trunk/include/functions_smarty.inc.php M trunk/docs/NEWS --- docs/NEWS | 4 ++++ include/admin/import.inc.php | 8 +++++--- include/db/mysql.inc.php | 15 +++++++++------ include/db/mysqli.inc.php | 13 +++++++------ include/db/postgres.inc.php | 12 +++++++----- include/db/sqlite.inc.php | 15 +++++++++------ include/functions_permalinks.inc.php | 5 +++-- include/functions_smarty.inc.php | 6 ++++-- include/plugin_api.inc.php | 17 +++++++++++------ .../serendipity_event_spartacus.php | 12 ++++++++---- .../serendipity_plugin_remoterss.php | 9 ++++++--- 11 files changed, 73 insertions(+), 43 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index c39f2e3..c86bbe7 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -2,6 +2,10 @@ Version 0.9-beta3 () ------------------------------------------------------------------------ + + * Fix some dreaded "only variables can be returned by referenced" + PHP 4.4 notices on some minor occasions (garvinhicking) + * Fix problem with b2evo importer when db was not in the same db as serendipity. Thanks to Judebert from the forums! (garvinhicking) diff --git a/include/admin/import.inc.php b/include/admin/import.inc.php index a6a9661..37ded5c 100644 --- a/include/admin/import.inc.php +++ b/include/admin/import.inc.php @@ -55,16 +55,18 @@ class Serendipity_Import { case 'ISO-8859-1': if (function_exists('iconv')) { - return iconv('ISO-8859-1', LANG_CHARSET, $string); + $out = iconv('ISO-8859-1', LANG_CHARSET, $string); } elseif (function_exists('recode')) { - return recode('iso-8859-1..' . LANG_CHARSET, $string); + $out = recode('iso-8859-1..' . LANG_CHARSET, $string); } else { return $string; } + return $out; case 'UTF-8': default: - return utf8_decode($string); + $out = utf8_decode($string) + return $out; } } diff --git a/include/db/mysql.inc.php b/include/db/mysql.inc.php index 3bd2ced..df5b46a 100644 --- a/include/db/mysql.inc.php +++ b/include/db/mysql.inc.php @@ -30,7 +30,9 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re static $type_map = array( 'assoc' => MYSQL_ASSOC, 'num' => MYSQL_NUM, - 'both' => MYSQL_BOTH + 'both' => MYSQL_BOTH, + 'true' => true, + 'false' => false ); // highlight_string(var_export($sql, 1)); @@ -42,7 +44,8 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re } if (!$expectError && mysql_error($serendipity['dbConn']) != '') { - return '
' . $sql . '
/ ' . mysql_error($serendipity['dbConn']); + $msg = '
' . $sql . '
/ ' . mysql_error($serendipity['dbConn']); + return $msg; } if (!$c) { @@ -53,10 +56,10 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re } } - return false; + return $type_map['false']; } if ($c === true) { - return true; + return $type_map['true']; } $result_type = $type_map[$result_type]; @@ -64,9 +67,9 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re switch(mysql_num_rows($c)) { case 0: if ($single) { - return false; + return $type_map['false']; } - return true; + return $type_map['true']; case 1: if ($single) { return mysql_fetch_array($c, $result_type); diff --git a/include/db/mysqli.inc.php b/include/db/mysqli.inc.php index 9923621..f1b8802 100644 --- a/include/db/mysqli.inc.php +++ b/include/db/mysqli.inc.php @@ -27,7 +27,7 @@ function serendipity_db_in_sql($col, &$search_ids) { */ function &serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr = false, $assocKey = false, $assocVal = false, $expectError = false) { global $serendipity; - $type_map = array('assoc' => MYSQLI_ASSOC, 'num' => MYSQLI_NUM, 'both' => MYSQLI_BOTH); + static $type_map = array('assoc' => MYSQLI_ASSOC, 'num' => MYSQLI_NUM, 'both' => MYSQLI_BOTH, 'true' => true, 'false' => false); if ($expectError) { $c = @mysqli_query($serendipity['dbConn'], $sql); @@ -36,7 +36,8 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re } if (!$expectError && mysqli_error($serendipity['dbConn']) != '') { - return mysqli_error($serendipity['dbConn']); + $msg = mysqli_error($serendipity['dbConn']); + return $msg; } if (!$c) { @@ -47,11 +48,11 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re } } - return false; + return $type_map['false']; } if ($c === true) { - return true; + return $type_map['true']; } $result_type = $type_map[$result_type]; @@ -59,9 +60,9 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re switch(mysqli_num_rows($c)) { case 0: if ($single) { - return false; + return $type_map['false']; } - return true; + return $type_map['true']; case 1: if ($single) { return mysqli_fetch_array($c, $result_type); diff --git a/include/db/postgres.inc.php b/include/db/postgres.inc.php index 744f55d..d348fef 100644 --- a/include/db/postgres.inc.php +++ b/include/db/postgres.inc.php @@ -99,7 +99,9 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re static $type_map = array( 'assoc' => PGSQL_ASSOC, 'num' => PGSQL_NUM, - 'both' => PGSQL_BOTH + 'both' => PGSQL_BOTH, + 'true' => true, + 'false' => false ); if (!isset($serendipity['dbPgsqlOIDS'])) { @@ -122,11 +124,11 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re } print "
$sql\n"; } - return false; + return $type_map['false']; } if ($serendipity['dbLastResult'] === true) { - return true; + return $type_map['true']; } $result_type = $type_map[$result_type]; @@ -136,9 +138,9 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re switch ($n) { case 0: if ($single) { - return false; + return $type_map['false']; } - return true; + return $type_map['true']; case 1: if ($single) { return pg_fetch_array($serendipity['dbLastResult'], 0, $result_type); diff --git a/include/db/sqlite.inc.php b/include/db/sqlite.inc.php index a24b4d3..36e6421 100644 --- a/include/db/sqlite.inc.php +++ b/include/db/sqlite.inc.php @@ -119,7 +119,9 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re static $type_map = array( 'assoc' => SQLITE_ASSOC, 'num' => SQLITE_NUM, - 'both' => SQLITE_BOTH + 'both' => SQLITE_BOTH, + 'true' => true, + 'false' => false ); static $debug = false; @@ -141,7 +143,8 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re if (!$expectError && !$serendipity['production']) { var_dump($res); var_dump($sql); - return "problem with query"; + $msg = "problem with query"; + return $msg; } if ($debug) { $fp = @fopen('sqlite.log', 'a'); @@ -149,18 +152,18 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re fclose($fp); } - return false; + return $type_map['false']; } if ($res === true) { - return true; + return $type_map['true']; } if (sqlite_num_rows($res) == 0) { if ($single) { - return false; + return $type_map['false']; } - return true; + return $type_map['true']; } else { $rows = array(); diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index 6a6d189..e37bf94 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -233,8 +233,9 @@ function &serendipity_permalinkPatterns($return = false) { foreach($PAT AS $constant => $value) { define('PAT_' . $constant, $value); } - - return true; + + $return = true; + return $return; } } diff --git a/include/functions_smarty.inc.php b/include/functions_smarty.inc.php index 4b21cdb..8e23213 100644 --- a/include/functions_smarty.inc.php +++ b/include/functions_smarty.inc.php @@ -144,7 +144,8 @@ function &serendipity_smarty_printComments($params, &$smarty) { ); } - return serendipity_printComments($comments, $params['mode']); + $out = serendipity_printComments($comments, $params['mode']); + return $out; } function serendipity_smarty_printTrackbacks($params, &$smarty) { @@ -157,7 +158,8 @@ function serendipity_smarty_printTrackbacks($params, &$smarty) { } function &serendipity_replaceSmartyVars(&$tpl_source, $smarty) { - return str_replace('$CONST.', '$smarty.const.', $tpl_source); + $tpl_source = str_replace('$CONST.', '$smarty.const.', $tpl_source); + return $tpl_source; } function serendipity_smarty_init() { diff --git a/include/plugin_api.inc.php b/include/plugin_api.inc.php index 58b024c..90ec3e3 100644 --- a/include/plugin_api.inc.php +++ b/include/plugin_api.inc.php @@ -407,7 +407,8 @@ class serendipity_plugin_api { if (!class_exists($class_name)) { $serendipity['debug']['pluginload'][] = "Classname $class_name still does not exist. Aborting."; - return false; + $retval = false; + return $retval; } $serendipity['debug']['pluginload'][] = "Returning new $class_name($instance_id)"; @@ -508,6 +509,7 @@ class serendipity_plugin_api { $data['stackable'] = '0'; } + // TODO: Check right columns! "upgradable" not existing? serendipity_db_insert('pluginlist', $data); serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}plugincategories WHERE class_name = '" . serendipity_db_escape_string($data['class_name']) . "'"); @@ -665,13 +667,14 @@ class serendipity_plugin_api { function &get_event_plugins($getInstance = false, $refresh = false) { static $event_plugins; + static $false = false; if (!$refresh && isset($event_plugins) && is_array($event_plugins)) { if ($getInstance) { if (isset($event_plugins[$getInstance]['p'])) { return $event_plugins[$getInstance]['p']; } - return false; + return $false; } return $event_plugins; } @@ -679,7 +682,7 @@ class serendipity_plugin_api { $plugins = serendipity_plugin_api::enum_plugins('event'); if (!is_array($plugins)) { - return false; + return $false; } $event_plugins = array(); @@ -698,7 +701,7 @@ class serendipity_plugin_api { if (isset($event_plugins[$getInstance]['p'])) { return $event_plugins[$getInstance]['p']; } - return false; + return $false; } return $event_plugins; @@ -758,10 +761,12 @@ class serendipity_plugin_api { $classes = serendipity_plugin_api::enum_plugin_classes(null); if (isset($classes[$plugin_name])) { - return serendipity_plugin_api::create_plugin_instance($plugin_name, null, $side, $authorid, $classes[$plugin_name]['pluginPath']); + $instance = serendipity_plugin_api::create_plugin_instance($plugin_name, null, $side, $authorid, $classes[$plugin_name]['pluginPath']); } else { - return false; + $instance = false; } + + return $instance; } } diff --git a/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php b/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php index 945fced..c6766a0 100644 --- a/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php +++ b/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php @@ -258,6 +258,8 @@ class serendipity_event_spartacus extends serendipity_event } function &fetchfile($url, $target, $cacheTimeout = 0, $decode_utf8 = false, $sub = 'plugins') { + static $error = false; + printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '' . basename($url) . ''); echo '
'; @@ -286,7 +288,7 @@ class serendipity_event_spartacus extends serendipity_event if (!is_dir($tdir) && !$this->rmkdir($tdir, $sub)) { printf(FILE_WRITE_ERROR, $tdir); echo '
'; - return false; + return $error; } $fp = @fopen($target, 'w'); @@ -294,7 +296,7 @@ class serendipity_event_spartacus extends serendipity_event if (!$fp) { printf(FILE_WRITE_ERROR, $target); echo '
'; - return false; + return $error; } if ($decode_utf8) { @@ -385,7 +387,8 @@ class serendipity_event_spartacus extends serendipity_event $last_crc = $this->get_config('last_crc_' . $url_type); if (!$no_cache && !$this->purgeCache && $last_crc == $new_crc) { - return 'cached'; + $out = 'cached'; + return $out; } // XML functions @@ -401,7 +404,8 @@ class serendipity_event_spartacus extends serendipity_event preg_match_all('@(.*)@imsU', $xml, $xml_matches); if (!is_array($xml_matches)) { - return 'cached'; + $out = 'cached'; + return $out; } $i = 0; diff --git a/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php b/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php index 47f3152..5341372 100644 --- a/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php +++ b/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php @@ -579,16 +579,19 @@ class serendipity_plugin_remoterss extends serendipity_plugin { case 'ISO-8859-1': if (function_exists('iconv')) { - return iconv('ISO-8859-1', LANG_CHARSET, $string); + $out = iconv('ISO-8859-1', LANG_CHARSET, $string); } elseif (function_exists('recode')) { - return recode('iso-8859-1..' . LANG_CHARSET, $string); + $out = recode('iso-8859-1..' . LANG_CHARSET, $string); } else { return $string; } + + return $out; case 'UTF-8': default: - return utf8_decode($string); + $out = utf8_decode($string) + return $out; } } } -- 2.39.5