Mobile app version of vmapp.org
Login or Join
Berryessa370

: Comments unexpectedly truncated in SocialEngine after about 675 characters When a user posts a comment on our SocialEngine website, the comments are unexpectedly truncated after about 670 characters.

@Berryessa370

Posted in: #Comments #Socialengine

When a user posts a comment on our SocialEngine website, the comments are unexpectedly truncated after about 670 characters.

Has anyone experienced this bug before?

The comments are stored in the database in their original untruncated state, so my guess is its' a bug in modules/Core/controllers/CommentController.php somewhere. But after scouring the code for several hours, I'm not closer to finding an answer.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Berryessa370

1 Comments

Sorted by latest first Latest Oldest Best

 

@Murray432

It looks like the bug is in the new line to break rules minifeature. Changing line 24 of /application/libraries/Engine/View/Helper/ViewMore.php:

protected $_maxLineBreaks = 4; // Truncate early if more than this nl


to 12; fixes the problem for now without removing the functionality entirely. I also noticed that the new line to break rule feature doesn't work as advertised. Changing lines 41-55:

// If using line breaks, ensure that there are not too many line breaks
if( $nl2br ) {
$string = trim(preg_replace('/[rn]+/', "n", $string));
if( ($c = substr_count($string, "n")) > $this->_maxLineBreaks) {
$pos = 0;
for( $i = 0; $i < $this->_maxLineBreaks; $i++ ) {
$pos = strpos($string, "n", $pos + 1);
}
if( $pos <= 0 || !is_int($pos) ) {
$pos = null;
}
if( $pos && $pos < $moreLength ) {
$moreLength = $pos;
}
}
}


to

if( $nl2br ) {
$string = preg_replace('{(<br[^>]*>s*)+}', '<br>', nl2br($string));
}


and removing lines 56-60 entirely seems to work better.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme