Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit ee9d8d1

Browse files
author
Jamie Snape
committed
Reduce number of calls to storage
1 parent 2bb293b commit ee9d8d1

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

core/controllers/components/ApihelperComponent.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ public function validateParams($args, $requiredList)
7171
*/
7272
public function getApiSetup()
7373
{
74-
$apiSetup = array();
75-
$apiSetup['testing'] = Zend_Registry::get('configGlobal')->environment == 'testing';
76-
$apiSetup['tmpDirectory'] = UtilityComponent::getTempDirectory();
77-
78-
return $apiSetup;
74+
return array();
7975
}
8076

8177
/**

core/controllers/components/ApisystemComponent.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public function uploadGeneratetoken($args)
435435
/** @var HttpuploadComponent $uploadComponent */
436436
$uploadComponent = MidasLoader::loadComponent('Httpupload');
437437
$apiSetup = $apihelperComponent->getApiSetup();
438-
$uploadComponent->setTestingMode($apiSetup['testing']);
438+
$uploadComponent->setTestingMode(Zend_Registry::get('configGlobal')->environment === 'testing');
439439

440440
return $uploadComponent->generateToken($args, $userDao->getKey().'/'.$item->getKey());
441441
}
@@ -513,12 +513,12 @@ public function uploadPerform($args)
513513
/** @var HttpuploadComponent $httpUploadComponent */
514514
$httpUploadComponent = MidasLoader::loadComponent('Httpupload');
515515
$apiSetup = $apihelperComponent->getApiSetup();
516-
$httpUploadComponent->setTestingMode($apiSetup['testing']);
516+
$httpUploadComponent->setTestingMode(Zend_Registry::get('configGlobal')->environment === 'testing');
517517

518518
if (array_key_exists('testingmode', $args)) {
519519
$httpUploadComponent->setTestingMode(true);
520520
if (!array_key_exists('localinput', $args)) {
521-
$args['localinput'] = $apiSetup['tmpDirectory'].'/'.$args['filename'];
521+
$args['localinput'] = UtilityComponent::getTempDirectory().'/'.$args['filename'];
522522
}
523523
}
524524

@@ -617,7 +617,7 @@ public function uploadGetoffset($args)
617617
/** @var ApihelperComponent $apihelperComponent */
618618
$apihelperComponent = MidasLoader::loadComponent('Apihelper');
619619
$apiSetup = $apihelperComponent->getApiSetup();
620-
$uploadComponent->setTestingMode($apiSetup['testing']);
620+
$uploadComponent->setTestingMode(Zend_Registry::get('configGlobal')->environment === 'testing');
621621

622622
return $uploadComponent->getOffset($args);
623623
}

core/controllers/components/HttpuploadComponent.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ public function generateToken($args, $dirname = '')
7676
if (!array_key_exists('filename', $args)) {
7777
throw new Exception('Parameter filename is not defined', MIDAS_HTTPUPLOAD_FILENAME_PARAM_UNDEFINED);
7878
}
79+
80+
$tempDirectory = UtilityComponent::getTempDirectory();
7981
$dir = $dirname === '' ? '' : '/'.$dirname;
80-
$dir = UtilityComponent::getTempDirectory().$dir;
82+
$dir = $tempDirectory.$dir;
8183

8284
if (!file_exists($dir)) {
8385
if (!mkdir($dir, 0777, true)) {
@@ -91,7 +93,7 @@ public function generateToken($args, $dirname = '')
9193
$uniqueIdentifier = $dirname.'/'.$uniqueIdentifier;
9294
}
9395

94-
$path = UtilityComponent::getTempDirectory().'/'.$uniqueIdentifier;
96+
$path = $tempDirectory.'/'.$uniqueIdentifier;
9597
if (file_exists($path)) {
9698
throw new Exception('Failed to generate upload token', MIDAS_HTTPUPLOAD_UPLOAD_TOKEN_GENERATION_FAILED);
9799
}

modules/api/controllers/IndexController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public function preDispatch()
4141
$this->apiEnable = true;
4242

4343
// define api parameters
44-
$this->apiSetup['testing'] = Zend_Registry::get('configGlobal')->environment == 'testing';
45-
$this->apiSetup['tmpDirectory'] = $this->getTempDirectory();
4644
$this->apiSetup['apiMethodPrefix'] = $this->Setting->getValueByName(API_METHOD_PREFIX_KEY, $this->moduleName);
4745

4846
$this->action = $actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();

0 commit comments

Comments
 (0)