r61888 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61887‎ | r61888 | r61889 >
Date:22:02, 2 February 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added support for form definition caching
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -124,8 +124,7 @@
125125 return false;
126126 }
127127
128 -
129 - function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null, $is_query = false, $embedded = false) {
 128+ function formHTML($form_def, $form_id, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null, $is_query = false, $embedded = false) {
130129 global $wgRequest, $wgUser, $wgParser;
131130 global $sfgTabIndex; // used to represent the current tab index in the form
132131 global $sfgFieldNum; // used for setting various HTML IDs
@@ -219,7 +218,22 @@
220219 $wgParser->mStripState = new StripState();
221220 $wgParser->mOptions = new ParserOptions();
222221 $wgParser->mOptions->initialiseFromUser($wgUser);
223 - $form_def = $wgParser->parse($form_def, $this->mPageTitle, $wgParser->mOptions)->getText();
 222+
 223+ // get the form definition from the cache, if we're using caching and it's
 224+ // there
 225+ $got_form_def_from_cache = false;
 226+ global $sfgCacheFormDefinitions;
 227+ if ($sfgCacheFormDefinitions) {
 228+ $db =& wfGetDB( DB_MASTER );
 229+ $res = $db->select('page_props', 'pp_value', "pp_propname = 'formdefinition' AND pp_page = $form_id");
 230+ if ($res->numRows() > 0) {
 231+ $form_def = $res->fetchObject()->pp_value;
 232+ $got_form_def_from_cache = true;
 233+ }
 234+ }
 235+ // otherwise, parse it
 236+ if (! $got_form_def_from_cache)
 237+ $form_def = $wgParser->parse($form_def, $this->mPageTitle, $wgParser->mOptions)->getText();
224238 $wgParser->mStripState = $old_strip_state;
225239
226240 // turn form definition file into an array of sections, one for each
@@ -1175,9 +1189,6 @@
11761190 }
11771191 } else {
11781192 $showFCKEditor = 0;
1179 - // for some reason, the following call was once necessary, but now
1180 - // causes problems
1181 - //$free_text = Sanitizer::safeEncodeAttribute($free_text);
11821193 }
11831194 // now that we have it, substitute free text into the form and page
11841195 $escaped_free_text = Sanitizer::safeEncodeAttribute( $free_text );

Status & tagging log