Skip to content

Commit

Permalink
Merge pull request #1550 from GPCsolutions/staticanalysis
Browse files Browse the repository at this point in the history
Various fixes to defects found using statical analysis tooling
  • Loading branch information
eldy committed Apr 23, 2014
2 parents 078a7f4 + 20842a5 commit 03d73bc
Show file tree
Hide file tree
Showing 99 changed files with 283 additions and 253 deletions.
2 changes: 1 addition & 1 deletion htdocs/admin/const.php
Expand Up @@ -38,7 +38,7 @@
$update=GETPOST('update','alpha');
$delete=GETPOST('delete'); // Do not use alpha here
$debug=GETPOST('debug','int');
$consts=GETPOST('const');
$consts=GETPOST('const','array');
$constname=GETPOST('constname','alpha');
$constvalue=GETPOST('constvalue');
$constnote=GETPOST('constnote','alpha');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/ajax/row.php
Expand Up @@ -60,7 +60,7 @@
$row->table_element_line = $table_element_line;
$row->fk_element = $fk_element;
$row->id = $element_id;
$result=$row->line_ajaxorder($newrowordertab);
$row->line_ajaxorder($newrowordertab);

// Reorder line to have position of chilren lines sharing same counter than parent lines
// This should be useless because there is no need to have children sharing same counter that parent.
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/class/commondocgenerator.class.php
Expand Up @@ -62,7 +62,7 @@ function get_substitutionarray_user($user,$outputlangs)
'myuser_fax'=>$user->office_fax,
'myuser_mobile'=>$user->user_mobile,
'myuser_email'=>$user->email,
'myuser_logo'=>$logotouse,
'myuser_logo'=>$user->photo,
'myuser_web'=>'' // url not exist in $user object
);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ function get_substitutionarray_thirdparty($object,$outputlangs)
{
$object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code);
}
if (empty($mysoc->state) && ! empty($mysoc->state_code))
if (empty($object->state) && ! empty($object->state_code))
{
$object->state=getState($object->state_code,0);
}
Expand Down Expand Up @@ -418,7 +418,7 @@ function get_substitutionarray_shipment_lines($line,$outputlangs)
* @param Object $object Object with extrafields (must have $object->array_options filled)
* @param array $array_to_fill Substitution array
* @param Extrafields $extrafields Extrafields object
* @param array_key $array_key Name of the key for return array
* @param string $array_key Name of the key for return array
* @param Translate $outputlangs Lang object to use for output
* @return array Substitution array
*/
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/class/commoninvoice.class.php
Expand Up @@ -253,6 +253,7 @@ function LibStatut($paye,$status,$mode=0,$alreadypaid=-1,$type=0)
}
if ($mode == 4)
{
$prefix='';
if (! $paye)
{
if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
Expand Down
16 changes: 8 additions & 8 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -83,10 +83,10 @@ function getFullName($langs,$option=0,$nameorder=-1,$maxlen=0)
if (empty($firstname)) $firstname=$this->firstname;

$ret='';
if ($option && $this->civilite_id)
if ($option && $this->civility_id)
{
if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' ';
if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' ';
else $ret.=$this->civility_id.' ';
}

$ret.=dolGetFirstLastname($firstname, $lastname, $nameorder);
Expand Down Expand Up @@ -241,8 +241,8 @@ function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger
/**
* Copy contact from one element to current
*
* @param int $objFrom Source element
* @param int $source Nature of contact ('internal' or 'external')
* @param CommonObject $objFrom Source element
* @param string $source Nature of contact ('internal' or 'external')
* @return int >0 if OK, <0 if KO
*/
function copy_linked_contact($objFrom, $source='internal')
Expand Down Expand Up @@ -1721,7 +1721,7 @@ function add_object_linked($origin=null, $origin_id=null)
* @param string $clause OR, AND clause
* @return void
*/
function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
{
global $conf;

Expand Down Expand Up @@ -2278,7 +2278,7 @@ function insertExtraFields()
*/
function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='')
{
global $_POST;
global $_POST, $conf;

$out = '';

Expand Down Expand Up @@ -2482,7 +2482,7 @@ function getTotalDiscount()
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($query);
$obj = $this->db->fetch_object($resql);

$pu_ht = $obj->pu_ht;
$qty= $obj->qty;
Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/class/conf.class.php
Expand Up @@ -119,6 +119,8 @@ function __construct()
*/
function setValues($db)
{
global $conf;

dol_syslog(get_class($this)."::setValues");

/*
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/class/cookie.class.php
Expand Up @@ -34,7 +34,7 @@ class DolCookie
var $myExpire;
var $myPath;
var $myDomain;
var $mySsecure;
var $mySecure;
var $cookiearray;
var $cookie;

Expand Down Expand Up @@ -80,7 +80,7 @@ function cryptCookie()
/**
* Decrypt the cookie
*
* @return void
* @return string
*/
function decryptCookie()
{
Expand Down Expand Up @@ -144,4 +144,4 @@ function _getCookie($cookie)

}

?>
?>
2 changes: 1 addition & 1 deletion htdocs/core/class/discount.class.php
Expand Up @@ -188,7 +188,7 @@ function delete($user)
// Check if we can remove the discount
if ($this->fk_facture_source)
{
$sql.="SELECT COUNT(rowid) as nb";
$sql="SELECT COUNT(rowid) as nb";
$sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except";
$sql.=" WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount
$sql.=" OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/dolprintipp.class.php
Expand Up @@ -126,7 +126,7 @@ function print_file($file,$module)
*/
function list_jobs($module)
{
global $conf,$db;
global $conf, $db, $bc;
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
$ipp = new CupsPrintIPP();
$ipp->setLog(DOL_DATA_ROOT.'/printipp.log','file',3); // logging very verbose
Expand Down
22 changes: 11 additions & 11 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -207,16 +207,16 @@ private function create($attrname, $type='varchar', $length=255, $elementtype='m
/**
* Add description of a new optional attribute
*
* @param string $attrname code of attribute
* @param string $label label of attribute
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour', 'float')
* @param int $pos Position of attribute
* @param int $size Size/length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @return int <=0 if KO, >0 if OK
* @param string $attrname code of attribute
* @param string $label label of attribute
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour', 'float')
* @param int $pos Position of attribute
* @param int $size Size/length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @return int <=0 if KO, >0 if OK
*/
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='')
{
Expand Down Expand Up @@ -581,7 +581,7 @@ function fetch_name_optionals_label($elementtype='adherent',$forceload=false)
*/
function showInputField($key,$value,$moreparam='',$keyprefix='')
{
global $conf,$langs;
global $conf,$langs,$db;

$label=$this->attribute_label[$key];
$type =$this->attribute_type[$key];
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/class/fileupload.class.php
Expand Up @@ -558,7 +558,8 @@ public function post()
isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null),
isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null),
isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null),
isset($upload['error']) ? $upload['error'] : null
isset($upload['error']) ? $upload['error'] : null,
0
);
}
header('Vary: Accept');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/html.form.class.php
Expand Up @@ -3160,7 +3160,7 @@ function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter
*/
function form_contacts($page, $societe, $selected='', $htmlname='contactidp')
{
global $langs;
global $langs, $conf;

if ($htmlname != "none")
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/class/html.formadmin.class.php
Expand Up @@ -199,9 +199,9 @@ function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib='')
/**
* Return combo list of available menu families
*
* @param string $selected Menu pre-selected
* @param string $htmlname Name of html select
* @param string $dirmenuarray Directories to scan
* @param string $selected Menu pre-selected
* @param string $htmlname Name of html select
* @param string[] $dirmenuarray Directories to scan
* @return void
*/
function select_menu_families($selected, $htmlname, $dirmenuarray)
Expand Down
3 changes: 1 addition & 2 deletions htdocs/core/class/html.formfile.class.php
Expand Up @@ -257,8 +257,7 @@ function show_documents($modulepart,$modulesubdir,$filedir,$urlsource,$genallowe
*/
function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='')
{
global $langs,$conf,$hookmanager;
global $bc;
global $langs,$conf,$hookmanager,$user,$bc;

// filedir = $conf->...->dir_ouput."/".get_exdir(id)
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
Expand Down
4 changes: 3 additions & 1 deletion htdocs/core/class/html.formmail.class.php
Expand Up @@ -58,7 +58,8 @@ class FormMail
var $withreplytoreadonly;
var $withtoreadonly;
var $withtoccreadonly;
var $withtopicreadonly;
var $withtocccreadonly;
var $withtopicreadonly;
var $withfilereadonly;
var $withdeliveryreceipt;
var $withcancel;
Expand Down Expand Up @@ -95,6 +96,7 @@ function __construct($db)
$this->withreplytoreadonly=1;
$this->withtoreadonly=0;
$this->withtoccreadonly=0;
$this->withtocccreadonly=0;
$this->witherrorstoreadonly=0;
$this->withtopicreadonly=0;
$this->withfilereadonly=0;
Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/class/html.formother.class.php
Expand Up @@ -391,7 +391,7 @@ function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0)
$moreinfo=0;
if (! empty($conf->global->MAIN_SHOW_LOGIN))
{
$out.=($moreinfo?' - ':' (').$obj->login;
$moreforfilter.=($moreinfo?' - ':' (').$obj_usr->login;
$moreinfo++;
}
if ($showstatus >= 0)
Expand Down Expand Up @@ -1095,9 +1095,10 @@ function updateBoxOrder(closing) {
* @param string $labelfield Label field
* @param string $selected Selected value
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib More attributes on HTML select tag
* @return void
*/
function select_dictionary($htmlname,$dictionarytable,$keyfield='code',$labelfield='label',$selected='',$useempty=0)
function select_dictionary($htmlname,$dictionarytable,$keyfield='code',$labelfield='label',$selected='',$useempty=0,$moreattrib='')
{
global $langs, $conf;

Expand Down
1 change: 1 addition & 0 deletions htdocs/core/class/html.formsms.class.php
Expand Up @@ -213,6 +213,7 @@ function limitChars(textarea, limit, infodiv)
else
{
dol_syslog("Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
$resultsender=array();
$resultsender[0]->number=$this->fromsms;
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/infobox.class.php
Expand Up @@ -201,7 +201,7 @@ static function saveboxorder($db, $zone,$boxorder,$userid=0)
$tab[$confuserzone]=1;
if (dol_set_user_param($db, $conf, $user, $tab) < 0)
{
$this->error=$db->lasterror();
$error=$db->lasterror();
$db->rollback();
return -3;
}
Expand Down

0 comments on commit 03d73bc

Please sign in to comment.