From 0b0857ed58507c443278baee1bddf4ba9746057c Mon Sep 17 00:00:00 2001 From: Prasad <prasad@vtiger.com> Date: Sun, 12 Sep 2021 23:58:51 +0530 Subject: [PATCH] Install Fixes for PHP 8 Support --- include/Webservices/DataTransform.php | 22 ++++++------- include/database/PearDatabase.php | 20 +++++++----- include/utils/VtlibUtils.php | 10 ++++++ includes/runtime/BaseModel.php | 2 +- includes/runtime/Controller.php | 12 ++++++- libraries/antlr/AntlrLexer.php | 8 ++--- libraries/antlr/AntlrParser.php | 4 +-- .../library/HTMLPurifier/Encoder.php | 2 +- .../HTMLPurifier/TagTransform/Font.php | 2 +- modules/CustomView/CustomView.php | 32 +++++++++++-------- modules/Install/models/ConfigFileUtils.php | 2 +- modules/Install/views/Index.php | 3 ++ 12 files changed, 75 insertions(+), 44 deletions(-) diff --git a/include/Webservices/DataTransform.php b/include/Webservices/DataTransform.php index 832c69b9c..def1ca11b 100644 --- a/include/Webservices/DataTransform.php +++ b/include/Webservices/DataTransform.php @@ -14,7 +14,7 @@ public static $recordModuleString = 'record_module'; public static $recordSource = 'WEBSERVICE'; - function sanitizeDataWithColumn($row,$meta){ + static function sanitizeDataWithColumn($row,$meta){ $newRow = array(); if(isset($row['count(*)'])){ @@ -30,7 +30,7 @@ return $newRow; } - function sanitizeDataWithCountColumn($row,$meta){ + static function sanitizeDataWithCountColumn($row,$meta){ $newRow = array(); foreach($row as $col=>$val){ $newRow['count'] = $val; @@ -38,7 +38,7 @@ return $newRow; } - function filterAndSanitize($row,$meta){ + static function filterAndSanitize($row,$meta){ $recordLabel = $row['label']; $row = DataTransform::filterAllColumns($row,$meta); $row = DataTransform::sanitizeData($row,$meta); @@ -48,7 +48,7 @@ return $row; } - function sanitizeData($newRow,$meta,$t=null){ + static function sanitizeData($newRow,$meta,$t=null){ $newRow = DataTransform::sanitizeReferences($newRow,$meta); $newRow = DataTransform::sanitizeOwnerFields($newRow,$meta,$t); @@ -57,7 +57,7 @@ return $newRow; } - function sanitizeForInsert($row,$meta){ + static function sanitizeForInsert($row,$meta){ global $adb; $associatedToUser = false; $parentTypeId = null; @@ -149,7 +149,7 @@ } - function filterAllColumns($row,$meta){ + static function filterAllColumns($row,$meta){ $recordString = DataTransform::$recordString; @@ -165,7 +165,7 @@ } - function sanitizeFields($row,$meta){ + static function sanitizeFields($row,$meta){ $default_charset = VTWS_PreserveGlobal::getGlobal('default_charset'); $recordString = DataTransform::$recordString; @@ -203,7 +203,7 @@ return $row; } - function sanitizeReferences($row,$meta){ + static function sanitizeReferences($row,$meta){ global $adb,$log; $references = $meta->getReferenceFieldDetails(); foreach($references as $field=>$typeList){ @@ -242,7 +242,7 @@ return $row; } - function sanitizeOwnerFields($row,$meta,$t=null){ + static function sanitizeOwnerFields($row,$meta,$t=null){ global $adb; $ownerFields = $meta->getOwnerFields(); foreach($ownerFields as $index=>$field){ @@ -288,7 +288,7 @@ return $row; } - function sanitizeDateFieldsForInsert($row,$meta){ + static function sanitizeDateFieldsForInsert($row,$meta){ global $current_user; $moduleFields = $meta->getModuleFields(); foreach($moduleFields as $fieldName=>$fieldObj){ @@ -302,7 +302,7 @@ return $row; } - function sanitizeCurrencyFieldsForInsert($row,$meta){ + static function sanitizeCurrencyFieldsForInsert($row,$meta){ global $current_user; $moduleFields = $meta->getModuleFields(); foreach($moduleFields as $fieldName=>$fieldObj){ diff --git a/include/database/PearDatabase.php b/include/database/PearDatabase.php index ee026a4ee..d91b073cb 100644 --- a/include/database/PearDatabase.php +++ b/include/database/PearDatabase.php @@ -525,7 +525,7 @@ class PearDatabase{ /* ADODB newly added. replacement for mysql_fetch_array() */ function fetch_array(&$result) { - if($result->EOF) { + if(!$result || $result->EOF) { //$this->println("ADODB fetch_array return null"); return NULL; } @@ -548,15 +548,15 @@ class PearDatabase{ function sql_quote($data) { if (is_array($data)) { - switch($data{'type'}) { + switch($data['type']) { case 'text': case 'numeric': case 'integer': case 'oid': - return $this->quote($data{'value'}); + return $this->quote($data['value']); break; case 'timestamp': - return $this->formatDate($data{'value'}); + return $this->formatDate($data['value']); break; default: throw new Exception("unhandled type: ".serialize($cur)); @@ -611,7 +611,7 @@ class PearDatabase{ function run_query_field($query,$field='') { $rowdata = $this->run_query_record($query); if(isset($field) && $field != '') - return $rowdata{$field}; + return $rowdata[$field]; else return array_shift($rowdata); } @@ -619,7 +619,7 @@ class PearDatabase{ function run_query_list($query,$field){ $records = $this->run_query_allrecords($query); foreach($records as $walk => $cur) - $list[] = $cur{$field}; + $list[] = $cur[$field]; } function run_query_field_html($query,$field){ @@ -652,7 +652,7 @@ class PearDatabase{ throw new Exception("empty arrays not allowed"); foreach($a as $walk => $cur) - $l .= ($l?',':'').$this->quote($cur{$field}); + $l .= ($l?',':'').$this->quote($cur[$field]); return ' ( '.$l.' ) '; } @@ -858,7 +858,11 @@ class PearDatabase{ function resetSettings($dbtype,$host,$dbname,$username,$passwd){ global $dbconfig, $dbconfigoption; - if($host == '') { + if (!$host && !$dbconfig) { + return; + } + + if($host == '' && $dbconfig) { $this->disconnect(); $this->setDatabaseType($dbconfig['db_type']); $this->setUserName($dbconfig['db_username']); diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php index 12b068873..3534aced3 100644 --- a/include/utils/VtlibUtils.php +++ b/include/utils/VtlibUtils.php @@ -883,4 +883,14 @@ function php7_compat_ereg($pattern, $str, $ignore_case=false) { if (!function_exists('ereg')) { function ereg($pattern, $str) { return php7_compat_ereg($pattern, $str); } } if (!function_exists('eregi')) { function eregi($pattern, $str) { return php7_compat_ereg($pattern, $str, true); } } + +/** + * PHP8 support + */ +if (!function_exists('get_magic_quotes_gpc')) { + function get_magic_quotes_gpc() { + return false; + } +} + ?> \ No newline at end of file diff --git a/includes/runtime/BaseModel.php b/includes/runtime/BaseModel.php index 2da7c6594..8493b73d9 100644 --- a/includes/runtime/BaseModel.php +++ b/includes/runtime/BaseModel.php @@ -28,7 +28,7 @@ class Vtiger_Base_Model { * @return Value for the given key */ public function get($key){ - return $this->valueMap[$key]; + return isset($this->valueMap[$key]) ? $this->valueMap[$key] : null; } /** diff --git a/includes/runtime/Controller.php b/includes/runtime/Controller.php index 4d55354af..692ddf4dc 100644 --- a/includes/runtime/Controller.php +++ b/includes/runtime/Controller.php @@ -170,6 +170,8 @@ abstract class Vtiger_View_Controller extends Vtiger_Action_Controller { } function getPageTitle(Vtiger_Request $request) { + $recordName = null; + $moduleName = $request->getModule(); $recordId = $request->get('record'); if($recordId && $moduleName) { @@ -201,6 +203,14 @@ abstract class Vtiger_View_Controller extends Vtiger_Action_Controller { $viewer->assign('LANGUAGE_STRINGS', $this->getJSLanguageStrings($request)); $viewer->assign('LANGUAGE', $currentUser->get('language')); + $viewer->assign('V7_THEME_PATH', ''); + $viewer->assign('MODULE_NAME', ''); + $viewer->assign('MODULE', ''); + $viewer->assign('VIEW', ''); + $viewer->assign('PARENT_MODULE', ''); + $viewer->assign('EXTENSION_MODULE', ''); + + if ($request->getModule() != 'Install') { $userCurrencyInfo = getCurrencySymbolandCRate($currentUser->get('currency_id')); $viewer->assign('USER_CURRENCY_SYMBOL', $userCurrencyInfo['symbol']); @@ -361,4 +371,4 @@ abstract class Vtiger_View_Controller extends Vtiger_Action_Controller { } return Vtiger_Language_Handler::export($moduleName, 'jsLanguageStrings'); } -} \ No newline at end of file +} diff --git a/libraries/antlr/AntlrLexer.php b/libraries/antlr/AntlrLexer.php index ac52e3a02..05a7ae016 100644 --- a/libraries/antlr/AntlrLexer.php +++ b/libraries/antlr/AntlrLexer.php @@ -140,7 +140,7 @@ abstract class AntlrLexer extends BaseRecognizer{ } } - public function matchAny() { + public function matchAny($input) { $this->input->consume(); } @@ -280,17 +280,17 @@ abstract class AntlrLexer extends BaseRecognizer{ * it all works out. You can instead use the rule invocation stack * to do sophisticated error recovery if you are in a fragment rule. */ - public function recover($re) { + public function recover($input, $re) { $this->input->consume(); } - public function traceIn($ruleName, $ruleIndex) { + public function traceIn($ruleName, $ruleIndex, $inputSymbol) { $inputSymbol = $this->input->LT(1)." line=".$this->getLine().":".$this->getCharPositionInLine(); parent::traceIn($ruleName, $ruleIndex, $inputSymbol); } - public function traceOut($ruleName, $ruleIndex) { + public function traceOut($ruleName, $ruleIndex, $inputSymbol) { $inputSymbol = $this->input->LT(1)." line=".$this->getLine().":".$this->getCharPositionInLine(); parent::traceOut($ruleName, $ruleIndex, $inputSymbol); } diff --git a/libraries/antlr/AntlrParser.php b/libraries/antlr/AntlrParser.php index d195e964e..230ae6591 100644 --- a/libraries/antlr/AntlrParser.php +++ b/libraries/antlr/AntlrParser.php @@ -86,11 +86,11 @@ class AntlrParser extends BaseRecognizer { return $this->input->getSourceName(); } - public function traceIn($ruleName, $ruleIndex) { + public function traceIn($ruleName, $ruleIndex, $inputSymbol) { parent::traceIn($ruleName, $ruleIndex, $this->input->LT(1)); } - public function traceOut($ruleName, $ruleIndex) { + public function traceOut($ruleName, $ruleIndex, $inputSymbol) { parent::traceOut($ruleName, $ruleIndex, $this->input->LT(1)); } diff --git a/libraries/htmlpurifier410/library/HTMLPurifier/Encoder.php b/libraries/htmlpurifier410/library/HTMLPurifier/Encoder.php index ea13abcdb..f6e45523c 100644 --- a/libraries/htmlpurifier410/library/HTMLPurifier/Encoder.php +++ b/libraries/htmlpurifier410/library/HTMLPurifier/Encoder.php @@ -159,7 +159,7 @@ class HTMLPurifier_Encoder $len = strlen($str); for ($i = 0; $i < $len; $i++) { - $in = ord($str{$i}); + $in = ord($str[$i]); $char .= $str[$i]; // append byte to char if (0 == $mState) { // When mState is zero we expect either a US-ASCII character diff --git a/libraries/htmlpurifier410/library/HTMLPurifier/TagTransform/Font.php b/libraries/htmlpurifier410/library/HTMLPurifier/TagTransform/Font.php index 2a186515e..99e01658c 100644 --- a/libraries/htmlpurifier410/library/HTMLPurifier/TagTransform/Font.php +++ b/libraries/htmlpurifier410/library/HTMLPurifier/TagTransform/Font.php @@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform if (isset($attr['size'])) { // normalize large numbers if ($attr['size'] !== '') { - if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { + if ($attr['size'][0] == '+' || $attr['size'][0] == '-') { $size = (int)$attr['size']; if ($size < -2) { $attr['size'] = '-2'; diff --git a/modules/CustomView/CustomView.php b/modules/CustomView/CustomView.php index 9860ad300..f329b8a7b 100644 --- a/modules/CustomView/CustomView.php +++ b/modules/CustomView/CustomView.php @@ -15,20 +15,24 @@ require_once 'include/Webservices/Utils.php'; global $adv_filter_options; global $mod_strings; -$adv_filter_options = array("e" => "" . $mod_strings['equals'] . "", - "n" => "" . $mod_strings['not equal to'] . "", - "s" => "" . $mod_strings['starts with'] . "", - "ew" => "" . $mod_strings['ends with'] . "", - "c" => "" . $mod_strings['contains'] . "", - "k" => "" . $mod_strings['does not contain'] . "", - "l" => "" . $mod_strings['less than'] . "", - "g" => "" . $mod_strings['greater than'] . "", - "m" => "" . $mod_strings['less or equal'] . "", - "h" => "" . $mod_strings['greater or equal'] . "", - "b" => "" . $mod_strings['before'] . "", - "a" => "" . $mod_strings['after'] . "", - "bw" => "" . $mod_strings['between'] . "", -); +$adv_filter_options = array(); + +if ($mod_strings) { + $adv_filter_options = array("e" => "" . $mod_strings['equals'] . "", + "n" => "" . $mod_strings['not equal to'] . "", + "s" => "" . $mod_strings['starts with'] . "", + "ew" => "" . $mod_strings['ends with'] . "", + "c" => "" . $mod_strings['contains'] . "", + "k" => "" . $mod_strings['does not contain'] . "", + "l" => "" . $mod_strings['less than'] . "", + "g" => "" . $mod_strings['greater than'] . "", + "m" => "" . $mod_strings['less or equal'] . "", + "h" => "" . $mod_strings['greater or equal'] . "", + "b" => "" . $mod_strings['before'] . "", + "a" => "" . $mod_strings['after'] . "", + "bw" => "" . $mod_strings['between'] . "", + ); +} class CustomView extends CRMEntity { diff --git a/modules/Install/models/ConfigFileUtils.php b/modules/Install/models/ConfigFileUtils.php index 4eff068d4..4430f00fa 100644 --- a/modules/Install/models/ConfigFileUtils.php +++ b/modules/Install/models/ConfigFileUtils.php @@ -101,7 +101,7 @@ class Install_ConfigFileUtils_Model { $buffer = str_replace( "_MASTER_CURRENCY_", $this->currencyName, $buffer); /* replace the application unique key variable */ - $buffer = str_replace( "_VT_APP_UNIQKEY_", md5(time() + rand(1,9999999) + md5($this->rootDirectory)) , $buffer); + $buffer = str_replace( "_VT_APP_UNIQKEY_", md5(sprintf("%d%s", (time() + rand(1,9999999)), md5($this->rootDirectory))) , $buffer); /* replace support email variable */ $buffer = str_replace( "_USER_SUPPORT_EMAIL_", $this->adminEmail, $buffer); diff --git a/modules/Install/views/Index.php b/modules/Install/views/Index.php index 61097a2ad..c74fd9558 100644 --- a/modules/Install/views/Index.php +++ b/modules/Install/views/Index.php @@ -129,6 +129,9 @@ class Install_Index_view extends Vtiger_View_Controller { $_SESSION['config_file_info'][$name] = $value; } + $rootUser = ''; + $rootPassword = ''; + $createDataBase = false; $createDB = $request->get('create_db'); if($createDB == 'on') { -- GitLab