r98114 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98113‎ | r98114 | r98115 >
Date:06:24, 26 September 2011
Author:questpc
Status:deferred
Tags:
Comment:
Renamed serialized interpretations to structured interpretations (to describe the purpose, not the implementation).
Modified paths:
  • /trunk/extensions/QPoll/archives/qpoll_serialized_interpretation.src (deleted) (history)
  • /trunk/extensions/QPoll/archives/qpoll_structured_interpretation.src (added) (history)
  • /trunk/extensions/QPoll/i18n/qp.i18n.php (modified) (history)
  • /trunk/extensions/QPoll/maintenance/qp_schemaupdater.php (modified) (history)
  • /trunk/extensions/QPoll/qp_interpret.php (modified) (history)
  • /trunk/extensions/QPoll/qp_pollstore.php (modified) (history)
  • /trunk/extensions/QPoll/qp_user.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/i18n/qp.i18n.php
@@ -123,6 +123,7 @@
124124 'qp_error_unique' => 'Question of type unique() has more proposals than possible answers defined: Impossible to complete.',
125125 'qp_error_no_more_attempts' => 'You have reached maximal number of submitting attempts for this poll.',
126126 'qp_error_interpretation_no_return' => 'Interpretation script returned no result.',
 127+ 'qp_error_structured_interpretation_is_too_long' => 'Structured interpretation is too long to be stored in database. Please correct your interpretation script.',
127128 'qp_error_no_json_decode' => 'Interpretation of poll answers requires json_decode() PHP function.',
128129 'qp_error_eval_missed_lang_attr' => 'XML attribute "lang" is required to choose proper interpretation language.',
129130 'qp_error_eval_mix_languages' => 'Single interpretation script cannot mix different interpretation languages: "$1", "$2".',
@@ -2634,6 +2635,7 @@
26352636 'qp_error_unique' => 'Опрос, имеющий тип unique(), не должен иметь больше ответов чем вопросов',
26362637 'qp_error_no_more_attempts' => 'Исчерпано количество попыток ответа на данный опрос',
26372638 'qp_error_interpretation_no_return' => 'Скрипт интерпретации не вернул результат',
 2639+ 'qp_error_structured_interpretation_is_too_long' => 'Структурированная интерпретация слишком длинна для хранения в базе данных. Пожалуйста скорректируйте Ваш скрипт интерпретации.',
26382640 );
26392641
26402642 /** Rusyn (Русиньскый)
Index: trunk/extensions/QPoll/maintenance/qp_schemaupdater.php
@@ -103,8 +103,8 @@
104104 'qp_poll_desc' => array( 'interpretation_namespace', 'interpretation_title' ),
105105 'qp_users_polls' => array( 'attempts', 'short_interpretation', 'long_interpretation' )
106106 ),
107 - 'qpoll_serialized_interpretation.src' => array(
108 - 'qp_users_polls' => array( 'serialized_interpretation' )
 107+ 'qpoll_structured_interpretation.src' => array(
 108+ 'qp_users_polls' => array( 'structured_interpretation' )
109109 )
110110 );
111111
Index: trunk/extensions/QPoll/qp_interpret.php
@@ -137,11 +137,22 @@
138138 if ( $interpResult->isError() ) {
139139 return $interpResult->setDefaultErrorMessage();
140140 }
141 - if ( !isset( $result['short'] ) || !isset( $result['long'] ) ) {
 141+ $interpCount = 0;
 142+ foreach ( qp_Setup::$show_interpretation as $interpType => $show ) {
 143+ if ( isset( $result[$interpType] ) ) {
 144+ $interpCount++;
 145+ }
 146+ }
 147+ if ( $interpCount == 0 ) {
142148 return $interpResult->setError( wfMsg( 'qp_error_interpretation_no_return' ) );
143149 }
144 - $interpResult->short = (string) $result['short'];
145 - $interpResult->long = (string) $result['long'];
 150+ $interpResult->structured = serialize( isset( $result['structured'] ) ? $result['structured'] : null );
 151+ if ( strlen( $interpResult->structured ) > qp_Setup::$structured_interpretation_max_length ) {
 152+ unset( $interpResult->structured );
 153+ return $interpResult->setError( wfMsg( 'qp_error_structured_interpretation_is_too_long' ) );
 154+ }
 155+ $interpResult->short = isset( $result['short'] ) ? strval( $result['short'] ) : '';
 156+ $interpResult->long = isset( $result['long'] ) ? strval( $result['long'] ) : '';
146157 return $interpResult;
147158 }
148159
Index: trunk/extensions/QPoll/archives/qpoll_serialized_interpretation.src
@@ -1,3 +0,0 @@
2 -ALTER TABLE /*$wgDBprefix*/qp_users_polls
3 - ADD COLUMN serialized_interpretation text NOT NULL default '';
Index: trunk/extensions/QPoll/archives/qpoll_structured_interpretation.src
@@ -0,0 +1,3 @@
 2+-- fields to store the interpretation results
 3+ALTER TABLE /*$wgDBprefix*/qp_users_polls
 4+ ADD COLUMN structured_interpretation text NOT NULL default '';
Index: trunk/extensions/QPoll/qp_user.php
@@ -202,11 +202,13 @@
203203 # it is important only for question type="text", where
204204 # proposal text contains serialized array of proposal parts and category fields
205205 public static $proposal_max_length = 768;
206 - # whether to show short, long, serialized interpretation results to end user
 206+ # not larger than DB field size, otherwise serialization will be invalid
 207+ public static $structured_interpretation_max_length = 65535;
 208+ # whether to show short, long, structured interpretation results to end user
207209 public static $show_interpretation = array(
208210 'short' => false,
209211 'long' => true,
210 - 'serialized' => false
 212+ 'structured' => false
211213 );
212214 /* end of default configuration settings */
213215
Index: trunk/extensions/QPoll/qp_pollstore.php
@@ -16,9 +16,10 @@
1717 # by default, it is public (displayed everywhere)
1818 # blank value means long answer is unavailable
1919 var $long = '';
20 - # serialized answer. one dimensional array with numeric keys and scalar values.
 20+ # structured answer. scalar value or an associative array.
 21+ # objects are not allowed.
2122 # it is exported to XLS voices and can be analyzed by external tools.
22 - var $serialized = '';
 23+ var $structured = null;
2324 # error message. non-blank value indicates interpretation script error
2425 # either due to incorrect script code, or a script-generated one
2526 var $error = '';

Status & tagging log