Skip to content

Commit

Permalink
Merge pull request #421 from pantheon-systems/php_5.3_fix
Browse files Browse the repository at this point in the history
Fixed PHP 5.3 backward-compatibility
  • Loading branch information
TeslaDethray committed Aug 21, 2015
2 parents 2d5d765 + a1ab6cc commit 895beca
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#Change Log
All notable changes to this project starting with the 0.6.0 release will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org)

##[0.7.1] - 2015-08-21
###Fixed
- PHP 5.3 incompatibility

##[0.7.0] - 2015-08-20
### Added
- `site delete` command will delete a site (moved from `sites delete`, which has been deprecated) (#370)
Expand Down
29 changes: 14 additions & 15 deletions php/Terminus/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,32 @@ public function __construct()
* );
*
*/
private function lookup( $args )
{
private function lookup($args) {
// adjust the target if it's a public request
if ( isset($args['uuid']) AND 'public' === $args['uuid'] ) {
if (isset($args['uuid']) && ($args['uuid'] == 'public')) {
$this->target = 'public';
}

if ('login' == $args['realm']) {
if (isset($args['realm']) && ($args['realm'] == 'login')) {
$this->target = 'login';
}

$args['host'] = @$args['host'] ?: TERMINUS_HOST;
if (!isset($args['host']) || ($args['host'] == '')) {
$args['host'] = TERMINUS_HOST;
}

// a substiution array to pass to the vsprintf
$substitutions = array( $args['host'], $args['realm'] );
if( isset($args['uuid']) AND $args['uuid'] !== 'public' ) {
array_push( $substitutions, $args['uuid'] );
//A substiution array to pass to the vsprintf
$substitutions = array($args['host'], $args['realm']);
if (isset($args['uuid']) && $args['uuid'] != 'public') {
array_push($substitutions, $args['uuid']);
}

$url = vsprintf( $this->patterns[$this->target], $substitutions );
$url = vsprintf($this->patterns[$this->target], $substitutions);

// now we have our base url add the path
$params = '';
if (@$args['path']) {
$params .= '/' . @$args['path'];
//Now that we have our base url, we add the path
if (isset($args['path']) && $args['path']) {
$url .= '/' . $args['path'];
}
$url .= $params;

return $url;
}
Expand Down
10 changes: 6 additions & 4 deletions php/Terminus/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ public function connectionInfo() {

$info = array_merge($info, $git_params);

if (isset($this->bindings->getByType('dbserver')[0])) {
$db_binding = $this->bindings->getByType('dbserver')[0];
$dbserver_binding = $this->bindings->getByType('dbserver');
if (isset($dbserver_binding[0])) {
$db_binding = $dbserver_binding[0];

$mysql_username = 'pantheon';
$mysql_password = $db_binding->get('password');
Expand Down Expand Up @@ -266,8 +267,9 @@ public function connectionInfo() {
$info = array_merge($info, $mysql_params);
}

if (isset($this->bindings->getByType('cacheserver')[0])) {
$cache_binding = $this->bindings->getByType('cacheserver')[0];
$cacheserver_binding = $this->bindings->getByType('cacheserver');
if (isset($cacheserver_binding[0])) {
$cache_binding = $cacheserver_binding[0];

$redis_password = $cache_binding->get('password');
$redis_host = $mysql_host = sprintf(
Expand Down
19 changes: 13 additions & 6 deletions php/Terminus/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ public static function send($url, $method, $data = array()) {
// create a new Guzzle\Http\Client
$browser = new Browser;
$browser->setUserAgent(self::userAgent());
$options = array();
$options['allow_redirects'] = @$data['allow_redirects'] ?: false;
$options['json'] = @$data['json'] ?: false;
if( @$data['body'] ) {
$options = array(
'allow_redirects' => false,
'verify' => false,
'json' => false
);
if (isset($data['allow_redirects'])) {
$options['allow_redirects'] = $data['allow_redirects'];
}
if (isset($data['json'])) {
$options['json'] = $data['json'];
}
if (isset($data['body']) && $data['body']) {
$options['body'] = $data['body'];
if (\Terminus::get_config("debug")) {
if (\Terminus::get_config('debug')) {
\Terminus\Loggers\Regular::debug($data['body']);
}
}
$options['verify'] = false;

$request = $browser->createRequest($method, $url, null, null, $options );

Expand Down
8 changes: 4 additions & 4 deletions php/Terminus/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public function __construct($attributes) {
# deprecated properties
# this->information is deprecated, use $this->attributes
$this->information = $this->attributes;
// cosmetic reasons for this
$this->metadata = @$this->attributes->metadata ?: new \stdClass();
# /deprecated properties
$this->metadata = new \stdClass();
if (isset($this->attributes->metadata)) {
$this->metadata = $this->attributes->metadata;
}

$this->org_memberships = new SiteOrganizationMemberships(array('site' => $this));
$this->user_memberships = new SiteUserMemberships(array('site' => $this));
Expand Down Expand Up @@ -526,7 +527,6 @@ public function get($attribute) {
}

/**
<<<<<<< HEAD
* Returns tags from the site/org join
*
* @return [array] $tags Tags in string format
Expand Down
5 changes: 3 additions & 2 deletions php/Terminus/SitesCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ public function __construct() {
private function find($name, $options = array()) {
$defaults = array('rebuild' => true);
$options = array_merge($defaults, $options);
$all = $this->all();

if (isset($this->all()[$name])) {
$site_data = $this->all()[$name];
if (isset($all[$name])) {
$site_data = $all[$name];
return $site_data;
} else {
if ($options['rebuild']) {
Expand Down
2 changes: 1 addition & 1 deletion php/terminus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//Can be used by plugins/themes to check if Terminus is running or not
define('Terminus', true);
define('TERMINUS_VERSION', '0.7.0');
define('TERMINUS_VERSION', '0.7.1');

$source = 'unknown';
if ((PHP_SAPI == 'cli') && isset($argv)) {
Expand Down

0 comments on commit 895beca

Please sign in to comment.