Edit report at https://bugs.php.net/bug.php?id=60076&edit=1

 ID:                 60076
 Updated by:         cataphr...@php.net
 Reported by:        boris at east dot fi
 Summary:            mb_substr reaches max execution time even on 200
                     character text
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            mbstring related
 Operating System:   linux/ubuntu 10.04
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

I can't reproduce this. I'd say the error is somewhere else. Can you reproduce 
this from the command line? If possible, can you profile PHP (or at least 
attach a debugger and show the stack trace)?


Previous Comments:
------------------------------------------------------------------------
[2011-10-17 12:15:04] boris at east dot fi

Description:
------------
mb_substr reaches max execution time of 30s even when it should subtract small 
amount of characters. In our case blog posts content (around 200 characters) 
was 
not been substracted to 140 with mb_substr. 

Workaround which does not bypass the max execution time is to use the following 
instead:
utf8_encode(substr(utf8_decode($str),$start,$length))

which looks ugly but at least works :)

Test script:
---------------
$utf8Text = "Terveisiä Pohjanmaalta! Anoppilaan kävi matka näin 
syyslomaviikon edellä ja ajattelin tehdä pienen tilannekatsauksen 
kesärenkaiden suhteen.


Kilometrit 15.10.2011

Hakka Bluet ovat rullanneet auton alla noin 1200 kilometriä, eivätkä renkaat 
ole aiheuttaneet hämmennystä. Sekä allekirjoittanut että muut autoa 
käyttäneet ovat tyytyväisiä. Koska ajo on ollut lähinnä työmatka-ajoa 
sekä rauhallista maantieajoa, ei mitään suuria ajo-ominaisuuskoitoksia ole 
matkan varrelle sattunut. Lähinnä tällä viikolla pari pakkasaamua ovat 
aiheuttaneet kiinnostusta pidon suhteen, mutta mustaa jäätäkään ei ole 
löytynyt sen vertaa, että ajonvakautus olisi edes herännyt. Kaikki siis 
hyvin, mennään hiljaa ja matalalla.";

$short = mb_substr($utf8Text, 0, 140, "UTF-8");



Expected result:
----------------
subtracted result. ie 
$short == "Terveisiä Pohjanmaalta! Anoppilaan kävi matka näin syyslomaviikon 
edellä ja ajattelin tehdä pienen tilannekatsauksen kesärenkaiden suhteen. 
Kilometrit" 

Actual result:
--------------
max execution time of 30s reached error


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60076&edit=1

Reply via email to