Skip to content

Commit 218e07e

Browse files
fix: guard against undefined properties on license object in Library (#1269)
* fix: guard against undefined properties on license object in Library When the license option is stored as a stdClass without `key` or `download_id` properties (e.g. on a free/unlicensed install), PHP 8 throws an undefined-property notice. Add isset() guards so both properties fall back to an empty string. * fix: fix telemetry error
1 parent 71156c2 commit 218e07e

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

classes/Visualizer/Render/Library.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ private function _renderProPopupBlocker() {
223223
$license_key = '';
224224
$download_id = '';
225225
if ( ! empty( $license ) && is_object( $license ) ) {
226-
$license_key = $license->key;
227-
$download_id = $license->download_id;
226+
$license_key = isset( $license->key ) ? $license->key : '';
227+
$download_id = isset( $license->download_id ) ? $license->download_id : '';
228228
}
229229
$admin_license_url = admin_url( 'options-general.php#visualizer_pro_license' );
230230
$renew_license_url = tsdk_utmify( Visualizer_Plugin::STORE_URL . '?edd_license_key=' . $license_key . '&download_id=' . $download_id, 'visualizer_license_block' );

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function ( $products ) {
169169

170170
$license = get_option( 'visualizer_pro_license_data', 'free' );
171171
if ( ! empty( $license ) && is_object( $license ) ) {
172-
$license = $license->key;
172+
$license = $license->key ?? 'free';
173173
}
174174
$track_hash = 'free' === $license ? 'free' : wp_hash( $license );
175175

0 commit comments

Comments
 (0)