diff --git a/.github/files/lint-project-structure.sh b/.github/files/lint-project-structure.sh index 0bdcaf2254ee5..2eed5522e096d 100755 --- a/.github/files/lint-project-structure.sh +++ b/.github/files/lint-project-structure.sh @@ -539,6 +539,29 @@ for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/block.jso fi done +# - In phpcs config, `0` doesn't do what you think. +debug "Checking for bad message exclusions in phpcs configs" +for FILE in $(git -c core.quotepath=off ls-files .phpcs.config.xml .phpcs.xml.dist .github/files/php-linting-phpcs.xml .github/files/phpcompatibility-dev-phpcs.xml '*/.phpcs.dir.xml' '*/.phpcs.dir.phpcompatibility.xml'); do + while IFS=$'\t' read -r LINE REF; do + EXIT=1 + echo "::error file=$FILE,line=$LINE::PHPCS config attempts to set severity 0 for the sniff message \"$REF\". To exclude a single message from a sniff, use \`\` instead." + done < <( php -- "$FILE" <<-'PHPDOC' + load( $argv[1] ); + $xpath = new DOMXPath( $doc ); + function has_message( $v ) { + return count( explode(".", $v[0]->value) ) >= 4; + } + $xpath->registerNamespace("php", "http://php.net/xpath"); + $xpath->registerPHPFunctions( "has_message" ); + foreach ( $xpath->evaluate( "//rule[php:function(\"has_message\", @ref)][severity[normalize-space(.)=\"0\"]]" ) as $node ) { + echo "{$node->getLineNo()}\t{$node->getAttribute("ref")}\n"; + } + PHPDOC + ) +done + # - .nvmrc should match .github/versions.sh. debug "Checking .nvmrc vs versions.sh" if [[ "$(<.nvmrc)" != "$NODE_VERSION" ]]; then diff --git a/.github/workflows/update-phan-stubs.yml b/.github/workflows/update-phan-stubs.yml index 2dcf7cf37b113..46c2230c4ce2b 100644 --- a/.github/workflows/update-phan-stubs.yml +++ b/.github/workflows/update-phan-stubs.yml @@ -33,19 +33,24 @@ jobs: id: changes run: | if git diff --exit-code; then - echo "No changes" + echo "::notice::No changes" + echo "needed=false" >> "$GITHUB_OUTPUT" + elif ! [[ "$(date +%e)" -le 7 && "$(date +%A)" == Thursday ]] && git diff --exit-code --ignore-matching-lines='^ \* Stubs automatically generated from' >/dev/null; then + echo "::notice::No changes (other than version bumps) and it's not the first Thursday" echo "needed=false" >> "$GITHUB_OUTPUT" elif git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin update/phan-custom-stubs >/dev/null; then TMP=$( git -c core.quotepath=off diff --name-only ) mapfile -t FILES <<<"$TMP" if git diff --quiet --exit-code origin/update/phan-custom-stubs "${FILES[@]}"; then - echo "Branch already exists and is up to date with these changes" + echo "::notice::Branch already exists and is up to date with these changes" echo "needed=false" >> "$GITHUB_OUTPUT" else + echo "::notice::Branch needs updating" echo "has-branch=true" >> "$GITHUB_OUTPUT" echo "needed=true" >> "$GITHUB_OUTPUT" fi else + echo "::notice::Branch needs creating" echo "has-branch=false" >> "$GITHUB_OUTPUT" echo "needed=true" >> "$GITHUB_OUTPUT" fi diff --git a/.phan/stubs/woocommerce-internal-stubs.php b/.phan/stubs/woocommerce-internal-stubs.php index c3eb561a77ca4..02751e4b17920 100644 --- a/.phan/stubs/woocommerce-internal-stubs.php +++ b/.phan/stubs/woocommerce-internal-stubs.php @@ -1,6 +1,6 @@ { + const maxLength = 4000; + const remainingLength = maxLength - currentPromptLength; + // 6 is the length of the ellipsis and the space before it + return content.length > remainingLength + ? content.substring( 0, remainingLength - 6 ) + ` [...]` + : content; +}; + +/** + * Create the prompt string based on the provided context. + * @param {string} postContent - the content of the post + * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated. + * @returns {string} the prompt string + */ +const getImageGenerationPrompt = ( postContent: string, userPrompt?: string ): string => { + /** + * If the user provide some custom prompt for the image generation, + * we will use it, add the post content as additional context and + * provide some guardrails for the generation. + */ + if ( userPrompt ) { + const imageGenerationPrompt = `I need a cover image for a blog post based on this user prompt: + +${ userPrompt.length > 1000 ? userPrompt.substring( 0, 1000 ) : userPrompt } + +Before creating the image, identify the main topic of the user prompt and relate it to the post content. +Do not represent the whole content in one image, keep it simple and just represent one single idea. +Do not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph. +Do not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes. +If the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions. +If the content is more abstract, use a more abstract style to represent the main idea. +Make sure the light and the style are visually appealing. +Do not add text to the image. + +For additional context, this is the post content: + +`; + // truncating the content so the whole prompt is not longer than 4000 characters, the model limit. + return imageGenerationPrompt + truncateContent( postContent, imageGenerationPrompt.length ); + } + + /** + * When the user does not provide a custom prompt, we will use the + * standard one, based solely on the post content. + */ + const imageGenerationPrompt = `I need a cover image for a blog post. +Before creating the image, identify the main topic of the content and only represent it. +Do not represent the whole content in one image, keep it simple and just represent one single idea. +Do not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph. +Do not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes. +If the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions. +If the content is more abstract, use a more abstract style to represent the main idea. +Make sure the light and the style are visually appealing. +Do not add text to the image. + +This is the post content: + +`; + // truncating the content so the whole prompt is not longer than 4000 characters, the model limit. + return imageGenerationPrompt + truncateContent( postContent, imageGenerationPrompt.length ); +}; + const useImageGenerator = () => { const generateImage = async function ( { feature, postContent, responseFormat = 'url', + userPrompt, }: { feature: string; postContent: string; responseFormat?: 'url' | 'b64_json'; + userPrompt?: string; } ): Promise< { data: Array< { [ key: string ]: string } > } > { let token = ''; @@ -31,21 +102,7 @@ const useImageGenerator = () => { try { debug( 'Generating image' ); - // TODO: fine tune the prompt as we move forward - const imageGenerationPrompt = - `I need a cover image for a blog post. -Before creating the image, identify the main topic of the content and only represent it. -Do not represent the whole content in one image, keep it simple and just represent one single idea. -Do not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph. -Do not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes. -If the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions. -If the content is more abstract, use a more abstract style to represent the main idea. -Make sure the light and the style are visually appealing. -Do not add text to the image. - -This is the post content: - -` + ( postContent.length > 3000 ? postContent.substring( 0, 3000 ) + ` [...]` : postContent ); // truncating the content so the whole prompt is not longer than 4000 characters, the model limit. + const imageGenerationPrompt = getImageGenerationPrompt( postContent, userPrompt ); const URL = 'https://public-api.wordpress.com/wpcom/v2/jetpack-ai-image'; diff --git a/projects/packages/my-jetpack/_inc/components/connected-product-card/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/connected-product-card/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/connected-product-card/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/connected-product-card/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/plans-section/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/plans-section/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/plans-section/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/plans-section/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/plans-section/stories/mock-data.js b/projects/packages/my-jetpack/_inc/components/plans-section/stories/broken/mock-data.js similarity index 100% rename from projects/packages/my-jetpack/_inc/components/plans-section/stories/mock-data.js rename to projects/packages/my-jetpack/_inc/components/plans-section/stories/broken/mock-data.js diff --git a/projects/packages/my-jetpack/_inc/components/product-card/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/product-card/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-card/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/product-card/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/product-cards-section/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/product-cards-section/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-cards-section/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/product-cards-section/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/product-detail-card/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/product-detail-card/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-detail-card/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/product-detail-card/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/product-detail-card/stories/mock-data.js b/projects/packages/my-jetpack/_inc/components/product-detail-card/stories/broken/mock-data.js similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-detail-card/stories/mock-data.js rename to projects/packages/my-jetpack/_inc/components/product-detail-card/stories/broken/mock-data.js diff --git a/projects/packages/my-jetpack/_inc/components/product-detail-card/stories/utils.js b/projects/packages/my-jetpack/_inc/components/product-detail-card/stories/broken/utils.js similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-detail-card/stories/utils.js rename to projects/packages/my-jetpack/_inc/components/product-detail-card/stories/broken/utils.js diff --git a/projects/packages/my-jetpack/_inc/components/product-detail-table/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/product-detail-table/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-detail-table/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/product-detail-table/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/product-detail-table/stories/mock-data.js b/projects/packages/my-jetpack/_inc/components/product-detail-table/stories/broken/mock-data.js similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-detail-table/stories/mock-data.js rename to projects/packages/my-jetpack/_inc/components/product-detail-table/stories/broken/mock-data.js diff --git a/projects/packages/my-jetpack/_inc/components/product-detail-table/stories/utils.js b/projects/packages/my-jetpack/_inc/components/product-detail-table/stories/broken/utils.js similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-detail-table/stories/utils.js rename to projects/packages/my-jetpack/_inc/components/product-detail-table/stories/broken/utils.js diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/stories/broken/index.stories.jsx similarity index 100% rename from projects/packages/my-jetpack/_inc/components/product-interstitial/stories/index.stories.jsx rename to projects/packages/my-jetpack/_inc/components/product-interstitial/stories/broken/index.stories.jsx diff --git a/projects/packages/my-jetpack/_inc/components/welcome-banner/stories/index.stories.js b/projects/packages/my-jetpack/_inc/components/welcome-banner/stories/broken/index.stories.js similarity index 100% rename from projects/packages/my-jetpack/_inc/components/welcome-banner/stories/index.stories.js rename to projects/packages/my-jetpack/_inc/components/welcome-banner/stories/broken/index.stories.js diff --git a/projects/packages/my-jetpack/changelog/fix-stop-building-broken-stories b/projects/packages/my-jetpack/changelog/fix-stop-building-broken-stories new file mode 100644 index 0000000000000..c5a24eab3bc1c --- /dev/null +++ b/projects/packages/my-jetpack/changelog/fix-stop-building-broken-stories @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Stop building broken storybook stories. + + diff --git a/projects/packages/phpcs-filter/README.md b/projects/packages/phpcs-filter/README.md index 7d7515940016c..848375c6bbaff 100644 --- a/projects/packages/phpcs-filter/README.md +++ b/projects/packages/phpcs-filter/README.md @@ -101,6 +101,11 @@ You can still exclude such a rule by setting its severity to zero. The 4-compone + + + + 0 + ``` ### `` diff --git a/projects/packages/phpcs-filter/changelog/fix-unexpected-phpcs-exclusions b/projects/packages/phpcs-filter/changelog/fix-unexpected-phpcs-exclusions new file mode 100644 index 0000000000000..a57c7cc967c40 --- /dev/null +++ b/projects/packages/phpcs-filter/changelog/fix-unexpected-phpcs-exclusions @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Add a doc note warning against using `0` when excluding individual sniff messages. diff --git a/projects/packages/sync/changelog/add-sync-woo-remove-order-items b/projects/packages/sync/changelog/add-sync-woo-remove-order-items new file mode 100644 index 0000000000000..048174b97ff2d --- /dev/null +++ b/projects/packages/sync/changelog/add-sync-woo-remove-order-items @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add Woocommerce event remove_order_items to Jetpack Sync diff --git a/projects/packages/sync/composer.json b/projects/packages/sync/composer.json index abbefef08b8c4..456ab304e5e46 100644 --- a/projects/packages/sync/composer.json +++ b/projects/packages/sync/composer.json @@ -58,7 +58,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.14.x-dev" + "dev-trunk": "2.15.x-dev" } }, "config": { diff --git a/projects/packages/sync/src/class-package-version.php b/projects/packages/sync/src/class-package-version.php index 609f917170ad2..f245eb1c5bd45 100644 --- a/projects/packages/sync/src/class-package-version.php +++ b/projects/packages/sync/src/class-package-version.php @@ -12,7 +12,7 @@ */ class Package_Version { - const PACKAGE_VERSION = '2.14.1-alpha'; + const PACKAGE_VERSION = '2.15.0-alpha'; const PACKAGE_SLUG = 'sync'; diff --git a/projects/packages/sync/src/modules/class-woocommerce.php b/projects/packages/sync/src/modules/class-woocommerce.php index f5cbd801c277f..d01332a911796 100644 --- a/projects/packages/sync/src/modules/class-woocommerce.php +++ b/projects/packages/sync/src/modules/class-woocommerce.php @@ -7,6 +7,7 @@ namespace Automattic\Jetpack\Sync\Modules; +use WC_Order; use WP_Error; /** @@ -93,6 +94,9 @@ public function __construct() { // Blacklist Action Scheduler comment types. add_filter( 'jetpack_sync_prevent_sending_comment_data', array( $this, 'filter_action_scheduler_comments' ), 10, 2 ); + + // Preprocess action to be sent by Jetpack sync. + add_action( 'woocommerce_remove_order_items', array( $this, 'action_woocommerce_remove_order_items' ), 10, 2 ); } /** @@ -128,6 +132,7 @@ public function init_listeners( $callable ) { add_action( 'woocommerce_new_order_item', $callable, 10, 4 ); add_action( 'woocommerce_update_order_item', $callable, 10, 4 ); add_action( 'woocommerce_delete_order_item', $callable, 10, 1 ); + add_action( 'woocommerce_remove_order_item_ids', $callable, 10, 1 ); $this->init_listeners_for_meta_type( 'order_item', $callable ); // Payment tokens. @@ -197,6 +202,25 @@ public function filter_order_item( $args ) { return $args; } + /** + * Retrieve the order item ids to be removed and send them as one action + * + * @param WC_Order $order The order argument. + * @param string $type Order item type. + */ + public function action_woocommerce_remove_order_items( WC_Order $order, $type ) { + if ( $type ) { + $order_items = $order->get_items( $type ); + } else { + $order_items = $order->get_items(); + } + $order_item_ids = array_keys( $order_items ); + + if ( $order_item_ids ) { + do_action( 'woocommerce_remove_order_item_ids', $order_item_ids ); + } + } + /** * Expand order item IDs to order items and their meta. * diff --git a/projects/packages/videopress/changelog/fix-stop-building-broken-stories b/projects/packages/videopress/changelog/fix-stop-building-broken-stories new file mode 100644 index 0000000000000..c5a24eab3bc1c --- /dev/null +++ b/projects/packages/videopress/changelog/fix-stop-building-broken-stories @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Stop building broken storybook stories. + + diff --git a/projects/packages/videopress/src/client/admin/components/pricing-section/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/pricing-section/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/pricing-section/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/pricing-section/stories/broken/index.stories.tsx diff --git a/projects/packages/videopress/src/client/admin/components/video-card/stories/index.mdx b/projects/packages/videopress/src/client/admin/components/video-card/stories/broken/index.mdx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-card/stories/index.mdx rename to projects/packages/videopress/src/client/admin/components/video-card/stories/broken/index.mdx diff --git a/projects/packages/videopress/src/client/admin/components/video-card/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/video-card/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-card/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/video-card/stories/broken/index.stories.tsx diff --git a/projects/packages/videopress/src/client/admin/components/video-filter/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/video-filter/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-filter/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/video-filter/stories/broken/index.stories.tsx diff --git a/projects/packages/videopress/src/client/admin/components/video-grid/stories/index.mdx b/projects/packages/videopress/src/client/admin/components/video-grid/stories/broken/index.mdx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-grid/stories/index.mdx rename to projects/packages/videopress/src/client/admin/components/video-grid/stories/broken/index.mdx diff --git a/projects/packages/videopress/src/client/admin/components/video-grid/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/video-grid/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-grid/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/video-grid/stories/broken/index.stories.tsx diff --git a/projects/packages/videopress/src/client/admin/components/video-grid/stories/style.module.scss b/projects/packages/videopress/src/client/admin/components/video-grid/stories/broken/style.module.scss similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-grid/stories/style.module.scss rename to projects/packages/videopress/src/client/admin/components/video-grid/stories/broken/style.module.scss diff --git a/projects/packages/videopress/src/client/admin/components/video-list/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/video-list/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-list/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/video-list/stories/broken/index.stories.tsx diff --git a/projects/packages/videopress/src/client/admin/components/video-row/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/video-row/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-row/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/video-row/stories/broken/index.stories.tsx diff --git a/projects/packages/videopress/src/client/admin/components/video-upload-area/stories/index.mdx b/projects/packages/videopress/src/client/admin/components/video-upload-area/stories/broken/index.mdx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-upload-area/stories/index.mdx rename to projects/packages/videopress/src/client/admin/components/video-upload-area/stories/broken/index.mdx diff --git a/projects/packages/videopress/src/client/admin/components/video-upload-area/stories/index.stories.tsx b/projects/packages/videopress/src/client/admin/components/video-upload-area/stories/broken/index.stories.tsx similarity index 100% rename from projects/packages/videopress/src/client/admin/components/video-upload-area/stories/index.stories.tsx rename to projects/packages/videopress/src/client/admin/components/video-upload-area/stories/broken/index.stories.tsx diff --git a/projects/packages/waf/.phpcs.dir.xml b/projects/packages/waf/.phpcs.dir.xml index fa2a7e03fa6df..a57cef4d3eedc 100644 --- a/projects/packages/waf/.phpcs.dir.xml +++ b/projects/packages/waf/.phpcs.dir.xml @@ -24,8 +24,10 @@ - - 0 + + + + diff --git a/projects/packages/waf/changelog/fix-unexpected-phpcs-exclusions b/projects/packages/waf/changelog/fix-unexpected-phpcs-exclusions new file mode 100644 index 0000000000000..eb94a145da642 --- /dev/null +++ b/projects/packages/waf/changelog/fix-unexpected-phpcs-exclusions @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Fix phpcs config. No change to functionality. + + diff --git a/projects/packages/wp-js-data-sync/.phan/baseline.php b/projects/packages/wp-js-data-sync/.phan/baseline.php index e6802082812fe..27340ccf2302c 100644 --- a/projects/packages/wp-js-data-sync/.phan/baseline.php +++ b/projects/packages/wp-js-data-sync/.phan/baseline.php @@ -14,7 +14,6 @@ // PhanUndeclaredMethod : 3 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 2 occurrences // PhanTypeMismatchArgumentProbablyReal : 2 occurrences - // PhanTypeMismatchReturn : 2 occurrences // PhanImpossibleCondition : 1 occurrence // PhanImpossibleTypeComparison : 1 occurrence // PhanParamTooMany : 1 occurrence @@ -22,6 +21,7 @@ // PhanRedundantCondition : 1 occurrence // PhanTypeMismatchArgumentNullable : 1 occurrence // PhanTypeMismatchProperty : 1 occurrence + // PhanTypeMismatchReturn : 1 occurrence // PhanUndeclaredTypeParameter : 1 occurrence // PhanUnreferencedUseNormal : 1 occurrence @@ -38,7 +38,7 @@ 'src/schema/types/class-type-assoc-array.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturn'], 'src/schema/types/class-type-string.php' => ['PhanImpossibleTypeComparison'], 'tests/php/schema/integration/test-integration-fallback-values.php' => ['PhanNonClassMethodCall'], - 'tests/php/schema/integration/test-integration-parsing-errors.php' => ['PhanNonClassMethodCall', 'PhanParamTooFew', 'PhanTypeMismatchReturn'], + 'tests/php/schema/integration/test-integration-parsing-errors.php' => ['PhanNonClassMethodCall', 'PhanParamTooFew'], 'tests/php/schema/type/test-type-assoc-array.php' => ['PhanTypeMismatchArgumentProbablyReal'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/wp-js-data-sync/.phpcs.dir.xml b/projects/packages/wp-js-data-sync/.phpcs.dir.xml index 5e4b35a1e3f88..9dbc643374582 100644 --- a/projects/packages/wp-js-data-sync/.phpcs.dir.xml +++ b/projects/packages/wp-js-data-sync/.phpcs.dir.xml @@ -27,35 +27,30 @@ - - 0 + + - - 0 + + + + + + - - 0 + + - - 0 + + - - 0 + + - - 0 + + - - 0 - - - 0 - - - 0 - - - 0 + + diff --git a/projects/packages/wp-js-data-sync/changelog/fix-unexpected-phpcs-exclusions b/projects/packages/wp-js-data-sync/changelog/fix-unexpected-phpcs-exclusions new file mode 100644 index 0000000000000..fc23a4b03a50a --- /dev/null +++ b/projects/packages/wp-js-data-sync/changelog/fix-unexpected-phpcs-exclusions @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix phpcs config, and phpdoc comments that were easy to fix. diff --git a/projects/packages/wp-js-data-sync/src/class-data-sync-entry-adapter.php b/projects/packages/wp-js-data-sync/src/class-data-sync-entry-adapter.php index fbd6dc106f77d..4896819e9b256 100644 --- a/projects/packages/wp-js-data-sync/src/class-data-sync-entry-adapter.php +++ b/projects/packages/wp-js-data-sync/src/class-data-sync-entry-adapter.php @@ -37,6 +37,7 @@ final class Data_Sync_Entry_Adapter implements Data_Sync_Entry { /** * For more explanation, see the class docblock. + * * @see Data_Sync_Entry_Adapter * The constructor accepts any entry that subscribes to at least "Entry_Can_Get", but can also * subscribe to any of the other Entry_Can_* interfaces. diff --git a/projects/packages/wp-js-data-sync/src/class-data-sync.php b/projects/packages/wp-js-data-sync/src/class-data-sync.php index dc4d33dbc9e78..6807e39ecbfc0 100644 --- a/projects/packages/wp-js-data-sync/src/class-data-sync.php +++ b/projects/packages/wp-js-data-sync/src/class-data-sync.php @@ -189,8 +189,8 @@ public function get_registry() { * However, you can provide an `$entry` instance that subscribes Entry_Can_* methods. * If you do, `Entry_Can_Get` interface is required, and all other Entry_Can_* interfaces are optional. * - * @param string $key - The key to register the entry under. - * @param Parser $parser - The parser to use for the entry. + * @param string $key - The key to register the entry under. + * @param Parser $parser - The parser to use for the entry. * @param Entry_Can_Get $custom_entry_instance - The entry to register. If null, a new Data_Sync_Option will be created. * * @return void diff --git a/projects/packages/wp-js-data-sync/src/contracts/interface-data-sync-action.php b/projects/packages/wp-js-data-sync/src/contracts/interface-data-sync-action.php index e9cecc4e4b6a2..7a91c5f771d0b 100644 --- a/projects/packages/wp-js-data-sync/src/contracts/interface-data-sync-action.php +++ b/projects/packages/wp-js-data-sync/src/contracts/interface-data-sync-action.php @@ -14,7 +14,7 @@ interface Data_Sync_Action { /** * Handles the action logic. * - * @param mixed $data JSON Data passed to the action. + * @param mixed $data JSON Data passed to the action. * @param \WP_REST_Request $request The request object. * @return mixed */ diff --git a/projects/packages/wp-js-data-sync/src/endpoints/class-action-endpoint.php b/projects/packages/wp-js-data-sync/src/endpoints/class-action-endpoint.php index fa9f8e01120a5..42628706d2cc9 100644 --- a/projects/packages/wp-js-data-sync/src/endpoints/class-action-endpoint.php +++ b/projects/packages/wp-js-data-sync/src/endpoints/class-action-endpoint.php @@ -41,7 +41,6 @@ class Action_Endpoint { /** * This class handles endpoints for DataSync actions. * - * * @param $namespace * @param $key * @param $action_name diff --git a/projects/packages/wp-js-data-sync/src/endpoints/class-endpoint.php b/projects/packages/wp-js-data-sync/src/endpoints/class-endpoint.php index d1a9e7ffa1cb0..7b9cbeab8977b 100644 --- a/projects/packages/wp-js-data-sync/src/endpoints/class-endpoint.php +++ b/projects/packages/wp-js-data-sync/src/endpoints/class-endpoint.php @@ -97,32 +97,36 @@ public function register_rest_routes() { } } - /* + /** * Handle GET Requests on /wp-json// + * * @param \WP_REST_Request $request - The request object. */ public function handle_get( $request ) { return $this->handler( $request, 'get' ); } - /* + /** * Handle POST, PUT, PATCH Requests on /wp-json///set + * * @param \WP_REST_Request $request - The request object. */ public function handle_set( $request ) { return $this->handler( $request, 'set' ); } - /* + /** * Handle POST, PUT, PATCH Requests on /wp-json///merge + * * @param \WP_REST_Request $request - The request object. */ public function handle_merge( $request ) { return $this->handler( $request, 'merge' ); } - /* + /** * Handle POST, DELETE Requests on /wp-json///delete + * * @param \WP_REST_Request $request - The request object. */ public function handle_delete( $request ) { diff --git a/projects/packages/wp-js-data-sync/src/schema/class-schema-parser.php b/projects/packages/wp-js-data-sync/src/schema/class-schema-parser.php index 9b4e715990ed6..7316a39520dae 100644 --- a/projects/packages/wp-js-data-sync/src/schema/class-schema-parser.php +++ b/projects/packages/wp-js-data-sync/src/schema/class-schema-parser.php @@ -41,10 +41,8 @@ public function __toString() { * * @param Parser $parser * - * * @return $this * @see Schema::either() - * */ private function or( Parser $parser ) { if ( $this->parser instanceof Modifier_Fallback ) { diff --git a/projects/packages/wp-js-data-sync/src/schema/class-schema.php b/projects/packages/wp-js-data-sync/src/schema/class-schema.php index c09ccca723113..bca54dc7281cb 100644 --- a/projects/packages/wp-js-data-sync/src/schema/class-schema.php +++ b/projects/packages/wp-js-data-sync/src/schema/class-schema.php @@ -63,7 +63,6 @@ * ]; * * $parsed_data = $my_schema->parse($input_data); - * */ class Schema { diff --git a/projects/packages/wp-js-data-sync/src/schema/interface-parser.php b/projects/packages/wp-js-data-sync/src/schema/interface-parser.php index 2460593f091a7..7d4da978f39d9 100644 --- a/projects/packages/wp-js-data-sync/src/schema/interface-parser.php +++ b/projects/packages/wp-js-data-sync/src/schema/interface-parser.php @@ -20,23 +20,24 @@ interface Parser extends \JsonSerializable { * If the input value is invalid, the method should return a default value. * or throw an exception, depending on the implementation. * - * @param mixed $value The input value to be parsed. - * @param Schema_Context $context Schema validation metadata. + * @param mixed $value The input value to be parsed. + * @param Schema_Context $context Schema validation metadata. * * @return mixed The parsed value. * @throws \RuntimeException If the input value is invalid. - * */ public function parse( $value, $context ); /** * The describe method is responsible for returning a description of the schema. + * * @return array */ public function schema(); /** * The __toString method is responsible for returning a string representation of the schema. + * * @return string */ public function __toString(); diff --git a/projects/packages/wp-js-data-sync/src/schema/types/class-type-array.php b/projects/packages/wp-js-data-sync/src/schema/types/class-type-array.php index 120bd4871a9fb..4b90e6de251c3 100644 --- a/projects/packages/wp-js-data-sync/src/schema/types/class-type-array.php +++ b/projects/packages/wp-js-data-sync/src/schema/types/class-type-array.php @@ -3,6 +3,7 @@ namespace Automattic\Jetpack\WP_JS_Data_Sync\Schema\Types; use Automattic\Jetpack\WP_JS_Data_Sync\Schema\Parser; +use Automattic\Jetpack\WP_JS_Data_Sync\Schema\Schema_Context; use Automattic\Jetpack\WP_JS_Data_Sync\Schema\Schema_Error; class Type_Array implements Parser { @@ -18,13 +19,15 @@ public function __construct( Parser $parser ) { $this->parser = $parser; } - /* + /** * This parse method expects that the $data passed to it is * an array of other Parser instances. * - * @param $data - an array of something to be parsed. + * @param array $value - an array of something to be parsed. + * @param Schema_Context $context - Schema context. * * @return array + * @throws Schema_Error If $value is not an array. */ public function parse( $value, $context ) { if ( ! is_array( $value ) ) { diff --git a/projects/packages/wp-js-data-sync/src/schema/types/class-type-assoc-array.php b/projects/packages/wp-js-data-sync/src/schema/types/class-type-assoc-array.php index 231f90f022eb1..9e7bc601aca90 100644 --- a/projects/packages/wp-js-data-sync/src/schema/types/class-type-assoc-array.php +++ b/projects/packages/wp-js-data-sync/src/schema/types/class-type-assoc-array.php @@ -35,7 +35,6 @@ public function __construct( $assoc_parser_array ) { * * @return array * @throws Schema_Error - If the $data passed to it is not an associative array. - * */ public function parse( $value, $context ) { // Allow coercing stdClass objects (often returned from json_decode) to an assoc array. diff --git a/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php b/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php index 2be37edcb33c2..292734a508b36 100755 --- a/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php +++ b/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php @@ -124,9 +124,11 @@ private function get_assoc_schema( $schema, $levels = 3, $i = 1 ) { } /** - * Creates an associative array with nested levels containing 'hello world' string. + * Creates an associative array with nested levels containing $data. * - * @param int $levels The depth of nesting in the associative array. + * @param mixed $data Data to contain. + * @param int $levels The depth of nesting in the associative array. + * @param int $i Current nesting depth, used for recursive calls. * * @return array The associative array with data. */ diff --git a/projects/plugins/automattic-for-agencies-client/changelog/add-sync-woo-remove-order-items b/projects/plugins/automattic-for-agencies-client/changelog/add-sync-woo-remove-order-items new file mode 100644 index 0000000000000..048174b97ff2d --- /dev/null +++ b/projects/plugins/automattic-for-agencies-client/changelog/add-sync-woo-remove-order-items @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add Woocommerce event remove_order_items to Jetpack Sync diff --git a/projects/plugins/automattic-for-agencies-client/changelog/add-sync-woo-remove-order-items#2 b/projects/plugins/automattic-for-agencies-client/changelog/add-sync-woo-remove-order-items#2 new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/automattic-for-agencies-client/changelog/add-sync-woo-remove-order-items#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/automattic-for-agencies-client/composer.lock b/projects/plugins/automattic-for-agencies-client/composer.lock index 1827e2c1ca6dc..a2dbe0ad89f35 100644 --- a/projects/plugins/automattic-for-agencies-client/composer.lock +++ b/projects/plugins/automattic-for-agencies-client/composer.lock @@ -993,7 +993,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "5f1e574ac98b4cfa494ee2585d7adb9efe89189b" + "reference": "bf72e4fd0707344623c04f5af5ae83ef1152ab14" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1025,7 +1025,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.14.x-dev" + "dev-trunk": "2.15.x-dev" } }, "autoload": { diff --git a/projects/plugins/backup/changelog/add-sync-woo-remove-order-items b/projects/plugins/backup/changelog/add-sync-woo-remove-order-items new file mode 100644 index 0000000000000..048174b97ff2d --- /dev/null +++ b/projects/plugins/backup/changelog/add-sync-woo-remove-order-items @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add Woocommerce event remove_order_items to Jetpack Sync diff --git a/projects/plugins/backup/changelog/add-sync-woo-remove-order-items#2 b/projects/plugins/backup/changelog/add-sync-woo-remove-order-items#2 new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/backup/changelog/add-sync-woo-remove-order-items#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/backup/composer.lock b/projects/plugins/backup/composer.lock index ce401c0ee1d91..c1cc191eca4f0 100644 --- a/projects/plugins/backup/composer.lock +++ b/projects/plugins/backup/composer.lock @@ -1546,7 +1546,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "5f1e574ac98b4cfa494ee2585d7adb9efe89189b" + "reference": "bf72e4fd0707344623c04f5af5ae83ef1152ab14" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1578,7 +1578,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.14.x-dev" + "dev-trunk": "2.15.x-dev" } }, "autoload": { diff --git a/projects/plugins/boost/.phpcs.dir.xml b/projects/plugins/boost/.phpcs.dir.xml index 0d50ca55e7c99..76a69739607ca 100644 --- a/projects/plugins/boost/.phpcs.dir.xml +++ b/projects/plugins/boost/.phpcs.dir.xml @@ -21,27 +21,30 @@ - - 0 + + + - - 0 + + + + - - 0 + + - - 0 + + + + + - - 0 + + - - 0 - - - 0 + + diff --git a/projects/plugins/boost/app/class-jetpack-boost.php b/projects/plugins/boost/app/class-jetpack-boost.php index 53327c8daf817..c56cd38c3cde4 100644 --- a/projects/plugins/boost/app/class-jetpack-boost.php +++ b/projects/plugins/boost/app/class-jetpack-boost.php @@ -147,7 +147,6 @@ private function register_deactivation_hook() { * @param array $allowed_query_args The list of allowed query args. * * @return array The modified list of allowed query args. - */ public static function whitelist_query_args( $allowed_query_args ) { $allowed_query_args[] = Generator::GENERATE_QUERY_ACTION; diff --git a/projects/plugins/boost/app/contracts/Pluggable.php b/projects/plugins/boost/app/contracts/Pluggable.php index d223dbfe76c93..6c6a63f020091 100644 --- a/projects/plugins/boost/app/contracts/Pluggable.php +++ b/projects/plugins/boost/app/contracts/Pluggable.php @@ -10,6 +10,7 @@ interface Pluggable extends Has_Setup, Has_Slug { /** * Whether the feature is available for use. * Use this to check for feature flags, etc. + * * @return bool */ public static function is_available(); diff --git a/projects/plugins/boost/app/features/setup-prompt/_inc/banner.php b/projects/plugins/boost/app/features/setup-prompt/_inc/banner.php index c64b91d351dbc..702452062d99b 100644 --- a/projects/plugins/boost/app/features/setup-prompt/_inc/banner.php +++ b/projects/plugins/boost/app/features/setup-prompt/_inc/banner.php @@ -3,6 +3,7 @@ * Boost Setup Prompt * DEPRECATED - this prompt has been removed as of version 2.3.1 */ + ?>
diff --git a/projects/plugins/boost/app/lib/Status.php b/projects/plugins/boost/app/lib/Status.php index 0557406789668..87d34e7faaf91 100644 --- a/projects/plugins/boost/app/lib/Status.php +++ b/projects/plugins/boost/app/lib/Status.php @@ -58,7 +58,7 @@ public function on_update( $new_status ) { * * For example: critical-css module status should be synced with cloud-css module. * - * @param $new_status + * @param mixed $new_status * @return void */ protected function update_mapped_modules( $new_status ) { diff --git a/projects/plugins/boost/app/lib/class-collection.php b/projects/plugins/boost/app/lib/class-collection.php index 7158851614f4c..9a4ba4be6898f 100644 --- a/projects/plugins/boost/app/lib/class-collection.php +++ b/projects/plugins/boost/app/lib/class-collection.php @@ -15,6 +15,8 @@ class Collection { * Disable autoloading by default. * * @see autoload() to enable autoloading. + * + * @var bool */ private $autoload = false; @@ -25,7 +27,7 @@ public function __construct( $key ) { $this->key = $key; } - /* + /** * Allow autoloading collections */ public function autoload() { @@ -49,7 +51,7 @@ public function get() { /** * Append a single item to the collection * - * @param $item + * @param mixed $item * * @return bool */ diff --git a/projects/plugins/boost/app/lib/class-site-urls.php b/projects/plugins/boost/app/lib/class-site-urls.php index d048132813cac..c2747ab60c504 100644 --- a/projects/plugins/boost/app/lib/class-site-urls.php +++ b/projects/plugins/boost/app/lib/class-site-urls.php @@ -97,8 +97,8 @@ private static function get_post_urls( $limit ) { * Removes duplicate URLs from the $post_urls list * based on the additional URLs. * - * @param $post_urls List of URLs to cleanup. - * @param $additional_urls List of URLs to lookup while cleaning. + * @param array $post_urls List of URLs to cleanup. + * @param array $additional_urls List of URLs to lookup while cleaning. * * @return array */ @@ -135,7 +135,7 @@ private static function get_public_post_types() { /** * Returns the group for the post. * - * @param $p Post object. + * @param \WP_Post $p Post object. * * @return string */ diff --git a/projects/plugins/boost/app/lib/critical-css/Critical_CSS_Invalidator.php b/projects/plugins/boost/app/lib/critical-css/Critical_CSS_Invalidator.php index 1967c4deee031..71ce3fd324986 100644 --- a/projects/plugins/boost/app/lib/critical-css/Critical_CSS_Invalidator.php +++ b/projects/plugins/boost/app/lib/critical-css/Critical_CSS_Invalidator.php @@ -4,6 +4,7 @@ * * Reset critical CSS when existing critical css values are stale. */ + namespace Automattic\Jetpack_Boost\Lib\Critical_CSS; use Automattic\Jetpack_Boost\Lib\Boost_Health; diff --git a/projects/plugins/boost/app/lib/critical-css/Critical_CSS_State.php b/projects/plugins/boost/app/lib/critical-css/Critical_CSS_State.php index c2a43dde4d306..77337d121c297 100644 --- a/projects/plugins/boost/app/lib/critical-css/Critical_CSS_State.php +++ b/projects/plugins/boost/app/lib/critical-css/Critical_CSS_State.php @@ -93,7 +93,7 @@ private function update_provider_state( $provider_key, $state ) { * Set a provider's state to error. * * @param string $provider_key The provider key. - * @param array $errors A list of errors to store with this provider. + * @param array $errors A list of errors to store with this provider. * @return bool|WP_Error True on success, WP_Error on failure. */ public function set_provider_errors( $provider_key, $errors ) { diff --git a/projects/plugins/boost/app/lib/critical-css/Display_Critical_CSS.php b/projects/plugins/boost/app/lib/critical-css/Display_Critical_CSS.php index 23c0080a9f8c3..98fdbd84ad008 100644 --- a/projects/plugins/boost/app/lib/critical-css/Display_Critical_CSS.php +++ b/projects/plugins/boost/app/lib/critical-css/Display_Critical_CSS.php @@ -14,7 +14,7 @@ class Display_Critical_CSS { protected $css; /** - * @param $css + * @param string $css */ public function __construct( $css ) { $this->css = $css; diff --git a/projects/plugins/boost/app/lib/minify/Dependency_Path_Mapping.php b/projects/plugins/boost/app/lib/minify/Dependency_Path_Mapping.php index aaa62bfae278b..90beb658ab471 100644 --- a/projects/plugins/boost/app/lib/minify/Dependency_Path_Mapping.php +++ b/projects/plugins/boost/app/lib/minify/Dependency_Path_Mapping.php @@ -8,10 +8,18 @@ * actually building the concatenation. */ class Dependency_Path_Mapping { - // Save entire site URL so we can check whether other URLs are based on it (internal URLs) + /** + * Save entire site URL so we can check whether other URLs are based on it (internal URLs) + * + * @var string + */ public $site_url; - // Save URI path and dir for mapping URIs to filesystem paths + /** + * Save URI path and dir for mapping URIs to filesystem paths + * + * @var string + */ public $site_uri_path = null; public $site_dir = null; public $content_uri_path = null; diff --git a/projects/plugins/boost/app/lib/minify/functions-helpers.php b/projects/plugins/boost/app/lib/minify/functions-helpers.php index 603497c547f23..79a17a493fddb 100644 --- a/projects/plugins/boost/app/lib/minify/functions-helpers.php +++ b/projects/plugins/boost/app/lib/minify/functions-helpers.php @@ -15,7 +15,7 @@ function jetpack_boost_minify_cache_buster() { * Cleanup the given cache folder, removing all files older than $file_age seconds. * * @param string $cache_folder The path to the cache folder to cleanup. - * @param int $file_age The age of files to purge, in seconds. + * @param int $file_age The age of files to purge, in seconds. */ function jetpack_boost_page_optimize_cache_cleanup( $cache_folder = false, $file_age = DAY_IN_SECONDS ) { if ( ! is_dir( $cache_folder ) ) { diff --git a/projects/plugins/boost/app/modules/image-size-analysis/Image_Size_Analysis_Fixer.php b/projects/plugins/boost/app/modules/image-size-analysis/Image_Size_Analysis_Fixer.php index 222dd3706bdea..5f628c0cf0d48 100644 --- a/projects/plugins/boost/app/modules/image-size-analysis/Image_Size_Analysis_Fixer.php +++ b/projects/plugins/boost/app/modules/image-size-analysis/Image_Size_Analysis_Fixer.php @@ -17,7 +17,6 @@ public static function setup() { * * @param string $url * @return string - * */ public static function fix_url( $url ) { $parsed_url = wp_parse_url( $url ); diff --git a/projects/plugins/boost/app/modules/image-size-analysis/data-sync/Image_Size_Analysis_Action_Fix.php b/projects/plugins/boost/app/modules/image-size-analysis/data-sync/Image_Size_Analysis_Action_Fix.php index d6bf6fcae81b2..8f2f7b2c20410 100644 --- a/projects/plugins/boost/app/modules/image-size-analysis/data-sync/Image_Size_Analysis_Action_Fix.php +++ b/projects/plugins/boost/app/modules/image-size-analysis/data-sync/Image_Size_Analysis_Action_Fix.php @@ -16,8 +16,7 @@ class Image_Analysis_Action_Fix implements Data_Sync_Action { * * @param mixed $data JSON Data passed to the action. * @param \WP_REST_Request $_request The request object. - * - * @throws \Exception + * @return array|\WP_Error WP_Error if the feature is not enabled, otherwise a response array. */ public function handle( $data, $_request ) { diff --git a/projects/plugins/boost/app/modules/optimizations/image-cdn/class-image-cdn.php b/projects/plugins/boost/app/modules/optimizations/image-cdn/class-image-cdn.php index 43e64f4de5e69..f526cc97ae848 100644 --- a/projects/plugins/boost/app/modules/optimizations/image-cdn/class-image-cdn.php +++ b/projects/plugins/boost/app/modules/optimizations/image-cdn/class-image-cdn.php @@ -38,7 +38,7 @@ public static function is_available() { /** * Add quality arg to existing photon args. * - * @param $args array - Existing photon args. + * @param array $args - Existing photon args. * * @return mixed */ diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache.php b/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache.php index 99ab78edf39d0..d7bd641eeaee8 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache.php @@ -13,12 +13,12 @@ use Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Pre_WordPress\Filesystem_Utils; class Page_Cache implements Pluggable, Has_Deactivate, Optimization { - /* + /** * @var array - The errors that occurred when removing the cache. */ private $removal_errors = array(); - /* + /** * The signature used to identify the advanced-cache.php file owned by Jetpack Boost. */ const ADVANCED_CACHE_SIGNATURE = 'Boost Cache Plugin'; @@ -28,7 +28,7 @@ class Page_Cache implements Pluggable, Has_Deactivate, Optimization { */ const ADVANCED_CACHE_VERSION = 'v0.0.3'; - /* + /** * @var Boost_Cache_Settings - The settings for the page cache. */ private $settings; diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache_Setup.php b/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache_Setup.php index 93b99d10ebcb9..5b0bf26c51d78 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache_Setup.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/Page_Cache_Setup.php @@ -12,6 +12,7 @@ class Page_Cache_Setup { /** * Runs setup steps and returns whether setup was successful or not. + * * @return bool|\WP_Error */ public static function run_setup() { @@ -76,7 +77,7 @@ private static function run_step( $step ) { } } - /* + /** * Enable caching step of setup. * * @return Boost_Cache_Error|bool - True on success, false if it was already enabled, error otherwise. @@ -242,7 +243,7 @@ public static function deactivate() { return true; } - /* + /** * Removes the boost-cache directory, removing all cached files and the config file. * Fired when the plugin is uninstalled. */ diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache.php b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache.php index 4ca4a1c6e8ee5..682053f2e840b 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache.php @@ -50,7 +50,7 @@ class Boost_Cache { private static $cache_engine_loaded = false; /** - * @param $storage - Optionally provide a Boost_Cache_Storage subclass to handle actually storing and retrieving cached content. Defaults to a new instance of File_Storage. + * @param ?Storage\Storage $storage - Optionally provide a Storage subclass to handle actually storing and retrieving cached content. Defaults to a new instance of File_Storage. */ public function __construct( $storage = null ) { $this->settings = Boost_Cache_Settings::get_instance(); @@ -216,8 +216,8 @@ public function delete_cache_by_post_id( $post_id ) { /** * Delete the cache for the post if the comment transitioned from one state to another. * - * @param string $new_status - The new status of the comment. - * @param string $old_status - The old status of the comment. + * @param string $new_status - The new status of the comment. + * @param string $old_status - The old status of the comment. * @param WP_Comment $comment - The comment that transitioned. */ public function delete_on_comment_transition( $new_status, $old_status, $comment ) { @@ -239,7 +239,7 @@ public function delete_on_comment_transition( $new_status, $old_status, $comment * After editing a comment, delete the cache for the post if the comment is approved. * If changing state and editing, both actions will be called, but the cache will only be deleted once. * - * @param int $comment_id - The id of the comment. + * @param int $comment_id - The id of the comment. * @param array $commentdata - The comment data. */ public function delete_on_comment_edit( $comment_id, $commentdata ) { @@ -254,8 +254,8 @@ public function delete_on_comment_edit( $comment_id, $commentdata ) { * After a comment is posted, delete the cache for the post if the comment is approved. * If the comment is not approved, only delete the cache for this post for this visitor. * - * @param int $comment_id - The id of the comment. - * @param int $comment_approved - The approval status of the comment. + * @param int $comment_id - The id of the comment. + * @param int $comment_approved - The approval status of the comment. * @param array $commentdata - The comment data. */ public function delete_on_comment_post( $comment_id, $comment_approved, $commentdata ) { @@ -267,7 +267,8 @@ public function delete_on_comment_post( $comment_id, $comment_approved, $comment */ if ( $comment_approved !== 1 ) { $parameters = $this->request->get_parameters(); - /** + + /* * if there are no cookies, then visitor did not click "remember me". * No need to delete the cache for this visitor as they'll be * redirected to a page with a hash in the URL for the moderation @@ -296,8 +297,8 @@ private function is_published( $status ) { /** * Delete the cached post if it transitioned from one state to another. * - * @param string $new_status - The new status of the post. - * @param string $old_status - The old status of the post. + * @param string $new_status - The new status of the post. + * @param string $old_status - The old status of the post. * @param WP_Post $post - The post that transitioned. */ public function delete_on_post_transition( $new_status, $old_status, $post ) { @@ -336,7 +337,7 @@ public function delete_on_post_transition( $new_status, $old_status, $post ) { /** * Delete the cache for the post if it was trashed. * - * @param int $post_id - The id of the post. + * @param int $post_id - The id of the post. * @param string $old_status - The old status of the post. */ public function delete_on_post_trash( $post_id, $old_status ) { diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Actions.php b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Actions.php index 4fafa8a1c9b1a..c2e452fc75362 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Actions.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Actions.php @@ -1,5 +1,4 @@ false, @@ -45,6 +47,7 @@ public static function get_instance() { /** * Ensure a settings file exists, if one isn't there already. + * * @return Boost_Cache_Error|bool - True if it was changed, or a Boost_Cache_Error on failure, false if it was already created. */ public function create_settings_file() { @@ -78,7 +81,7 @@ private function log_init_error( $message ) { } } - /* + /** * Load the settings from the config file, if available. Falls back to defaults if not. */ private function init_settings() { @@ -111,7 +114,7 @@ private function init_settings() { $this->settings = $file_settings; } - /* + /** * Returns the value of the given setting. * * @param string $setting - The setting to get. @@ -125,7 +128,7 @@ public function get( $setting, $default = false ) { return $this->settings[ $setting ]; } - /* + /** * Returns true if the cache is enabled. * * @return bool @@ -134,7 +137,7 @@ public function get_enabled() { return $this->get( 'enabled', false ); } - /* + /** * Returns an array of URLs that should not be cached. * * @return array @@ -154,6 +157,7 @@ public function get_logging() { /** * Sets the given settings, and saves them to the config file. + * * @param array $settings - The settings to set in a key => value associative * array. This will be merged with the existing settings. * Example: diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Utils.php b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Utils.php index a6533acde0d3a..38b6142ce2329 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Utils.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Boost_Cache_Utils.php @@ -39,6 +39,7 @@ public static function trailingslashit( $string ) { /** * Returns a sanitized directory path. + * * @param string $path - The path to sanitize. * @return string */ diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Filesystem_Utils.php b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Filesystem_Utils.php index bcc591ab02fad..c37195ef12781 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Filesystem_Utils.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Filesystem_Utils.php @@ -10,6 +10,7 @@ class Filesystem_Utils { /** * Recursively delete a directory. + * * @param string $path - The directory to delete. * @param bool $type - The type of delete. DELETE_FILES to delete all files in the given directory. DELETE_ALL to delete everything in the given directory, recursively. * @return bool|Boost_Cache_Error @@ -64,6 +65,7 @@ public static function delete_directory( $path, $type ) { /** * Returns true if the given directory is inside the boost-cache directory. + * * @param string $dir - The directory to check. * @return bool */ @@ -75,7 +77,7 @@ public static function is_boost_cache_directory( $dir ) { /** * Given a request_uri and its parameters, return the filename to use for this cached data. Does not include the file path. * - * @param array $parameters - An associative array of all the things that make this request special/different. Includes GET parameters and COOKIEs normally. + * @param array $parameters - An associative array of all the things that make this request special/different. Includes GET parameters and COOKIEs normally. */ public static function get_request_filename( $parameters ) { diff --git a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Logger.php b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Logger.php index 3328b12eab4a5..04d6625e3f499 100644 --- a/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Logger.php +++ b/projects/plugins/boost/app/modules/optimizations/page-cache/pre-wordpress/Logger.php @@ -11,6 +11,8 @@ class Logger { /** * The singleton instance of the logger. + * + * @var self */ private static $instance = null; @@ -26,6 +28,8 @@ class Logger { /** * The Process Identifier used by this Logger instance. + * + * @var int|float */ private $pid = null; diff --git a/projects/plugins/boost/app/rest-api/endpoints/Update_Cloud_CSS.php b/projects/plugins/boost/app/rest-api/endpoints/Update_Cloud_CSS.php index ef31b41db43d8..c9be1e097d0a1 100644 --- a/projects/plugins/boost/app/rest-api/endpoints/Update_Cloud_CSS.php +++ b/projects/plugins/boost/app/rest-api/endpoints/Update_Cloud_CSS.php @@ -4,6 +4,7 @@ * * This endpoint is used by WP.com to push the generated CSS to the boost plugin. */ + namespace Automattic\Jetpack_Boost\REST_API\Endpoints; use Automattic\Jetpack_Boost\Lib\Critical_CSS\Critical_CSS_State; @@ -33,7 +34,6 @@ * - type: string - machine readable error type. * - meta: Object - JSON string compatible object containing extra metadata for consumption in the UI. */ - class Update_Cloud_CSS implements Endpoint { public function name() { diff --git a/projects/plugins/boost/changelog/add-sync-woo-remove-order-items b/projects/plugins/boost/changelog/add-sync-woo-remove-order-items new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/boost/changelog/add-sync-woo-remove-order-items @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/boost/changelog/add-sync-woo-remove-order-items#2 b/projects/plugins/boost/changelog/add-sync-woo-remove-order-items#2 new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/boost/changelog/add-sync-woo-remove-order-items#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/boost/changelog/add-sync-woo-remove-order-items#3 b/projects/plugins/boost/changelog/add-sync-woo-remove-order-items#3 new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/boost/changelog/add-sync-woo-remove-order-items#3 @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/boost/changelog/fix-boost-webpack-css-gen b/projects/plugins/boost/changelog/fix-boost-webpack-css-gen new file mode 100644 index 0000000000000..81c91dfa0c578 --- /dev/null +++ b/projects/plugins/boost/changelog/fix-boost-webpack-css-gen @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Changes to development assets + + diff --git a/projects/plugins/boost/changelog/fix-unexpected-phpcs-exclusions b/projects/plugins/boost/changelog/fix-unexpected-phpcs-exclusions new file mode 100644 index 0000000000000..73a26fbe577ad --- /dev/null +++ b/projects/plugins/boost/changelog/fix-unexpected-phpcs-exclusions @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fixed phpcs config, and phpdoc comments that seemed easy to fix. No change to functionality. + + diff --git a/projects/plugins/boost/compatibility/boost-1.3.1.php b/projects/plugins/boost/compatibility/boost-1.3.1.php index 3ff8ad8f6a40b..342e0a3d24a7a 100644 --- a/projects/plugins/boost/compatibility/boost-1.3.1.php +++ b/projects/plugins/boost/compatibility/boost-1.3.1.php @@ -25,7 +25,6 @@ function jetpack_boost_131_option_fallback( $default, $option ) { * silently migrate the options to the new format, * that way the code above is never run. */ - function jetpack_boost_131_option_migration() { /** diff --git a/projects/plugins/boost/compatibility/js-concatenate.php b/projects/plugins/boost/compatibility/js-concatenate.php index 8566c57019e49..3b1d2855b3268 100644 --- a/projects/plugins/boost/compatibility/js-concatenate.php +++ b/projects/plugins/boost/compatibility/js-concatenate.php @@ -2,6 +2,7 @@ /** * Exclude known scripts that causes problem when concatenated. */ + namespace Automattic\Jetpack_Boost\Compatibility\JS_Concatenate; function maybe_do_not_concat( $do_concat, $handle ) { diff --git a/projects/plugins/boost/compatibility/lib/class-sync-jetpack-module-status.php b/projects/plugins/boost/compatibility/lib/class-sync-jetpack-module-status.php index a020d7af5b1e8..7b97fd6027f0d 100644 --- a/projects/plugins/boost/compatibility/lib/class-sync-jetpack-module-status.php +++ b/projects/plugins/boost/compatibility/lib/class-sync-jetpack-module-status.php @@ -6,10 +6,18 @@ */ class Sync_Jetpack_Module_Status { - /** Slug of the Jetpack module */ + /** + * Slug of the Jetpack module + * + * @var string + */ public $jetpack_module_slug; - /** Slug of the Boost module */ + /** + * Slug of the Boost module + * + * @var string + */ public $boost_module_slug; public function __construct( $boost_module_slug, $jetpack_module_slug ) { diff --git a/projects/plugins/boost/compatibility/score-prompt.php b/projects/plugins/boost/compatibility/score-prompt.php index 3cddb9a83312b..12f66f9ba24a4 100644 --- a/projects/plugins/boost/compatibility/score-prompt.php +++ b/projects/plugins/boost/compatibility/score-prompt.php @@ -4,6 +4,7 @@ * * @package automattic/jetpack-boost */ + // Old value is the previous DS key, fallback to even older non-ds value. $old_value = (array) get_option( 'jetpack_boost_ds_dismissed_score_prompt', get_option( 'jb_show_score_prompt' ) ); if ( false !== $old_value ) { diff --git a/projects/plugins/boost/composer.lock b/projects/plugins/boost/composer.lock index cd34e4608f320..fed41eaac43c8 100644 --- a/projects/plugins/boost/composer.lock +++ b/projects/plugins/boost/composer.lock @@ -1530,7 +1530,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "5f1e574ac98b4cfa494ee2585d7adb9efe89189b" + "reference": "bf72e4fd0707344623c04f5af5ae83ef1152ab14" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1562,7 +1562,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.14.x-dev" + "dev-trunk": "2.15.x-dev" } }, "autoload": { diff --git a/projects/plugins/boost/webpack.config.js b/projects/plugins/boost/webpack.config.js index c50383cdbedee..551bea373999d 100644 --- a/projects/plugins/boost/webpack.config.js +++ b/projects/plugins/boost/webpack.config.js @@ -10,18 +10,26 @@ const cssGenPath = path.dirname( path.dirname( require.resolve( 'jetpack-boost-critical-css-gen' ) ) ); -const cssGenCopyPatterns = [ - { - from: path.join( cssGenPath, 'dist/bundle.js' ), - to: 'critical-css-gen.js', - }, -]; +let cssGenCopyPatterns; -if ( ! isProduction ) { - cssGenCopyPatterns.push( { - from: path.join( cssGenPath, 'dist/bundle.js.map' ), - to: 'critical-css-gen.js.map', - } ); +if ( isProduction ) { + cssGenCopyPatterns = [ + { + from: path.join( cssGenPath, 'dist/bundle.js' ), + to: 'critical-css-gen.js', + }, + ]; +} else { + cssGenCopyPatterns = [ + { + from: path.join( cssGenPath, 'dist/bundle.full.js' ), + to: 'critical-css-gen.js', + }, + { + from: path.join( cssGenPath, 'dist/bundle.full.js.map' ), + to: 'bundle.full.js.map', + }, + ]; } const imageGuideCopyPatterns = [ diff --git a/projects/plugins/boost/wp-js-data-sync.php b/projects/plugins/boost/wp-js-data-sync.php index 11cda86f0a9ea..d70bf0cf65a71 100644 --- a/projects/plugins/boost/wp-js-data-sync.php +++ b/projects/plugins/boost/wp-js-data-sync.php @@ -1,9 +1,11 @@ register_action( $key, $action_name, $request_schema, $instance ); @@ -64,7 +66,7 @@ function jetpack_boost_register_readonly_option( $key, $callback ) { } /** - * @param $key + * @param string $key * * @return Data_Sync_Entry */ diff --git a/projects/plugins/crm/.phan/baseline.php b/projects/plugins/crm/.phan/baseline.php index a1250f3a4703f..0fd5323e2a61f 100644 --- a/projects/plugins/crm/.phan/baseline.php +++ b/projects/plugins/crm/.phan/baseline.php @@ -101,7 +101,6 @@ // PhanRedefineFunction : 2 occurrences // PhanTypeVoidArgument : 2 occurrences // PhanUndeclaredClassInstanceof : 2 occurrences - // PhanCommentParamOnEmptyParamList : 1 occurrence // PhanImpossibleTypeComparisonInLoop : 1 occurrence // PhanNoopVariable : 1 occurrence // PhanParamSuspiciousOrder : 1 occurrence @@ -353,7 +352,7 @@ 'tests/php/automation/transactions/class-transaction-condition-test.php' => ['PhanUnreferencedUseNormal'], 'tests/php/automation/transactions/class-transaction-trigger-test.php' => ['PhanUnreferencedUseNormal'], 'tests/php/bootstrap.php' => ['PhanUndeclaredConstant'], - 'tests/php/event-manager/class-event-manager-faker.php' => ['PhanCommentParamOnEmptyParamList', 'PhanUndeclaredTypeReturnType'], + 'tests/php/event-manager/class-event-manager-faker.php' => ['PhanUndeclaredTypeReturnType'], 'tests/php/event-manager/class-event-manager-test.php' => ['PhanCommentVarInsteadOfParam', 'PhanParamTooMany'], 'tests/php/rest-api/v4/class-rest-authentication-test.php' => ['PhanTypeMismatchReturn'], 'tests/php/rest-api/v4/class-rest-contacts-controller-test.php' => ['PhanPluginNeverReturnFunction'], diff --git a/projects/plugins/crm/.phpcs.dir.xml b/projects/plugins/crm/.phpcs.dir.xml index 0fd7d94455d83..5e1510189d7c4 100644 --- a/projects/plugins/crm/.phpcs.dir.xml +++ b/projects/plugins/crm/.phpcs.dir.xml @@ -2,8 +2,8 @@ - - 0 + + @@ -27,16 +27,16 @@ - - 0 + + - - 0 + + diff --git a/projects/plugins/crm/changelog/fix-unexpected-phpcs-exclusions b/projects/plugins/crm/changelog/fix-unexpected-phpcs-exclusions new file mode 100644 index 0000000000000..73a26fbe577ad --- /dev/null +++ b/projects/plugins/crm/changelog/fix-unexpected-phpcs-exclusions @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fixed phpcs config, and phpdoc comments that seemed easy to fix. No change to functionality. + + diff --git a/projects/plugins/crm/src/automation/class-automation-engine.php b/projects/plugins/crm/src/automation/class-automation-engine.php index e70d0b88b1433..41a0a7e54b985 100644 --- a/projects/plugins/crm/src/automation/class-automation-engine.php +++ b/projects/plugins/crm/src/automation/class-automation-engine.php @@ -350,7 +350,7 @@ public function execute_workflow( Automation_Workflow $workflow, Trigger $trigge $step->validate_and_execute( $data_type ); - //todo: return Step instance instead of array + // todo: return Step instance instead of array $step_id = $step->get_next_step_id(); $step_data = $workflow->get_step( $step_id ); diff --git a/projects/plugins/crm/src/automation/class-base-trigger.php b/projects/plugins/crm/src/automation/class-base-trigger.php index b4d04ed560789..3aaf1f34b377c 100644 --- a/projects/plugins/crm/src/automation/class-base-trigger.php +++ b/projects/plugins/crm/src/automation/class-base-trigger.php @@ -75,7 +75,6 @@ public function init( Automation_Workflow $workflow ) { * @param int $priority The priority of the action. * @param int $accepted_args The number of arguments the action accepts. * @since 6.2.0 - * */ protected function listen_to_wp_action( string $hook_name, int $priority = 10, int $accepted_args = 1 ): void { add_action( $hook_name, array( $this, 'execute_workflow' ), $priority, $accepted_args ); diff --git a/projects/plugins/crm/src/entities/factories/class-entity-factory.php b/projects/plugins/crm/src/entities/factories/class-entity-factory.php index 2bd1395534992..fc189693e5c78 100644 --- a/projects/plugins/crm/src/entities/factories/class-entity-factory.php +++ b/projects/plugins/crm/src/entities/factories/class-entity-factory.php @@ -196,7 +196,7 @@ public static function get_fields_map(): array { /** * Return the associative fields map. * - * tags, files, etc. + * Tags, files, etc. * * @since 6.2.0 * diff --git a/projects/plugins/crm/tests/.phpcs.dir.xml b/projects/plugins/crm/tests/.phpcs.dir.xml index 19b909c4d2bd0..75d841bb1e65e 100644 --- a/projects/plugins/crm/tests/.phpcs.dir.xml +++ b/projects/plugins/crm/tests/.phpcs.dir.xml @@ -2,37 +2,71 @@ - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/plugins/crm/tests/php/automation/class-workflow-repository-test.php b/projects/plugins/crm/tests/php/automation/class-workflow-repository-test.php index 85291a9903d62..6308d12f71544 100644 --- a/projects/plugins/crm/tests/php/automation/class-workflow-repository-test.php +++ b/projects/plugins/crm/tests/php/automation/class-workflow-repository-test.php @@ -237,7 +237,7 @@ public function dataprovider_pagination_criteria() { * @since 6.2.0 * * @param array $args Dynamic criteria for pagination. - * @param int $expected_count The expected number of returned workflows. + * @param int $expected_count The expected number of returned workflows. */ public function test_find_by_pagination( array $args, int $expected_count ) { $workflow_data = Automation_Faker::instance()->workflow_with_condition_action(); diff --git a/projects/plugins/crm/tests/php/class-jpcrm-base-integration-test-case.php b/projects/plugins/crm/tests/php/class-jpcrm-base-integration-test-case.php index 98371a4d69e60..31b1792e4fc7b 100644 --- a/projects/plugins/crm/tests/php/class-jpcrm-base-integration-test-case.php +++ b/projects/plugins/crm/tests/php/class-jpcrm-base-integration-test-case.php @@ -66,7 +66,7 @@ public function add_transaction( array $args = array() ) { * Get a contact. * * @param int|string $id The ID of the contact we want to get. - * @param array $args (Optional) A list of arguments we should use for the contact. + * @param array $args (Optional) A list of arguments we should use for the contact. * @return Contact|null */ public function get_contact( $id, array $args = array() ) { diff --git a/projects/plugins/crm/tests/php/event-manager/class-event-manager-faker.php b/projects/plugins/crm/tests/php/event-manager/class-event-manager-faker.php index ac11df0c19878..bc0c6e1313b7a 100644 --- a/projects/plugins/crm/tests/php/event-manager/class-event-manager-faker.php +++ b/projects/plugins/crm/tests/php/event-manager/class-event-manager-faker.php @@ -27,7 +27,6 @@ public function contact_data() { /** * Return data for a dummy invoice. * - * @param bool $get_as_data_type If true, return the data as a Data_Type_Invoice object. * @return array|Data_Type_Invoice */ public function invoice_data() { diff --git a/projects/plugins/crm/tests/php/rest-api/class-rest-base-test-case.php b/projects/plugins/crm/tests/php/rest-api/class-rest-base-test-case.php index 49c128aee678f..c668530f3c02f 100644 --- a/projects/plugins/crm/tests/php/rest-api/class-rest-base-test-case.php +++ b/projects/plugins/crm/tests/php/rest-api/class-rest-base-test-case.php @@ -39,7 +39,7 @@ public function create_wp_user( $args = array() ) { * This user will use the 'zerobs_admin' role by default and can be used * to test e.g. API endpoints. * - * @param array $args A list of arguments to create the WP user from. + * @param array $args A list of arguments to create the WP user from. * * @return int */ diff --git a/projects/plugins/inspect/.phpcs.dir.xml b/projects/plugins/inspect/.phpcs.dir.xml index 5b5a9497e9b86..b39086dbfe7ef 100644 --- a/projects/plugins/inspect/.phpcs.dir.xml +++ b/projects/plugins/inspect/.phpcs.dir.xml @@ -8,8 +8,9 @@ - - 0 + + + diff --git a/projects/plugins/inspect/changelog/fix-unexpected-phpcs-exclusions b/projects/plugins/inspect/changelog/fix-unexpected-phpcs-exclusions new file mode 100644 index 0000000000000..b0e13d15171f3 --- /dev/null +++ b/projects/plugins/inspect/changelog/fix-unexpected-phpcs-exclusions @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix phpcs config. No change to functionality. + + diff --git a/projects/plugins/jetpack/3rd-party/class.jetpack-amp-support.php b/projects/plugins/jetpack/3rd-party/class.jetpack-amp-support.php index 142c9324834fb..3cc6c12fa04cd 100644 --- a/projects/plugins/jetpack/3rd-party/class.jetpack-amp-support.php +++ b/projects/plugins/jetpack/3rd-party/class.jetpack-amp-support.php @@ -24,12 +24,6 @@ public static function init() { add_action( 'amp_post_template_footer', array( 'Jetpack_AMP_Support', 'add_stats_pixel' ) ); } - /** - * Remove this during the init hook in case users have enabled it during - * the after_setup_theme hook, which triggers before init. - */ - remove_theme_support( 'jetpack-devicepx' ); - // Sharing. add_filter( 'jetpack_sharing_display_markup', array( 'Jetpack_AMP_Support', 'render_sharing_html' ), 10, 2 ); add_filter( 'sharing_enqueue_scripts', array( 'Jetpack_AMP_Support', 'amp_disable_sharedaddy_css' ) ); diff --git a/projects/plugins/jetpack/changelog/add-sync-woo-remove-order-items b/projects/plugins/jetpack/changelog/add-sync-woo-remove-order-items new file mode 100644 index 0000000000000..2b9a080d8e528 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-sync-woo-remove-order-items @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Jetpack Sync: Add Woocommerce event remove_order_items to Jetpack Sync diff --git a/projects/plugins/jetpack/changelog/add-sync-woo-remove-order-items#2 b/projects/plugins/jetpack/changelog/add-sync-woo-remove-order-items#2 new file mode 100644 index 0000000000000..a1c1831fa1ef7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-sync-woo-remove-order-items#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Updated composer.lock. + + diff --git a/projects/plugins/jetpack/changelog/add-valid-tier-plans b/projects/plugins/jetpack/changelog/add-valid-tier-plans new file mode 100644 index 0000000000000..c86946de85d4d --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-valid-tier-plans @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Add a method to find all plans that are valid for a given newsletter tier. diff --git a/projects/plugins/jetpack/changelog/feature-ads-txt-multisite b/projects/plugins/jetpack/changelog/feature-ads-txt-multisite new file mode 100644 index 0000000000000..a973983fd0731 --- /dev/null +++ b/projects/plugins/jetpack/changelog/feature-ads-txt-multisite @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +WordAds: ensure that ads.txt works on subdirectory websites. diff --git a/projects/plugins/jetpack/changelog/remove-deprecate-site-logo b/projects/plugins/jetpack/changelog/remove-deprecate-site-logo new file mode 100644 index 0000000000000..eef8f69a68cc8 --- /dev/null +++ b/projects/plugins/jetpack/changelog/remove-deprecate-site-logo @@ -0,0 +1,4 @@ +Significance: minor +Type: compat + +Theme tools: deprecated site-logo functionality in favour of core supported custom-logo. diff --git a/projects/plugins/jetpack/changelog/udpate-deprecate-theme-tool-devicepx b/projects/plugins/jetpack/changelog/udpate-deprecate-theme-tool-devicepx new file mode 100644 index 0000000000000..23f7372fb1c29 --- /dev/null +++ b/projects/plugins/jetpack/changelog/udpate-deprecate-theme-tool-devicepx @@ -0,0 +1,4 @@ +Significance: minor +Type: compat + +Theme tools: deprecated devicepx functionality diff --git a/projects/plugins/jetpack/changelog/update-ai-featured-image-support-prompt-editing b/projects/plugins/jetpack/changelog/update-ai-featured-image-support-prompt-editing new file mode 100644 index 0000000000000..eab0a8297dfed --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-ai-featured-image-support-prompt-editing @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +AI Featured Image: allow users to write prompts for the image generation. diff --git a/projects/plugins/jetpack/changelog/update-block-hooks-init-fix b/projects/plugins/jetpack/changelog/update-block-hooks-init-fix new file mode 100644 index 0000000000000..db0be84b0aad9 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-block-hooks-init-fix @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Subscriptions: Fix registering block hooks for REST API calls diff --git a/projects/plugins/jetpack/changelog/update-migration_source_site_domain b/projects/plugins/jetpack/changelog/update-migration_source_site_domain new file mode 100644 index 0000000000000..dc3d944b19ca3 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-migration_source_site_domain @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Add handler for the migration_source_site_domain option diff --git a/projects/plugins/jetpack/changelog/update-subscribe-centered b/projects/plugins/jetpack/changelog/update-subscribe-centered new file mode 100644 index 0000000000000..3983a24dc06f5 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-subscribe-centered @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Subscriptions: Fix Subscribed button alignment diff --git a/projects/plugins/jetpack/changelog/update-subscribe-widget-confirm-follow b/projects/plugins/jetpack/changelog/update-subscribe-widget-confirm-follow new file mode 100644 index 0000000000000..37195276196f9 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-subscribe-widget-confirm-follow @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Subscription widget: remove "follow" term from confirmation message diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index b991b4d6e6f65..24fb912671cb8 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -2448,7 +2448,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "5f1e574ac98b4cfa494ee2585d7adb9efe89189b" + "reference": "bf72e4fd0707344623c04f5af5ae83ef1152ab14" }, "require": { "automattic/jetpack-connection": "@dev", @@ -2480,7 +2480,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.14.x-dev" + "dev-trunk": "2.15.x-dev" } }, "autoload": { diff --git a/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php b/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php index 59f0e9a88adf7..aed34fed329b1 100644 --- a/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php +++ b/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php @@ -9,6 +9,7 @@ namespace Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service; use Automattic\Jetpack\Extensions\Premium_Content\JWT; +use WP_Error; use WP_Post; use const Automattic\Jetpack\Extensions\Subscriptions\META_NAME_FOR_POST_TIER_ID_SETTINGS; @@ -247,6 +248,97 @@ private function maybe_gate_access_for_user_if_post_tier( $post_id, $user_abbrev return $this->maybe_gate_access_for_user_if_tier( $tier_id, $user_abbreviated_subscriptions ); } + /** + * Get all plans id that make access valid for a post with this tier id. + * + * @param int $tier_id Newsletter tier post ID. + * + * @return array|WP_Error + */ + public static function get_valid_plan_ids_for_tier( int $tier_id ) { + // Valid plans are: + // - monthly plan with ID $tier_id + // - yearly plan related to this $tier_id (in meta jetpack_memberships_tier) + // - monthly tiers with same currency and price same or higher than original tier + // - yearly plans that are more expensive than the yearly plan linked to the original tier + + $valid_plan_ids = array(); + + $all_plans = \Jetpack_Memberships::get_all_plans(); + + // Let's get the current tier + $tier = null; + foreach ( $all_plans as $post ) { + if ( $post->ID === $tier_id ) { + $tier = $post; + break; + } + } + + if ( $tier === null ) { + // We have an error + return new WP_Error( 'related-plan-not-found', 'The plan related to the tier cannot be found' ); + } + + $tier_price = self::find_metadata( $tier, 'jetpack_memberships_price' ); + $tier_currency = self::find_metadata( $tier, 'jetpack_memberships_currency' ); + $tier_product_id = self::find_metadata( $tier, 'jetpack_memberships_product_id' ); + + if ( $tier_price === null || $tier_currency === null || $tier_product_id === null ) { + // There is an issue with the meta + return new WP_Error( 'wrong-data-plan-not-found', 'The plan related to the tier is missing data' ); + } + + $valid_plan_ids[] = $tier_id; + + $tier_price = floatval( $tier_price ); + + // At this point we know the post is + $annual_tier = null; + foreach ( $all_plans as $plan ) { + if ( intval( self::find_metadata( $plan, 'jetpack_memberships_tier' ) ) === $tier_id ) { + $annual_tier = $plan; + break; + } + } + + $annual_tier_price = null; + if ( ! empty( $annual_tier ) ) { + $annual_tier_price = floatval( self::find_metadata( $annual_tier, 'jetpack_memberships_price' ) ); + $valid_plan_ids[] = $annual_tier->ID; + } + + foreach ( $all_plans as $post ) { + if ( in_array( $post->ID, $valid_plan_ids, true ) ) { + continue; + } + + $plan_price = self::find_metadata( $post, 'jetpack_memberships_price' ); + $plan_currency = self::find_metadata( $post, 'jetpack_memberships_currency' ); + $plan_interval = self::find_metadata( $post, 'jetpack_memberships_interval' ); + + if ( $plan_price === null || $plan_currency === null || $plan_interval === null ) { + // There is an issue with the meta + continue; + } + + $plan_price = floatval( $plan_price ); + + if ( $tier_currency !== $plan_currency ) { + // For now, we don't count if there are different currency (not sure how to convert price in a pure JP env) + continue; + } + + if ( ( $plan_interval === '1 month' && $plan_price >= $tier_price ) || + ( $annual_tier_price !== null && $plan_interval === '1 year' && $plan_price >= $annual_tier_price ) + ) { + $valid_plan_ids [] = $post->ID; + } + } + + return $valid_plan_ids; + } + /** * Find metadata in post * @@ -255,7 +347,7 @@ private function maybe_gate_access_for_user_if_post_tier( $post_id, $user_abbrev * * @return mixed|null */ - private function find_metadata( $post, $meta_key ) { + private static function find_metadata( $post, $meta_key ) { if ( $post instanceof WP_Post ) { return $post->{$meta_key}; @@ -301,9 +393,9 @@ public function maybe_gate_access_for_user_if_tier( $tier_id, $user_abbreviated_ return false; } - $tier_price = $this->find_metadata( $tier, 'jetpack_memberships_price' ); - $tier_currency = $this->find_metadata( $tier, 'jetpack_memberships_currency' ); - $tier_product_id = $this->find_metadata( $tier, 'jetpack_memberships_product_id' ); + $tier_price = self::find_metadata( $tier, 'jetpack_memberships_price' ); + $tier_currency = self::find_metadata( $tier, 'jetpack_memberships_currency' ); + $tier_product_id = self::find_metadata( $tier, 'jetpack_memberships_product_id' ); $annual_tier_price = $tier_price * 12; if ( $tier_price === null || $tier_currency === null || $tier_product_id === null ) { @@ -317,15 +409,16 @@ public function maybe_gate_access_for_user_if_tier( $tier_id, $user_abbreviated_ $annual_tier_id = null; $annual_tier = null; foreach ( $all_plans as $plan ) { - if ( intval( $this->find_metadata( $plan, 'jetpack_memberships_tier' ) ) === $tier_id ) { + if ( intval( self::find_metadata( $plan, 'jetpack_memberships_tier' ) ) === $tier_id ) { $annual_tier = $plan; break; } } + $annual_tier_price = null; if ( ! empty( $annual_tier ) ) { $annual_tier_id = $annual_tier->ID; - $annual_tier_price = floatval( $this->find_metadata( $annual_tier, 'jetpack_memberships_price' ) ); + $annual_tier_price = floatval( self::find_metadata( $annual_tier, 'jetpack_memberships_price' ) ); } foreach ( $user_abbreviated_subscriptions as $subscription_plan_id => $details ) { @@ -338,7 +431,7 @@ public function maybe_gate_access_for_user_if_tier( $tier_id, $user_abbreviated_ $subscription_post = null; foreach ( $all_plans as $plan ) { - if ( intval( $this->find_metadata( $plan, 'jetpack_memberships_product_id' ) ) === intval( $subscription_plan_id ) ) { + if ( intval( self::find_metadata( $plan, 'jetpack_memberships_product_id' ) ) === intval( $subscription_plan_id ) ) { $subscription_post = $plan; break; } @@ -355,9 +448,9 @@ public function maybe_gate_access_for_user_if_tier( $tier_id, $user_abbreviated_ return false; } - $subscription_price = $this->find_metadata( $subscription_post, 'jetpack_memberships_price' ); - $subscription_currency = $this->find_metadata( $subscription_post, 'jetpack_memberships_currency' ); - $subscription_interval = $this->find_metadata( $subscription_post, 'jetpack_memberships_interval' ); + $subscription_price = self::find_metadata( $subscription_post, 'jetpack_memberships_price' ); + $subscription_currency = self::find_metadata( $subscription_post, 'jetpack_memberships_currency' ); + $subscription_interval = self::find_metadata( $subscription_post, 'jetpack_memberships_interval' ); if ( $subscription_price === null || $subscription_currency === null || $subscription_interval === null ) { // There is an issue with the meta @@ -372,7 +465,7 @@ public function maybe_gate_access_for_user_if_tier( $tier_id, $user_abbreviated_ } if ( ( $subscription_interval === '1 month' && $subscription_price >= $tier_price ) || - ( $subscription_interval === '1 year' && $subscription_price >= $annual_tier_price ) + ( $annual_tier_price !== null && $subscription_interval === '1 year' && $subscription_price >= $annual_tier_price ) ) { // One subscription is more expensive than the minimum set by the post' selected tier return false; @@ -507,13 +600,13 @@ private function token_from_request() { /** * Return true if any ID/date pairs are valid. Otherwise false. * - * @param int[] $valid_plan_ids List of valid plan IDs. - * @param array $token_subscriptions : ID must exist in the provided $valid_subscriptions parameter. - * The provided end date needs to be greater than now(). + * @param int[] $valid_plan_ids List of valid plan IDs. + * @param object[] $token_subscriptions : ID must exist in the provided $valid_subscriptions parameter. + * The provided end date needs to be greater than now(). * * @return bool */ - public static function validate_subscriptions( $valid_plan_ids, $token_subscriptions ) { + public static function validate_subscriptions( array $valid_plan_ids, array $token_subscriptions ) { // Create a list of product_ids to compare against. $product_ids = array(); foreach ( $valid_plan_ids as $plan_id ) { @@ -522,6 +615,7 @@ public static function validate_subscriptions( $valid_plan_ids, $token_subscript $product_ids[] = $product_id; } } + foreach ( $token_subscriptions as $product_id => $token_subscription ) { if ( in_array( intval( $product_id ), $product_ids, true ) ) { $end = is_int( $token_subscription->end_date ) ? $token_subscription->end_date : strtotime( $token_subscription->end_date ); diff --git a/projects/plugins/jetpack/extensions/blocks/subscriber-login/subscriber-login.php b/projects/plugins/jetpack/extensions/blocks/subscriber-login/subscriber-login.php index d3e95cbd4265d..5967d68284e21 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriber-login/subscriber-login.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriber-login/subscriber-login.php @@ -47,7 +47,17 @@ function ( $options ) { } ); - Jetpack_Subscription_Site::init()->handle_subscriber_login_block_placements(); + // If called via REST API, we need to register later in the lifecycle + if ( ( new Host() )->is_wpcom_platform() && ! jetpack_is_frontend() ) { + add_action( + 'restapi_theme_init', + function () { + Jetpack_Subscription_Site::init()->handle_subscriber_login_block_placements(); + } + ); + } else { + Jetpack_Subscription_Site::init()->handle_subscriber_login_block_placements(); + } } add_action( 'init', __NAMESPACE__ . '\register_block' ); diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/block.json b/projects/plugins/jetpack/extensions/blocks/subscriptions/block.json index 93a92688f8dc2..c53c3b9b32fe7 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/block.json +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/block.json @@ -104,7 +104,7 @@ }, "successMessage": { "type": "string", - "default": "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm Follow' to start subscribing." + "default": "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm' to start subscribing." }, "appSource": { "type": "string" diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/constants.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/constants.js index c71d94d8e01de..b898d165d7b1f 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/constants.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/constants.js @@ -21,6 +21,6 @@ export const DEFAULT_FONTSIZE_VALUE = '16px'; export const DEFAULT_SUBSCRIBE_PLACEHOLDER = __( 'Type your email…', 'jetpack' ); export const DEFAULT_SUBMIT_BUTTON_LABEL = __( 'Subscribe', 'jetpack' ); export const DEFAULT_SUCCESS_MESSAGE = __( - "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm Follow' to start subscribing.", + "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm' to start subscribing.", 'jetpack' ); diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index e9f7e305958ff..a5cf7d6cff6df 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -182,7 +182,17 @@ function ( $options ) { } ); - Jetpack_Subscription_Site::init()->handle_subscribe_block_placements(); + // If called via REST API, we need to register later in the lifecycle + if ( ( new Host() )->is_wpcom_platform() && ! jetpack_is_frontend() ) { + add_action( + 'restapi_theme_init', + function () { + Jetpack_Subscription_Site::init()->handle_subscribe_block_placements(); + } + ); + } else { + Jetpack_Subscription_Site::init()->handle_subscribe_block_placements(); + } } add_action( 'init', __NAMESPACE__ . '\register_block', 9 ); @@ -644,7 +654,7 @@ function render_block( $attributes ) { 'success_message' => get_attribute( $attributes, 'successMessage', - esc_html__( "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm Follow' to start subscribing.", 'jetpack' ) + esc_html__( "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm' to start subscribing.", 'jetpack' ) ), 'show_subscribers_total' => (bool) get_attribute( $attributes, 'showSubscribersTotal' ), 'subscribers_total' => get_subscriber_count( $include_social_followers ), @@ -721,7 +731,7 @@ function render_for_website( $data, $classes, $styles ) {
>
-

{ __( 'Create and use an AI generated featured image for your post.', 'jetpack' ) }

@@ -252,29 +279,19 @@ export default function FeaturedImage( { busy, disabled }: { busy: boolean; disa { isFeaturedImageModalVisible && (
-
- { ( requireUpgrade || notEnoughRequests ) && ! currentPointer?.generating && ( - - ) } - +
+
+ +
@@ -304,17 +321,34 @@ export default function FeaturedImage( { busy, disabled }: { busy: boolean; disa ) } -
+
+ { ( requireUpgrade || notEnoughRequests ) && ! currentPointer?.generating && ( + + ) } + +
} Instance of the Page Object class */ static async init( page, checkSelectors = true ) { const it = new this( page ); diff --git a/tools/e2e-commons/pages/wpcom/authorize.js b/tools/e2e-commons/pages/wpcom/authorize.js index 7285770d47f57..d1ec9656dfd84 100644 --- a/tools/e2e-commons/pages/wpcom/authorize.js +++ b/tools/e2e-commons/pages/wpcom/authorize.js @@ -6,26 +6,20 @@ export default class AuthorizePage extends WpPage { super( page, { expectedSelectors: [ '.jetpack-connect__logged-in-form' ] } ); } - async approve( repeat = true ) { + async approve( options ) { + const { redirectUrl, repeat = true } = options; const authorizeButtonSelector = '.jetpack-connect__authorize-form button'; try { - return await Promise.all( [ - this.click( authorizeButtonSelector ), - this.waitToDisappear(), - this.waitForDomContentLoaded( 50000 ), - ] ); + await this.click( authorizeButtonSelector ); + + await this.page.waitForURL( redirectUrl ); } catch ( error ) { if ( repeat ) { const message = 'Jetpack connection failed. Retrying once again.'; logger.error( message ); - return await this.approve( false ); + return await this.approve( { ...options, repeat: false } ); } throw error; } } - - async waitToDisappear() { - await this.waitForElementToBeHidden( '.jetpack-connect__logged-in-form-loading' ); - await this.waitForElementToBeHidden( '.jetpack-connect__authorize-form button' ); - } }