Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Import.php |
— | — | @@ -34,7 +34,8 @@ |
35 | 35 | if ( count( $msglines ) < 2 ) { // error: no elements for this namespace |
36 | 36 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
37 | 37 | $this->addError( wfMsgForContent( 'smw_unknown_importns', $onto_ns ) ); |
38 | | - return true; |
| 38 | + $this->m_dataitem = new SMWDIString( 'ERROR' ); |
| 39 | + return; |
39 | 40 | } |
40 | 41 | |
41 | 42 | // browse list in smw_import_* for section |
— | — | @@ -94,7 +95,7 @@ |
95 | 96 | // |
96 | 97 | // if (null != $error) { |
97 | 98 | // $this->addError($error); |
98 | | -// return true; |
| 99 | +// return; |
99 | 100 | // } |
100 | 101 | // } |
101 | 102 | |
— | — | @@ -103,16 +104,13 @@ |
104 | 105 | } catch ( SMWStringLengthException $e ) { |
105 | 106 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
106 | 107 | $this->addError( wfMsgForContent( 'smw_maxstring', '"' . $this->m_namespace . ' ' . $this->m_section . ' ' . $this->m_uri . '"' ) ); |
107 | | - $this->m_dataitem = new SMWDIString( '' ); |
| 108 | + $this->m_dataitem = new SMWDIString( 'ERROR' ); |
108 | 109 | } |
109 | 110 | |
110 | 111 | // check whether caption is set, otherwise assign link statement to caption |
111 | 112 | if ( $this->m_caption === false ) { |
112 | 113 | $this->m_caption = "[" . $this->m_uri . " " . $this->m_qname . "] (" . $this->m_name . ")"; |
113 | 114 | } |
114 | | - |
115 | | - |
116 | | - return true; |
117 | 115 | } |
118 | 116 | |
119 | 117 | protected function parseDBkeys( $args ) { |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Linear.php |
— | — | @@ -30,8 +30,7 @@ |
31 | 31 | $this->m_unitin = $this->m_unitids[$unit]; |
32 | 32 | $this->m_dataitem = new SMWDINumber( $number / $this->m_unitfactors[$this->m_unitin], $this->m_typeid ); |
33 | 33 | return true; |
34 | | - } else { // unsupported unit, initialize at least the dataitem (just a fallback, not relevant) |
35 | | - $this->m_dataitem = new SMWDINumber( 0 ); |
| 34 | + } else { // unsupported unit |
36 | 35 | return false; |
37 | 36 | } |
38 | 37 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_TypeList.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | } catch ( SMWStringLengthException $e ) { |
61 | 61 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
62 | 62 | $this->addError( wfMsgForContent( 'smw_maxstring', '"' . $stringvalue . '"' ) ); |
63 | | - $this->m_dataitem = new SMWDIString( '' ); |
| 63 | + $this->m_dataitem = new SMWDIString( 'ERROR' ); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Number.php |
— | — | @@ -100,6 +100,7 @@ |
101 | 101 | if ( $this->m_caption === false ) { |
102 | 102 | $this->m_caption = $value; |
103 | 103 | } |
| 104 | + $this->m_dataitem = null; |
104 | 105 | $this->m_unitin = false; |
105 | 106 | $this->m_unitvalues = false; |
106 | 107 | $number = $unit = ''; |
— | — | @@ -111,7 +112,9 @@ |
112 | 113 | } elseif ( $this->convertToMainUnit( $number, $unit ) === false ) { // so far so good: now convert unit and check if it is allowed |
113 | 114 | $this->addError( wfMsgForContent( 'smw_unitnotallowed', $unit ) ); |
114 | 115 | } // note that convertToMainUnit() also sets m_dataitem if valid |
115 | | - return true; |
| 116 | + if ( $this->m_dataitem === null ) { // make sure this is always set |
| 117 | + $this->m_dataitem = new SMWDINumber( 32202, $this->m_typeid ); |
| 118 | + } |
116 | 119 | } |
117 | 120 | |
118 | 121 | protected function parseDBkeys( $args ) { |
— | — | @@ -277,8 +280,7 @@ |
278 | 281 | * Compute the value based on the given input number and unit string. |
279 | 282 | * If the unit is not supported, return false, otherwise return true. |
280 | 283 | * This is called when parsing user input, where the given unit value |
281 | | - * has already been normalized. Note that the internal data item must |
282 | | - * always be set, even if this method returns false. |
| 284 | + * has already been normalized. |
283 | 285 | * |
284 | 286 | * This class does not support any (non-empty) units, but subclasses |
285 | 287 | * may overwrite this behavior. |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Error.php |
— | — | @@ -25,7 +25,6 @@ |
26 | 26 | $this->m_caption = $value; |
27 | 27 | } |
28 | 28 | $this->m_dataitem = new SMWDIBlob( $value ); |
29 | | - return true; |
30 | 29 | } |
31 | 30 | |
32 | 31 | protected function parseDBkeys( $args ) { |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Bool.php |
— | — | @@ -45,7 +45,6 @@ |
46 | 46 | $this->addError( wfMsgForContent( 'smw_noboolean', $value ) ); |
47 | 47 | } |
48 | 48 | $this->m_dataitem = new SMWDIBool( $boolvalue, $this->m_typeid ); |
49 | | - return true; |
50 | 49 | } |
51 | 50 | |
52 | 51 | protected function parseDBkeys( $args ) { |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Time.php |
— | — | @@ -82,9 +82,12 @@ |
83 | 83 | * |
84 | 84 | * I18N includes the preferred order of dates, e.g. to interpret "5 6 2010". |
85 | 85 | * |
86 | | - * @todo Try to reuse more of MediaWiki's records, e.g. to obtain month names or to |
87 | | - * format dates. The problem is that MW is based on SIO timestamps that don't extend to |
88 | | - * very ancient or future dates, and that MW uses PHP functions that are bound to UNIX time. |
| 86 | + * @todo Theparsing process can encounter many kinds of well-defined problems |
| 87 | + * but uses only one error message. More detailed reporting should be done. |
| 88 | + * @todo Try to reuse more of MediaWiki's records, e.g. to obtain month names |
| 89 | + * or to format dates. The problem is that MW is based on SIO timestamps that |
| 90 | + * don't extend to very ancient or future dates, and that MW uses PHP functions |
| 91 | + * that are bound to UNIX time. |
89 | 92 | * |
90 | 93 | * @author Markus Krötzsch |
91 | 94 | * @author Fabian Howahl |
— | — | @@ -143,6 +146,7 @@ |
144 | 147 | if ( $this->m_caption === false ) { // Store the caption now. |
145 | 148 | $this->m_caption = $value; |
146 | 149 | } |
| 150 | + $this->m_dataitem = null; |
147 | 151 | |
148 | 152 | /// TODO Direct JD input currently cannot cope with decimal numbers |
149 | 153 | $datecomponents = array(); |
— | — | @@ -157,19 +161,21 @@ |
158 | 162 | $jd = floatval( reset( $datecomponents ) ); |
159 | 163 | if ( $calendarmodel == 'MJD' ) $jd += SMWTimeValue::MJD_EPOCH; |
160 | 164 | $this->m_dataitem = SMWDITime::newFromJD( $jd, SMWDITime::CM_GREGORIAN, SMWDITime::PREC_YMDT, $this->m_typeid ); |
161 | | - return true; |
162 | 165 | } catch ( SMWDataItemException $e ) { |
163 | | - // fall through |
| 166 | + smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
| 167 | + $this->addError( wfMsgForContent( 'smw_nodatetime', $this->m_wikivalue ) ); |
164 | 168 | } |
| 169 | + } else { |
| 170 | + smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
| 171 | + $this->addError( wfMsgForContent( 'smw_nodatetime', $this->m_wikivalue ) ); |
165 | 172 | } |
166 | | - smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
167 | | - $this->addError( wfMsgForContent( 'smw_nodatetime', $this->m_wikivalue ) ); |
168 | | - } elseif ( $this->setDateFromParsedValues( $datecomponents, $calendarmodel, $era, $hours, $minutes, $seconds, $timeoffset ) ) { |
169 | | - return true; |
| 173 | + } else { |
| 174 | + $this->setDateFromParsedValues( $datecomponents, $calendarmodel, $era, $hours, $minutes, $seconds, $timeoffset ); |
170 | 175 | } |
171 | 176 | } |
172 | | - $this->m_dataitem = new SMWDITime( SMWDITime::CM_GREGORIAN, 32202 ); // always default to something |
173 | | - return true; |
| 177 | + if ( $this->m_dataitem === null ) { // make sure that m_dataitem is set in any case |
| 178 | + $this->m_dataitem = new SMWDITime( SMWDITime::CM_GREGORIAN, 32202 ); |
| 179 | + } |
174 | 180 | } |
175 | 181 | |
176 | 182 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_URI.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | if ( $value == '' ) { // do not accept empty strings |
68 | 68 | $this->addError( wfMsgForContent( 'smw_emptystring' ) ); |
69 | 69 | $this->m_dataitem = new SMWDIURI( 'http', '//example.com', '', '', $this->m_typeid ); // define data item to have some value |
70 | | - return true; |
| 70 | + return; |
71 | 71 | } |
72 | 72 | |
73 | 73 | switch ( $this->m_mode ) { |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | if ( $uri == mb_substr( $value, 0, mb_strlen( $uri ) ) ) { // disallowed URI! |
86 | 86 | $this->addError( wfMsgForContent( 'smw_baduri', $value ) ); |
87 | 87 | $this->m_dataitem = new SMWDIURI( 'http', '//example.com', '', '', $this->m_typeid ); // define data item to have some value |
88 | | - return true; |
| 88 | + return; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | // decompose general URI components |
— | — | @@ -149,10 +149,7 @@ |
150 | 150 | } catch ( SMWDataItemException $e ) { |
151 | 151 | $this->addError( wfMsgForContent( 'smw_baduri', $this->m_wikitext ) ); |
152 | 152 | $this->m_dataitem = new SMWDIURI( 'http', '//example.com', '', '', $this->m_typeid ); // define data item to have some value |
153 | | - return true; |
154 | 153 | } |
155 | | - |
156 | | - return true; |
157 | 154 | } |
158 | 155 | |
159 | 156 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php |
— | — | @@ -126,6 +126,7 @@ |
127 | 127 | if ( $this->m_caption === false ) { |
128 | 128 | $this->m_caption = $value; |
129 | 129 | } |
| 130 | + $this->m_dataitem = null; |
130 | 131 | $this->m_sortkey = ''; |
131 | 132 | if ( $value != '' ) { |
132 | 133 | $this->m_title = Title::newFromText( $value, $this->m_fixNamespace ); |
— | — | @@ -148,12 +149,16 @@ |
149 | 150 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
150 | 151 | $this->addError( wfMsgForContent( 'smw_notitle', $value ) ); |
151 | 152 | } |
| 153 | + if ( $this->m_dataitem === null ) { // make sure that m_dataitem is set in any case |
| 154 | + $this->m_dataitem = new SMWDIWikiPage( 'ERROR', NS_MAIN, '', $this->m_typeid ); |
| 155 | + } |
152 | 156 | } |
153 | 157 | |
154 | 158 | protected function parseDBkeys( $args ) { |
155 | 159 | if ( count( $args ) != 4 ) { |
156 | 160 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
157 | 161 | $this->addError( wfMsgForContent( 'smw_notitle', $this->getPrefixedText() ) ); |
| 162 | + $this->m_dataitem = new SMWDIWikiPage( 'ERROR', NS_MAIN, '', $this->m_typeid ); |
158 | 163 | } else { |
159 | 164 | $this->m_dataitem = new SMWDIWikiPage( $args[0], floatval( $args[1] ), $args[2], $args[3], $this->m_typeid ); |
160 | 165 | $this->m_textform = str_replace( '_', ' ', $this->m_dataitem->getDBkey() ); |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_String.php |
— | — | @@ -30,10 +30,9 @@ |
31 | 31 | $this->m_dataitem = new SMWDIString( $value, $this->m_typeid ); |
32 | 32 | } catch ( SMWStringLengthException $e ) { |
33 | 33 | $this->addError( wfMsgForContent( 'smw_maxstring', '"' . mb_substr( $value, 0, 15 ) . ' … ' . mb_substr( $value, mb_strlen( $value ) - 15 ) . '"' ) ); |
34 | | - $this->m_dataitem = new SMWDIBlob( $value, $this->m_typeid ); // just to make sure that something is defined here |
| 34 | + $this->m_dataitem = new SMWDIBlob( 'ERROR', $this->m_typeid ); // just to make sure that something is defined here |
35 | 35 | } |
36 | 36 | } |
37 | | - return true; |
38 | 37 | } |
39 | 38 | |
40 | 39 | protected function parseDBkeys( $args ) { |