Max Execution Timeout 30 Seconds/Mbstring Error Laravel 6*
Asked Answered
J

3

6

I am working in Laravel 6.2 and have a basic database that houses a questions table that brings back an id, slug, title, body, timestamps. I have a route set up at questions that calls a controller which queries the DB and the passes the questions to a view index.blade.php and here I display questions with pagination. The issue is that I can display the $questions->title just fine but when I try to display the $question->body I keep getting a specific timeout error. I already changed the max_execution in my .ini from 30 to 300 and to no avail.

Specific Error

PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /home/projects/inquiry-app/vendor/symfony/polyfill-mbstring/Mbstring.php on line 603

Line 603:

return (string) iconv_substr($s, $start, $length, $encoding);

Web.php

Route::get('/', function () {
    return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('questions', 'QuestionsController');

QuestionsController

class QuestionsController extends Controller
{
    public function index()
    {
        $questions = Question::latest()->paginate(2);

        return view('questions.index', compact('questions'));
    }
}

index.blade.php

 @foreach($questions as $question)
                            <div class="media">
                                <div class="media-body">
                                    <h3 class="mt-0">{{$question->title}}</h3>
{{--                                    <p>{{Str::limit($question->body, 10)}}</p>--}}
                                </div>
                            </div>
                            <hr>
                       @endforeach

Any ideas why I would be getting this error? The page loads if the $question->body line is commented out.

I am on Ubuntu 19.04, Laravel 6.2, php7.3(FPM/FastCGI)

Thank you.

Jessee answered 22/1, 2020 at 2:46 Comment(0)
J
3

Answer to my own question. When I remove the {{Str::limit}} from the $question->body line it works perfectly. I am unsure why this is causing an issue but by removing that part of the code, it seems to work now.

Jessee answered 22/1, 2020 at 2:52 Comment(0)
L
8

To late but for someone got this issue.
This issue came from php mb-string not work well.
So reinstall php mb-string can fix this error.

Laynelayney answered 19/7, 2020 at 0:59 Comment(0)
J
3

Answer to my own question. When I remove the {{Str::limit}} from the $question->body line it works perfectly. I am unsure why this is causing an issue but by removing that part of the code, it seems to work now.

Jessee answered 22/1, 2020 at 2:52 Comment(0)
A
3

Edit: Too late to answer OP's question.

If you are using Apache, check which version of PHP is being served.

php-cli used was php8.0 however, Apache was using php7.4. This resulted in Symfony's polyfill-mbstring library to timeout because the module was not enabled.

Angelineangelique answered 2/2, 2021 at 22:32 Comment(1)
How did you fix it?Interim

© 2022 - 2024 — McMap. All rights reserved.