Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public function resolve( DataReference $reference ) {
return $this->resolved_data_references[ $reference->id ];
}

// @TODO: Clean up the semantics of this class. Resolve() and separate resolve_uncached() seem confusing. There's.
// a bunch of implicit behaviors related to caching. Ideally we would either have a self-contained resolution.
// method, or co-locate the resolution logic with the data reference classes and only use this class for.
// @TODO: Clean up the semantics of this class. Resolve() and separate resolve_uncached() seem confusing. There's
// a bunch of implicit behaviors related to caching. Ideally we would either have a self-contained resolution
// method, or co-locate the resolution logic with the data reference classes and only use this class for
// caching.
public function resolve_uncached( DataReference $reference ) {
$progress_tracker = $this->sub_trackers[ $reference->id ] ?? new Tracker();
Expand Down Expand Up @@ -123,7 +123,7 @@ public function resolve_uncached( DataReference $reference ) {
$tracked_stream,
$filename
);
// TODO: Consider a clearer name. Some not-so-great ballpark ideas:.
// TODO: Consider a clearer name. Some not-so-great ballpark ideas:
// BlueprintParentPath, BlueprintRootPath, BlueprintContextPath, BlueprintRelativePath.
} elseif ( $reference instanceof ExecutionContextPath ) {
$path = $reference->get_path();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function consume_all(): string {

public function close_reading(): void {
$this->stream->close_reading();
// Optionally ensure tracker is set to 100% if not already.
// Optionally ensure tracker is set to 100% if not already
// This depends on whether closing implies completion.
// For now, we rely on consume_all or reaching end of data.
// If the stream is closed prematurely, the progress will reflect the last read amount.
Expand All @@ -102,7 +102,7 @@ private function updateProgress(): void {
}

$progress = ( $this->stream->tell() / $this->stream_length ) * 100;
// It's possible to seek() backwards. Let's make sure we never decrease.
// It's possible to seek() backwards. Let's make sure we never decrease
// the reported progress.
if ( $progress > $this->tracker->getProgress() ) {
$this->tracker->set( $progress );
Expand Down
10 changes: 5 additions & 5 deletions components/Blueprints/SiteResolver/class-newsiteresolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public static function resolve( Runtime $runtime, Tracker $progress, ?VersionCon
}

// 3. Install WordPress if not installed yet.
// Technically, this is a "new site" resolver, but it's entirely possible.
// the developer-provided WordPress zip already has a sqlite database with the.
// a WordPress site installed..
// Technically, this is a "new site" resolver, but it's entirely possible
// the developer-provided WordPress zip already has a sqlite database with
// a WordPress site installed.
if ( ! self::is_wordpress_installed( $runtime, $progress ) ) {
if ( ! $target_fs->exists( '/wp-config.php' ) ) {
if ( $target_fs->exists( 'wp-config-sample.php' ) ) {
Expand All @@ -128,7 +128,7 @@ public static function resolve( Runtime $runtime, Tracker $progress, ?VersionCon
'install',
'--path=' . $runtime->get_configuration()->get_target_site_root(),

// For Docker compatibility. If we got this far, Blueprint runner was already.
// For Docker compatibility. If we got this far, Blueprint runner was already
// allowed to run as root.
'--allow-root',
'--url=' . $runtime->get_configuration()->get_target_site_url(),
Expand Down Expand Up @@ -222,7 +222,7 @@ function ( $v ) {
preg_match( '/^\d+\.\d+$/', $version_string ) &&
$version_string === $api_version['partial_version']
) {
// When the Blueprint provides a version like 6.6, we must match on the partial.
// When the Blueprint provides a version like 6.6, we must match on the partial
// version, e.g. "6.6".
return $api_version['download'];
}
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/Steps/class-activatepluginstep.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Represents the 'activatePlugin' step.
*/
class ActivatePluginStep implements StepInterface {
// Inline PHP script to avoid reading a static script.php file via.
// Inline PHP script to avoid reading a static script.php file via
// file_get_contents() inside the built blueprints.phar file.
const ACTIVATE_PLUGIN_SCRIPT = <<<'PHP'
<?php
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/Steps/class-activatethemestep.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class ActivateThemeStep implements StepInterface {

// Inline PHP script to avoid reading a static script.php file via.
// Inline PHP script to avoid reading a static script.php file via
// file_get_contents() inside the built blueprints.phar file.
const ACTIVATE_THEME_SCRIPT = <<<'PHP'
<?php
Expand Down
4 changes: 2 additions & 2 deletions components/Blueprints/Steps/class-defineconstantsstep.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct( array $constants ) {
*/
public function run( Runtime $runtime, Tracker $tracker ) {
$tracker->setCaption( 'Defining wp-config constants' );
// Inline PHP script to avoid reading a static script.php file via.
// Inline PHP script to avoid reading a static script.php file via
// file_get_contents() inside the built blueprints.phar file.
$runtime->eval_php_code_in_subprocess(
<<<'PHP'
Expand Down Expand Up @@ -296,7 +296,7 @@ function rewrite_wp_config_to_define_constants( $content, $constants = array() )
continue;
}

// We now have a define() call that defines a constant we're looking for.
// We now have a define() call that defines a constant we're looking for
// Let's rewrite its value to the one
$output = array_merge(
$output,
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/Steps/class-importcontentstep.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function importWxr( Runtime $runtime, array $content_definition, Tracker
foreach ( $this->output_lines( $output ) as $line ) {
$data = @json_decode( $line, true );
if ( ! is_array( $data ) ) {
// Non-JSON output is treated as a crash. We use a dedicated file pipe.
// Non-JSON output is treated as a crash. We use a dedicated file pipe
// for communication and it should never contain a non-JSON line.
$import_process->stop();
throw new ProcessFailedException( $import_process );
Expand Down
4 changes: 2 additions & 2 deletions components/Blueprints/Steps/class-importmediastep.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ function ( $media ) {
if ( ! $resolved instanceof File ) {
// TODO: What if the schema specifies a resource type that can only be resolved to a file?
// Then the resolver could throw the error instead of requiring each step to check.
// But since the resolve interface can return either a File or Directory,.
// But since the resolve interface can return either a File or Directory,
// would we have to check anyway?
// Would there be any value in the runtime having specific methods like resolveFile().
// Would there be any value in the runtime having specific methods like resolveFile()
// and resolveDirectory() that throw if they cannot resolve the requested type?
throw new RuntimeException( "Failed to resolve media file: $human_readable_name" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct( ?string $theme_slug = null ) {

public function run( Runtime $runtime, Tracker $tracker ) {
$tracker->setCaption( 'Importing theme starter content' . ( $this->theme_slug ? ' for ' . $this->theme_slug : '' ) );
// Inline PHP script to avoid reading a static script.php file via.
// Inline PHP script to avoid reading a static script.php file via
// file_get_contents() inside the built blueprints.phar file.
$runtime->eval_php_code_in_subprocess(
<<<'PHP'
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/Steps/class-installthemestep.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function ( $temp_dir ) use ( $runtime, $tracker ) {

$tracker->set( 50 );

// Inline PHP script to avoid reading a static script.php file via.
// Inline PHP script to avoid reading a static script.php file via
// file_get_contents() inside the built blueprints.phar file.
$output = $runtime->eval_php_code_in_subprocess(
<<<'PHP'
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/Steps/class-wpclistep.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function run( Runtime $runtime, Tracker $tracker ) {
' ',
array(
$this->wp_cli_path ?? $runtime->get_wp_cli_path(),
// For Docker compatibility. If we got this far, the Blueprint runner was already.
// For Docker compatibility. If we got this far, the Blueprint runner was already
// allowed to run as root.
'--allow-root',
'--path=' . $runtime->get_configuration()->get_target_site_root(),
Expand Down
6 changes: 3 additions & 3 deletions components/Blueprints/Steps/scripts/import-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ function ( $processor ) {
$import_session = ImportSession::create(
array(
'data_source' => 'local_directory',
// @TODO: the phrase "file_name" doesn't make sense here. We're sourcing.
// data from a directory, not a file. This string is used to tell.
// the user in the UI what this they're importing in this import.
// @TODO: the phrase "file_name" doesn't make sense here. We're sourcing
// data from a directory, not a file. This string is used to tell
// the user in the UI what this they're importing in this import
// session. Let's rename it to something more descriptive.
'file_name' => $options['source'],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ private function validate_object( array $path, $data, array $schema ): ?Validati
$missing = array_diff( $schema['required'], array_keys( $arr ) );
if ( $missing ) {
foreach ( $missing as $m ) {
// For missing fields, the error pointer should be to the parent object,.
// For missing fields, the error pointer should be to the parent object,
// as the field itself doesn't exist yet to point to.
$children_errors[] = new ValidationError(
$this->convert_path_to_string( $path ), // Error is about the object at $path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public function upgrade( array $validated_v1_blueprint ): array {
}

// Unsupported fields.
// @TODO: Actually transpile a few of them:.
// @TODO: Actually transpile a few of them:
// * features -> runtimeOptions.playground.features.
// -> or consider moving this to runtime configuration – as in.
// -> or consider moving this to runtime configuration – as in
// permissions to access the network, disk, etc.
// * landingPage -> runtimeOptions.landingPage.
// * login -> runtimeOptions.login.
Expand Down Expand Up @@ -516,7 +516,7 @@ public function upgrade( array $validated_v1_blueprint ): array {
$v2steps[] = $v2step;
break;
case 'wp-cli':
// @TODO: Don't naively replace on the entire command. Actually parse it and only replace at the beginning.
// @TODO: Don't naively replace on the entire command. Actually parse it and only replace at the beginning
// of each argument value.
$cmd = str_replace( '/wordpress/', '', $v1step['command'] );
$cmd = str_replace( 'wordpress/', '', $cmd );
Expand Down Expand Up @@ -583,7 +583,7 @@ protected static function convert_v1_resource_to_v2_reference( $resource ) {
}
return $url;
case 'bundled':
// BundledReference – must start with.
// BundledReference – must start with
// ./ or /.
$path = $resource['path'];
if ( 0 !== strncmp( $path, './', strlen( './' ) ) && 0 !== strncmp( $path, '/', strlen( '/' ) ) ) {
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/bin/blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ function cliArgsToRunnerConfiguration( array $positional_args, array $options ):
mkdir( $target_site_root, 0755, true );
} elseif ( is_dir( $absolute_target_site_root ) ) {
$fs = LocalFilesystem::create( $absolute_target_site_root );
// Delete all the files and directories in the target site root, but preserve the.
// Delete all the files and directories in the target site root, but preserve the
// target directory itself. Why? In Playground CLI, `/wordpress` is likely to be a.
// mount removing a mount root throws an Exception.
foreach ( $fs->ls( '/' ) as $file ) {
Expand Down
38 changes: 19 additions & 19 deletions components/Blueprints/class-runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function run(): void {

try {
$progress = $this->main_tracker;
// Create all top-level progress stages upfront so the tracker knows what %.
// Create all top-level progress stages upfront so the tracker knows what %
// of the total work is being done with every progress update.
$progress->split(
array(
Expand All @@ -233,7 +233,7 @@ public function run(): void {
$this->load_blueprint();
$this->validate_blueprint();
$this->assets->set_execution_context( $this->blueprint_execution_context );
// Create the execution plan early on to surface any errors before.
// Create the execution plan early on to surface any errors before
// making the user wait for any downloads or site resolution.
$plan = $this->create_execution_plan();
$progress['blueprint']->finish();
Expand Down Expand Up @@ -308,8 +308,8 @@ private function load_blueprint() {
return;
}

// AbsoluteLocalPath is a necessary special case to correctly support.
// Windows absolute paths. There's so much more to them than C:\.
// AbsoluteLocalPath is a necessary special case to correctly support
// Windows absolute paths. There's so much more to them than C:\
//
// See https://www.fileside.app/blog/2023-03-17_windows-file-paths/.
if ( $reference instanceof AbsoluteLocalPath ) {
Expand All @@ -320,9 +320,9 @@ private function load_blueprint() {
$blueprint_string = $resolved->getStream()->consume_all();
$this->blueprint_execution_context = LocalFilesystem::create( dirname( $reference->get_path() ) );
} else {
// For the purposes of Blueprint resolution, the execution context is the.
// current working directory. This way, a path such as ./blueprint.json.
// will mean "a blueprint.json file in the current working directory" and not.
// For the purposes of Blueprint resolution, the execution context is the
// current working directory. This way, a path such as ./blueprint.json
// will mean "a blueprint.json file in the current working directory" and not
// "a ./blueprint.json path without a point of reference".
$this->assets->set_execution_context( LocalFilesystem::create( getcwd() ) );
$resolved = $this->assets->resolve( $reference );
Expand Down Expand Up @@ -353,13 +353,13 @@ private function load_blueprint() {
// JSON file.
$blueprint_string = $stream->consume_all();
if ( $reference instanceof URLReference ) {
// @TODO: Only display this if the Blueprint references any bundled files. And in that case,.
// @TODO: Only display this if the Blueprint references any bundled files. And in that case,
// make it a fatal error.
$this->configuration->get_logger()->warning( 'Blueprints loaded from remote URLs have no execution context.' );
$this->blueprint_execution_context = InMemoryFilesystem::create();
} elseif ( $reference instanceof ExecutionContextPath ) {
// It was resolved as an ExecutionContextPath, but it's actually a local.
// filesystem path at this point.
// It was resolved as an ExecutionContextPath, but it's actually a local
// filesystem path at this point
// The execution context is the directory containing the blueprint.json file.
$this->blueprint_execution_context = LocalFilesystem::create( dirname( $reference->get_path() ) );
} elseif ( $reference instanceof InlineFile ) {
Expand Down Expand Up @@ -498,9 +498,9 @@ private function validate_blueprint(): void {
throw new BlueprintExecutionException( 'Invalid WordPress version string in wordpressVersion.min: ' . $wp_version['min'] );
}
}
// Latest version is implicitly the default and it's only for resolving.
// the WordPress version to install. It's not used for version checks on.
// existing sites and VersionConstraint doesn't support it. It doesn't have.
// Latest version is implicitly the default and it's only for resolving
// the WordPress version to install. It's not used for version checks on
// existing sites and VersionConstraint doesn't support it. It doesn't have
// enough information anyway – the meaning of "latest" changes over time.
if ( isset( $wp_version['max'] ) && 'latest' !== $wp_version['max'] ) {
$this->recommended_wp_version = $wp_version['max'];
Expand All @@ -525,8 +525,8 @@ private function validate_blueprint(): void {
if ( ! empty( $wp_constraint_errors ) ) {
throw new BlueprintExecutionException( 'Invalid WordPress version constraint: ' . implode( '; ', $wp_constraint_errors ) );
}
// Note: In here's we're only checking if the version constraint is defined.
// correctly. The actual version check for WordPress is done in.
// Note: In here's we're only checking if the version constraint is defined
// correctly. The actual version check for WordPress is done in
// NewSiteResolver and ExistingSiteResolver.
}

Expand Down Expand Up @@ -686,11 +686,11 @@ private function create_execution_plan(): array {
}

foreach ( $plan as $step ) {
// @TODO: Make sure this doesn't get included twice in the execution plan,.
// @TODO: Make sure this doesn't get included twice in the execution plan,
// e.g. if the Blueprint specified this step manually.
if ( $step instanceof ImportContentStep ) {
// if($this->configuration->is_running_as_phar()) {.
// throw new InvalidArgumentException( '@TODO: Importing content is not supported when running as phar.' );.
// if($this->configuration->is_running_as_phar()) {
// throw new InvalidArgumentException( '@TODO: Importing content is not supported when running as phar.' );
// } else {.
$libraries_phar_path = __DIR__ . '/../../dist/php-toolkit.phar';
if ( ! file_exists( $libraries_phar_path ) ) {
Expand Down Expand Up @@ -1122,7 +1122,7 @@ private function execute_plan( Tracker $progress, array $steps, Runtime $runtime
// Determine if we should continue or stop execution.
$continue_on_error = $this->continue_on_error ?? false;
if ( ! $continue_on_error ) {
// @TODO: Correlate this message with the original Blueprint,.
// @TODO: Correlate this message with the original Blueprint,
// as in – was the step created because of "installPlugin" or not?
// Which entry of it? etc.
throw new BlueprintExecutionException(
Expand Down
2 changes: 1 addition & 1 deletion components/Blueprints/class-runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function ( $script_path ) use ( $code, $env, $input, $timeout ) {
// @TODO: Cleaning up the temporary directory is not done here.
$temp_dir = $this->create_temporary_directory();

// Still put the script in a temporary file as the path may be refering.
// Still put the script in a temporary file as the path may be refering
// to a file inside the currently executed .phar archive.
$actual_script_path = wp_join_unix_paths( $temp_dir, 'script.php' );
$code = '<?php function append_output( $output ) { file_put_contents( getenv("OUTPUT_FILE"), $output, FILE_APPEND ); } $_SERVER["HTTP_HOST"] = "localhost"; ?>';
Expand Down
2 changes: 1 addition & 1 deletion components/ByteStream/class-memorypipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct( ?string $bytes = null, $expected_length = null ) {
if ( null !== $bytes ) {
$this->buffer = $bytes;
$this->expected_length = strlen( $bytes );
// If we have a full buffer, it's already in memory and we don't need.
// If we have a full buffer, it's already in memory and we don't need
// to clean up old data as we stream it.
// If we did clean up old data, we would lose the ability to seek() to.
// the beginning of the buffer.
Expand Down
Loading
Loading