Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Process] BC Break exported bash functions as environment variables #21704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hboomsma opened this issue Feb 21, 2017 · 4 comments
Closed

[Process] BC Break exported bash functions as environment variables #21704

hboomsma opened this issue Feb 21, 2017 · 4 comments

Comments

@hboomsma
Copy link

Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.2.x

This problem occurs after an upgrade to symfony 3.2.x if you use kriswallsmith/assetic and have exported bash functions in your current environment variables. In previous versions they were ignored by proc_open but in the 3.2 branch they are added using a self built environment string which tries to load these functions into sh which respectfully declines. This causes a bc break.

Results per symfony/process version when adding a bash function environment variable:

Installed 3.1.*
========================================
hello world

Installed 3.2.0
========================================
sh: 1: export: BASH_FUNC_foo%%: bad variable name

Installed *
========================================
sh: 1: export: BASH_FUNC_foo%%: bad variable name

Installed 3.2.x-dev
========================================
sh: 1: export: BASH_FUNC_foo%%: bad variable name

Installed dev-master
========================================
hello world

The script to check:

#!/usr/bin/env bash                                                                                                                                                                                                  
# Create and export bash function                                                                                                                                                                                    
foo() { echo 'bar'; }                                                                                                                                                                                                
export -f foo                                                                                                                                                                                                        
                                                                                                                                                                                                                     
# Load bash function foo and add it to a process                                                                                                                                                                     
# using a process builder, run it and show output.                                                                                                                                                                   
PHPCODE='                                                                                                                                                                                                            
require __DIR__ . "/vendor/autoload.php";                                                                                                                                                                            
                                                                                                                                                                                                                     
$foo = getenv("BASH_FUNC_foo%%");                                                                                                                                                                                    
$pb = new \Symfony\Component\Process\ProcessBuilder(["echo", "hello world"]);                                                                                                                                        
$pb->setEnv("BASH_FUNC_foo%%", $foo);                                                                                                                                                                                
$p = $pb->getProcess();                                                                                                                                                                                              
$p->run();                                                                                                                                                                                                           
                                                                                                                                                                                                                     
echo $p->getErrorOutput() . $p->getOutput() . PHP_EOL;                                                                                                                                                               
'                                                                                                                                                                                                                    
                                                                                                                                                                                                                     
# Try multiple versions of the symfony/process component                                                                                                                                                             
for VERSION in '3.1.*' '3.2.0' '*' '3.2.x-dev' 'dev-master'; do                                                                                                                                                      
    composer -q require symfony/process "$VERSION"                                                                                                                                                                   
    echo "Installed $VERSION"                                                                                                                                                                                        
    echo '=================='                                                                                                                                                                                        
    php -r "$PHPCODE"                                                                                                                                                                                                
done  
@fabpot
Copy link
Member

fabpot commented Feb 21, 2017

ping @nicolas-grekas

@nicolas-grekas
Copy link
Member

Fixed in #21776

fabpot added a commit that referenced this issue Feb 27, 2017
This PR was merged into the 3.2 branch.

Discussion
----------

[Process] Fix ignoring of bad env var names

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21704
| License       | MIT
| Doc PR        | -

Patch backported from master, which is free from the linked issue.

Commits
-------

406bb09 [Process] Fix ignoring of bad env var names
@fabpot fabpot closed this as completed Feb 27, 2017
@pjordaan
Copy link

pjordaan commented Mar 8, 2017

I run into this bug when upgrading. When will Symfony 3.2.5 be released

@xabbuh
Copy link
Member

xabbuh commented Mar 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants