diff --git a/build/32bits/phalcon.c b/build/32bits/phalcon.c index ce936bd406..cd79c2cd42 100644 --- a/build/32bits/phalcon.c +++ b/build/32bits/phalcon.c @@ -16984,9 +16984,8 @@ PHALCON_INIT_CLASS(Phalcon_Db_Column){ static PHP_METHOD(Phalcon_Db_Column, __construct){ zval *column_name, *definition, *type, *not_null; - zval *primary, *size, *is_numeric = NULL, *scale, *dunsigned; + zval *primary, *size, *is_numeric, *scale, *dunsigned; zval *auto_increment, *first, *after, *bind_type; - zval *t0 = NULL, *t1 = NULL; PHALCON_MM_GROW(); @@ -17022,30 +17021,12 @@ static PHP_METHOD(Phalcon_Db_Column, __construct){ } if (phalcon_array_isset_quick_string(definition, SS("scale"), 458672173UL)) { + int i_type = phalcon_get_intval(type); - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_NVAR(t1); - ZVAL_LONG(t1, 9); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { + if (i_type == 3 || i_type == 7 || i_type == 9) { PHALCON_OBS_VAR(scale); phalcon_array_fetch_quick_string(&scale, definition, SS("scale"), 458672173UL, PH_NOISY); phalcon_update_property_this_quick(this_ptr, SL("_scale"), scale, 2819877996UL TSRMLS_CC); - } else { - PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type does not support scale parameter"); - return; } } @@ -17056,7 +17037,7 @@ static PHP_METHOD(Phalcon_Db_Column, __construct){ } if (phalcon_array_isset_quick_string(definition, SS("isNumeric"), 1643974676UL)) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_quick_string(&is_numeric, definition, SS("isNumeric"), 1643974676UL, PH_NOISY); phalcon_update_property_this_quick(this_ptr, SL("_isNumeric"), is_numeric, 2501917651UL TSRMLS_CC); } @@ -17175,8 +17156,7 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ zval *data, *definition, *column_name, *column_type; zval *not_null, *primary, *size, *scale, *dunsigned, *after; - zval *is_numeric = NULL, *first, *bind_type; - zval *t0 = NULL, *t1 = NULL; + zval *is_numeric, *first, *bind_type; PHALCON_MM_GROW(); @@ -17189,6 +17169,7 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_INIT_VAR(definition); array_init(definition); + if (!phalcon_array_isset_quick_string(data, SS("_columnName"), 3251978323UL)) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required"); return; @@ -17196,76 +17177,65 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_OBS_VAR(column_name); phalcon_array_fetch_quick_string(&column_name, data, SS("_columnName"), 3251978323UL, PH_NOISY); + if (phalcon_array_isset_quick_string(data, SS("_type"), 3991959110UL)) { PHALCON_OBS_VAR(column_type); phalcon_array_fetch_quick_string(&column_type, data, SS("_type"), 3991959110UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("type"), 276192743UL, &column_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("type"), 276192743UL, &column_type, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_notNull"), 628108368UL)) { PHALCON_OBS_VAR(not_null); phalcon_array_fetch_quick_string(¬_null, data, SS("_notNull"), 628108368UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("notNull"), 1960377425UL, ¬_null, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("notNull"), 1960377425UL, ¬_null, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_primary"), 3445614760UL)) { PHALCON_OBS_VAR(primary); phalcon_array_fetch_quick_string(&primary, data, SS("_primary"), 3445614760UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("primary"), 482916521UL, &primary, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("primary"), 482916521UL, &primary, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_size"), 3990209087UL)) { PHALCON_OBS_VAR(size); phalcon_array_fetch_quick_string(&size, data, SS("_size"), 3990209087UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("size"), 274442720UL, &size, PH_COPY | PH_SEPARATE); - } - - if (phalcon_array_isset_quick_string(data, SS("_scale"), 2819877996UL)) { - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, column_type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, column_type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { - PHALCON_OBS_VAR(scale); - phalcon_array_fetch_quick_string(&scale, data, SS("_scale"), 2819877996UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("scale"), 458672173UL, &scale, PH_COPY | PH_SEPARATE); - } - } + phalcon_array_update_quick_string(&definition, SS("size"), 274442720UL, &size, PH_COPY); + } + + if (phalcon_array_isset_quick_string(data, SS("_scale"), 2819877996UL)) { + PHALCON_OBS_VAR(scale); + phalcon_array_fetch_quick_string(&scale, data, SS("_scale"), 2819877996UL, PH_NOISY); + phalcon_array_update_quick_string(&definition, SS("scale"), 458672173UL, &scale, PH_COPY); + } if (phalcon_array_isset_quick_string(data, SS("_unsigned"), 127907201UL)) { PHALCON_OBS_VAR(dunsigned); phalcon_array_fetch_quick_string(&dunsigned, data, SS("_unsigned"), 127907201UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("unsigned"), 1143113122UL, &dunsigned, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("unsigned"), 1143113122UL, &dunsigned, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_after"), 2119674294UL)) { PHALCON_OBS_VAR(after); phalcon_array_fetch_quick_string(&after, data, SS("_after"), 2119674294UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("after"), 4053435767UL, &after, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("after"), 4053435767UL, &after, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_isNumeric"), 2501917651UL)) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_quick_string(&is_numeric, data, SS("_isNumeric"), 2501917651UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("isNumeric"), 1643974676UL, &is_numeric, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("isNumeric"), 1643974676UL, &is_numeric, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_first"), 2318852460UL)) { PHALCON_OBS_VAR(first); phalcon_array_fetch_quick_string(&first, data, SS("_first"), 2318852460UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("first"), 4252613933UL, &first, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("first"), 4252613933UL, &first, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_bindType"), 926651555UL)) { PHALCON_OBS_VAR(bind_type); phalcon_array_fetch_quick_string(&bind_type, data, SS("_bindType"), 926651555UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("bindType"), 1941857476UL, &bind_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("bindType"), 1941857476UL, &bind_type, PH_COPY); } object_init_ex(return_value, phalcon_db_column_ce); @@ -36523,8 +36493,8 @@ static PHP_METHOD(Phalcon_Acl_Adapter_Memory, dropResourceAccess){ } } else { - PHALCON_INIT_NVAR(access_key); - PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_name); + PHALCON_INIT_VAR(access_key); + PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_list); phalcon_unset_property_array(this_ptr, SL("_accessList"), access_key TSRMLS_CC); } @@ -61218,6 +61188,10 @@ static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray){ phalcon_fast_count(row_count, records TSRMLS_CC); phalcon_update_property_this_quick(this_ptr, SL("_count"), row_count, 2208664173UL TSRMLS_CC); } + else { + PHALCON_INIT_NVAR(records); + array_init(records); + } } } diff --git a/build/64bits/phalcon.c b/build/64bits/phalcon.c index 70d7f86f19..ece5c3bd99 100644 --- a/build/64bits/phalcon.c +++ b/build/64bits/phalcon.c @@ -16984,9 +16984,8 @@ PHALCON_INIT_CLASS(Phalcon_Db_Column){ static PHP_METHOD(Phalcon_Db_Column, __construct){ zval *column_name, *definition, *type, *not_null; - zval *primary, *size, *is_numeric = NULL, *scale, *dunsigned; + zval *primary, *size, *is_numeric, *scale, *dunsigned; zval *auto_increment, *first, *after, *bind_type; - zval *t0 = NULL, *t1 = NULL; PHALCON_MM_GROW(); @@ -17022,30 +17021,12 @@ static PHP_METHOD(Phalcon_Db_Column, __construct){ } if (phalcon_array_isset_quick_string(definition, SS("scale"), 6954010724397UL)) { + int i_type = phalcon_get_intval(type); - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_NVAR(t1); - ZVAL_LONG(t1, 9); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { + if (i_type == 3 || i_type == 7 || i_type == 9) { PHALCON_OBS_VAR(scale); phalcon_array_fetch_quick_string(&scale, definition, SS("scale"), 6954010724397UL, PH_NOISY); phalcon_update_property_this_quick(this_ptr, SL("_scale"), scale, 229457152699500UL TSRMLS_CC); - } else { - PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type does not support scale parameter"); - return; } } @@ -17056,7 +17037,7 @@ static PHP_METHOD(Phalcon_Db_Column, __construct){ } if (phalcon_array_isset_quick_string(definition, SS("isNumeric"), 8246464942291357716UL)) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_quick_string(&is_numeric, definition, SS("isNumeric"), 8246464942291357716UL, PH_NOISY); phalcon_update_property_this_quick(this_ptr, SL("_isNumeric"), is_numeric, 13863196544613759955UL TSRMLS_CC); } @@ -17175,8 +17156,7 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ zval *data, *definition, *column_name, *column_type; zval *not_null, *primary, *size, *scale, *dunsigned, *after; - zval *is_numeric = NULL, *first, *bind_type; - zval *t0 = NULL, *t1 = NULL; + zval *is_numeric, *first, *bind_type; PHALCON_MM_GROW(); @@ -17189,6 +17169,7 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_INIT_VAR(definition); array_init(definition); + if (!phalcon_array_isset_quick_string(data, SS("_columnName"), 14754295275943444563UL)) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required"); return; @@ -17196,76 +17177,65 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_OBS_VAR(column_name); phalcon_array_fetch_quick_string(&column_name, data, SS("_columnName"), 14754295275943444563UL, PH_NOISY); + if (phalcon_array_isset_quick_string(data, SS("_type"), 6953249044038UL)) { PHALCON_OBS_VAR(column_type); phalcon_array_fetch_quick_string(&column_type, data, SS("_type"), 6953249044038UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("type"), 210729590247UL, &column_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("type"), 210729590247UL, &column_type, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_notNull"), 249878642403847248UL)) { PHALCON_OBS_VAR(not_null); phalcon_array_fetch_quick_string(¬_null, data, SS("_notNull"), 249878642403847248UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("notNull"), 7572720792960081UL, ¬_null, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("notNull"), 7572720792960081UL, ¬_null, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_primary"), 249878731120699560UL)) { PHALCON_OBS_VAR(primary); phalcon_array_fetch_quick_string(&primary, data, SS("_primary"), 249878731120699560UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("primary"), 7572809509812393UL, &primary, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("primary"), 7572809509812393UL, &primary, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_size"), 6953247294015UL)) { PHALCON_OBS_VAR(size); phalcon_array_fetch_quick_string(&size, data, SS("_size"), 6953247294015UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("size"), 210727840224UL, &size, PH_COPY | PH_SEPARATE); - } - - if (phalcon_array_isset_quick_string(data, SS("_scale"), 229457152699500UL)) { - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, column_type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, column_type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { - PHALCON_OBS_VAR(scale); - phalcon_array_fetch_quick_string(&scale, data, SS("_scale"), 229457152699500UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("scale"), 6954010724397UL, &scale, PH_COPY | PH_SEPARATE); - } - } + phalcon_array_update_quick_string(&definition, SS("size"), 210727840224UL, &size, PH_COPY); + } + + if (phalcon_array_isset_quick_string(data, SS("_scale"), 229457152699500UL)) { + PHALCON_OBS_VAR(scale); + phalcon_array_fetch_quick_string(&scale, data, SS("_scale"), 229457152699500UL, PH_NOISY); + phalcon_array_update_quick_string(&definition, SS("scale"), 6954010724397UL, &scale, PH_COPY); + } if (phalcon_array_isset_quick_string(data, SS("_unsigned"), 8246005001317496193UL)) { PHALCON_OBS_VAR(dunsigned); phalcon_array_fetch_quick_string(&dunsigned, data, SS("_unsigned"), 8246005001317496193UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("unsigned"), 249909588158219682UL, &dunsigned, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("unsigned"), 249909588158219682UL, &dunsigned, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_after"), 229456452495798UL)) { PHALCON_OBS_VAR(after); phalcon_array_fetch_quick_string(&after, data, SS("_after"), 229456452495798UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("after"), 6953310520695UL, &after, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("after"), 6953310520695UL, &after, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_isNumeric"), 13863196544613759955UL)) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_quick_string(&is_numeric, data, SS("_isNumeric"), 13863196544613759955UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("isNumeric"), 8246464942291357716UL, &is_numeric, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("isNumeric"), 8246464942291357716UL, &is_numeric, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_first"), 229456651673964UL)) { PHALCON_OBS_VAR(first); phalcon_array_fetch_quick_string(&first, data, SS("_first"), 229456651673964UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("first"), 6953509698861UL, &first, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("first"), 6953509698861UL, &first, PH_COPY); } if (phalcon_array_isset_quick_string(data, SS("_bindType"), 8245978059786392739UL)) { PHALCON_OBS_VAR(bind_type); phalcon_array_fetch_quick_string(&bind_type, data, SS("_bindType"), 8245978059786392739UL, PH_NOISY); - phalcon_array_update_quick_string(&definition, SS("bindType"), 249882646627116228UL, &bind_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_quick_string(&definition, SS("bindType"), 249882646627116228UL, &bind_type, PH_COPY); } object_init_ex(return_value, phalcon_db_column_ce); @@ -36523,8 +36493,8 @@ static PHP_METHOD(Phalcon_Acl_Adapter_Memory, dropResourceAccess){ } } else { - PHALCON_INIT_NVAR(access_key); - PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_name); + PHALCON_INIT_VAR(access_key); + PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_list); phalcon_unset_property_array(this_ptr, SL("_accessList"), access_key TSRMLS_CC); } @@ -61218,6 +61188,10 @@ static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray){ phalcon_fast_count(row_count, records TSRMLS_CC); phalcon_update_property_this_quick(this_ptr, SL("_count"), row_count, 229456541485677UL TSRMLS_CC); } + else { + PHALCON_INIT_NVAR(records); + array_init(records); + } } } diff --git a/build/safe/phalcon.c b/build/safe/phalcon.c index 79efa534da..a9096fce46 100644 --- a/build/safe/phalcon.c +++ b/build/safe/phalcon.c @@ -16984,9 +16984,8 @@ PHALCON_INIT_CLASS(Phalcon_Db_Column){ static PHP_METHOD(Phalcon_Db_Column, __construct){ zval *column_name, *definition, *type, *not_null; - zval *primary, *size, *is_numeric = NULL, *scale, *dunsigned; + zval *primary, *size, *is_numeric, *scale, *dunsigned; zval *auto_increment, *first, *after, *bind_type; - zval *t0 = NULL, *t1 = NULL; PHALCON_MM_GROW(); @@ -17022,30 +17021,12 @@ static PHP_METHOD(Phalcon_Db_Column, __construct){ } if (phalcon_array_isset_string(definition, SS("scale"))) { + int i_type = phalcon_get_intval(type); - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_NVAR(t1); - ZVAL_LONG(t1, 9); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { + if (i_type == 3 || i_type == 7 || i_type == 9) { PHALCON_OBS_VAR(scale); phalcon_array_fetch_string(&scale, definition, SL("scale"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_scale"), scale TSRMLS_CC); - } else { - PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type does not support scale parameter"); - return; } } @@ -17056,7 +17037,7 @@ static PHP_METHOD(Phalcon_Db_Column, __construct){ } if (phalcon_array_isset_string(definition, SS("isNumeric"))) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_string(&is_numeric, definition, SL("isNumeric"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_isNumeric"), is_numeric TSRMLS_CC); } @@ -17175,8 +17156,7 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ zval *data, *definition, *column_name, *column_type; zval *not_null, *primary, *size, *scale, *dunsigned, *after; - zval *is_numeric = NULL, *first, *bind_type; - zval *t0 = NULL, *t1 = NULL; + zval *is_numeric, *first, *bind_type; PHALCON_MM_GROW(); @@ -17189,6 +17169,7 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_INIT_VAR(definition); array_init(definition); + if (!phalcon_array_isset_string(data, SS("_columnName"))) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required"); return; @@ -17196,76 +17177,65 @@ static PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_OBS_VAR(column_name); phalcon_array_fetch_string(&column_name, data, SL("_columnName"), PH_NOISY); + if (phalcon_array_isset_string(data, SS("_type"))) { PHALCON_OBS_VAR(column_type); phalcon_array_fetch_string(&column_type, data, SL("_type"), PH_NOISY); - phalcon_array_update_string(&definition, SL("type"), &column_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("type"), &column_type, PH_COPY); } if (phalcon_array_isset_string(data, SS("_notNull"))) { PHALCON_OBS_VAR(not_null); phalcon_array_fetch_string(¬_null, data, SL("_notNull"), PH_NOISY); - phalcon_array_update_string(&definition, SL("notNull"), ¬_null, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("notNull"), ¬_null, PH_COPY); } if (phalcon_array_isset_string(data, SS("_primary"))) { PHALCON_OBS_VAR(primary); phalcon_array_fetch_string(&primary, data, SL("_primary"), PH_NOISY); - phalcon_array_update_string(&definition, SL("primary"), &primary, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("primary"), &primary, PH_COPY); } if (phalcon_array_isset_string(data, SS("_size"))) { PHALCON_OBS_VAR(size); phalcon_array_fetch_string(&size, data, SL("_size"), PH_NOISY); - phalcon_array_update_string(&definition, SL("size"), &size, PH_COPY | PH_SEPARATE); - } - - if (phalcon_array_isset_string(data, SS("_scale"))) { - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, column_type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, column_type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { - PHALCON_OBS_VAR(scale); - phalcon_array_fetch_string(&scale, data, SL("_scale"), PH_NOISY); - phalcon_array_update_string(&definition, SL("scale"), &scale, PH_COPY | PH_SEPARATE); - } - } + phalcon_array_update_string(&definition, SL("size"), &size, PH_COPY); + } + + if (phalcon_array_isset_string(data, SS("_scale"))) { + PHALCON_OBS_VAR(scale); + phalcon_array_fetch_string(&scale, data, SL("_scale"), PH_NOISY); + phalcon_array_update_string(&definition, SL("scale"), &scale, PH_COPY); + } if (phalcon_array_isset_string(data, SS("_unsigned"))) { PHALCON_OBS_VAR(dunsigned); phalcon_array_fetch_string(&dunsigned, data, SL("_unsigned"), PH_NOISY); - phalcon_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY); } if (phalcon_array_isset_string(data, SS("_after"))) { PHALCON_OBS_VAR(after); phalcon_array_fetch_string(&after, data, SL("_after"), PH_NOISY); - phalcon_array_update_string(&definition, SL("after"), &after, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("after"), &after, PH_COPY); } if (phalcon_array_isset_string(data, SS("_isNumeric"))) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_string(&is_numeric, data, SL("_isNumeric"), PH_NOISY); - phalcon_array_update_string(&definition, SL("isNumeric"), &is_numeric, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("isNumeric"), &is_numeric, PH_COPY); } if (phalcon_array_isset_string(data, SS("_first"))) { PHALCON_OBS_VAR(first); phalcon_array_fetch_string(&first, data, SL("_first"), PH_NOISY); - phalcon_array_update_string(&definition, SL("first"), &first, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("first"), &first, PH_COPY); } if (phalcon_array_isset_string(data, SS("_bindType"))) { PHALCON_OBS_VAR(bind_type); phalcon_array_fetch_string(&bind_type, data, SL("_bindType"), PH_NOISY); - phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY); } object_init_ex(return_value, phalcon_db_column_ce); @@ -36523,8 +36493,8 @@ static PHP_METHOD(Phalcon_Acl_Adapter_Memory, dropResourceAccess){ } } else { - PHALCON_INIT_NVAR(access_key); - PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_name); + PHALCON_INIT_VAR(access_key); + PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_list); phalcon_unset_property_array(this_ptr, SL("_accessList"), access_key TSRMLS_CC); } @@ -61218,6 +61188,10 @@ static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray){ phalcon_fast_count(row_count, records TSRMLS_CC); phalcon_update_property_this(this_ptr, SL("_count"), row_count TSRMLS_CC); } + else { + PHALCON_INIT_NVAR(records); + array_init(records); + } } } diff --git a/ext/acl/adapter/memory.c b/ext/acl/adapter/memory.c index c2ca477b7e..76966acf0e 100644 --- a/ext/acl/adapter/memory.c +++ b/ext/acl/adapter/memory.c @@ -474,8 +474,8 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, dropResourceAccess){ } } else { - PHALCON_INIT_NVAR(access_key); - PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_name); + PHALCON_INIT_VAR(access_key); + PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_list); phalcon_unset_property_array(this_ptr, SL("_accessList"), access_key TSRMLS_CC); } diff --git a/ext/db/column.c b/ext/db/column.c index 1dece49e93..86817278fe 100644 --- a/ext/db/column.c +++ b/ext/db/column.c @@ -115,9 +115,8 @@ PHALCON_INIT_CLASS(Phalcon_Db_Column){ PHP_METHOD(Phalcon_Db_Column, __construct){ zval *column_name, *definition, *type, *not_null; - zval *primary, *size, *is_numeric = NULL, *scale, *dunsigned; + zval *primary, *size, *is_numeric, *scale, *dunsigned; zval *auto_increment, *first, *after, *bind_type; - zval *t0 = NULL, *t1 = NULL; PHALCON_MM_GROW(); @@ -165,30 +164,12 @@ PHP_METHOD(Phalcon_Db_Column, __construct){ * Check if the column has a decimal scale */ if (phalcon_array_isset_string(definition, SS("scale"))) { + int i_type = phalcon_get_intval(type); - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_NVAR(t1); - ZVAL_LONG(t1, 9); - is_equal_function(is_numeric, type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { + if (i_type == 3 || i_type == 7 || i_type == 9) { PHALCON_OBS_VAR(scale); phalcon_array_fetch_string(&scale, definition, SL("scale"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_scale"), scale TSRMLS_CC); - } else { - PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type does not support scale parameter"); - return; } } @@ -205,7 +186,7 @@ PHP_METHOD(Phalcon_Db_Column, __construct){ * Check if the field is numeric */ if (phalcon_array_isset_string(definition, SS("isNumeric"))) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_string(&is_numeric, definition, SL("isNumeric"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_isNumeric"), is_numeric TSRMLS_CC); } @@ -407,8 +388,7 @@ PHP_METHOD(Phalcon_Db_Column, __set_state){ zval *data, *definition, *column_name, *column_type; zval *not_null, *primary, *size, *scale, *dunsigned, *after; - zval *is_numeric = NULL, *first, *bind_type; - zval *t0 = NULL, *t1 = NULL; + zval *is_numeric, *first, *bind_type; PHALCON_MM_GROW(); @@ -421,6 +401,7 @@ PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_INIT_VAR(definition); array_init(definition); + if (!phalcon_array_isset_string(data, SS("_columnName"))) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required"); return; @@ -428,76 +409,65 @@ PHP_METHOD(Phalcon_Db_Column, __set_state){ PHALCON_OBS_VAR(column_name); phalcon_array_fetch_string(&column_name, data, SL("_columnName"), PH_NOISY); + if (phalcon_array_isset_string(data, SS("_type"))) { PHALCON_OBS_VAR(column_type); phalcon_array_fetch_string(&column_type, data, SL("_type"), PH_NOISY); - phalcon_array_update_string(&definition, SL("type"), &column_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("type"), &column_type, PH_COPY); } if (phalcon_array_isset_string(data, SS("_notNull"))) { PHALCON_OBS_VAR(not_null); phalcon_array_fetch_string(¬_null, data, SL("_notNull"), PH_NOISY); - phalcon_array_update_string(&definition, SL("notNull"), ¬_null, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("notNull"), ¬_null, PH_COPY); } if (phalcon_array_isset_string(data, SS("_primary"))) { PHALCON_OBS_VAR(primary); phalcon_array_fetch_string(&primary, data, SL("_primary"), PH_NOISY); - phalcon_array_update_string(&definition, SL("primary"), &primary, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("primary"), &primary, PH_COPY); } if (phalcon_array_isset_string(data, SS("_size"))) { PHALCON_OBS_VAR(size); phalcon_array_fetch_string(&size, data, SL("_size"), PH_NOISY); - phalcon_array_update_string(&definition, SL("size"), &size, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("size"), &size, PH_COPY); } - if (phalcon_array_isset_string(data, SS("_scale"))) { - PHALCON_INIT_VAR(t0); - ZVAL_LONG(t0, 3); - PHALCON_INIT_VAR(is_numeric); - is_equal_function(is_numeric, column_type, t0 TSRMLS_CC); - if (PHALCON_IS_NOT_TRUE(is_numeric)) { - PHALCON_INIT_VAR(t1); - ZVAL_LONG(t1, 7); - is_equal_function(is_numeric, column_type, t1 TSRMLS_CC); - } - - if (PHALCON_IS_TRUE(is_numeric)) { - PHALCON_OBS_VAR(scale); - phalcon_array_fetch_string(&scale, data, SL("_scale"), PH_NOISY); - phalcon_array_update_string(&definition, SL("scale"), &scale, PH_COPY | PH_SEPARATE); - } - } + if (phalcon_array_isset_string(data, SS("_scale"))) { + PHALCON_OBS_VAR(scale); + phalcon_array_fetch_string(&scale, data, SL("_scale"), PH_NOISY); + phalcon_array_update_string(&definition, SL("scale"), &scale, PH_COPY); + } if (phalcon_array_isset_string(data, SS("_unsigned"))) { PHALCON_OBS_VAR(dunsigned); phalcon_array_fetch_string(&dunsigned, data, SL("_unsigned"), PH_NOISY); - phalcon_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY); } if (phalcon_array_isset_string(data, SS("_after"))) { PHALCON_OBS_VAR(after); phalcon_array_fetch_string(&after, data, SL("_after"), PH_NOISY); - phalcon_array_update_string(&definition, SL("after"), &after, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("after"), &after, PH_COPY); } if (phalcon_array_isset_string(data, SS("_isNumeric"))) { - PHALCON_OBS_NVAR(is_numeric); + PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_string(&is_numeric, data, SL("_isNumeric"), PH_NOISY); - phalcon_array_update_string(&definition, SL("isNumeric"), &is_numeric, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("isNumeric"), &is_numeric, PH_COPY); } if (phalcon_array_isset_string(data, SS("_first"))) { PHALCON_OBS_VAR(first); phalcon_array_fetch_string(&first, data, SL("_first"), PH_NOISY); - phalcon_array_update_string(&definition, SL("first"), &first, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("first"), &first, PH_COPY); } if (phalcon_array_isset_string(data, SS("_bindType"))) { PHALCON_OBS_VAR(bind_type); phalcon_array_fetch_string(&bind_type, data, SL("_bindType"), PH_NOISY); - phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY | PH_SEPARATE); + phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY); } object_init_ex(return_value, phalcon_db_column_ce); diff --git a/ext/mvc/model/resultset/simple.c b/ext/mvc/model/resultset/simple.c index 3be317d1f4..06d3c7dbbf 100644 --- a/ext/mvc/model/resultset/simple.c +++ b/ext/mvc/model/resultset/simple.c @@ -336,6 +336,10 @@ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray){ phalcon_fast_count(row_count, records TSRMLS_CC); phalcon_update_property_this(this_ptr, SL("_count"), row_count TSRMLS_CC); } + else { + PHALCON_INIT_NVAR(records); + array_init(records); + } } } diff --git a/ext/tests/issue-1364.phpt b/ext/tests/issue-1364.phpt new file mode 100644 index 0000000000..d1aed1bba2 --- /dev/null +++ b/ext/tests/issue-1364.phpt @@ -0,0 +1,11 @@ +--TEST-- +Segfault in 1.2.4 - https://github.com/phalcon/cphalcon/issues/1364 +--SKIPIF-- + +--FILE-- +add("test", new \Phalcon\Validation\Validator\PresenceOf()); +$v->validate(array("test")); +?> +--EXPECT-- diff --git a/ext/tests/scanbuild-1.phpt b/ext/tests/scanbuild-1.phpt new file mode 100644 index 0000000000..09f909b939 --- /dev/null +++ b/ext/tests/scanbuild-1.phpt @@ -0,0 +1,10 @@ +--TEST-- +Branch condition evaluates to a garbage value - zim_Phalcon_Db_Column___set_state +--SKIPIF-- + +--FILE-- + true, '_columnName' => 'column', '_type' => 'integer'); +\Phalcon\Db\Column::__set_state($data); +?> +--EXPECT-- diff --git a/ext/tests/scanbuild-2.phpt b/ext/tests/scanbuild-2.phpt new file mode 100644 index 0000000000..f0dbb175b9 --- /dev/null +++ b/ext/tests/scanbuild-2.phpt @@ -0,0 +1,16 @@ +--TEST-- +Branch condition evaluates to a garbage value - zim_Phalcon_Db_Column___set_state +--SKIPIF-- + +--FILE-- + true, '_columnName' => 'column', '_scale' => 1); +try { + \Phalcon\Db\Column::__set_state($data); + assert(false); +} +catch (Exception $e) { + assert(true); +} +?> +--EXPECT-- diff --git a/ext/tests/scanbuild-6.phpt b/ext/tests/scanbuild-6.phpt new file mode 100644 index 0000000000..d3964b95d4 --- /dev/null +++ b/ext/tests/scanbuild-6.phpt @@ -0,0 +1,28 @@ +--TEST-- +Segmentation fault in zim_Phalcon_Mvc_Collection_save +--SKIPIF-- + +--FILE-- +_dependencyInjector); + return parent::save(); + } +} + +$di = new \Phalcon\DI\FactoryDefault(); +$di->setShared('collectionManager', function() { return new \Phalcon\Mvc\Collection\Manager(); }); +$c = new \EvilCollection(); +try { + $c->save(); + assert(false); +} +catch (Exception $e) { + assert(true); +} +?> +--EXPECT-- diff --git a/ext/tests/scanbuild-7.phpt b/ext/tests/scanbuild-7.phpt new file mode 100644 index 0000000000..5b6cf29f34 --- /dev/null +++ b/ext/tests/scanbuild-7.phpt @@ -0,0 +1,10 @@ +--TEST-- +Dereference of null pointer in zim_Phalcon_Acl_Adapter_Memory_dropResourceAccess +--SKIPIF-- + +--FILE-- +dropResourceAccess('resource', 'accesslist'); +?> +--EXPECT--