Skip to content

Commit

Permalink
[#5086] Fix issues with Package Management when open_basedir is in ef…
Browse files Browse the repository at this point in the history
…fect
  • Loading branch information
Shaun McCormick committed Oct 13, 2011
1 parent 7cf4103 commit d22b2dd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/docs/changelog.txt
Expand Up @@ -2,6 +2,7 @@
This file shows the changes in recent releases of MODX. The most current release is usually the
development release, and is only shown to give an idea of what's currently in the pipeline.

- [#5086] Fix issues with Package Management when open_basedir is in effect
- [#4947] Adjust ensuring of admin access to context to only needed policies
- [#5078] Have default resource field context settings, such as default_template, respected in Quick create
- [#5909] Allow blank extensions in Add Content Type window
Expand Down
4 changes: 4 additions & 0 deletions core/model/modx/modx.class.php
Expand Up @@ -241,6 +241,10 @@ class modX extends xPDO {
* @var modMail $mail
*/
public $mail;
/**
* @var modRestClient $rest
*/
public $rest;
/**
* @var array An array of regex patterns regulary cleansed from content.
*/
Expand Down
17 changes: 17 additions & 0 deletions core/model/modx/processors/workspace/packages/rest/download.php
Expand Up @@ -2,6 +2,8 @@
/**
* Download a package by passing in its location
*
* @var modX $modx
*
* @package modx
* @subpackage processors.workspace.packages.rest
*/
Expand Down Expand Up @@ -29,6 +31,7 @@
$_package_cache = $modx->getOption('core_path').'packages/';

/* create transport package object */
/** @var modTransportPackage $package */
$package = $modx->newObject('transport.modTransportPackage');
$package->set('signature',$signature);
$package->set('state',1);
Expand All @@ -37,6 +40,7 @@
$package->set('provider',$scriptProperties['provider']);

/* get provider and metadata */
/** @var modTransportProvider $provider */
$provider = $modx->getObject('transport.modTransportProvider',$scriptProperties['provider']);
if (empty($provider)) return $modx->error->failure($modx->lexicon('provider_err_nf'));

Expand All @@ -45,6 +49,7 @@
if (!$loaded) return $modx->error->failure($modx->lexicon('provider_err_no_client'));

/* send request to provider and handle response */
/** @var modRestResponse $response */
$response = $provider->request('package','GET',array(
'signature' => $signature,
));
Expand Down Expand Up @@ -79,6 +84,18 @@
}
}

/* get file url */
if (!is_array($modx->version)) { $modx->getVersionData(); }
$productVersion = $modx->version['code_name'].'-'.$modx->version['full_version'];
$response = $modx->rest->request($location,'','GET',array(
'revolution_version' => $productVersion,
'getUrl' => true,
));
if (empty($response) || empty($response->response)) {
return $modx->error->failure($modx->lexicon('provider_err_connect',array('error' => $response->getError())));
}
$location = $response->response;

/* download package */
if (!$package->transferPackage($location,$_package_cache)) {
$msg = $modx->lexicon('package_download_err',array('location' => $location));
Expand Down
2 changes: 1 addition & 1 deletion core/model/modx/rest/modrestcurlclient.class.php
Expand Up @@ -65,7 +65,7 @@ public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),a
$q = http_build_query($params);
switch ($method) {
case 'GET':
$path .= '?'.$q;
$path .= (strpos($host,'?') === false ? '?' : '&').$q;
break;
case 'POST':
curl_setopt($ch,CURLOPT_POST,1);
Expand Down

1 comment on commit d22b2dd

@u007
Copy link

@u007 u007 commented on d22b2dd Oct 21, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would be nice if you have a patch for 2.1.3,
im facing the same issue ... regarding unable to download package

Please sign in to comment.