phpbb/phpBB/includes
Nils Adermann 6e31ce8573 Do not store email templates in database. [Bug #54505]
To explain what this is about, first a short phpBB code history lesson: ;-)

r9823 originally introduced the usage of our template class for emails. The
messenger class uses set_custom_template() to initialise the template object
which neither disables storedb nor inheritance. These two values are set in
$user->theme rather than inside a particular template instance (quite a design
failure if I may add). Thus the html page that is displayed to the user also
determines these settings for the email templates. This obviously causes
problems because both emails and other custom templates can quite simply not
be stored in the database because the db table only stores the filename, not
the path and requires a template id.

r9839 then generally disabled storedb and template inheritance for custom
templates to fix Bug #40515. This works for custom templates, but not for
emails where lots of template objects are created. In such a situation the
last call to set(_custom)_template() would now determine the values of storedb
and inheritance in _tpl_load. So any page sending emails would neither load
its template from the database nor use template inheritance. The same revision
also introduced orig_tpl_* variables in set_template() which on their own are
very much pointless, but could allow resetting the storedb and inheritance
values if they were used to reset $user->theme just before template execution
in _tpl_load.

In r10150 these orig_tpl_* variables are correctly used to access information
about the template of the page being displayed - contrary to the last template
used - from within the bbcode, fixing Bug #51285. However r10150 also introduces
a pointless $template_mode parameter for set_custom_template(). $template_mode
is really just a boolean flag (value you can be 'template' or an arbitrary other
value) that if it set circumvents the unsetting of storedb and template
inheritance. The very code that had been added to prevent issues with emails and
custom templates. Fixing the problem introduced by r8839 but at the same time
reintroducing the much greater problem from the original implementation of email
templates.

And now an explanation of what I did:

Based on this I have now changed the set_custom_template method to always
disable storedb. It can now properly use inheritance, you simply tell it the
path where the parent template can be found, by default the path is false which
will turn inheritance off. To make this work the template class now always
overwrites $user->theme storedb and inheritance variabbles with orig_tpl_* just
before rendering a template in _tpl_load. This way they are guaranteed to always
contain the value they had at the time set_template/set_custom_template were
called. This fixes [Bug #54505].

In summary, using global state is simply a horrible idea in object oriented
programming. Always Pass values, that an object depends on, as parameters - never
through magic global variables. Following this principle will safe you from a lot
of headaches.

Please test this patch as much as possible to make sure templates still work
properly for you, focus on multiple languages, missing language files, and
custom templates in systems that make use of the template class outside of
phpBB itself.


git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10460 89ea8834-ac86-4346-8a33-228a782c2dd0
2010-01-26 16:52:46 +00:00
..
acm Oops thanks rxu, fixes r10309 refs #54465 2010-01-07 09:09:39 +00:00
acp Add a warning for users of old PHP versions about ending support. 2010-01-26 15:26:07 +00:00
auth Make sure captcha factory is there. Make sure language array is there. 2010-01-20 00:20:46 +00:00
captcha okay, now the confirm_id is no longer enough to get a new row into the qa table 2010-01-26 15:34:21 +00:00
db Database updater now separates ADD COLUMN from SET NOT NULL and SET DEFAULT, when using PostgreSQL <= 7.4 [Bug #54435] 2010-01-26 02:06:37 +00:00
diff improve code to detect and solve conflicts for code removed from one version to another. 2009-09-20 16:20:20 +00:00
hooks - fixed database updater 2007-10-04 12:03:05 +00:00
mcp Fix bug #55045 - Do not duplicate previous/next links in pagination text of moderator logs and user notes in MCP for subsilver2. 2010-01-24 16:00:18 +00:00
questionnaire [Feature] Ability to use HTTP authentication in ATOM feeds by passing the GET parameter auth=http 2010-01-19 19:08:51 +00:00
search Safe us some more calls to $db->sql_escape(). 2010-01-11 23:26:56 +00:00
ucp [Fix] Don't send activation email when user tries to change email without permission (fix by nrohler). (Bug #56335) 2010-01-25 09:11:16 +00:00
utf - replaced the drop down menu log filter thing with log searching 2009-08-21 21:47:19 +00:00
auth.php Fix Bug #48875 - we compare the bitlength, therefore we indeed do not need to re-cache if we think acl options got changed (which we did) 2009-07-30 14:35:29 +00:00
bbcode.php Fix #51285 and more issues with template inherence on set_custom_template 2009-09-16 08:11:52 +00:00
cache.php Bug #54265 - Regression: Word Censors and Cases 2009-11-26 17:41:47 +00:00
constants.php Tag as 3.0.6 2009-11-14 20:11:38 +00:00
functions.php Trigger error right away if user has exceeded login attempts instead of asking for the authentication data over and over again without accepting it even if it is correct. 2010-01-20 01:05:36 +00:00
functions_admin.php - Bug #56255 - Moving topics to a forum where you are on queue 2010-01-18 16:41:21 +00:00
functions_compress.php - Bug #56255 - Moving topics to a forum where you are on queue 2010-01-18 16:41:21 +00:00
functions_content.php Deprecate $allow_reply parameter to truncate_string() (Bug #56675) 2010-01-25 18:02:37 +00:00
functions_convert.php Apply locale-independent basename() to attachment filenames. New function added: utf8_basename(). (Bug #43335 - Patch by ocean=Yohsuke) 2009-08-01 12:28:50 +00:00
functions_display.php No longer include subforums in forum feed. 2010-01-12 21:15:32 +00:00
functions_install.php The easy solution to all my problems with SQLite is this. :( #56105 2010-01-17 17:41:21 +00:00
functions_jabber.php Fix Jabber SASL PLAIN authentication failures. (Bug #52995) 2009-10-29 15:04:19 +00:00
functions_messenger.php Do not store email templates in database. [Bug #54505] 2010-01-26 16:52:46 +00:00
functions_module.php [Change] Alllow applications to set custom module inclusion path (idea by HoL) 2008-11-23 12:42:34 +00:00
functions_posting.php [Fix] Do not automatically unsubscribe users from topics, when email and jabber is disabled. 2010-01-24 22:30:43 +00:00
functions_privmsgs.php Do not permit unauthorised users to delete private messages from folder listing. #54355 2009-12-11 22:27:00 +00:00
functions_profile_fields.php Correctly check for empty strings in custom profile fields. #55335 2009-12-11 22:55:15 +00:00
functions_template.php Revert INC/DEC feature. It is not consistent with the other template variables - bad idea. ;) We will get to it though... but not now. 2009-08-30 11:15:24 +00:00
functions_transfer.php Also fix bug #46295 in ftp_fsock class. 2009-07-22 03:02:45 +00:00
functions_upload.php why am i so dumb sometimes... /me hits myself with the dumbness stick... 2009-09-13 14:31:32 +00:00
functions_user.php Bug #52525 2009-10-05 17:54:55 +00:00
index.htm Add blank indexes to stop nosey people being, erm, nosey 2001-11-21 13:06:56 +00:00
message_parser.php check for additional empty config variables... 2009-11-01 15:33:44 +00:00
session.php [Fix] Don't send activation email when user tries to change email without permission (fix by nrohler). (Bug #56335) 2010-01-25 18:19:18 +00:00
template.php Do not store email templates in database. [Bug #54505] 2010-01-26 16:52:46 +00:00