Skip to content

Fix internal variable bleeding in REPL eval context#80

Merged
swissspidy merged 6 commits intomainfrom
copilot/fix-internal-variables-conflict
Feb 23, 2026
Merged

Fix internal variable bleeding in REPL eval context#80
swissspidy merged 6 commits intomainfrom
copilot/fix-internal-variables-conflict

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

  • Understand the issue: $line variable bleeds from eval context
  • Explore repository structure and identify affected file
  • Rename internal variables in start() method to avoid conflicts ($line$__repl_input_line, $out$__repl_output, $evl$__repl_eval_result)
  • Keep $line in prompt() method as it's local and doesn't bleed
  • Add tests to validate the fix for all renamed variables
  • Run linting and static analysis - all passed
  • Address code review feedback
  • All changes complete and verified
Original prompt

This section details on the original issue you should resolve

<issue_title>Internal variables bleed over and cause conflicts</issue_title>
<issue_description>I haven't had the chance to dig into this further, but just wanted to log this somewhere to prevent forgetting about it.

Assigning a value to $line in wp shell gives very unexpected results, causing some pretty confusing behavior and bugs.

Behavior:

wp shell

wp> $line = 'this wont work';
=> string(14) 'this wont work'
wp> $line;
=> string(13) "return $line;"

wp> $linetest = 'this will';
=> string(9) "this will"
wp> $linetest;
=> string(9) "this will"
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@schlessera</author><body>
`$line` is one of the variables that bleed over from the context that evaluates the code that was typed in.

While I don't think we can provide a completely clean context with `eval()`, we can certainly make sure we're not using something that is as easy to run into conflicts with than `$line`.</body></comment_new>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/WP_CLI/Shell/REPL.php 87.50% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI and others added 2 commits January 25, 2026 17:04
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix internal variables bleed over issue in wp shell Fix internal variable bleeding in REPL eval context Jan 25, 2026
Copilot AI requested a review from swissspidy January 25, 2026 17:05
@swissspidy swissspidy requested a review from Copilot January 25, 2026 17:13

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review January 25, 2026 17:20
@swissspidy swissspidy requested a review from a team as a code owner January 25, 2026 17:20
@swissspidy
Copy link
Member

/gemini review

@swissspidy swissspidy added this to the 2.0.17 milestone Feb 22, 2026
gemini-code-assist[bot]

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy merged commit 6366639 into main Feb 23, 2026
59 of 60 checks passed
@swissspidy swissspidy deleted the copilot/fix-internal-variables-conflict branch February 23, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:shell Related to 'shell' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal variables bleed over and cause conflicts

3 participants