Skip to content
Snippets Groups Projects
Commit 2b221131 authored by Uma's avatar Uma
Browse files

Merge branch 'PHP7Constructor' into 'master'

Php7 constructor

Hello,

I have rewrited the php4 constructor to be compatible with php7.

see link : https://cweiske.de/tagebuch/php4-constructors-php7.htm

I have tested on my vtiger on 5.6 and 7 and all working fine.

See merge request !337
parents b13d323b 4fd6e7e3
No related branches found
No related tags found
No related merge requests found
Showing
with 185 additions and 52 deletions
......@@ -156,7 +156,7 @@ class PEAR
// }}}
// {{{ constructor
/**
* Constructor. Registers this object in
* $_PEAR_destructor_object_list for destructor emulation if a
......@@ -167,7 +167,7 @@ class PEAR
* @access public
* @return void
*/
function PEAR($error_class = null)
function __construct($error_class = null)
{
$classname = strtolower(get_class($this));
if ($this->_debug) {
......@@ -191,6 +191,13 @@ class PEAR
}
}
}
function PEAR($error_class = null)
{
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($error_class);
}
// }}}
// {{{ destructor
......@@ -842,7 +849,7 @@ class PEAR_Error
* @access public
*
*/
function PEAR_Error($message = 'unknown error', $code = null,
function __construct($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
if ($mode === null) {
......@@ -900,6 +907,15 @@ class PEAR_Error
eval('$e = new Exception($this->message, $this->code);throw($e);');
}
}
function PEAR_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($message, $code,$mode, $options, $userinfo);
}
// }}}
// {{{ getMode()
......
......@@ -30,15 +30,15 @@ class VtigerConfig {
static function get($key, $defvalue='') {
if (self::has($key)) {
global $$key;
return $$key;
global ${$key};
return ${$key};
}
return $defvalue;
}
static function has($key) {
global $$key;
return (isset($$key));
global ${$key};
return (isset(${$key}));
}
static function getOD($key, $defvalue='') {
......
......@@ -44,14 +44,21 @@ class Tracker {
"item_id",
"item_summary"
);
function Tracker()
function __construct()
{
$this->log = LoggerManager::getLogger('Tracker');
// $this->db = PearDatabase::getInstance();
global $adb;
// $this->db = PearDatabase::getInstance();
global $adb;
$this->db = $adb;
}
function Tracker()
{
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct();
}
/**
* Add this new item to the vtiger_tracker vtiger_table. If there are too many items (global config for now)
......
......@@ -25,15 +25,21 @@ class ListViewSession {
* Portions created by vtigerCRM are Copyright (C) vtigerCRM.
* All Rights Reserved.
*/
function ListViewSession()
{
global $log,$currentModule;
function __construct()
{
global $log,$currentModule;
$log->debug("Entering ListViewSession() method ...");
$this->module = $currentModule;
$this->sortby = 'ASC';
$this->start =1;
}
function ListViewSession()
{
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct();
}
function getCurrentPage($currentModule,$viewId){
......
......@@ -23,13 +23,20 @@ class RelatedListViewSession {
var $sorder = null;
var $sortby = null;
var $page_view = null;
function RelatedListViewSession() {
global $log,$currentModule;
function __construct()
{
global $log,$currentModule;
$log->debug("Entering RelatedListViewSession() method ...");
$this->module = $currentModule;
$this->start =1;
}
function RelatedListViewSession() {
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct();
}
public static function addRelatedModuleToSession($relationId, $header) {
......
......@@ -34,12 +34,19 @@ abstract class EntityMeta{
protected $ownerFields;
protected $moduleFields = null;
protected function EntityMeta($webserviceObject,$user){
$this->webserviceObject = $webserviceObject;
protected function __construct($webserviceObject,$user)
{
$this->webserviceObject = $webserviceObject;
$this->objectName = $this->webserviceObject->getEntityName();
$this->objectId = $this->webserviceObject->getEntityId();
$this->user = $user;
}
protected function EntityMeta($webserviceObject,$user){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($webserviceObject,$user);
}
public function getEmailFields(){
......
......@@ -35,9 +35,8 @@
private $preLogin;
private $operationId;
private $operationParams;
function OperationManager($adb,$operationName,$format, $sessionManager){
function __construct($adb,$operationName,$format, $sessionManager)
{
$this->format = strtolower($format);
$this->sessionManager = $sessionManager;
$this->formatObjects = array();
......@@ -58,6 +57,13 @@
$this->inParamProcess["encoded"] = &$this->formatObjects[$this->format]["decode"];
$this->fillOperationDetails($operationName);
}
function OperationManager($adb,$operationName,$format, $sessionManager){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($adb,$operationName,$format, $sessionManager);
}
function isPreLoginOperation(){
return $this->preLogin == 1;
......
......@@ -14,42 +14,42 @@ class VTWS_PreserveGlobal{
static function preserveGlobal($name,$value){
//$name store the name of the global.
global $$name;
global ${$name};
//To not push null value . Ideally we should not push null value for any name
//But current user null is dangerous so we are checking for only current user
if(!empty($$name) || $name != 'current_user') {
if(!empty(${$name}) || $name != 'current_user') {
if(!is_array(VTWS_PreserveGlobal::$globalData[$name])){
VTWS_PreserveGlobal::$globalData[$name] = array();
}
VTWS_PreserveGlobal::$globalData[$name][] = $$name;
VTWS_PreserveGlobal::$globalData[$name][] = ${$name};
}
$$name = $value;
return $$name;
${$name} = $value;
return ${$name};
}
static function restore($name){
//$name store the name of the global.
global $$name;
global ${$name};
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0){
$$name = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
${$name} = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
}
$$name;
${$name};
}
static function getGlobal($name){
global $$name;
return VTWS_PreserveGlobal::preserveGlobal($name,$$name);
global ${$name};
return VTWS_PreserveGlobal::preserveGlobal($name,${$name});
}
static function flush(){
foreach (VTWS_PreserveGlobal::$globalData as $name => $detail) {
//$name store the name of the global.
global $$name;
global ${$name};
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0) {
$$name = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
${$name} = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
}
}
}
......
......@@ -19,11 +19,19 @@
private $hasError ;
private $error ;
private $user;
function Parser($user, $q){
function __construct($user, $q)
{
$this->query = $q;
$this->out = array();
$this->hasError = false;
$this->user = $user;
$this->user = $user;
}
function Parser($user, $q){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($user, $q);
}
function parse(){
......
......@@ -26,8 +26,8 @@
private $sessionVar = "__SessionExists";
private $error ;
function SessionManager(){
function __construct()
{
global $maxWebServiceSessionLifeSpan, $maxWebServiceSessionIdleTime;
$now = time();
......@@ -42,6 +42,13 @@
//otherwise it subtracts the time from previous time
HTTP_Session2::setIdle($this->idleLife, true);
}
function SessionManager(){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct();
}
function isValid(){
......
......@@ -14,11 +14,18 @@
var $result ;
var $error;
function State(){
function __construct()
{
$this->success = false;
$this->result = array();
$this->error = array();
}
function State(){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct();
}
}
......
......@@ -13,7 +13,8 @@ class VtigerCRMActorMeta extends EntityMeta {
protected static $fieldTypeMapping = array();
protected static $referenceTypeMapping = array();
function VtigerCRMActorMeta($tableName,$webserviceObject,$adb,$user){
function __construct($tableName,$webserviceObject,$adb,$user)
{
parent::__construct($webserviceObject,$user);
$this->baseTable = $tableName;
$this->idColumn = null;
......@@ -23,6 +24,12 @@ class VtigerCRMActorMeta extends EntityMeta {
$this->tableIndexList = null;
$this->defaultTableList = array();
}
function VtigerCRMActorMeta($tableName,$webserviceObject,$adb,$user){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($tableName,$webserviceObject,$adb,$user);
}
public function getIdColumn() {
if($this->idColumn === null) {
......
......@@ -13,8 +13,8 @@ class VtigerCRMObject{
private $moduleName ;
private $moduleId ;
private $instance ;
function VtigerCRMObject($moduleCredential, $isId=false){
function __construct($moduleCredential, $isId=false)
{
if($isId){
$this->moduleId = $moduleCredential;
......@@ -26,6 +26,12 @@ class VtigerCRMObject{
$this->instance = null;
$this->getInstance();
}
function VtigerCRMObject($moduleCredential, $isId=false){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($moduleCredential, $isId);
}
public function getModuleName(){
return $this->moduleName;
......
......@@ -21,7 +21,8 @@ class VtigerCRMObjectMeta extends EntityMeta {
private $hasDeleteAccess;
private $assignUsers;
function VtigerCRMObjectMeta($webserviceObject,$user){
function __construct($webserviceObject,$user)
{
parent::__construct($webserviceObject,$user);
......@@ -50,6 +51,12 @@ class VtigerCRMObjectMeta extends EntityMeta {
}
$this->tabId = null;
}
function VtigerCRMObjectMeta($webserviceObject,$user){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($webserviceObject,$user);
}
/**
* returns tabid of the current object.
......
......@@ -13,11 +13,18 @@ class VtigerModuleOperation extends WebserviceEntityOperation {
protected $isEntity = true;
protected $partialDescribeFields = null;
public function VtigerModuleOperation($webserviceObject,$user,$adb,$log){
public function __construct($webserviceObject,$user,$adb,$log)
{
parent::__construct($webserviceObject,$user,$adb,$log);
$this->meta = $this->getMetaInstance();
$this->tabId = $this->meta->getTabId();
}
public function VtigerModuleOperation($webserviceObject,$user,$adb,$log){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($webserviceObject,$user,$adb,$log);
}
protected function getMetaInstance(){
if(empty(WebserviceEntityOperation::$metaCache[$this->webserviceObject->getEntityName()][$this->user->id])){
......
......@@ -15,7 +15,8 @@ class VtigerWebserviceObject{
private $handlerPath;
private $handlerClass;
private function VtigerWebserviceObject($entityId,$entityName,$handler_path,$handler_class){
private function __construct($entityId,$entityName,$handler_path,$handler_class)
{
$this->id = $entityId;
$this->name = $entityName;
// Quick Fix to override default Actor class & path (good to update DB itself)
......@@ -28,6 +29,13 @@ class VtigerWebserviceObject{
$this->handlerClass = $handler_class;
}
private function VtigerWebserviceObject($entityId,$entityName,$handler_path,$handler_class){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($entityId,$entityName,$handler_path,$handler_class);
}
// Cache variables to enable result re-use
private static $_fromNameCache = array();
......
......@@ -13,11 +13,17 @@
public $code;
public $message;
function WebServiceException($errCode,$msg){
function __construct($errCode,$msg)
{
$this->code = $errCode;
$this->message = $msg;
}
function WebServiceException($errCode,$msg){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($errCode,$msg);
}
}
......
......@@ -21,12 +21,19 @@ abstract class WebserviceEntityOperation{
protected static $metaCache = array();
protected function WebserviceEntityOperation($webserviceObject,$user,$adb,$log){
protected function __construct($webserviceObject,$user,$adb,$log)
{
$this->user = $user;
$this->log = $log;
$this->webserviceObject = $webserviceObject;
$this->pearDB = $adb;
}
protected function WebserviceEntityOperation($webserviceObject,$user,$adb,$log){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($webserviceObject,$user,$adb,$log);
}
public function create($elementType,$element){
throw new WebServiceException(WebServiceErrorCode::$OPERATIONNOTSUPPORTED,
......
......@@ -31,8 +31,9 @@ class RecurringType {
* Constructor for class RecurringType
* @param array $repeat_arr - array contains recurring info
*/
function RecurringType($repeat_arr) {
function __construct($repeat_arr)
{
$st_date = explode("-", $repeat_arr["startdate"]);
$st_time = explode(":", $repeat_arr["starttime"]);
$end_date = explode("-", $repeat_arr["enddate"]);
......@@ -75,6 +76,12 @@ class RecurringType {
$this->recurringdates = $this->_getRecurringDates();
}
function RecurringType($repeat_arr) {
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends `foo` calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($repeat_arr);
}
public static function fromUserRequest($requestArray) {
// All the information from the user is received in User Time zone
......
......@@ -276,9 +276,16 @@ class ExportUtils{
var $fieldsArr = array();
var $picklistValues = array();
function ExportUtils($module, $fields_array){
function __construct($module, $fields_array)
{
self::__init($module, $fields_array);
}
function ExportUtils($module, $fields_array){
// PHP4-style constructor.
// This will NOT be invoked, unless a sub-class that extends calls it.
// In that case, call the new-style constructor to keep compatibility.
self::__construct($module, $fields_array);
}
function __init($module, $fields_array){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment