[Vtigercrm-developers] Vtiger_Request get and a default value

Zygmuntowicz Michal m.zygmuntowicz at onet.pl
Thu Dec 12 09:18:35 GMT 2013


But the problem I see here is that if the request has a value set for some key
(and it is found the the valuemap) and the defaultmap has a value for the same key too,
the get function will return the default value (from defaultmap) instead of the value
from the request (found in the valuemap). E.g.:

valuemap contains ('mode' => 'edit')
defaultmap contains ('mode' => 'delete')

when we call get('mode') the retrun value will be always 'delete',
no matter what the valuemap actually contains.


From: Prasad 
Sent: Thursday, December 12, 2013 6:27 AM
To: vtigercrm-developers at lists.vtigercrm.com 
Subject: Re: [Vtigercrm-developers] Vtiger_Request get and a default value


Michal, 


You are right - (defvalue) has less precedence than (defaultmap).
If there is a value defined in defaultmap - defvalue will be ignored.


Regards,
Prasad




Connect with us on: Twitter I Facebook I Blog I Wiki I Forums I Website



On Wed, Dec 11, 2013 at 8:16 PM, Zygmuntowicz Michal <m.zygmuntowicz at onet.pl> wrote:

  Hello,

  I've just took a look at Vtiger_Request class and found
  the following code:

      ...
      function get($key, $defvalue = '') {
          $value = $defvalue;
          if(isset($this->valuemap[$key])) {
              $value = $this->valuemap[$key];
          }
          if($defvalue === '' && isset($this->defaultmap[$key])) {
              $value = $this->defaultmap[$key];
          }
      ...

  It seems that if a default value is set in the defaultmap,
  it always overrides the value from the request - is it intentional?

  My guess is that the condition should look like:
          if($value === '' && isset($this->defaultmap[$key])) {
  instead of:
          if($defvalue === '' && isset($this->defaultmap[$key])) {

  Regards,
  Michał Zygmuntowicz


  _______________________________________________
  http://www.vtiger.com/





--------------------------------------------------------------------------------


_______________________________________________
http://www.vtiger.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20131212/5487cc9a/attachment.html>


More information about the vtigercrm-developers mailing list