Comments (16)
Any clue? The writeFile
method (the one triggering the error) hasn't been changed.
A reproduction scenario would help. Does the error not occur with Smarty v4.3?
from smarty.
Right. I just tested with 4.3 and found the same error. How to help?
from smarty.
I have something more in logs. An access error on renaming (with v4.3):
[2023-08-31T00:30:52+02:00] PHP Warning: rename(C:\devel\www\wkxlocal\cache\templates\default\compile\wrt64efc31c2f0678_24005802,C:\devel\www\wkxlocal\cache\templates\default\compile\98311c0ceca995f0db9f4ad41b2dcfa2b27b16c2_0.file.display.tpl.php): Accès refusé (code: 5) in C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Smarty.php on line 1818
[2023-08-31T00:30:52+02:00] #1 rename called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Smarty.php:1818]
[2023-08-31T00:30:52+02:00] #2 Smarty\Smarty->writeFile called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:232]
[2023-08-31T00:30:52+02:00] #3 Smarty\Template\Compiled->write called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:195]
[2023-08-31T00:30:52+02:00] #4 Smarty\Template\Compiled->compileAndWrite called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:148]
[2023-08-31T00:30:52+02:00] #5 Smarty\Template\Compiled->compileAndLoad called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:108]
[2023-08-31T00:30:52+02:00] #6 Smarty\Template\Compiled->render called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:184]
[2023-08-31T00:30:52+02:00] #7 Smarty\Template->render called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:639]
[2023-08-31T00:30:52+02:00] #8 Smarty\Template->_execute called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:576]
[2023-08-31T00:30:52+02:00] #9 Smarty\Template->display called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Smarty.php:2243]
[2023-08-31T00:30:52+02:00] #10 Smarty\Smarty->display called at [C:\devel\www\wkxlocal\core\libs\CLOSE.php:241]
[2023-08-31T00:30:52+02:00] #11 CLOSE->__construct called at [C:\devel\www\wkxlocal\core\libs\CLOSE.php:367]
[2023-08-31T00:30:52+02:00] #12 CLOSEPOPUP->__construct called at [C:\devel\www\wkxlocal\core\startup\FACTORY.php:608]
[2023-08-31T00:30:52+02:00] #13 FACTORY_CLOSEPOPUP::getInstance called at [C:\devel\www\wkxlocal\public\tinymce\plugins\wkxcharmap\dialog_column_right.php:105]
[2023-08-31T00:30:52+02:00]
from smarty.
from smarty.
An other example after cleaning the compile directory by hand (with v4.3):
[2023-08-31T00:48:28+02:00] PHP Warning: rename(C:\devel\www\wkxlocal\cache\templates\default\compile\wrt64efc73bef1716_94705877,C:\devel\www\wkxlocal\cache\templates\default\compile\e8aa5c4d14c9bcd5d59a3c94eb62fdd56be81fe7_0.file.content.tpl.php): Accès refusé (code: 5) in C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Smarty.php on line 1818
[2023-08-31T00:48:28+02:00] #1 rename called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Smarty.php:1818]
[2023-08-31T00:48:28+02:00] #2 Smarty\Smarty->writeFile called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:232]
[2023-08-31T00:48:28+02:00] #3 Smarty\Template\Compiled->write called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:195]
[2023-08-31T00:48:28+02:00] #4 Smarty\Template\Compiled->compileAndWrite called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:148]
[2023-08-31T00:48:28+02:00] #5 Smarty\Template\Compiled->compileAndLoad called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:108]
[2023-08-31T00:48:28+02:00] #6 Smarty\Template\Compiled->render called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:184]
[2023-08-31T00:48:28+02:00] #7 Smarty\Template->render called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:289]
[2023-08-31T00:48:28+02:00] #8 Smarty\Template->renderSubTemplate called at [C:\devel\www\wkxlocal\cache\templates\default\compile\98311c0ceca995f0db9f4ad41b2dcfa2b27b16c2_0.file.display.tpl.php:81]
[2023-08-31T00:48:28+02:00] #9 content_64efc73bd4d1c4_85818131 called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\GeneratedPhpFile.php:110]
[2023-08-31T00:48:28+02:00] #10 Smarty\Template\GeneratedPhpFile->getRenderedTemplateCode called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template\Compiled.php:115]
[2023-08-31T00:48:28+02:00] #11 Smarty\Template\Compiled->render called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:184]
[2023-08-31T00:48:28+02:00] #12 Smarty\Template->render called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:639]
[2023-08-31T00:48:28+02:00] #13 Smarty\Template->_execute called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Template.php:576]
[2023-08-31T00:48:28+02:00] #14 Smarty\Template->display called at [C:\devel\www\wkxlocal\core\libs\vendor\smarty\smarty\smarty\src\Smarty.php:2252]
[2023-08-31T00:48:28+02:00] #15 Smarty\Smarty->display called at [C:\devel\www\wkxlocal\core\libs\CLOSE.php:241]
[2023-08-31T00:48:28+02:00] #16 CLOSE->__construct called at [C:\devel\www\wkxlocal\core\libs\CLOSE.php:367]
[2023-08-31T00:48:28+02:00] #17 CLOSEPOPUP->__construct called at [C:\devel\www\wkxlocal\core\startup\FACTORY.php:608]
[2023-08-31T00:48:28+02:00] #18 FACTORY_CLOSEPOPUP::getInstance called at [C:\devel\www\wkxlocal\public\tinymce\plugins\wkxcharmap\dialog_column_left.php:82]
[2023-08-31T00:48:28+02:00]
from smarty.
What are the steps you take that trigger the error?
from smarty.
WIKINDX use globals to collect variables to render. Smarty is called only at the end for rendering by the CLOSE::_construct() function. Smarty's behavior is configured just before rendering by TEMPLATE::loadTemplate().
There are only two differences from the common case where the error is not triggered:
- The setForceCompile() is called
- The CLOSE::_construct() is called by CLOSENOMENU::_construct() which disables the menu template included from the display template.
Maybe I'm doing something incompatible during configuration, calling functions in the wrong order, or there's an error in the template?
Do you need any other information?
from smarty.
- Does the error occur every time you call
$smarty->display()
? - Can you provide a minimal example (without any of the WIKINDX code) that triggers this error?
from smarty.
This happens whenever $smarty->display()
is called, Force compile is enabled, and the menu is hidden. In a context where the menu is displayed there is no error.
I'm preparing a minimal example for tomorrow.
from smarty.
A minimal example is attached.
You need to call many time the index.php page from this archive with a browser to trigger the error.
The error occurs less often because I removed a lot of code.
My understanding of the error is this: as index.php uses an HTML frame to call two pages that are rendered separately but at the same time when Force Compile is enabled the destruction of the templates can cause a race condition when the compiled templates are recreated.
from smarty.
Yes, that seems reasonable. And I'm not sure this can be fixed easily.
This is one the reasons why you would not want to use force compile in production.
from smarty.
We don't use it in production fortunately. Forgetting to disable it during development is the only annoyance. So I no longer see any reason to worry about this problem either.
I'm just wondering why this strategy of writing to a temporary file then renaming it to write it directly to the file?
from smarty.
Interestingly, I believe this was introduced to prevent a race condition where two processes would write to the same file... 🤪
from smarty.
Concurrency is hard... It would have been better to write directly and if that fails to set a pause of a few microseconds then try again once.
I am making a proposal since this seems like an opportunity. I wrote an SQLite storage backend of the cached and compiled pages. This was to test feasibility and performance. It seemed more efficient to me than writing directly to files. Is this a good replacement option or a contribution you would accept? And if you accept it, I undertake to maintain this code.
from smarty.
SQLite stores the whole database as a single file and locks the database file during writing.
Thus, I doubt it would be more efficient than writing to (separate) files directly.
from smarty.
I noticed during the test that the same page was displayed twice as fast.
But it's true that it wasn't a server facing the internet.
https://sourceforge.net/p/wikindx/v5bugs/604/#788e/7713
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
- Smarty_Internal_Template::render(): Cannot use output buffering in output buffering display handlers HOT 7
- 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 7
- 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 HOT 1
- 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.