Skip to content

Commit fc21efc

Browse files
committed
Allow circular dependencies
1 parent e776630 commit fc21efc

File tree

7 files changed

+210
-107
lines changed

7 files changed

+210
-107
lines changed

Zend/zend_compile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,14 @@ typedef struct _zend_user_module_desc {
574574
struct _zend_user_module {
575575
zend_user_module_desc desc;
576576
bool is_loading;
577+
bool is_persistent;
577578
HashTable deps;
578579
HashTable class_table;
579580
HashTable function_table;
580581
// TODO: move these elsewhere
581582
HashTable scripts;
582583
HashTable classmap;
584+
struct _zend_user_module_dir_cache *dir_cache;
583585
};
584586

585587
#define ZEND_RETURN_VALUE 0

Zend/zend_execute_API.c

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,45 +1680,13 @@ void zend_unset_timeout(void) /* {{{ */
16801680
}
16811681
/* }}} */
16821682

1683-
ZEND_API zend_never_inline ZEND_COLD void zend_circular_module_dependency_error(zend_user_module *module)
1684-
{
1685-
smart_str s = {0};
1686-
zend_user_module *other;
1687-
bool add = false;
1688-
ZEND_HASH_FOREACH_PTR(CG(module_table), other) {
1689-
if (!add) {
1690-
if (other == module) {
1691-
add = true;
1692-
} else {
1693-
continue;
1694-
}
1695-
}
1696-
if (!other->is_loading) {
1697-
continue;
1698-
}
1699-
if (smart_str_get_len(&s) != 0) {
1700-
smart_str_appends(&s, " -> ");
1701-
}
1702-
smart_str_append(&s, other->desc.name);
1703-
} ZEND_HASH_FOREACH_END();
1704-
1705-
smart_str_0(&s);
1706-
1707-
zend_string *path_str = smart_str_extract(&s);
1708-
1709-
zend_throw_exception_ex(NULL, 0,
1710-
"Circular dependency found between the following modules: %s",
1711-
ZSTR_VAL(path_str));
1712-
1713-
zend_string_release(path_str);
1714-
}
1715-
17161683
static ZEND_COLD void report_class_fetch_error(zend_string *class_name, uint32_t fetch_type)
17171684
{
17181685
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
17191686
return;
17201687
}
17211688

1689+
#if 0
17221690
if (CG(active_module)) {
17231691
/* We are loading a module. Check if the class is part of a module being
17241692
* loaded. */
@@ -1743,6 +1711,7 @@ static ZEND_COLD void report_class_fetch_error(zend_string *class_name, uint32_t
17431711
}
17441712
} ZEND_HASH_FOREACH_END();
17451713
}
1714+
#endif
17461715

17471716
if (EG(exception)) {
17481717
if (!(fetch_type & ZEND_FETCH_CLASS_EXCEPTION)) {

Zend/zend_hash.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,10 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht,
13281328
ZEND_HASH_MAP_FOREACH(ht, 0); \
13291329
_ptr = Z_PTR_P(_z);
13301330

1331+
#define ZEND_HASH_MAP_FOREACH_VAL_FROM(ht, _val, _from) \
1332+
ZEND_HASH_MAP_FOREACH_FROM(ht, 0, _from); \
1333+
_val = _z;
1334+
13311335
#define ZEND_HASH_MAP_FOREACH_PTR_FROM(ht, _ptr, _from) \
13321336
ZEND_HASH_MAP_FOREACH_FROM(ht, 0, _from); \
13331337
_ptr = Z_PTR_P(_z);

0 commit comments

Comments
 (0)