Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Regarding Edit 3, if you are experiencing different results on different distributions with the same code and data set then my guess is that the CentOS binaries you are using have been modified by their developers and a bug has been introduced, perhaps in operator precedence.</p> <p>As a general rule, I personally prefer to enclose each clause or group of clauses in parentheses in order to reduce the chances of something like this happening, thus I suggest giving the following a try:</p> <pre><code>if ((!$this-&gt;id_lang &amp;&amp; isset($this-&gt;{$field}[$id_language]) &amp;&amp; !empty($this-&gt;{$field}[$id_language])) || ($this-&gt;id_lang &amp;&amp; isset($this-&gt;$field) &amp;&amp; !empty($this-&gt;$field))) { $fields[$id_language][$field] = (($this-&gt;id_lang === null) ? pSQL($this-&gt;$field) : pSQL($this-&gt;{$field}[$id_language])); } else if (in_array($field, $this-&gt;fieldsRequiredLang)) { $fields[$id_language][$field] = (($this-&gt;id_lang === null) ? pSQL($this-&gt;$field) : pSQL($this-&gt;{$field}[Configuration::get('PS_LANG_DEFAULT')])); } else { $fields[$id_language][$field] = ''; } </code></pre> <p>This way, you force the parser to evaluate the various clauses and operators in the order you define rather than the order the parser thinks they should be processed.</p> <h2>Original Answer</h2> <p>$field is being set to true because the === operator compares two values and returns true if they contain both the same value and the same type.</p> <p>By setting $id to null, you are essentially running this:</p> <pre><code>$field = (null === null); </code></pre> <p>You could expand your current code to clarify the logic as follows:</p> <pre><code>if ($id === null) { $field = true; } else { $field = false; } </code></pre> <p>Or, you could just simply run:</p> <pre><code>$field = ($id === null); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload