Comments (7)
Without a reproduction scenario it's hard to say. Have you searched for the error online? Maybe this helps: https://stackoverflow.com/questions/33936067/cannot-use-output-buffering-in-output-buffering-display-handlers#34164495
This might suggest that you are calling Smarty from an ob_start callback. But I don't know if that is accurate of course.
from smarty.
I'm not using such a callback. To solve this issue I've had removed my only ob_start('ob_gzhandler');
call and currently using no output buffering at all. The result was the error logged above. Could perhaps a misconfigured php.ini relate to that?
from smarty.
@Chrissyx I've tried to reproduce this, but I can't. Can you show a (preferably minimal) example that triggers this error?
from smarty.
After spending five more hours into researching the issue, I think I finally found it. It happens by displaying a fairly large website with a lot of HTML data. Locally on my machine I got a blank page and this error logged by system:
PHP Fatal error: PHP Request Shutdown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
However by using the debugger on the same view it crashed due to this:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 49690624 bytes) in vendor\smarty\smarty\libs\sysplugins\smarty_internal_template.php on line 234
Note that providing and assigning the data to render is no problem at all. It actually fails by printing out the surrounding tags as stated in the TPL file, e.g. as list entries with images and links. Not sure if Smarty can handle it better, but the initial error was definitely misleading.
from smarty.
That must be a SERIOUSLY complex template if 128MB of RAM isn't enough to render it. Does the problem go away if you bump the PHP limit up to 256MB?
from smarty.
Yes, it solves the problem and the page renders with no errors in the log.
The template is not complex at all, it's just a long list with ~120k entries. I saved the page and it resulted in a 31 MB downloaded HTML file. So yeah, that might explain something.
from smarty.
That sounds about right. At line 234, Smarty retrieves the template output from its internal buffer and writes it to output. If you have your own gzipping output buffer active however, PHP will need to allocate enough space to store the output in memory. From you error message, this is 49690624 bytes or approximately 47 MB which approximately matches your resulting 31 MB downloaded file.
Since the application has already used a bunch of memory for loading the data, the templates and passing the data to the templates, this in turn results in a memory overflow.
One could imagine a more efficient method of rendering the data in smaller batches and eliminating output buffers where possible, but for this use case an increasing the memory limit seems the easiest fix.
from smarty.
Related Issues (20)
- PHP Deprecated: Using Smarty::loadFilter() to load filters is deprecated and will be removed in a future release.
- Smarty v5 $smarty.template behavior doesn't match v5 documentation (it now includes a type and directory part)
- Smarty v5 built-in json_encode modifier doesn't take Smarty $_CHARSET encoding into account, and can't be overridden using registerPlugin() HOT 18
- value and name of backed enums
- use a trailing comma in arrays HOT 1
- Support nullsafe operator HOT 2
- Fatal error: Uncaught --> Smarty: Unable to write file [file_path] thrown in C:\[project_path]\vendor\smarty\smarty\src\Smarty.php on line 1732 HOT 6
- Request for `prependTemplateDir()` or more options with `addTemplateDir()` - weight, duplicate handling HOT 9
- undefined extension class 'Smarty_Internal_Method_Get_Template_Vars' HOT 1
- Is it possible patch v2 for PHP8 instead of migrating to v4+? HOT 1
- default modifier ignores nocache on variables
- Smarty registered classes check prevents use of class constants to avoid typo bugs in templates HOT 2
- 4.5.3: Function whitelist via Smarty_Security is being ignored
- Misleading error messages with {capture}
- Smarty v5 Error: {section} Tag First Argument Type Mismatch when opening and closing tag on NoCache HOT 3
- Help with Smarty dateformat modifier - change to dd/mm/yyyy HOT 5
- Error: For loop not working when using extends resource type
- Smarty Not Working HOT 3
- XAXOKPIMUE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smarty.