php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60076 mb_substr reaches max execution time even on 200 character text
Submitted: 2011-10-17 12:15 UTC Modified: 2013-02-18 00:35 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: boris at east dot fi Assigned:
Status: No Feedback Package: mbstring related
PHP Version: 5.3.8 OS: linux/ubuntu 10.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: boris at east dot fi
New email:
PHP Version: OS:

 

 [2011-10-17 12:15 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-18 15:09 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2011-10-18 15:09 UTC] cataphract@php.net
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)?
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 13:01:29 2024 UTC