From 122c93f42e237a4a5490ab94206903c9481616f8 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 17 Jan 2025 15:07:40 +0530 Subject: [PATCH 1/2] Social | Fix social connections list initial state feature check --- .../changelog/fix-social-connections-list-feature-check | 4 ++++ .../packages/publicize/src/class-publicize-script-data.php | 3 +-- .../changelog/fix-social-connections-list-feature-check | 4 ++++ .../changelog/fix-social-connections-list-feature-check | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 projects/packages/publicize/changelog/fix-social-connections-list-feature-check create mode 100644 projects/plugins/jetpack/changelog/fix-social-connections-list-feature-check create mode 100644 projects/plugins/social/changelog/fix-social-connections-list-feature-check diff --git a/projects/packages/publicize/changelog/fix-social-connections-list-feature-check b/projects/packages/publicize/changelog/fix-social-connections-list-feature-check new file mode 100644 index 0000000000000..db871891de374 --- /dev/null +++ b/projects/packages/publicize/changelog/fix-social-connections-list-feature-check @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Social | Fix feature check for social connections list initial state diff --git a/projects/packages/publicize/src/class-publicize-script-data.php b/projects/packages/publicize/src/class-publicize-script-data.php index 89ffe9f3131ba..0033f7b1de325 100644 --- a/projects/packages/publicize/src/class-publicize-script-data.php +++ b/projects/packages/publicize/src/class-publicize-script-data.php @@ -163,8 +163,7 @@ public static function get_store_initial_state() { return array( 'connectionData' => array( - // We do not have this method on WPCOM Publicize class yet. - 'connections' => ! $is_wpcom ? self::publicize()->get_all_connections_for_user() : array(), + 'connections' => self::has_feature_flag( 'connections-management' ) ? self::publicize()->get_all_connections_for_user() : array(), ), 'shareStatus' => $share_status, ); diff --git a/projects/plugins/jetpack/changelog/fix-social-connections-list-feature-check b/projects/plugins/jetpack/changelog/fix-social-connections-list-feature-check new file mode 100644 index 0000000000000..76c3a4215d02f --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-social-connections-list-feature-check @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Social | Fix publicize error in the editor due to malformed connections data diff --git a/projects/plugins/social/changelog/fix-social-connections-list-feature-check b/projects/plugins/social/changelog/fix-social-connections-list-feature-check new file mode 100644 index 0000000000000..d4868fdf6e0a2 --- /dev/null +++ b/projects/plugins/social/changelog/fix-social-connections-list-feature-check @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix publicize error in the editor due to malformed connections data From c8387f137a8933f0e21dbc97bf4d72e0654b1e69 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 17 Jan 2025 16:18:19 +0530 Subject: [PATCH 2/2] Fix phan --- projects/packages/publicize/.phan/baseline.php | 3 --- projects/packages/publicize/.phan/config.php | 1 + projects/packages/publicize/src/class-services.php | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/projects/packages/publicize/.phan/baseline.php b/projects/packages/publicize/.phan/baseline.php index 73ac3608fa9a5..df09a5c8732d3 100644 --- a/projects/packages/publicize/.phan/baseline.php +++ b/projects/packages/publicize/.phan/baseline.php @@ -17,7 +17,6 @@ // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeMismatchReturnProbablyReal : 2 occurrences // PhanTypeMissingReturn : 2 occurrences - // PhanUndeclaredClassMethod : 2 occurrences // PhanImpossibleCondition : 1 occurrence // PhanNoopNew : 1 occurrence // PhanParamSignatureMismatch : 1 occurrence @@ -29,7 +28,6 @@ // PhanTypeMismatchDefault : 1 occurrence // PhanTypeMismatchDimFetch : 1 occurrence // PhanTypeMismatchReturn : 1 occurrence - // PhanUndeclaredFunction : 1 occurrence // PhanUndeclaredMethod : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions @@ -40,7 +38,6 @@ 'src/class-publicize-ui.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-publicize.php' => ['PhanParamSignatureMismatch', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMissingReturn'], 'src/class-rest-controller.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'], - 'src/rest-api/class-base-controller.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredFunction'], 'src/rest-api/class-connections-controller.php' => ['PhanPluginMixedKeyNoKey', 'PhanUndeclaredMethod'], 'src/rest-api/class-connections-post-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/social-image-generator/class-post-settings.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], diff --git a/projects/packages/publicize/.phan/config.php b/projects/packages/publicize/.phan/config.php index 075dd16643b9e..d60576709a738 100644 --- a/projects/packages/publicize/.phan/config.php +++ b/projects/packages/publicize/.phan/config.php @@ -13,6 +13,7 @@ return make_phan_config( dirname( __DIR__ ), array( + '+stubs' => array( 'wpcom' ), 'parse_file_list' => array( // Reference files to handle code checking for stuff from Jetpack-the-plugin or other in-monorepo plugins. // Wherever feasible we should really clean up this sort of thing instead of adding stuff here. diff --git a/projects/packages/publicize/src/class-services.php b/projects/packages/publicize/src/class-services.php index 26e49b096b40b..b43c6af0aae0a 100644 --- a/projects/packages/publicize/src/class-services.php +++ b/projects/packages/publicize/src/class-services.php @@ -26,11 +26,9 @@ class Services { public static function get_all( $force_refresh = false ) { if ( defined( 'IS_WPCOM' ) && constant( 'IS_WPCOM' ) ) { if ( function_exists( 'require_lib' ) ) { - // @phan-suppress-next-line PhanUndeclaredFunction - phan is dumb not to see the function_exists check. require_lib( 'external-connections' ); } - // @phan-suppress-next-line PhanUndeclaredClassMethod - We are here because we are on WPCOM. $external_connections = \WPCOM_External_Connections::init(); $services = array_values( $external_connections->get_external_services_list( 'publicize', get_current_blog_id() ) );