From dc77b3c73ec45b2a84a91cb0e44c1bd75da1f584 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Mon, 10 Apr 2017 10:47:10 +0300 Subject: [PATCH 1/2] Added support 'unsetIgnore' --- .../Core/Utils/Database/Schema/Converter.php | 12 ++++++++++ application/Espo/Core/Utils/Util.php | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/application/Espo/Core/Utils/Database/Schema/Converter.php b/application/Espo/Core/Utils/Database/Schema/Converter.php index 535fe6bdc9..a7f925c3b5 100644 --- a/application/Espo/Core/Utils/Database/Schema/Converter.php +++ b/application/Espo/Core/Utils/Database/Schema/Converter.php @@ -125,12 +125,24 @@ class Converter //check if exist files in "Tables" directory and merge with ormMetadata $ormMeta = Util::merge($ormMeta, $this->getCustomTables($ormMeta)); + if (isset($ormMeta['unsetIgnore'])) { + $protectedOrmMeta = array(); + foreach ($ormMeta['unsetIgnore'] as $protectedKey) { + $protectedOrmMeta = Util::merge( $protectedOrmMeta, Util::fillArrayKeys($protectedKey, Util::getValueByKey($ormMeta, $protectedKey)) ); + } + unset($ormMeta['unsetIgnore']); + } + //unset some keys in orm if (isset($ormMeta['unset'])) { $ormMeta = Util::unsetInArray($ormMeta, $ormMeta['unset']); unset($ormMeta['unset']); } //END: unset some keys in orm + if (isset($protectedOrmMeta)) { + $ormMeta = Util::merge($ormMeta, $protectedOrmMeta); + } + if (isset($entityList)) { $entityList = is_string($entityList) ? (array) $entityList : $entityList; diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.php index a227d521e8..76f8870d06 100644 --- a/application/Espo/Core/Utils/Util.php +++ b/application/Espo/Core/Utils/Util.php @@ -580,5 +580,27 @@ class Util return $diff; } + + /** + * Fill array with specified keys + * + * @param array|string $keys + * @param mixed $value + * + * @return array + */ + public static function fillArrayKeys($keys, $value) + { + $arrayKeys = is_array($keys) ? $keys : explode('.', $keys); + + $array = array(); + foreach (array_reverse($arrayKeys) as $i => $key) { + $array = array( + $key => ($i == 0) ? $value : $array, + ); + } + + return $array; + } } From 9b2324755b70d00f7b0f1598cee9b065f51dfbea Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Mon, 10 Apr 2017 10:55:42 +0300 Subject: [PATCH 2/2] Fixed wrong php path for Scheduled job in Windows --- application/Espo/Core/Utils/ScheduledJob.php | 3 ++- application/Espo/Core/Utils/System.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/Utils/ScheduledJob.php b/application/Espo/Core/Utils/ScheduledJob.php index 11b5149534..025e3e2a0c 100644 --- a/application/Espo/Core/Utils/ScheduledJob.php +++ b/application/Espo/Core/Utils/ScheduledJob.php @@ -55,7 +55,7 @@ class ScheduledJob protected $cronSetup = array( 'linux' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BIN-DIR} -f {CRON-FILE} > /dev/null 2>&1', - 'windows' => '{PHP-BIN-DIR}.exe -f {FULL-CRON-PATH}', + 'windows' => '{PHP-BINARY} -f {FULL-CRON-PATH}', 'mac' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BIN-DIR} -f {CRON-FILE} > /dev/null 2>&1', 'default' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BIN-DIR} -f {CRON-FILE} > /dev/null 2>&1', ); @@ -165,6 +165,7 @@ class ScheduledJob $data = array( 'PHP-BIN-DIR' => $this->getSystemUtil()->getPhpBin(), + 'PHP-BINARY' => $this->getSystemUtil()->getPhpBinary(), 'CRON-FILE' => $this->cronFile, 'DOCUMENT_ROOT' => $this->getSystemUtil()->getRootDir(), 'FULL-CRON-PATH' => Util::concatPath($this->getSystemUtil()->getRootDir(), $this->cronFile), diff --git a/application/Espo/Core/Utils/System.php b/application/Espo/Core/Utils/System.php index a9da2405ce..d5107ccdde 100644 --- a/application/Espo/Core/Utils/System.php +++ b/application/Espo/Core/Utils/System.php @@ -28,6 +28,7 @@ ************************************************************************/ namespace Espo\Core\Utils; + class System { /** @@ -105,7 +106,17 @@ class System */ public function getPhpBin() { - return (defined("PHP_BINDIR"))? PHP_BINDIR.DIRECTORY_SEPARATOR.'php' : 'php'; + return defined("PHP_BINDIR") ? PHP_BINDIR . DIRECTORY_SEPARATOR . 'php' : 'php'; + } + + /** + * Get PHP binary + * + * @return string + */ + public function getPhpBinary() + { + return defined("PHP_BINARY") ? PHP_BINARY : 'php'; } /**