Commit dec9ff24a39f0ef4ca5218134bb2db3bc9698c04

Authored by kevin_fourie
1 parent c387c4b4

Merged in from STABLE trunk...

KTS-3660
"Clicking on Document fieldsets causes KT to hang"
Fixed. The while loop would become infinite if the string was longer than 50 chars and had no spaces.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3a-Release-Branch@9247 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/admin/documentFieldsv2.php
@@ -223,21 +223,26 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -223,21 +223,26 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
223 } 223 }
224 224
225 function getTypesForFieldset($oFieldset) { 225 function getTypesForFieldset($oFieldset) {
  226 + global $default;
226 if ($oFieldset->getIsGeneric()) { 227 if ($oFieldset->getIsGeneric()) {
227 return _kt('All types use this generic fieldset.'); 228 return _kt('All types use this generic fieldset.');
228 } 229 }
229 230
230 $types = $oFieldset->getAssociatedTypes(); 231 $types = $oFieldset->getAssociatedTypes();
231 if (PEAR::isError($types)) { 232 if (PEAR::isError($types)) {
  233 + $default->log->debug('Fieldsets admin: Error retrieving list of associated document types.');
232 return _kt('Error retrieving list of types.'); 234 return _kt('Error retrieving list of types.');
233 } 235 }
234 if (empty($types)) { 236 if (empty($types)) {
235 return _kt('None'); 237 return _kt('None');
236 } 238 }
  239 +
237 $aNames = array(); 240 $aNames = array();
238 foreach ($types as $oType) { 241 foreach ($types as $oType) {
239 if (!PEAR::isError($oType)) { 242 if (!PEAR::isError($oType)) {
240 $aNames[] = $oType->getName(); 243 $aNames[] = $oType->getName();
  244 + }else{
  245 + $default->log->debug('Fieldsets admin: Document type gives error: '.$oType->getMessage());
241 } 246 }
242 } 247 }
243 248
@@ -247,9 +252,12 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -247,9 +252,12 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
247 if($length < 50){ 252 if($length < 50){
248 return $list; 253 return $list;
249 } 254 }
  255 + $default->log->debug('Fieldsets admin: wrapping the list of doc types from length '.$length);
250 256
  257 + // Wrap the list to 50 characters per line
251 $wrapList = ''; 258 $wrapList = '';
252 - while ($length > 50){ 259 + $cut = 0;
  260 + while ($length > 50 && $cut !== false){
253 $cut = strpos($list, ' ', 50); 261 $cut = strpos($list, ' ', 50);
254 $wrapList .= mb_strcut($list, 0, $cut); 262 $wrapList .= mb_strcut($list, 0, $cut);
255 $wrapList .= '<br />'; 263 $wrapList .= '<br />';