-
Notifications
You must be signed in to change notification settings - Fork 31
Legacy license field improvements #2960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
960edff
fa916c2
859574d
ae61456
b18e87d
3d08cb4
07c8007
c401e02
aab9e63
0b03b38
a8f9d74
e2231e8
ddce579
f6e1239
085650f
bdabde4
98e3f64
90489d5
52d1051
6298ee3
c7b54fd
c53de37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: minor | ||
| Type: fix | ||
|
|
||
| Warn users when they attempt to enter a Unified license key into the standalone license key field |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| use function lw_harbor_get_unified_license_key; | ||
| use function lw_harbor_is_feature_enabled; | ||
| use function lw_harbor_is_feature_available; | ||
| use function lw_harbor_is_capability_license_active; | ||
|
|
||
| /** | ||
| * Controller for setting up the Harbor library. | ||
|
|
@@ -29,12 +30,21 @@ | |
| * @package TEC\Common\Libraries\Harbor | ||
| */ | ||
| class Harbor extends Controller_Contract { | ||
| /** | ||
| * Prefix for Liquid Web unified license keys. | ||
| * | ||
| * @since 6.12.0 | ||
| * | ||
| * @var string | ||
| */ | ||
| public const UNIFIED_LICENSE_KEY_PREFIX = 'LWSW-'; | ||
|
dpanta94 marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * The TEC product slug to Harbor product slug map. | ||
| * | ||
| * @since 6.11.0 | ||
| * | ||
| * @var array | ||
| * @var array<string, string> | ||
| */ | ||
| private const TEC_PRODUCT_SLUG_TO_HARBOR_PRODUCT_SLUG_MAP = [ | ||
| 'the-events-calendar' => 'the-events-calendar', | ||
|
|
@@ -232,7 +242,7 @@ public function register_legacy_licenses( array $licenses ): array { | |
| return array_values( | ||
| array_filter( | ||
| $licenses, | ||
| static fn( array $license ): bool => ! empty( $license['key'] ) && ! str_starts_with( $license['key'], 'LWSW-' ) | ||
| fn( array $license ): bool => ! empty( $license['key'] ) && ! $this->is_unified_license_key( $license['key'] ) | ||
| ) | ||
| ); | ||
| } | ||
|
|
@@ -265,6 +275,65 @@ public function is_product_licensed( string $product ): bool { | |
| return lw_harbor_is_feature_available( $product ); | ||
| } | ||
|
|
||
| /** | ||
| * Whether a license key uses the unified Liquid Web format. | ||
| * | ||
| * @since 6.12.0 | ||
|
pramodjodhani marked this conversation as resolved.
Outdated
|
||
| * | ||
| * @param string $key The license key. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function is_unified_license_key( string $key ): bool { | ||
| return str_starts_with( trim( $key ), self::UNIFIED_LICENSE_KEY_PREFIX ); | ||
| } | ||
|
|
||
| /** | ||
| * Whether a TEC product license field is managed by Harbor. | ||
| * | ||
| * When true, the unified license key should be shown read-only and should not | ||
| * be validated through legacy PUE per-product fields. | ||
| * | ||
| * Checks that the product's license is actually active/valid for this site, not | ||
| * merely that the customer's tier entitles them to it β a customer can be entitled | ||
| * to a product without having activated it here, in which case a legacy per-product | ||
| * key should still be accepted. | ||
|
pramodjodhani marked this conversation as resolved.
|
||
| * | ||
| * @since 6.12.0 | ||
| * @since TBD Check per-site license activation of the product's capability via | ||
| * `lw_harbor_is_capability_license_active()` instead of tier entitlement via | ||
| * `is_product_licensed()`. | ||
| * | ||
| * @param string $tec_product_slug The TEC product slug. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function is_license_field_managed_by_harbor( string $tec_product_slug ): bool { | ||
| if ( ! lw_harbor_has_unified_license_key() ) { | ||
| return false; | ||
| } | ||
|
|
||
| return lw_harbor_is_capability_license_active( | ||
| $this->get_harbor_product_slug( $tec_product_slug ) | ||
| ); | ||
|
Comment on lines
+353
to
+360
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ποΈ Data Integrity & Integration | π Major | ποΈ Heavy lift Use the active-capability check for all legacy PUE paths. Line 313 correctly checks whether the capability is active on this site. However, If a customer is entitled to a capability but has not activated it on this site, the field remains editable but PUE still reads and uses the unified key. A saved legacy key cannot become effective. Use the active-capability predicate for these legacy PUE paths. Add coverage with an entitled capability that is not activated on the current site. π€ Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dpanta94 I think this comment makes sense and should be implemented. But I want to confirm this with you, as its possible I might have not full context of why
|
||
| } | ||
|
|
||
| /** | ||
| * Error message shown when a unified license key is entered in a per-product field. | ||
| * | ||
| * @since 6.12.0 | ||
| * | ||
| * @return string | ||
| */ | ||
| public function get_unified_license_key_entry_error_message(): string { | ||
| return sprintf( | ||
| /* translators: %1$s: opening anchor tag, %2$s: closing anchor tag. */ | ||
| __( 'It seems to be a unified license key. Please %1$sclick here%2$s to enter it in the LW License Manager.', 'tribe-common' ), | ||
| '<a href="' . esc_url( lw_harbor_get_license_page_url() ) . '" target=_blank >', | ||
| '</a>' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Get the unified license key if the feature is enabled. | ||
| * | ||
|
|
||
|
pramodjodhani marked this conversation as resolved.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets make sure we release new version of harbor before merging so we dont ship a dev version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been reverted back to
^1.4since we dont need any new functions, we are now utilising the existing functionslw_harbor_is_feature_enabledπ