Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 22nd, 2012  |  syntax: None  |  size: 1.68 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
  2. index c3c35eb..b1feb7a 100644
  3. --- a/Zend/zend_compile.c
  4. +++ b/Zend/zend_compile.c
  5. @@ -6089,7 +6089,19 @@ void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC
  6.  
  7.         zend_do_end_variable_parse(variable, BP_VAR_IS, 0 TSRMLS_CC);
  8.  
  9. -       zend_check_writable_variable(variable);
  10. +       if (type == ZEND_ISEMPTY) {
  11. +               // if the empty() argument is the result of a function call we already
  12. +               // know that the variable exists, so we can just convert the empty()
  13. +               // call to a boolean not
  14. +               if (zend_is_function_or_method_call(variable)) {
  15. +                       zend_do_unary_op(ZEND_BOOL_NOT, result, variable TSRMLS_CC);
  16. +                       return;
  17. +               }
  18. +       } else {
  19. +               // it doesn't make sense to pass the result of a function call to
  20. +               // isset() as it will always be bool(true). Thus disallow them here
  21. +               zend_check_writable_variable(variable);
  22. +       }
  23.  
  24.         if (variable->op_type == IS_CV) {
  25.                 last_op = get_next_op(CG(active_op_array) TSRMLS_CC);
  26. diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
  27. index d0730b7..1a9d212 100644
  28. --- a/Zend/zend_language_parser.y
  29. +++ b/Zend/zend_language_parser.y
  30. @@ -1149,6 +1149,7 @@ encaps_var_offset:
  31.  internal_functions_in_yacc:
  32.                 T_ISSET '(' isset_variables ')' { $$ = $3; }
  33.         |       T_EMPTY '(' variable ')'        { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); }
  34. +       |       T_EMPTY '(' expr_without_variable ')' { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$3 TSRMLS_CC); }
  35.         |       T_INCLUDE expr                  { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); }
  36.         |       T_INCLUDE_ONCE expr     { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); }
  37.         |       T_EVAL '(' expr ')'     { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); }