]> git.mjollnir.org Git - s9y.git/commitdiff
* Fix some dreaded "only variables can be returned by referenced"
authorgarvinhicking <garvinhicking>
Mon, 17 Oct 2005 13:04:11 +0000 (13:04 +0000)
committergarvinhicking <garvinhicking>
Mon, 17 Oct 2005 13:04:11 +0000 (13:04 +0000)
      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
include/admin/import.inc.php
include/db/mysql.inc.php
include/db/mysqli.inc.php
include/db/postgres.inc.php
include/db/sqlite.inc.php
include/functions_permalinks.inc.php
include/functions_smarty.inc.php
include/plugin_api.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php
plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php

index c39f2e346cf8f361aa6d8c96b43a93e3775d8aa8..c86bbe7a102debc84538a05dba3a1b832911a613 100644 (file)
--- 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)
 
index a6a9661848be7cdae9fba6ef3fe201d77b9665c8..37ded5c179f669d81c230d8d7bcac8ac56183bc4 100644 (file)
@@ -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;
         }
     }
 
index 3bd2cedcbdc7ef9c2aa39bf6c0d420270eb6c2fb..df5b46af3c817fb312c15270801a0726abdc1719 100644 (file)
@@ -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 '<pre>' . $sql . '</pre> / ' . mysql_error($serendipity['dbConn']);
+        $msg = '<pre>' . $sql . '</pre> / ' . 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);
index 99236216f44a7b6483ecfbd9e396250c5d855ffc..f1b8802f67c1d2d26d637788385469f3343a7223 100644 (file)
@@ -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);
index 744f55d7eca8002f57c9da8c499c1423b0302325..d348fef6df04c0ad9470e2bf9c96ab455fa208ff 100644 (file)
@@ -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 "<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];
@@ -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);
index a24b4d312d75cee4dfcf653637a6d34612d88ff3..36e6421a394e04474e6d3e8e8ec59a6f51dca76e 100644 (file)
@@ -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();
 
index 6a6d18902903451522f46a6a90c791088bf5cc5a..e37bf94ebc8ae5a06df9ce49811faef83ea76bb9 100644 (file)
@@ -233,8 +233,9 @@ function &serendipity_permalinkPatterns($return = false) {
         foreach($PAT AS $constant => $value) {
             define('PAT_' . $constant, $value);
         }
-        
-        return true;
+
+        $return = true;
+        return $return;
     }
 }
 
index 4b21cdb574f108de3ae0c9c831b160faba92e9b3..8e2321387528444206be763707bdbbdadd181049 100644 (file)
@@ -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() {
index 58b024cbe1857e08926f87f7d0dcde4536ab7e8c..90ec3e3b0e8acd5d13fcd210f99e13e9f2322e43 100644 (file)
@@ -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;
     }
 }
 
index 945fced736c46160f3cce2aa9a2aeeaf6a21950f..c6766a0181e397f1bbc96c42bd097fbff44edb5b 100644 (file)
@@ -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, '<a href="' . $url . '">' . basename($url) . '</a>');
         echo '<br />';
 
@@ -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 '<br />';
-                    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 '<br />';
-                    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('@(<package version="[^"]+">.*</package>)@imsU', $xml, $xml_matches);
         if (!is_array($xml_matches)) {
-            return 'cached';
+            $out = 'cached';
+            return $out;
         }
         
         $i = 0;
index 47f31523a8dfe572d348ebb2cacceccbf98223d4..534137221664a6dc5a3701cdfe0ae015968e98ba 100644 (file)
@@ -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;
         }
     }
 }