Adding new function that allows us to stop using the @ error suppression operator...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 13 Nov 2007 00:11:15 +0000 (00:11 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 13 Nov 2007 00:11:15 +0000 (00:11 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12763 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/global.php
src/compose.php

index f470a48..1f560e8 100644 (file)
@@ -84,6 +84,40 @@ function sqstripslashes(&$array) {
 }
 
 /**
+ * Squelch error output to screen (only) for the given function.
+ *
+ * This provides an alternative to the @ error-suppression
+ * operator where errors will not be shown in the interface
+ * but will show up in the server log file (assuming the
+ * administrator has configured PHP logging).
+ *
+ * @since 1.4.12 and 1.5.2
+ *
+ * @param string $function The function to be executed
+ * @param array  $args     The arguments to be passed to the function
+ *                         (OPTIONAL; default no arguments)
+ *                         NOTE: The caller must take extra action if
+ *                               the function being called is supposed
+ *                               to use any of the parameters by
+ *                               reference.  In the following example,
+ *                               $x is passed by reference and $y is
+ *                               passed by value to the "my_func"
+ *                               function.
+ * sq_call_function_suppress_errors('my_func', array(&$x, $y));
+ *
+ * @return mixed The return value, if any, of the function being
+ *               executed will be returned.
+ *
+ */
+function sq_call_function_suppress_errors($function, $args=NULL) {
+   $display_errors = ini_get('display_errors');
+   ini_set('display_errors', '0');
+   $ret = call_user_func_array($function, $args);
+   ini_set('display_errors', $display_errors);
+   return $ret;
+}
+
+/**
  * Add a variable to the session.
  * @param mixed $var the variable to register
  * @param string $name the name to refer to this variable
@@ -365,7 +399,8 @@ function sqsession_is_active() {
 function sqsession_start() {
     global $base_uri;
 
-    @session_start();
+    sq_call_function_suppress_errors('session_start');
+    // was: @session_start();
     $session_id = session_id();
 
     // session_starts sets the sessionid cookie buth without the httponly var
index 9acb916..29aa150 100644 (file)
@@ -1421,8 +1421,8 @@ function saveAttachedFiles($session) {
 
     // m_u_f works better with restricted PHP installs (safe_mode, open_basedir),
     // if that doesn't work, try a simple rename.
-    if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$fullpath)) {
-        if (!@rename($_FILES['attachfile']['tmp_name'], $fullpath)) {
+    if (!sq_call_function_suppress_errors('move_uploaded_file', array($_FILES['attachfile']['tmp_name'], $fullpath))) {
+        if (!sq_call_function_suppress_errors('rename', array($_FILES['attachfile']['tmp_name'], $fullpath))) {
             return true;
         }
     }