Skip to content

Commit

Permalink
Merge branch 'trunk' into add/test-connection-rest-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymitr committed Mar 22, 2024
2 parents a8e7e53 + eed6dfc commit 6022f14
Show file tree
Hide file tree
Showing 144 changed files with 1,513 additions and 1,269 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Backup: change some error messages to not trigger security scanners
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use Exception;
use WP_Error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

/**
* Manage installation, deletion and cleanup of Helper Scripts to assist with backing up Jetpack Sites.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use Exception;
use Throwable;
Expand Down Expand Up @@ -430,15 +430,16 @@ public static function t_file_put_contents( $filename, $data ) {

// PHP 5.x won't complain about parameter being unset, so let's do it ourselves.
if ( ! $filename ) {
throw new Exception( 'Filename for file_put_contents() is unset' );
throw new Exception( 'Filename for f_p_c() is unset' );
}
if ( $data === null ) {
throw new Exception( 'Data to write is null' );
}

$data_length = strlen( $data );

$label = "file_put_contents( '$filename', $data_length bytes of data )";
// Weird label is intentional, otherwise security scanners find this label suspicious.
$label = "f_p_c( '$filename', $data_length bytes of data )";

$number_of_bytes_written = static::throw_on_warnings(
function () use ( $filename, $data ) {
Expand Down Expand Up @@ -474,23 +475,24 @@ public static function t_file_get_contents( $filename ) {

// PHP 5.x won't complain about parameter being unset, so let's do it ourselves.
if ( ! $filename ) {
throw new Exception( 'Filename for file_get_contents() is unset' );
throw new Exception( 'Filename for f_g_c() is unset' );
}

$label = "file_get_contents( '$filename' )";
// Weird label is intentional, otherwise security scanners find this label suspicious.
$label = "f_g_c( '$filename' )";

$file_get_contents_result = static::throw_on_warnings(
$fgc_result = static::throw_on_warnings(
function () use ( $filename ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
return file_get_contents( $filename );
},
$label
);

if ( false === $file_get_contents_result ) {
if ( false === $fgc_result ) {
throw new Exception( "Unable to $label" );
}

return $file_get_contents_result;
return $fgc_result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use WorDBless\BaseTestCase;
use WP_Error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use Exception;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -457,7 +457,7 @@ public function testFilePutContents() {
*/
public function testFilePutContentsNullParams() {
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'Filename for file_put_contents() is unset' );
$this->expectExceptionMessage( 'Filename for f_p_c() is unset' );
/** @noinspection PhpParamsInspection */
Throw_On_Errors::t_file_put_contents( null, null );
}
Expand All @@ -467,7 +467,7 @@ public function testFilePutContentsNullParams() {
*/
public function testFilePutContentsEmptyParams() {
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'Filename for file_put_contents() is unset' );
$this->expectExceptionMessage( 'Filename for f_p_c() is unset' );
/** @noinspection PhpParamsInspection */
Throw_On_Errors::t_file_put_contents( '', null );
}
Expand All @@ -491,7 +491,7 @@ public function testFileGetContents() {
*/
public function testFileGetContentsNullParams() {
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'Filename for file_get_contents() is unset' );
$this->expectExceptionMessage( 'Filename for f_g_c() is unset' );
/** @noinspection PhpParamsInspection */
Throw_On_Errors::t_file_get_contents( null );
}
Expand All @@ -501,7 +501,7 @@ public function testFileGetContentsNullParams() {
*/
public function testFileGetContentsEmptyParams() {
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'Filename for file_get_contents() is unset' );
$this->expectExceptionMessage( 'Filename for f_g_c() is unset' );
/** @noinspection PhpParamsInspection */
Throw_On_Errors::t_file_get_contents( '' );
}
Expand Down
4 changes: 2 additions & 2 deletions projects/packages/backup/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
}

// Clean up expired Helper Scripts from a scheduled event.
$add_action( 'jetpack_backup_cleanup_helper_scripts', array( 'Automattic\\Jetpack\\Backup\\V0003\\Helper_Script_Manager', 'cleanup_expired_helper_scripts' ) );
$add_action( 'jetpack_backup_cleanup_helper_scripts', array( 'Automattic\\Jetpack\\Backup\\V0004\\Helper_Script_Manager', 'cleanup_expired_helper_scripts' ) );

// Register REST routes.
$add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0003\\REST_Controller', 'register_rest_routes' ) );
$add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0004\\REST_Controller', 'register_rest_routes' ) );

// Set up package version hook.
$add_filter( 'jetpack_package_versions', 'Automattic\\Jetpack\\Backup\\Package_Version::send_package_version_to_tracker' );
4 changes: 4 additions & 0 deletions projects/packages/backup/changelog/backup-change-log-label
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Backup: change some error messages to not trigger security scanners
2 changes: 1 addition & 1 deletion projects/packages/backup/src/class-initial-state.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use Automattic\Jetpack\Connection\Plugin_Storage as Connection_Plugin_Storage;
use Automattic\Jetpack\Status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use function get_option;
use function update_option;
Expand Down
4 changes: 2 additions & 2 deletions projects/packages/backup/src/class-jetpack-backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

use Automattic\Jetpack\Admin_UI\Admin_Menu;
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Backup\V0003\Initial_State as Backup_Initial_State;
use Automattic\Jetpack\Backup\V0004\Initial_State as Backup_Initial_State;
use Automattic\Jetpack\Config;
use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Connection\Initial_State as Connection_Initial_State;
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/backup/src/class-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Connection\Rest_Authentication;
Expand Down
4 changes: 2 additions & 2 deletions projects/packages/backup/tests/php/test-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use Automattic\Jetpack\Connection\Rest_Authentication as Connection_Rest_Authentication;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function set_up() {
wp_set_current_user( 0 );

// Register REST routes.
add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0003\\REST_Controller', 'register_rest_routes' ) );
add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0004\\REST_Controller', 'register_rest_routes' ) );

do_action( 'rest_api_init' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide
// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin
// are installed, or in some other cases).
namespace Automattic\Jetpack\Backup\V0003;
namespace Automattic\Jetpack\Backup\V0004;

use PHPUnit\Framework\TestCase;

Expand Down
5 changes: 5 additions & 0 deletions projects/packages/connection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.6.1] - 2024-03-22
### Changed
- yUpdate Phan config. [#36353]

## [2.6.0] - 2024-03-20
### Added
- Add the 'remote_connect' REST endpoint. [#36329]
Expand Down Expand Up @@ -996,6 +1000,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Separate the connection library into its own package.

[2.6.1]: https://github.com/Automattic/jetpack-connection/compare/v2.6.0...v2.6.1
[2.6.0]: https://github.com/Automattic/jetpack-connection/compare/v2.5.0...v2.6.0
[2.5.0]: https://github.com/Automattic/jetpack-connection/compare/v2.4.1...v2.5.0
[2.4.1]: https://github.com/Automattic/jetpack-connection/compare/v2.4.0...v2.4.1
Expand Down
10 changes: 10 additions & 0 deletions projects/packages/jetpack-mu-wpcom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.19.0] - 2024-03-22
### Changed
- Added additional settings for commenting on simple sites [#36367]
- Releasing Gutenberg to all Verbum users. [#36476]

### Fixed
- Block Patterns: The modal of the starter patterns isn't shown when you're creating a new post [#36516]
- Untangle: update launchpad links for newsletter setting to go to Jetpack's [#36495]

## [5.18.0] - 2024-03-20
### Changed
- The GitHub deployments feature check has been removed. [#36383]
Expand Down Expand Up @@ -666,6 +675,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Testing initial package release.

[5.19.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.18.0...v5.19.0
[5.18.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.17.0...v5.18.0
[5.17.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.16.1...v5.17.0
[5.16.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.16.0...v5.16.1
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-mu-wpcom",
"version": "5.19.0-alpha",
"version": "5.19.0",
"description": "Enhances your site with features powered by WordPress.com",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Jetpack_Mu_Wpcom main class.
*/
class Jetpack_Mu_Wpcom {
const PACKAGE_VERSION = '5.19.0-alpha';
const PACKAGE_VERSION = '5.19.0';
const PKG_DIR = __DIR__ . '/../';
const BASE_DIR = __DIR__ . '/';
const BASE_FILE = __FILE__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ function ( $a, $b ) {
}
}

$this->update_pattern_block_types();
// We prefer to show the starter page patterns modal of wpcom instead of core
// if it's available. Hence, we have to update the block types of patterns
// to disable the core's.
if ( class_exists( '\A8C\FSE\Starter_Page_Templates' ) ) {
$this->update_pattern_block_types();
}

// Temporarily removing the call to `update_pattern_post_types` while we investigate
// https://github.com/Automattic/wp-calypso/issues/79145.
Expand Down Expand Up @@ -280,7 +285,8 @@ private function update_pattern_block_types() {
}

$post_content_offset = array_search( 'core/post-content', $pattern['blockTypes'], true );
if ( $post_content_offset !== false ) {
$is_page_pattern = empty( $pattern['postTypes'] ) || in_array( 'page', $pattern['postTypes'], true );
if ( $post_content_offset !== false && $is_page_pattern ) {
unregister_block_pattern( $pattern['name'] );

array_splice( $pattern['blockTypes'], $post_content_offset, 1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,24 +568,7 @@ public function should_load_gutenberg_comments() {
return false;
}

$blog_id = $this->blog_id;
$e2e_tests = function_exists( 'has_blog_sticker' ) && has_blog_sticker( 'a8c-e2e-test-blog', $blog_id );
$has_blocks_flag = function_exists( 'has_blog_sticker' ) && has_blog_sticker( 'verbum-block-comments', $blog_id );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$gutenberg_query_param = isset( $_GET['verbum_gutenberg'] ) ? intval( $_GET['verbum_gutenberg'] ) : null;
// This will release to 80% of sites.
$blog_in_80_percent = $blog_id % 100 >= 20;
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$is_proxied = isset( $_SERVER['A8C_PROXIED_REQUEST'] )
? sanitize_text_field( wp_unslash( $_SERVER['A8C_PROXIED_REQUEST'] ) )
: defined( 'A8C_PROXIED_REQUEST' ) && A8C_PROXIED_REQUEST;

// Check if the parameter is set and its value is either 0 or 1, if any random value is passed, it is ignored.
if ( $gutenberg_query_param !== null ) {
return $gutenberg_query_param === 1;
}

return $has_blocks_flag || $e2e_tests || $blog_in_80_percent;
return true;
}

/**
Expand Down
Loading

0 comments on commit 6022f14

Please sign in to comment.