Can anyone, please, suggest what is the purpose of a 'break' statement within an 'if' block in a function views_ui_config_item_extra_form:2445 ?

PHP manual says 'break' is only allowed within for, foreach, while, do-while or switch structure, but here we have it only inside an 'if' inside a function.

(I've bumped into this mainly because I'm trying to use a non-standard PHP compiler which gives a compile-time error here, telling something: Cannot break/continue 1 level(s). I was already given an explanation in the similar case, which appeared to be a bug in core Drupal code: #763948: In the file install.pgsql.inc there is an undocumented usage of PHP function pg_result_error without an argument.. So I hope to learn something new this time too.)

Thanks in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Category: support » bug

Looks to me like it's a leftover from code changes and/or cut & paste.

esteewhy’s picture

Thank You, Earl.

Indeed, there seems to be some meaning in an 'orphaned' break, according to a commenters out here. At least my brief experiment shows that 'break' terminates the script entirely:

<?php
function test_break() {
  if(true) {
    if(true) {
      echo "one";
      break;
    }
    echo "two";
  }
  echo "three";
}

test_break();
echo "four";
?>
esteewhy’s picture

Ups, there seems to be more to this: 2 more places where such 'break' exists. So I've updated the patch accordingly.

dawehner’s picture

Status: Active » Needs review

UPdate status

dawehner’s picture

Status: Needs review » Needs work

Can we modify the indentation to keep the good codestyle?

The rest looks fine

esteewhy’s picture

esteewhy’s picture

Daniel, could You please also suggest: do I need to take any action on the similar issue #763948: In the file install.pgsql.inc there is an undocumented usage of PHP function pg_result_error without an argument. ?

dawehner’s picture

Thanks for rerolling the patch. Here is the patch for 6.x-3.x.

The patch from #6 looks fine but i cannot RTBC the patch anymore because i uploaded already a patch :) Thanks for your work.

dawehner’s picture

But the patch from #6 looks fine.

For #763948: In the file install.pgsql.inc there is an undocumented usage of PHP function pg_result_error without an argument. i think the central problem is that there are not many people looking at patches against 6.x. Core dev's are concentrating on bringing d7 out. Additional another problem might be that you use pg. There are really not many people which uses it on d6 and i'm not sure whether it's a good think to do. You step into many different kind of problems.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.