From 73bcc3bfe3489ef7d749cf59d228a5ed69cfc597 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Nov 2015 17:39:13 +0100 Subject: [PATCH] The temp dir for cache used by rester is correctly managed: No temp or data files must be stored outside of documents directory. --- htdocs/api/class/api.class.php | 11 +++++++++-- htdocs/core/modules/modApi.class.php | 4 ++-- htdocs/langs/en_US/admin.lang | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 33bbe56e0a1..d866b03460a 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -17,6 +17,7 @@ use Luracast\Restler\Restler; use Luracast\Restler\RestException; +use Luracast\Restler\Defaults; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -40,10 +41,16 @@ class DolibarrApi /** * Constructor * - * @param DoliDb $db Database handler + * @param DoliDb $db Database handler + * @param string $cachedir Cache dir */ - function __construct($db) { + function __construct($db, $cachedir='') + { global $conf; + + if (empty($cachedir)) $cachedir = $conf->api->dir_temp; + Defaults::$cacheDirectory = $cachedir; + $this->db = $db; $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); $this->r = new Restler($production_mode); diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index fae4de09032..8008590cce7 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -57,7 +57,7 @@ class modApi extends DolibarrModules // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "REST interface"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'development'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) @@ -72,7 +72,7 @@ class modApi extends DolibarrModules // Data directories to create when module is enabled. // Example: this->dirs = array("/api/temp"); - $this->dirs = array(); + $this->dirs = array('/api/temp'); // Config pages. Put here list of php page, stored into api/admin directory, to use to setup module. $this->config_page_url = array("index.php@api"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5dfcf89a0b6..0ee9aff707f 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1596,7 +1596,7 @@ EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint availa ApiSetup=API module setup ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscellaneous web services. KeyForApiAccess=Key to use API (parameter "api_key") -ApiProductionMode=Enable production mode +ApiProductionMode=Enable production mode (this will activate use of a caches for services management) ApiEndPointIs=You can access to the API at url ApiExporerIs=You can explore the API at url OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed