From d818621633e2c687264682f0504869858f9c780d Mon Sep 17 00:00:00 2001
From: Ben Coburn <btcoburn@silicodon.net>
Date: Fri, 8 Sep 2006 21:34:33 +0200
Subject: [PATCH] suppress boring errors

Suppress any errors from set_time_limit,
unlink, and file_exists functions.
see: http://www.freelists.org/archives/dokuwiki/09-2006/msg00004.html

darcs-hash:20060908193433-05dcb-013617431870ab5bfb2ce8c6e99ba5af13493228.gz
---
 inc/common.php                               | 24 ++++++++++----------
 inc/init.php                                 |  2 +-
 inc/io.php                                   |  4 ++--
 inc/pageutils.php                            |  4 ++--
 inc/pluginutils.php                          |  2 +-
 inc/template.php                             |  2 +-
 lib/exe/detail.php                           |  2 +-
 lib/exe/indexer.php                          | 12 +++++-----
 lib/plugins/config/settings/config.class.php |  2 +-
 lib/plugins/importoldchangelog/action.php    |  6 ++---
 lib/plugins/plugin/admin.php                 |  2 +-
 11 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/inc/common.php b/inc/common.php
index 65ea4c897..ca60b8edc 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -538,7 +538,7 @@ function checklock($id){
 
   //lockfile expired
   if((time() - filemtime($lock)) > $conf['locktime']){
-    unlink($lock);
+    @unlink($lock);
     return false;
   }
 
@@ -898,7 +898,7 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) {
   }
 
   $file = metaFN($id, '.changes');
-  if (!file_exists($file)) { return false; }
+  if (!@file_exists($file)) { return false; }
   if (filesize($file)<$chunk_size || $chunk_size==0) {
     // read whole file
     $lines = file($file);
@@ -995,12 +995,12 @@ function getRevisions($id, $first, $num, $chunk_size=8192) {
   $num = max($num, 0);
   $chunk_size = max($chunk_size, 0);
   if ($first<0) { $first = 0; }
-  else if (file_exists(wikiFN($id))) {
+  else if (@file_exists(wikiFN($id))) {
      // skip current revision if the page exists
     $first = max($first+1, 0);
   }
 
-  if (!file_exists($file)) { return $revs; }
+  if (!@file_exists($file)) { return $revs; }
   if (filesize($file)<$chunk_size || $chunk_size==0) {
     // read whole file
     $lines = file($file);
@@ -1085,7 +1085,7 @@ function saveWikiText($id,$text,$summary,$minor=false){
   $file = wikiFN($id);
   $old  = saveOldRevision($id);
   $wasRemoved = empty($text);
-  $wasCreated = !file_exists($file);
+  $wasCreated = !@file_exists($file);
   $wasReverted = ($REV==true);
 
   if ($wasRemoved){
@@ -1096,7 +1096,7 @@ function saveWikiText($id,$text,$summary,$minor=false){
     $changelog = metaFN($id, '.changes');
     foreach ($mfiles as $mfile) {
       // but keep per-page changelog to preserve page history
-      if (file_exists($mfile) && $mfile!==$changelog) { @unlink($mfile); }
+      if (@file_exists($mfile) && $mfile!==$changelog) { @unlink($mfile); }
     }
     $del = true;
     // autoset summary on deletion
@@ -1351,20 +1351,20 @@ function check(){
   if(is_writable($conf['changelog'])){
     msg('Changelog is writable',1);
   }else{
-    if (file_exists($conf['changelog'])) {
+    if (@file_exists($conf['changelog'])) {
       msg('Changelog is not writable',-1);
     }
   }
 
-  if (isset($conf['changelog_old']) && file_exists($conf['changelog_old'])) {
+  if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) {
     msg('Old changelog exists.', 0);
   }
 
-  if (file_exists($conf['changelog'].'_failed')) {
+  if (@file_exists($conf['changelog'].'_failed')) {
     msg('Importing old changelog failed.', -1);
-  } else if (file_exists($conf['changelog'].'_importing')) {
+  } else if (@file_exists($conf['changelog'].'_importing')) {
     msg('Importing old changelog now.', 0);
-  } else if (file_exists($conf['changelog'].'_import_ok')) {
+  } else if (@file_exists($conf['changelog'].'_import_ok')) {
     msg('Old changelog imported.', 1);
   }
 
@@ -1467,7 +1467,7 @@ function subscriber_addresslist($id){
 
   $mlist = array();
   $file=metaFN($id,'.mlist');
-  if (file_exists($file)) {
+  if (@file_exists($file)) {
     $mlist = file($file);
   }
   if(count($mlist) > 0) {
diff --git a/inc/init.php b/inc/init.php
index 69dd4766b..2ba16c2c3 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -17,7 +17,7 @@
   if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/');
 
   // check for error reporting override or set error reporting to sane values
-  if (!defined('DOKU_E_LEVEL') && file_exists(DOKU_CONF.'report_e_all')) {
+  if (!defined('DOKU_E_LEVEL') && @file_exists(DOKU_CONF.'report_e_all')) {
     define('DOKU_E_LEVEL', E_ALL);
   }
   if (!defined('DOKU_E_LEVEL')) { error_reporting(E_ALL ^ E_NOTICE); }
diff --git a/inc/io.php b/inc/io.php
index f9fbbd103..2b1272675 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -170,7 +170,7 @@ function io_saveFile($file,$content,$append=false){
   global $conf;
   $mode = ($append) ? 'ab' : 'wb';
 
-  $fileexists = file_exists($file);
+  $fileexists = @file_exists($file);
   io_makeFileDir($file);
   io_lock($file);
   if(substr($file,-3) == '.gz'){
@@ -470,7 +470,7 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=20
     $file = $file.$name;
   }
 
-  $fileexists = file_exists($file);
+  $fileexists = @file_exists($file);
   $fp = @fopen($file,"w");
   if(!$fp) return false;
   fwrite($fp,$data);
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 5fadd7a36..69e04f489 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -169,9 +169,9 @@ function wikiFN($raw_id,$rev='',$clean=true){
     $fn = $conf['olddir'].'/'.utf8_encodeFN($id).'.'.$rev.'.txt';
     if($conf['compression']){
       //test for extensions here, we want to read both compressions
-       if (file_exists($fn . '.gz')){
+       if (@file_exists($fn . '.gz')){
           $fn .= '.gz';
-       }else if(file_exists($fn . '.bz2')){
+       }else if(@file_exists($fn . '.bz2')){
           $fn .= '.bz2';
        }else{
           //file doesnt exist yet, so we take the configured extension
diff --git a/inc/pluginutils.php b/inc/pluginutils.php
index a93cca936..0adba09f3 100644
--- a/inc/pluginutils.php
+++ b/inc/pluginutils.php
@@ -73,7 +73,7 @@ function &plugin_load($type,$name){
   }
 
   //try to load the wanted plugin file
-  if (file_exists(DOKU_PLUGIN."$name/$type.php")){
+  if (@file_exists(DOKU_PLUGIN."$name/$type.php")){
     include_once(DOKU_PLUGIN."$name/$type.php");
   }else{
     list($plugin, $component) = preg_split("/_/",$name, 2);
diff --git a/inc/template.php b/inc/template.php
index 81913a8e7..7392b5413 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -635,7 +635,7 @@ function tpl_youarehere($sep=' &raquo; '){
   $page = $part.$parts[$i];
   if($page == $conf['start']) return;
   echo $sep;
-  if(file_exists(wikiFN($page))){
+  if(@file_exists(wikiFN($page))){
     $title = p_get_first_heading($page);
     if(!$title) $title = $parts[$i];
     tpl_link(wl($page),$title,'title="'.$page.'"');
diff --git a/lib/exe/detail.php b/lib/exe/detail.php
index 3a7e61597..a9fe72b91 100644
--- a/lib/exe/detail.php
+++ b/lib/exe/detail.php
@@ -35,7 +35,7 @@
   if($AUTH >= AUTH_READ){
     // check if image exists
     $SRC = mediaFN($IMG);
-    if(!file_exists($SRC)){
+    if(!@file_exists($SRC)){
       //doesn't exist!
 
     }
diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index d65707911..ad2ad8010 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -47,8 +47,8 @@ function runTrimRecentChanges() {
     // Uses the imporoldchangelog plugin to upgrade the changelog automaticaly.
     // FIXME: Remove this from runTrimRecentChanges when it is no longer needed.
     if (isset($conf['changelog_old']) &&
-        file_exists($conf['changelog_old']) && !file_exists($conf['changelog']) &&
-        !file_exists($conf['changelog'].'_importing') && !file_exists($conf['changelog'].'_tmp')) {
+        @file_exists($conf['changelog_old']) && !@file_exists($conf['changelog']) &&
+        !@file_exists($conf['changelog'].'_importing') && !@file_exists($conf['changelog'].'_tmp')) {
             $tmp = array(); // no event data
             trigger_event('TEMPORARY_CHANGELOG_UPGRADE_EVENT', $tmp);
             return true;
@@ -58,9 +58,9 @@ function runTrimRecentChanges() {
     // Trims the recent changes cache to the last $conf['changes_days'] recent
     // changes or $conf['recent'] items, which ever is larger.
     // The trimming is only done once a day.
-    if (file_exists($conf['changelog']) &&
+    if (@file_exists($conf['changelog']) &&
         (filectime($conf['changelog'])+86400)<time() &&
-        !file_exists($conf['changelog'].'_tmp')) {
+        !@file_exists($conf['changelog'].'_tmp')) {
             io_lock($conf['changelog']);
             $lines = file($conf['changelog']);
             if (count($lines)<$conf['recent']) {
@@ -86,12 +86,12 @@ function runTrimRecentChanges() {
                 }
             }
             io_saveFile($conf['changelog'].'_tmp', implode('', $out_lines));
-            unlink($conf['changelog']);
+            @unlink($conf['changelog']);
             if (!rename($conf['changelog'].'_tmp', $conf['changelog'])) {
                 // rename failed so try another way...
                 io_unlock($conf['changelog']);
                 io_saveFile($conf['changelog'], implode('', $out_lines));
-                unlink($conf['changelog'].'_tmp');
+                @unlink($conf['changelog'].'_tmp');
             } else {
                 io_unlock($conf['changelog']);
             }
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 57d27e7eb..4981c795c 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -190,7 +190,7 @@ if (!class_exists('configuration')) {
       $local = eval('return '.$this->_local_file.';');
 
       if (!is_writable(dirname($local))) return true;
-      if (file_exists($local) && !is_writable($local)) return true;
+      if (@file_exists($local) && !is_writable($local)) return true;
 
       return false;
     }
diff --git a/lib/plugins/importoldchangelog/action.php b/lib/plugins/importoldchangelog/action.php
index 400ff6a18..e927b3e26 100644
--- a/lib/plugins/importoldchangelog/action.php
+++ b/lib/plugins/importoldchangelog/action.php
@@ -117,7 +117,7 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
     function resetTimer() {
         // Add 5 minutes to the script execution timer...
         // This should be much more than needed.
-        set_time_limit(5*60);
+        @set_time_limit(5*60);
         // Note: Has no effect in safe-mode!
     }
 
@@ -150,7 +150,7 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
         ksort($recent); // ensure correct order of recent changes
         io_unlock($conf['changelog']); // hand off the lock to io_saveFile
         io_saveFile($conf['changelog'], implode('', $recent));
-        unlink($conf['changelog'].'_importing'); // changelog importing unlock
+        @unlink($conf['changelog'].'_importing'); // changelog importing unlock
     }
 
 }
@@ -163,7 +163,7 @@ function importoldchangelog_plugin_shutdown() {
     $path['failed']    = $conf['changelog'].'_failed';
     $path['import_ok'] = $conf['changelog'].'_import_ok';
     io_unlock($path['changelog']); // guarantee unlocking
-    if (file_exists($path['importing'])) {
+    if (@file_exists($path['importing'])) {
         // import did not finish
         rename($path['importing'], $path['failed']) or trigger_error('Importing changelog failed.', E_USER_WARNING);
         @unlink($path['import_ok']);
diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php
index 03efae3bf..643754771 100644
--- a/lib/plugins/plugin/admin.php
+++ b/lib/plugins/plugin/admin.php
@@ -723,7 +723,7 @@ class ap_manage {
       $path = DOKU_PLUGIN.$plugin.'/';
 
       foreach ($plugin_types as $type) {
-        if (file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; }
+        if (@file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; }
 
         if ($dh = @opendir($path.$type.'/')) {
           while (false !== ($cp = readdir($dh))) {
-- 
GitLab