Skip to content

Commit

Permalink
Adding 0.4.0 beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
phalcon committed May 27, 2012
1 parent a24b719 commit 7f08dcb
Show file tree
Hide file tree
Showing 105 changed files with 7,365 additions and 2,821 deletions.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ php:
- 5.3

before_script:
- sudo apt-get install memcached
- wget http://pecl.php.net/get/memcache-2.2.6.tgz
- tar -xzf memcache-2.2.6.tgz
- sh -c "cd memcache-2.2.6 && phpize && ./configure --enable-memcache && make && sudo make install"
- echo "extension=memcache.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- wget http://pecl.php.net/get/apc-3.1.9.tgz
- tar -xzf apc-3.1.9.tgz
- sh -c "cd APC-3.1.9 && phpize && ./configure --enable-apc && make && sudo make install"
- echo "extension=apc.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- echo "apc.enable_cli = On" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- cd dev/
- export CFLAGS="-O2 -fno-delete-null-pointer-checks"
- sh -c "phpize && ./configure --enable-phalcon && make && sudo make install"
- echo "extension=phalcon.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- cd ..
- cd ..
- mysql -uroot -e 'create database phalcon_test charset=utf8 collate=utf8_unicode_ci;'
- mysql -uroot phalcon_test < unit-tests/schemas/mysql/phalcon_test.sql

Expand Down
22 changes: 20 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
0.4.0
- Fixed possible segmentation fault when releasing memory of zval strings that has constant values
- Fixed bug that avoids auto-globals jit initialization inside phalcon on some old versions of PHP
- Fixed bug avoiding that auto-globals will jit-initialized inside Phalcon on some old versions of PHP
- Moved zval separation to phalcon_array_update_*
- Moved zval separation to phalcon_array_append_*
- Moved zval constructor to phalcon_array_update_*
- Implemented functions to avoid using an array of zvals parameters for static and method calls
- Implemented functions to avoid use arrays of zvals parameters for static and method calls
- Removed error reporting silence from the extension
- Removed thousands of unnecessary referencing/deferencing vars when calling functions/methods
- Moved multi-dimensional array updates to less complex functions
- Moved access to static properties to a function that controls possible invalid access to non existent properties
- Fixed memory leaks in Phalcon_Cache and Phalcon_Transaction_Manager
- Added virtual foreign keys to Phalcon_Model (ORM)
- Implemented the possibility to serialize Phalcon_Model_Resultset objects
- Implemented the possibility to access Phalcon_Model_Resultset as an array of objects
- Added Phalcon_Cache_Backend_Apc, Phalcon_Cache_Backend_Memcache, Phalcon_Cache_Frontend_None and Phalcon_Cache_Frontend_Data
- Added Phalcon_Request::hasPost and Phalcon_Request::hasQuery
- Added parameter "persistent" to Phalcon_Db allowing to create persistent connections
- Added alphanum to Phalcon_Filter to filter strings allowing filter only alpha-numeric characters
- Refactored Phalcon_Tag::select and Phalcon_Tag::selectStatic, now uses the same code in Phalcon_Tag_Select
- Added Phalcon_Tag::checkField helper to create input[type="checkbox"] tags
- Added Phalcon_View::getParams to recover extra params sended to the request
- Sometimes when Phalcon throws an internal exception or E_ERROR the memory stack is not properly cleaned
producing an unstable state, this situation was fixed
- Phalcon_View was refactored to allow other templating engines like Mustache or Twig
- Added Phalcon_Translate for multi-lingual translation messages based on adapters
- Added calculation functions to Phalcon_Model: count, sum, average, minimum and maximum

0.3.5
- Most of throw exception process has been rewrriten to use less instructions
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ We need to compile a shared library from C source to generate phalcon.so extensi

# git clone git://github.com/phalcon/cphalcon.git
# cd cphalcon/target/release
# export CFLAGS="-O2 -fno-delete-null-pointer-checks"
# phpize
# ./configure --enable-phalcon
# make
Expand All @@ -59,3 +60,9 @@ will queue a build into the continuos integration service and will run all phpun
everything is going well and the project is stable. The current build status is:

[![Build Status](https://secure.travis-ci.org/phalcon/cphalcon.png?branch=master)](http://travis-ci.org/phalcon/cphalcon)


License
--------------

See the docs/LICENSE.txt file.
3 changes: 3 additions & 0 deletions dev/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ PHP_METHOD(Phalcon_Acl, __construct){
}

if (!adapter_name) {

PHALCON_INIT_VAR(adapter_name);
ZVAL_STRING(adapter_name, "Memory", 1);
}

if (!options) {

PHALCON_INIT_VAR(a0);
array_init(a0);
PHALCON_CPY_WRT(options, a0);
Expand Down Expand Up @@ -129,6 +131,7 @@ PHP_METHOD(Phalcon_Acl, __call){
}

if (!arguments) {

PHALCON_INIT_VAR(a0);
array_init(a0);
PHALCON_CPY_WRT(arguments, a0);
Expand Down
119 changes: 33 additions & 86 deletions dev/acl/adapter/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,31 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, __construct){
PHALCON_INIT_VAR(a0);
array_init(a0);
zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, "_rolesNames", strlen("_rolesNames"), a0 TSRMLS_CC);

PHALCON_INIT_VAR(a1);
array_init(a1);
zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, "_roles", strlen("_roles"), a1 TSRMLS_CC);

PHALCON_INIT_VAR(a2);
array_init(a2);
zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, "_resources", strlen("_resources"), a2 TSRMLS_CC);

PHALCON_INIT_VAR(a3);
array_init(a3);
zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, "_access", strlen("_access"), a3 TSRMLS_CC);

PHALCON_INIT_VAR(a4);
array_init(a4);
zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, "_roleInherits", strlen("_roleInherits"), a4 TSRMLS_CC);

PHALCON_INIT_VAR(a5);
array_init(a5);
add_assoc_bool_ex(a5, "*", strlen("*")+1, 1);
zend_update_property(phalcon_acl_adapter_memory_ce, this_ptr, "_resourcesNames", strlen("_resourcesNames"), a5 TSRMLS_CC);

PHALCON_INIT_VAR(a6);
array_init(a6);

PHALCON_INIT_VAR(a7);
array_init(a7);
add_assoc_bool_ex(a7, "*", strlen("*")+1, 1);
Expand Down Expand Up @@ -144,6 +151,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole){
}

if (!access_inherits) {

PHALCON_INIT_VAR(access_inherits);
ZVAL_NULL(access_inherits);
}
Expand Down Expand Up @@ -175,6 +183,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole){
phalcon_read_property(&t1, this_ptr, "_roles", sizeof("_roles")-1, PHALCON_NOISY TSRMLS_CC);
phalcon_array_append(&t1, object, PHALCON_NO_SEPARATE_THX TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_roles", strlen("_roles"), t1 TSRMLS_CC);

PHALCON_INIT_VAR(t2);
ZVAL_BOOL(t2, 1);

Expand Down Expand Up @@ -232,7 +241,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole){
PHP_METHOD(Phalcon_Acl_Adapter_Memory, addInherit){

zval *role_name = NULL, *role_to_inherit = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL;
zval *i0 = NULL;
zval *r0 = NULL, *r1 = NULL;
zval *a0 = NULL;
Expand Down Expand Up @@ -290,18 +299,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addInherit){

PHALCON_ALLOC_ZVAL_MM(t4);
phalcon_read_property(&t4, this_ptr, "_roleInherits", sizeof("_roleInherits")-1, PHALCON_NOISY TSRMLS_CC);
if (Z_TYPE_P(t4) == IS_ARRAY) {
PHALCON_ALLOC_ZVAL_MM(t5);
phalcon_array_fetch(&t5, t4, role_name, PHALCON_SILENT TSRMLS_CC);
}
if (Z_REFCOUNT_P(t5) > 1) {
phalcon_array_update(&t4, role_name, &t5, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC);
}
if (Z_TYPE_P(t5) != IS_ARRAY) {
convert_to_array(t5);
phalcon_array_update(&t4, role_name, &t5, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC);
}
phalcon_array_append(&t5, role_to_inherit, PHALCON_NO_SEPARATE_THX TSRMLS_CC);
phalcon_array_update_multi_append_2(&t4, role_name, role_to_inherit, PHALCON_NO_SEPARATE_THX TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_roleInherits", strlen("_roleInherits"), t4 TSRMLS_CC);
PHALCON_CALL_METHOD_NORETURN(this_ptr, "_rebuildaccesslist", PHALCON_NO_CHECK);
PHALCON_MM_RESTORE();
Expand Down Expand Up @@ -396,6 +394,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResource){
}

if (!access_list) {

PHALCON_INIT_VAR(a0);
array_init(a0);
PHALCON_CPY_WRT(access_list, a0);
Expand Down Expand Up @@ -423,13 +422,15 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResource){
phalcon_read_property(&t1, this_ptr, "_resources", sizeof("_resources")-1, PHALCON_NOISY TSRMLS_CC);
phalcon_array_append(&t1, object, PHALCON_NO_SEPARATE_THX TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_resources", strlen("_resources"), t1 TSRMLS_CC);

PHALCON_INIT_VAR(a1);
array_init(a1);

PHALCON_ALLOC_ZVAL_MM(t2);
phalcon_read_property(&t2, this_ptr, "_accessList", sizeof("_accessList")-1, PHALCON_NOISY TSRMLS_CC);
phalcon_array_update(&t2, resource_name, &a1, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_accessList", strlen("_accessList"), t2 TSRMLS_CC);

PHALCON_INIT_VAR(t3);
ZVAL_BOOL(t3, 1);

Expand All @@ -455,7 +456,6 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess){

zval *resource_name = NULL, *access_list = NULL, *access_name = NULL;
zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL;
zval *t7 = NULL, *t8 = NULL;
zval *i0 = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL;
HashTable *ah0;
Expand Down Expand Up @@ -502,18 +502,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess){
ZVAL_BOOL(t2, 1);
PHALCON_INIT_VAR(t3);
phalcon_read_property(&t3, this_ptr, "_accessList", sizeof("_accessList")-1, PHALCON_NOISY TSRMLS_CC);
if (Z_TYPE_P(t3) == IS_ARRAY) {
PHALCON_INIT_VAR(t4);
phalcon_array_fetch(&t4, t3, resource_name, PHALCON_SILENT TSRMLS_CC);
}
if (Z_REFCOUNT_P(t4) > 1) {
phalcon_array_update(&t3, resource_name, &t4, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC);
}
if (Z_TYPE_P(t4) != IS_ARRAY) {
convert_to_array(t4);
phalcon_array_update(&t3, resource_name, &t4, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC);
}
phalcon_array_update(&t4, access_name, &t2, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC);
phalcon_array_update_multi_2(&t3, resource_name, access_name, &t2, PHALCON_NO_SEPARATE_THX TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_accessList", strlen("_accessList"), t3 TSRMLS_CC);
}
zend_hash_move_forward_ex(ah0, &hp0);
Expand All @@ -522,29 +511,18 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess){
if(0){ };
}
} else {
PHALCON_ALLOC_ZVAL_MM(t5);
phalcon_read_property(&t5, this_ptr, "_accessList", sizeof("_accessList")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(t4);
phalcon_read_property(&t4, this_ptr, "_accessList", sizeof("_accessList")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_ALLOC_ZVAL_MM(r2);
phalcon_array_fetch(&r2, t5, resource_name, PHALCON_NOISY TSRMLS_CC);
phalcon_array_fetch(&r2, t4, resource_name, PHALCON_NOISY TSRMLS_CC);
eval_int = phalcon_array_isset(r2, access_list);
if (!eval_int) {
PHALCON_INIT_VAR(t6);
ZVAL_BOOL(t6, 1);
PHALCON_ALLOC_ZVAL_MM(t7);
phalcon_read_property(&t7, this_ptr, "_accessList", sizeof("_accessList")-1, PHALCON_NOISY TSRMLS_CC);
if (Z_TYPE_P(t7) == IS_ARRAY) {
PHALCON_ALLOC_ZVAL_MM(t8);
phalcon_array_fetch(&t8, t7, resource_name, PHALCON_SILENT TSRMLS_CC);
}
if (Z_REFCOUNT_P(t8) > 1) {
phalcon_array_update(&t7, resource_name, &t8, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_CTOR TSRMLS_CC);
}
if (Z_TYPE_P(t8) != IS_ARRAY) {
convert_to_array(t8);
phalcon_array_update(&t7, resource_name, &t8, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC);
}
phalcon_array_update(&t8, access_list, &t6, PHALCON_NO_SEPARATE_THX, PHALCON_COPY, PHALCON_NO_CTOR TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_accessList", strlen("_accessList"), t7 TSRMLS_CC);
PHALCON_INIT_VAR(t5);
ZVAL_BOOL(t5, 1);
PHALCON_ALLOC_ZVAL_MM(t6);
phalcon_read_property(&t6, this_ptr, "_accessList", sizeof("_accessList")-1, PHALCON_NOISY TSRMLS_CC);
phalcon_array_update_multi_2(&t6, resource_name, access_list, &t5, PHALCON_NO_SEPARATE_THX TSRMLS_CC);
phalcon_update_property_zval(this_ptr, "_accessList", strlen("_accessList"), t6 TSRMLS_CC);
}
}

Expand Down Expand Up @@ -996,14 +974,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, isAllowed){
goto fee_c945_4;
} else {
PHALCON_INIT_VAR(resource_name);
hash_type = zend_hash_get_current_key_ex(ah0, &hash_index, &hash_index_len, &hash_num, 0, &hp0);
if (hash_type == HASH_KEY_IS_STRING) {
ZVAL_STRINGL(resource_name, hash_index, hash_index_len-1, 1);
} else {
if (hash_type == HASH_KEY_IS_LONG) {
ZVAL_LONG(resource_name, hash_num);
}
}
PHALCON_GET_FOREACH_KEY(resource_name, ah0, hp0);
}
PHALCON_INIT_VAR(resource_access);
ZVAL_ZVAL(resource_access, *hd, 1, 0);
Expand Down Expand Up @@ -1036,14 +1007,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, isAllowed){
goto fee_c945_5;
} else {
PHALCON_INIT_VAR(resource_name);
hash_type = zend_hash_get_current_key_ex(ah1, &hash_index, &hash_index_len, &hash_num, 0, &hp1);
if (hash_type == HASH_KEY_IS_STRING) {
ZVAL_STRINGL(resource_name, hash_index, hash_index_len-1, 1);
} else {
if (hash_type == HASH_KEY_IS_LONG) {
ZVAL_LONG(resource_name, hash_num);
}
}
PHALCON_GET_FOREACH_KEY(resource_name, ah1, hp1);
}
PHALCON_INIT_VAR(resource_access);
ZVAL_ZVAL(resource_access, *hd, 1, 0);
Expand Down Expand Up @@ -1103,16 +1067,19 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){

PHALCON_ALLOC_ZVAL_MM(r2);
mul_function(r2, number_roles, number_roles TSRMLS_CC);

PHALCON_INIT_VAR(t1);
ZVAL_LONG(t1, 2);

PHALCON_ALLOC_ZVAL_MM(r3);
div_function(r3, r2, t1 TSRMLS_CC);
PHALCON_CALL_FUNC_PARAMS_1(r1, "ceil", r3, 0x01C);
PHALCON_CPY_WRT(middle, r1);

PHALCON_INIT_VAR(i);
ZVAL_LONG(i, 0);
fs_c945_6:

PHALCON_INIT_VAR(r4);
is_smaller_or_equal_function(r4, i, middle TSRMLS_CC);
if (!zend_is_true(r4)) {
Expand All @@ -1128,14 +1095,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){
goto fee_c945_7;
} else {
PHALCON_INIT_VAR(role_name);
hash_type = zend_hash_get_current_key_ex(ah0, &hash_index, &hash_index_len, &hash_num, 0, &hp0);
if (hash_type == HASH_KEY_IS_STRING) {
ZVAL_STRINGL(role_name, hash_index, hash_index_len-1, 1);
} else {
if (hash_type == HASH_KEY_IS_LONG) {
ZVAL_LONG(role_name, hash_num);
}
}
PHALCON_GET_FOREACH_KEY(role_name, ah0, hp0);
}
PHALCON_INIT_VAR(one);
ZVAL_ZVAL(one, *hd, 1, 0);
Expand Down Expand Up @@ -1172,14 +1132,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){
goto fee_c945_9;
} else {
PHALCON_INIT_VAR(resource_name);
hash_type = zend_hash_get_current_key_ex(ah2, &hash_index, &hash_index_len, &hash_num, 0, &hp2);
if (hash_type == HASH_KEY_IS_STRING) {
ZVAL_STRINGL(resource_name, hash_index, hash_index_len-1, 1);
} else {
if (hash_type == HASH_KEY_IS_LONG) {
ZVAL_LONG(resource_name, hash_num);
}
}
PHALCON_GET_FOREACH_KEY(resource_name, ah2, hp2);
}
PHALCON_INIT_VAR(access);
ZVAL_ZVAL(access, *hd, 1, 0);
Expand All @@ -1191,14 +1144,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){
goto fee_c945_10;
} else {
PHALCON_INIT_VAR(name);
hash_type = zend_hash_get_current_key_ex(ah3, &hash_index, &hash_index_len, &hash_num, 0, &hp3);
if (hash_type == HASH_KEY_IS_STRING) {
ZVAL_STRINGL(name, hash_index, hash_index_len-1, 1);
} else {
if (hash_type == HASH_KEY_IS_LONG) {
ZVAL_LONG(name, hash_num);
}
}
PHALCON_GET_FOREACH_KEY(name, ah3, hp3);
}
PHALCON_INIT_VAR(value);
ZVAL_ZVAL(value, *hd, 1, 0);
Expand Down Expand Up @@ -1253,6 +1199,7 @@ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){
increment_function(i);
goto fs_c945_6;
fe_c945_6:
if(0){}

PHALCON_MM_RESTORE();
}
Expand Down
1 change: 1 addition & 0 deletions dev/acl/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ PHP_METHOD(Phalcon_Acl_Resource, __construct){
}

if (!description) {

PHALCON_INIT_VAR(description);
ZVAL_NULL(description);
}
Expand Down
1 change: 1 addition & 0 deletions dev/acl/role.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ PHP_METHOD(Phalcon_Acl_Role, __construct){
}

if (!description) {

PHALCON_INIT_VAR(description);
ZVAL_STRING(description, "", 1);
}
Expand Down
2 changes: 1 addition & 1 deletion dev/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/**
* Phalcon_Cache
*
* Phalcon_Cache can be used to caches output fragments to improve performance
* Phalcon_Cache can be used to cache output fragments to improve performance
*
*
*/
Expand Down
Loading

0 comments on commit 7f08dcb

Please sign in to comment.