Add try catch around JSON parse of users meta values (https://github.com/woocommerce/woocommerce-admin/pull/6819)
* Add try catch around JSON parse of users meta values * Add changelog
This commit is contained in:
parent
89c19a4d20
commit
28d4c03ae0
|
@ -1,3 +1,7 @@
|
||||||
|
# Unreleased
|
||||||
|
|
||||||
|
- Fix parsing bad JSON string data in useUserPreferences hook. #6819
|
||||||
|
|
||||||
# 1.2.0
|
# 1.2.0
|
||||||
|
|
||||||
- Add management of persisted queries to navigation data store.
|
- Add management of persisted queries to navigation data store.
|
||||||
|
|
|
@ -18,11 +18,21 @@ import { STORE_NAME } from './constants';
|
||||||
const getWooCommerceMeta = ( user ) => {
|
const getWooCommerceMeta = ( user ) => {
|
||||||
const wooMeta = user.woocommerce_meta || {};
|
const wooMeta = user.woocommerce_meta || {};
|
||||||
|
|
||||||
const userData = mapValues( wooMeta, ( data ) => {
|
const userData = mapValues( wooMeta, ( data, key ) => {
|
||||||
if ( ! data || data.length === 0 ) {
|
if ( ! data || data.length === 0 ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return JSON.parse( data );
|
try {
|
||||||
|
return JSON.parse( data );
|
||||||
|
} catch ( e ) {
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
console.error(
|
||||||
|
`Error parsing value '${ data }' for ${ key }`,
|
||||||
|
e.message
|
||||||
|
);
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
return '';
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
return userData;
|
return userData;
|
||||||
|
|
|
@ -104,6 +104,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
|
||||||
- Fix: Pause inbox message "GivingFeedbackNotes" #6802
|
- Fix: Pause inbox message "GivingFeedbackNotes" #6802
|
||||||
- Tweak: Sort the extension task list by completion status and allow toggling visibility. #6792
|
- Tweak: Sort the extension task list by completion status and allow toggling visibility. #6792
|
||||||
- Fix: Missed DB version number updates causing unnecessary upgrades. #6818
|
- Fix: Missed DB version number updates causing unnecessary upgrades. #6818
|
||||||
|
- Fix: Parsing bad JSON string data from user WooCommerce meta. #6819
|
||||||
|
|
||||||
== 2.2.0 3/30/2021 ==
|
== 2.2.0 3/30/2021 ==
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue