Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1358183 - environment variables does not pass to PHP
Summary: environment variables does not pass to PHP
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Timothy Williams
QA Contact: Wang Haoran
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-20 09:17 UTC by v.samadi@gmail.com
Modified: 2017-05-31 18:22 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-31 18:22:11 UTC


Attachments (Terms of Use)

Description v.samadi@gmail.com 2016-07-20 09:17:36 UTC
Problem:
DB Related envinroment does not pass to php application such as `OPENSHIFT_MYSQL_DB_HOST` or `OPENSHIFT_MYSQL_DB_USERNAME`.

App Components:
PHP 5.4, MySQL 5.5, phpMyAdmin 4.0



I've tried my php code on two scenarios:
1- create 'PHP 5.4' app then add 'MySQL 5.5' and then 'phpMyAdmin 4.0'
2- create app with all components at once 'PHP 5.4, MySQL 5.5, phpMyAdmin 4.0'

In both scenarios phpMyAdmin can connect to db normally. Then I tried below php code in both of them:

<?php
$dbhost = getenv('OPENSHIFT_MYSQL_DB_HOST'); // Host name 
$dbport = getenv('OPENSHIFT_MYSQL_DB_PORT'); // Host port
$dbusername = getenv('OPENSHIFT_MYSQL_DB_USERNAME'); // Mysql username 
$dbpassword = getenv('OPENSHIFT_MYSQL_DB_PASSWORD'); // Mysql password 
$db_name = getenv('OPENSHIFT_GEAR_NAME'); // Database name 
$mysqlCon = mysqli_connect($dbhost, $dbusername, $dbpassword, $db_name, $dbport) or die("Error: " . mysqli_error($mysqlCon));
mysqli_select_db($mysqlCon, $db_name) or die("Error: " . mysqli_error($mysqlCon));

echo 'Connected :)';


Expected results:
In both cases application should connect to db.
However in first scenario, php code could not access dataabse related environment variables like OPENSHIFT_MYSQL_DB_HOST or OPENSHIFT_MYSQL_DB_PORT and getenv returns null. but in second case code goes fines and connect to db.

Additional info:
1- other variables like `OPENSHIFT_APP_NAME` pass normally.
2- `env` command in SSH list all variables (include db ones)
3- `rhc env-list appname` does not list anything.
4- more details in http://stackoverflow.com/questions/38475568/openshift-databases-environment-variables-are-not-set-in-php

Comment 1 Michal Fojtik 2016-07-20 09:21:10 UTC
I think this is a v2 bug?

Comment 2 v.samadi@gmail.com 2016-07-20 10:29:57 UTC
This happend to current version of openshift. I just created these apps today.

Comment 3 Ben Parees 2016-07-20 13:05:20 UTC
rhc is v2, definitely. I assume you are using the v2 openshift online environment.

moving to "image" since we don't have a cartridge component anymore.

Comment 4 Eric Paris 2017-05-31 18:22:11 UTC
We apologize, however, we do not plan to address this report at this time. The majority of our active development is for the v3 version of OpenShift. If you would like for Red Hat to reconsider this decision, please reach out to your support representative. We are very sorry for any inconvenience this may cause.


Note You need to log in before you can comment on or make changes to this bug.