Skip to content

Commit a1ab6cc

Browse files
author
tesladethray
committed
Fixed PHP 5.3 backward compatibility
1 parent 2d5d765 commit a1ab6cc

File tree

7 files changed

+45
-32
lines changed

7 files changed

+45
-32
lines changed

CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#Change Log
22
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)
33

4+
##[0.7.1] - 2015-08-21
5+
###Fixed
6+
- PHP 5.3 incompatibility
7+
48
##[0.7.0] - 2015-08-20
59
### Added
610
- `site delete` command will delete a site (moved from `sites delete`, which has been deprecated) (#370)

php/Terminus/Endpoint.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,32 @@ public function __construct()
5050
* );
5151
*
5252
*/
53-
private function lookup( $args )
54-
{
53+
private function lookup($args) {
5554
// adjust the target if it's a public request
56-
if ( isset($args['uuid']) AND 'public' === $args['uuid'] ) {
55+
if (isset($args['uuid']) && ($args['uuid'] == 'public')) {
5756
$this->target = 'public';
5857
}
5958

60-
if ('login' == $args['realm']) {
59+
if (isset($args['realm']) && ($args['realm'] == 'login')) {
6160
$this->target = 'login';
6261
}
6362

64-
$args['host'] = @$args['host'] ?: TERMINUS_HOST;
63+
if (!isset($args['host']) || ($args['host'] == '')) {
64+
$args['host'] = TERMINUS_HOST;
65+
}
6566

66-
// a substiution array to pass to the vsprintf
67-
$substitutions = array( $args['host'], $args['realm'] );
68-
if( isset($args['uuid']) AND $args['uuid'] !== 'public' ) {
69-
array_push( $substitutions, $args['uuid'] );
67+
//A substiution array to pass to the vsprintf
68+
$substitutions = array($args['host'], $args['realm']);
69+
if (isset($args['uuid']) && $args['uuid'] != 'public') {
70+
array_push($substitutions, $args['uuid']);
7071
}
7172

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

74-
// now we have our base url add the path
75-
$params = '';
76-
if (@$args['path']) {
77-
$params .= '/' . @$args['path'];
75+
//Now that we have our base url, we add the path
76+
if (isset($args['path']) && $args['path']) {
77+
$url .= '/' . $args['path'];
7878
}
79-
$url .= $params;
8079

8180
return $url;
8281
}

php/Terminus/Environment.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ public function connectionInfo() {
225225

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

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

231232
$mysql_username = 'pantheon';
232233
$mysql_password = $db_binding->get('password');
@@ -266,8 +267,9 @@ public function connectionInfo() {
266267
$info = array_merge($info, $mysql_params);
267268
}
268269

269-
if (isset($this->bindings->getByType('cacheserver')[0])) {
270-
$cache_binding = $this->bindings->getByType('cacheserver')[0];
270+
$cacheserver_binding = $this->bindings->getByType('cacheserver');
271+
if (isset($cacheserver_binding[0])) {
272+
$cache_binding = $cacheserver_binding[0];
271273

272274
$redis_password = $cache_binding->get('password');
273275
$redis_host = $mysql_host = sprintf(

php/Terminus/Request.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,23 @@ public static function send($url, $method, $data = array()) {
2323
// create a new Guzzle\Http\Client
2424
$browser = new Browser;
2525
$browser->setUserAgent(self::userAgent());
26-
$options = array();
27-
$options['allow_redirects'] = @$data['allow_redirects'] ?: false;
28-
$options['json'] = @$data['json'] ?: false;
29-
if( @$data['body'] ) {
26+
$options = array(
27+
'allow_redirects' => false,
28+
'verify' => false,
29+
'json' => false
30+
);
31+
if (isset($data['allow_redirects'])) {
32+
$options['allow_redirects'] = $data['allow_redirects'];
33+
}
34+
if (isset($data['json'])) {
35+
$options['json'] = $data['json'];
36+
}
37+
if (isset($data['body']) && $data['body']) {
3038
$options['body'] = $data['body'];
31-
if (\Terminus::get_config("debug")) {
39+
if (\Terminus::get_config('debug')) {
3240
\Terminus\Loggers\Regular::debug($data['body']);
3341
}
3442
}
35-
$options['verify'] = false;
3643

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

php/Terminus/Site.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ public function __construct($attributes) {
5151
# deprecated properties
5252
# this->information is deprecated, use $this->attributes
5353
$this->information = $this->attributes;
54-
// cosmetic reasons for this
55-
$this->metadata = @$this->attributes->metadata ?: new \stdClass();
56-
# /deprecated properties
54+
$this->metadata = new \stdClass();
55+
if (isset($this->attributes->metadata)) {
56+
$this->metadata = $this->attributes->metadata;
57+
}
5758

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

528529
/**
529-
<<<<<<< HEAD
530530
* Returns tags from the site/org join
531531
*
532532
* @return [array] $tags Tags in string format

php/Terminus/SitesCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ public function __construct() {
4040
private function find($name, $options = array()) {
4141
$defaults = array('rebuild' => true);
4242
$options = array_merge($defaults, $options);
43+
$all = $this->all();
4344

44-
if (isset($this->all()[$name])) {
45-
$site_data = $this->all()[$name];
45+
if (isset($all[$name])) {
46+
$site_data = $all[$name];
4647
return $site_data;
4748
} else {
4849
if ($options['rebuild']) {

php/terminus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
$source = 'unknown';
88
if ((PHP_SAPI == 'cli') && isset($argv)) {

0 commit comments

Comments
 (0)