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