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
2 changes: 1 addition & 1 deletion inc/Workspace/WorkspaceCoreUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private function build_primary_freshness_report( string $repo_path, string $hand
);
}

return $this->build_primary_freshness_report_from_status_output((string) ( $status_result['output'] ?? '' ), $handle);
return $this->build_primary_freshness_report_from_status_output(( string ) ( $status_result['output'] ?? '' ), $handle);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions inc/Workspace/WorkspaceRepositoryLifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,10 @@ public function show_repo( string $handle ): array|\WP_Error {
if ( empty($inspection['exists']) && null === $context_policy ) {
$resolved_handle = $this->resolve_primary_repo_name($handle);
if ( ! is_wp_error($resolved_handle) && $resolved_handle !== $handle ) {
$handle = $resolved_handle;
$parsed = $this->parse_handle($handle);
$repo_path = $this->workspace_path . '/' . $parsed['dir_name'];
$inspection = WorkspaceTargetInspector::inspect($repo_path, $parsed['dir_name']);
$handle = $resolved_handle;
$parsed = $this->parse_handle($handle);
$repo_path = $this->workspace_path . '/' . $parsed['dir_name'];
$inspection = WorkspaceTargetInspector::inspect($repo_path, $parsed['dir_name']);
if ( is_wp_error($inspection) ) {
return $inspection;
}
Expand All @@ -780,7 +780,7 @@ public function show_repo( string $handle ): array|\WP_Error {
'commit' => $inspection['commit'] ?? null,
'dirty' => (int) ( $inspection['dirty'] ?? 0 ),
'primary_freshness' => ! $parsed['is_worktree'] && is_string($inspection['branch_status'] ?? null)
? $this->build_primary_freshness_report_from_status_output((string) $inspection['branch_status'], $parsed['dir_name'])
? $this->build_primary_freshness_report_from_status_output(( string ) $inspection['branch_status'], $parsed['dir_name'])
: null,
);
if ( null !== $context_policy ) {
Expand Down
4 changes: 2 additions & 2 deletions inc/Workspace/WorkspaceTargetInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function inspect( string $path, string $handle ): array|\WP_Error
$result = ProcessRunner::run(
$command,
array(
'timeout_seconds' => $timeout,
'timeout_seconds' => $timeout,
'separate_streams' => true,
'output_cap_bytes' => 32768,
'error_code' => 'workspace_target_lookup_failed',
Expand Down Expand Up @@ -81,7 +81,7 @@ public static function inspect( string $path, string $handle ): array|\WP_Error
);
}

$decoded = json_decode((string) ( $result['stdout'] ?? '' ), true);
$decoded = json_decode(( string ) ( $result['stdout'] ?? '' ), true);
if ( ! is_array($decoded) ) {
return new \WP_Error(
'workspace_target_lookup_invalid_response',
Expand Down
10 changes: 5 additions & 5 deletions inc/Workspace/workspace-target-probe.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
exit(2);
}

$path = (string) $argv[1];
$workspace_path = (string) $argv[1];
$filesystem_probe = (string) ( $argv[2] ?? '' );
$git_command = (string) ( $argv[3] ?? 'git' );

Expand All @@ -18,20 +18,20 @@
$output = array();
$exit = 0;
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec -- Injected read-only probe remains outer-deadline-controlled.
exec($filesystem_probe . ' ' . escapeshellarg($path), $output, $exit);
exec($filesystem_probe . ' ' . escapeshellarg($workspace_path), $output, $exit);
$exists = 0 === $exit && '1' === trim(implode("\n", $output));
} else {
$exists = is_dir($path);
$exists = is_dir($workspace_path);
}
if ( ! $exists ) {
fwrite(STDOUT, json_encode(array( 'exists' => false ), JSON_UNESCAPED_SLASHES));
exit(0);
}

/** @return string|null */
$git_probe = static function ( string $operation, string $args ) use ( $path, $git_command ): ?string {
$git_probe = static function ( string $operation, string $args ) use ( $workspace_path, $git_command ): ?string {
fwrite(STDERR, 'DMC_BOUNDARY:git:' . $operation . "\n");
$command = $git_command . ' --no-optional-locks -C ' . escapeshellarg($path) . ' ' . $args . ' 2>&1';
$command = $git_command . ' --no-optional-locks -C ' . escapeshellarg($workspace_path) . ' ' . $args . ' 2>&1';
$output = array();
$exit = 0;
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec -- Isolated, outer-deadline-controlled read-only probe.
Expand Down