[Vtigercrm-developers] unnecessary htmlentities conversion in vtiger 6.1 beta database classes
Holbok István
holbok at gmail.com
Thu Aug 14 15:25:55 GMT 2014
Dear vtiger Team,
In the way to prepare vtiger 6.1 to support php 5.5, I suggest to review
the database classes also.
Here are some minor, easy to provide changes, that will not affect any
other codes, but the usability will increase.
There is a file:
*...\include\database\PearDatabase.php*
with the most used database class.
And about line 526 there is a function *fetch_array*:
/* ADODB newly added. replacement for mysql_fetch_array() */
function fetch_array(&$result) {
if($result->EOF) {
//$this->println("ADODB fetch_array return null");
return NULL;
}
$arr = $result->FetchRow();
if(is_array($arr))
$arr = array_map('*to_html*', $arr);
return $this->change_key_case($arr);
}
As it shown, this function will convert all possible strings to
htmlentities during fetch [ array_map('to_html', $arr) ]. This
conversion in some of case unnecessary.
This function would be more useful in the following form:
/* ADODB newly added. replacement for mysql_fetch_array() */
function fetch_array(&$result, *$encode=true*) {
if($result->EOF) {
//$this->println("ADODB fetch_array return null");
return NULL;
}
$arr = $result->FetchRow();
if(is_array($arr) && $encode)
$arr = array_map('*to_html*', $arr);
return $this->change_key_case($arr);
}
At this case htmlentities encoding can be disabled by $encode=false.
Or in line 787:
function fetch_row(&$result, $encode=true) {
return $this->getNextRow($result);
}
It looks like it supports the disabling htmlentities encoding, but
inside the function it suppress the possibility.
This function should be after correction:
function fetch_row(&$result, $encode=true) {
return $this->getNextRow($result, *$encode*);
}
The getNextRow supports the $encode parameter.
function getNextRow(&$result, $encode=true){
global $log;
$log->info('getNextRow');
if(isset($result)){
$row = $this->change_key_case($result->FetchRow());
if($row && $encode&& is_array($row))
return array_map('to_html', $row);
return $row;
}
return null;
}
--
üdvözlettel:
*Holbok István*
+3670-342-0900
*e-mail:* holbok at gmail.com
*SkyPe:* holboki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140814/9684c9f8/attachment.html>
More information about the vtigercrm-developers
mailing list