Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sapi/cli: Extend --ini to print INI settings changed from the builtin default #17459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_

while (ini_entry->name) {
p = pemalloc(sizeof(zend_ini_entry), 1);
p->def = ini_entry;
p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, 1);
p->on_modify = ini_entry->on_modify;
p->mh_arg1 = ini_entry->mh_arg1;
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct _zend_ini_entry {
uint8_t orig_modifiable;
uint8_t modified;

const zend_ini_entry_def *def;
};

BEGIN_EXTERN_C()
Expand Down
33 changes: 33 additions & 0 deletions sapi/cli/php_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,14 @@ BOOL WINAPI php_cli_win32_ctrl_handler(DWORD sig)
#endif
/*}}}*/

static int zend_ini_entry_cmp(Bucket *a, Bucket *b)
{
zend_ini_entry *A = Z_PTR(a->val);
zend_ini_entry *B = Z_PTR(b->val);

return zend_binary_strcasecmp(ZSTR_VAL(A->name), ZSTR_LEN(A->name), ZSTR_VAL(B->name), ZSTR_LEN(B->name));
Girgias marked this conversation as resolved.
Show resolved Hide resolved
}

static int do_cli(int argc, char **argv) /* {{{ */
{
int c;
Expand Down Expand Up @@ -1096,6 +1104,31 @@ static int do_cli(int argc, char **argv) /* {{{ */
zend_printf("Loaded Configuration File: %s\n", php_ini_opened_path ? php_ini_opened_path : "(none)");
zend_printf("Scan for additional .ini files in: %s\n", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
zend_printf("Additional .ini files parsed: %s\n", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
zend_printf("\n");
zend_printf("Non-default INI settings:\n");
zend_ini_entry *ini_entry;
HashTable *sorted = zend_array_dup(EG(ini_directives));
zend_array_sort(sorted, zend_ini_entry_cmp, 1);
ZEND_HASH_PACKED_FOREACH_PTR(sorted, ini_entry) {
if (ini_entry->value == NULL && ini_entry->def->value == NULL) {
continue;
}
if (ini_entry->value != NULL && ini_entry->def->value != NULL && zend_string_equals_cstr(ini_entry->value, ini_entry->def->value, ini_entry->def->value_length)) {
continue;
}

zend_printf(
"%s: %s%s%s -> %s%s%s\n",
ZSTR_VAL(ini_entry->name),
ini_entry->def->value ? "\"" : "",
ini_entry->def->value ? ini_entry->def->value : "(none)",
ini_entry->def->value ? "\"" : "",
ini_entry->value ? "\"" : "",
ini_entry->value ? ZSTR_VAL(ini_entry->value) : "(none)",
ini_entry->value ? "\"" : ""
);
} ZEND_HASH_FOREACH_END();
zend_array_destroy(sorted);
break;
}
}
Expand Down
Loading