Commit 4efc2774114dffe50b6ccf3e7d52257d8e9539b9

Authored by Conrad Vermeulen
1 parent 7f5553fb

KTS-2134

"Add @ in front of file functions such as unlink. There are cases that seem to break webservices because of warnings."
Fixed.

Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6857 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 30 additions and 30 deletions
lib/util/ktutil.inc
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 * License Version 1.1.2 ("License"); You may not use this file except in 8 * License Version 1.1.2 ("License"); You may not use this file except in
9 * compliance with the License. You may obtain a copy of the License at 9 * compliance with the License. You may obtain a copy of the License at
10 * http://www.knowledgetree.com/KPL 10 * http://www.knowledgetree.com/KPL
11 - * 11 + *
12 * Software distributed under the License is distributed on an "AS IS" 12 * Software distributed under the License is distributed on an "AS IS"
13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
14 * See the License for the specific language governing rights and 14 * See the License for the specific language governing rights and
@@ -19,9 +19,9 @@ @@ -19,9 +19,9 @@
19 * (ii) the KnowledgeTree copyright notice 19 * (ii) the KnowledgeTree copyright notice
20 * in the same form as they appear in the distribution. See the License for 20 * in the same form as they appear in the distribution. See the License for
21 * requirements. 21 * requirements.
22 - * 22 + *
23 * The Original Code is: KnowledgeTree Open Source 23 * The Original Code is: KnowledgeTree Open Source
24 - * 24 + *
25 * The Initial Developer of the Original Code is The Jam Warehouse Software 25 * The Initial Developer of the Original Code is The Jam Warehouse Software
26 * (Pty) Ltd, trading as KnowledgeTree. 26 * (Pty) Ltd, trading as KnowledgeTree.
27 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright 27 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
@@ -98,8 +98,8 @@ class KTUtil { @@ -98,8 +98,8 @@ class KTUtil {
98 } 98 }
99 99
100 function &arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { 100 function &arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) {
101 - if (!is_array($aArray)) {  
102 - $aArray = (array) $aArray; 101 + if (!is_array($aArray)) {
  102 + $aArray = (array) $aArray;
103 } 103 }
104 if (empty($aArray)) { 104 if (empty($aArray)) {
105 return $mDefault; 105 return $mDefault;
@@ -141,7 +141,7 @@ class KTUtil { @@ -141,7 +141,7 @@ class KTUtil {
141 $aNewParams[] = $oParam; 141 $aNewParams[] = $oParam;
142 } 142 }
143 } 143 }
144 - $aParams = array_merge($aParams, $aNewParams); 144 + $aParams = array_merge($aParams, $aNewParams);
145 } else { 145 } else {
146 return PEAR::raiseError(_kt("Weird WhereClause passed")); 146 return PEAR::raiseError(_kt("Weird WhereClause passed"));
147 } 147 }
@@ -254,7 +254,7 @@ class KTUtil { @@ -254,7 +254,7 @@ class KTUtil {
254 } 254 }
255 } 255 }
256 if ($bMove) { 256 if ($bMove) {
257 - rmdir($sSrc); 257 + @rmdir($sSrc);
258 } 258 }
259 } 259 }
260 // }}} 260 // }}}
@@ -264,7 +264,7 @@ class KTUtil { @@ -264,7 +264,7 @@ class KTUtil {
264 return KTUtil::copyDirectory($sSrc, $sDst, true); 264 return KTUtil::copyDirectory($sSrc, $sDst, true);
265 } 265 }
266 // }}} 266 // }}}
267 - 267 +
268 // {{{ deleteDirectory 268 // {{{ deleteDirectory
269 function deleteDirectory($sPath) { 269 function deleteDirectory($sPath) {
270 if (OS_UNIX) { 270 if (OS_UNIX) {
@@ -288,11 +288,11 @@ class KTUtil { @@ -288,11 +288,11 @@ class KTUtil {
288 KTUtil::deleteDirectory($sFullFilename); 288 KTUtil::deleteDirectory($sFullFilename);
289 continue; 289 continue;
290 } 290 }
291 - chmod($sFullFilename, 0666);  
292 - unlink($sFullFilename); 291 + @chmod($sFullFilename, 0666);
  292 + @unlink($sFullFilename);
293 } 293 }
294 closedir($hPath); 294 closedir($hPath);
295 - rmdir($sPath); 295 + @rmdir($sPath);
296 } 296 }
297 // }}} 297 // }}}
298 298
@@ -339,7 +339,7 @@ class KTUtil { @@ -339,7 +339,7 @@ class KTUtil {
339 } 339 }
340 } 340 }
341 // }}} 341 // }}}
342 - 342 +
343 // {{{ copyFile 343 // {{{ copyFile
344 function copyFile ($sSrc, $sDst) { 344 function copyFile ($sSrc, $sDst) {
345 // Only 4.3.3 and above allow us to use rename across partitions 345 // Only 4.3.3 and above allow us to use rename across partitions
@@ -365,7 +365,7 @@ class KTUtil { @@ -365,7 +365,7 @@ class KTUtil {
365 } 365 }
366 } 366 }
367 } 367 }
368 - // }}} 368 + // }}}
369 369
370 // {{{ getTableName 370 // {{{ getTableName
371 /** 371 /**
@@ -501,7 +501,7 @@ class KTUtil { @@ -501,7 +501,7 @@ class KTUtil {
501 // }}} 501 // }}}
502 502
503 // now accepts strings OR arrays! 503 // now accepts strings OR arrays!
504 - // {{{ addQueryString 504 + // {{{ addQueryString
505 function addQueryString($url, $qs) { 505 function addQueryString($url, $qs) {
506 require_once(KT_DIR . '/thirdparty/pear/Net/URL.php'); 506 require_once(KT_DIR . '/thirdparty/pear/Net/URL.php');
507 $oUrl = new Net_URL($url); 507 $oUrl = new Net_URL($url);
@@ -516,7 +516,7 @@ class KTUtil { @@ -516,7 +516,7 @@ class KTUtil {
516 $host = $oKTConfig->get("KnowledgeTree/serverName"); 516 $host = $oKTConfig->get("KnowledgeTree/serverName");
517 $host = explode(':', $host); 517 $host = explode(':', $host);
518 $oUrl->host = $host[0]; 518 $oUrl->host = $host[0];
519 - 519 +
520 if(!is_array($qs)) { 520 if(!is_array($qs)) {
521 $aQs = $oUrl->_parseRawQuerystring($qs); 521 $aQs = $oUrl->_parseRawQuerystring($qs);
522 } else { 522 } else {
@@ -535,7 +535,7 @@ class KTUtil { @@ -535,7 +535,7 @@ class KTUtil {
535 $KTConfig =& KTConfig::getSingleton(); 535 $KTConfig =& KTConfig::getSingleton();
536 $root = $KTConfig->get("KnowledgeTree/rootUrl"); 536 $root = $KTConfig->get("KnowledgeTree/rootUrl");
537 $url = generateLink($base); 537 $url = generateLink($base);
538 - 538 +
539 if (!empty($subpath)) { 539 if (!empty($subpath)) {
540 $hasPathInfo = $KTConfig->get("KnowledgeTree/pathInfoSupport"); 540 $hasPathInfo = $KTConfig->get("KnowledgeTree/pathInfoSupport");
541 if ($hasPathInfo) { 541 if ($hasPathInfo) {
@@ -544,7 +544,7 @@ class KTUtil { @@ -544,7 +544,7 @@ class KTUtil {
544 $url = KTUtil::addQueryString($url, "kt_path_info=" . $subpath); 544 $url = KTUtil::addQueryString($url, "kt_path_info=" . $subpath);
545 } 545 }
546 } 546 }
547 - 547 +
548 return KTUtil::addQueryString($url, $qs); 548 return KTUtil::addQueryString($url, $qs);
549 } 549 }
550 // }}} 550 // }}}
@@ -610,19 +610,19 @@ class KTUtil { @@ -610,19 +610,19 @@ class KTUtil {
610 } 610 }
611 $i += 1; 611 $i += 1;
612 } 612 }
613 - 613 +
614 $oStopwords =& KTStopwords::getSingleton(); 614 $oStopwords =& KTStopwords::getSingleton();
615 615
616 $words = array(); 616 $words = array();
617 foreach ($word_parts as $part) { 617 foreach ($word_parts as $part) {
618 $w = (array) explode(' ', $part); 618 $w = (array) explode(' ', $part);
619 - foreach ($w as $potential) {  
620 - if (strlen($potential) >= $iMinWord && !$oStopwords->isStopword($potential)) {  
621 - $words[] = $potential; 619 + foreach ($w as $potential) {
  620 + if (strlen($potential) >= $iMinWord && !$oStopwords->isStopword($potential)) {
  621 + $words[] = $potential;
622 } 622 }
623 } 623 }
624 - }  
625 - 624 + }
  625 +
626 return array( 626 return array(
627 'words' => $words, 627 'words' => $words,
628 'phrases' => $phrases, 628 'phrases' => $phrases,
@@ -630,7 +630,7 @@ class KTUtil { @@ -630,7 +630,7 @@ class KTUtil {
630 } 630 }
631 631
632 function phraseQuote($sQuery) { 632 function phraseQuote($sQuery) {
633 - foreach(KTUtil::phraseSplit($sQuery) as $k => $v) { 633 + foreach(KTUtil::phraseSplit($sQuery) as $k => $v) {
634 $t = array(); 634 $t = array();
635 foreach ($v as $part) { 635 foreach ($v as $part) {
636 $t[] = sprintf('+"%s"', $part); 636 $t[] = sprintf('+"%s"', $part);
@@ -657,7 +657,7 @@ class KTUtil { @@ -657,7 +657,7 @@ class KTUtil {
657 } 657 }
658 return null; 658 return null;
659 } 659 }
660 - 660 +
661 function getSystemSetting($name, $default = null) { 661 function getSystemSetting($name, $default = null) {
662 // XXX make this use a cache layer? 662 // XXX make this use a cache layer?
663 $sTable = KTUtil::getTableName('system_settings'); 663 $sTable = KTUtil::getTableName('system_settings');
@@ -666,15 +666,15 @@ class KTUtil { @@ -666,15 +666,15 @@ class KTUtil {
666 array($name), 666 array($name),
667 ); 667 );
668 $res = DBUtil::getOneResultKey($aQuery, 'value'); 668 $res = DBUtil::getOneResultKey($aQuery, 'value');
669 - if (PEAR::isError($res)) { 669 + if (PEAR::isError($res)) {
670 return PEAR::raiseError(sprintf(_kt('Unable to retrieve system setting %s: %s'), $name, $res->getMessage())); 670 return PEAR::raiseError(sprintf(_kt('Unable to retrieve system setting %s: %s'), $name, $res->getMessage()));
671 } 671 }
672 - 672 +
673 if (is_null($res)) { return $default; } 673 if (is_null($res)) { return $default; }
674 - 674 +
675 return $res; 675 return $res;
676 } 676 }
677 - 677 +
678 function setSystemSetting($name, $value) { 678 function setSystemSetting($name, $value) {
679 // we either need to insert or update: 679 // we either need to insert or update:
680 $sTable = KTUtil::getTableName('system_settings'); 680 $sTable = KTUtil::getTableName('system_settings');
@@ -752,7 +752,7 @@ class KTUtil { @@ -752,7 +752,7 @@ class KTUtil {
752 $aRet = array(); 752 $aRet = array();
753 foreach ($aEntities as $oEnt) { 753 foreach ($aEntities as $oEnt) {
754 $meth = array(&$oEnt, $sIdFunc); 754 $meth = array(&$oEnt, $sIdFunc);
755 - $id = call_user_func($meth); 755 + $id = call_user_func($meth);
756 $aRet[$id] = $oEnt; 756 $aRet[$id] = $oEnt;
757 } 757 }
758 return $aRet; 758 return $aRet;