Index: branches/salvatoreingala/Gadgets/Gadgets_body.php |
— | — | @@ -172,7 +172,16 @@ |
173 | 173 | $m = array(); |
174 | 174 | if ( preg_match( '/gadget-([a-zA-Z](?:[-_:.\w\d ]*[a-zA-Z0-9])?)-config/', $option, $m ) ) { |
175 | 175 | $gadgetName = $m[1]; |
176 | | - $preferencesCache[$gadgetName] = FormatJson::decode( $value, true ); |
| 176 | + wfSuppressWarnings(); |
| 177 | + $gadgetPrefs = unserialize( $value ); |
| 178 | + wfRestoreWarnings(); |
| 179 | + if ( $gadgetPrefs !== false ) { |
| 180 | + $preferencesCache[$gadgetName] = $gadgetPrefs; |
| 181 | + } else { |
| 182 | + //should not happen; just in case |
| 183 | + wfDebug( __METHOD__ . ": couldn't unserialize settings for gadget " . |
| 184 | + "$gadgetName and user {$curUser->getID()}. Ignoring.\n" ); |
| 185 | + } |
177 | 186 | unset( $options[$option] ); |
178 | 187 | } |
179 | 188 | } |
— | — | @@ -180,20 +189,19 @@ |
181 | 190 | //Record preferences for each gadget |
182 | 191 | $gadgets = Gadget::loadList(); |
183 | 192 | foreach ( $gadgets as $gadget ) { |
184 | | - if ( isset( $preferencesCache[$gadget->getName()] ) ) { |
185 | | - if ( $gadget->getPrefsDescription() !== null ) { |
186 | | - if ( isset( $preferencesCache[$gadget->getName()] ) ) { |
187 | | - $userPrefs = $preferencesCache[$gadget->getName()]; |
188 | | - } |
189 | | - |
190 | | - if ( !isset( $userPrefs ) ) { |
191 | | - $userPrefs = array(); //no saved prefs (or invalid JSON), use defaults |
192 | | - } |
193 | | - |
194 | | - Gadget::matchPrefsWithDescription( $gadget->getPrefsDescription(), $userPrefs ); |
195 | | - |
196 | | - $gadget->setPrefs( $userPrefs ); |
| 193 | + $prefsDescription = $gadget->getPrefsDescription(); |
| 194 | + if ( $prefsDescription !== null ) { |
| 195 | + if ( isset( $preferencesCache[$gadget->getName()] ) ) { |
| 196 | + $userPrefs = $preferencesCache[$gadget->getName()]; |
197 | 197 | } |
| 198 | + |
| 199 | + if ( !isset( $userPrefs ) ) { |
| 200 | + $userPrefs = array(); //no saved prefs (or invalid entry in DB), use defaults |
| 201 | + } |
| 202 | + |
| 203 | + Gadget::matchPrefsWithDescription( $prefsDescription, $userPrefs ); |
| 204 | + |
| 205 | + $gadget->setPrefs( $userPrefs ); |
198 | 206 | } |
199 | 207 | } |
200 | 208 | |
— | — | @@ -223,8 +231,8 @@ |
224 | 232 | if ( $gadget->getPrefs() !== null ) { |
225 | 233 | //TODO: should remove prefs that equal their default |
226 | 234 | |
227 | | - $prefsJson = FormatJson::encode( $gadget->getPrefs() ); |
228 | | - $options["gadget-{$gadget->getName()}-config"] = $prefsJson; |
| 235 | + $prefsSerialized = serialize( $gadget->getPrefs() ); |
| 236 | + $options["gadget-{$gadget->getName()}-config"] = $prefsSerialized; |
229 | 237 | } |
230 | 238 | } |
231 | 239 | |