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)
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;
}
}
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));
}
if (!$expectError && mysql_error($serendipity['dbConn']) != '') {
- return '<pre>' . $sql . '</pre> / ' . mysql_error($serendipity['dbConn']);
+ $msg = '<pre>' . $sql . '</pre> / ' . mysql_error($serendipity['dbConn']);
+ return $msg;
}
if (!$c) {
}
}
- return false;
+ return $type_map['false'];
}
if ($c === true) {
- return true;
+ return $type_map['true'];
}
$result_type = $type_map[$result_type];
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);
*/
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);
}
if (!$expectError && mysqli_error($serendipity['dbConn']) != '') {
- return mysqli_error($serendipity['dbConn']);
+ $msg = mysqli_error($serendipity['dbConn']);
+ return $msg;
}
if (!$c) {
}
}
- return false;
+ return $type_map['false'];
}
if ($c === true) {
- return true;
+ return $type_map['true'];
}
$result_type = $type_map[$result_type];
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);
static $type_map = array(
'assoc' => PGSQL_ASSOC,
'num' => PGSQL_NUM,
- 'both' => PGSQL_BOTH
+ 'both' => PGSQL_BOTH,
+ 'true' => true,
+ 'false' => false
);
if (!isset($serendipity['dbPgsqlOIDS'])) {
}
print "<br><code>$sql</code>\n";
}
- return false;
+ return $type_map['false'];
}
if ($serendipity['dbLastResult'] === true) {
- return true;
+ return $type_map['true'];
}
$result_type = $type_map[$result_type];
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);
static $type_map = array(
'assoc' => SQLITE_ASSOC,
'num' => SQLITE_NUM,
- 'both' => SQLITE_BOTH
+ 'both' => SQLITE_BOTH,
+ 'true' => true,
+ 'false' => false
);
static $debug = false;
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');
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();
foreach($PAT AS $constant => $value) {
define('PAT_' . $constant, $value);
}
-
- return true;
+
+ $return = true;
+ return $return;
}
}
);
}
- return serendipity_printComments($comments, $params['mode']);
+ $out = serendipity_printComments($comments, $params['mode']);
+ return $out;
}
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() {
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)";
$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']) . "'");
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;
}
$plugins = serendipity_plugin_api::enum_plugins('event');
if (!is_array($plugins)) {
- return false;
+ return $false;
}
$event_plugins = array();
if (isset($event_plugins[$getInstance]['p'])) {
return $event_plugins[$getInstance]['p'];
}
- return false;
+ return $false;
}
return $event_plugins;
$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;
}
}
}
function &fetchfile($url, $target, $cacheTimeout = 0, $decode_utf8 = false, $sub = 'plugins') {
+ static $error = false;
+
printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . basename($url) . '</a>');
echo '<br />';
if (!is_dir($tdir) && !$this->rmkdir($tdir, $sub)) {
printf(FILE_WRITE_ERROR, $tdir);
echo '<br />';
- return false;
+ return $error;
}
$fp = @fopen($target, 'w');
if (!$fp) {
printf(FILE_WRITE_ERROR, $target);
echo '<br />';
- return false;
+ return $error;
}
if ($decode_utf8) {
$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
preg_match_all('@(<package version="[^"]+">.*</package>)@imsU', $xml, $xml_matches);
if (!is_array($xml_matches)) {
- return 'cached';
+ $out = 'cached';
+ return $out;
}
$i = 0;
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;
}
}
}