From 76041b06c78cf971a7ecf2853399525febb93821 Mon Sep 17 00:00:00 2001
From: Kevin Duret <kduret@centreon.com>
Date: Thu, 24 Aug 2017 14:38:24 +0200
Subject: [PATCH] fix(clapi): retrieve clapi export header

export header was deleted, but api did not work anymore

Refs: #5541
---
 www/class/centreon-clapi/centreonAPI.class.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php
index a1ee35e5ba..d6c6bc3413 100644
--- a/www/class/centreon-clapi/centreonAPI.class.php
+++ b/www/class/centreon-clapi/centreonAPI.class.php
@@ -689,7 +689,7 @@ class CentreonAPI
             while ($string = fgets($handle)) {
                 $i++;
                 $tab = preg_split('/;/', $string);
-                if (strlen(trim($string)) != 0) {
+                if (strlen(trim($string)) != 0 && !preg_match('/^\{OBJECT_TYPE\}/', $string)) {
                     $this->object = trim($tab[0]);
                     $this->action = trim($tab[1]);
                     $this->variables = trim(substr($string, strlen($tab[0] . ";" . $tab[1] . ";")));
@@ -819,6 +819,7 @@ class CentreonAPI
             exit($this->return_code);
         } else {
             // header
+            echo "{OBJECT_TYPE}{$this->delim}{COMMAND}{$this->delim}{PARAMETERS}\n";
             if (count($this->aExport) > 0) {
                 foreach ($this->aExport as $oObjet) {
                     if (method_exists($this->objectTable[$oObjet], 'export')) {
-- 
GitLab