Field isTranslated AND php operator

i just found out about php operators and/or are not the same as &&/||. so i was wondering is the multilang field implementation correct as it is?
can someone explain to me why it will not always return isNotEmpty?

1 Like

Thank you for letting us know, that was indeed a bug and is now fixed for Kirby 2.4.

1 Like

checked again. i think it was fine, as long as its directly at the return statement and not in a variable.

function testa() {
  $a = true and false;
  return $a; // will return true (which is not what might be expected)
function testb() {
  return true and false; // will return false (which is correct)
ecco(testa(), 'true', 'false'); // true
ecco(testb(), 'true', 'false'); // false

You are right! But anyway, it’s better to clean that stuff up in case that condition is moved to a variable definition later.

1 Like


Use of parentheses, even when not strictly necessary, can often increase readability of the code by making grouping explicit rather than relying on the implicit operator precedence and associativity.

I suggest to use brackets β€œ( …)” around that, what is after an equal sign.

Thank you for the feedback, but just replacing every use of and with && is an easier and less confusion solution in my opinion.