Skip to content

Commit

Permalink
Zend: support relative paths for extensions
Browse files Browse the repository at this point in the history
This would simplify greatly puppetization of Zend modules such as xdebug
in heterogeneous environments.

For example:
zend_extension="/usr/lib/php5/20090626/xdebug.so"
can become:
zend_extension=xdebug.so
  • Loading branch information
Pierre Carrier committed Aug 11, 2012
1 parent 66a6d1b commit aa52639
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Zend/zend_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/* $Id$ */

#include "zend_extensions.h"
#include "php.h"

ZEND_API zend_llist zend_extensions;
static int last_resource_number;
Expand All @@ -30,8 +31,28 @@ int zend_load_extension(const char *path)
DL_HANDLE handle;
zend_extension *new_extension;
zend_extension_version_info *extension_version_info;
char *normalized_path;
char *extension_dir = INI_STR("extension_dir");
int extension_dir_len = strlen(extension_dir);

if (strchr(path, '/') == NULL || strchr(path, DEFAULT_SLASH) == NULL) {
if (extension_dir && extension_dir[0]) {
if (IS_SLASH(extension_dir[extension_dir_len-1])) {
spprintf(&normalized_path, 0, "%s%s", extension_dir, path);
} else {
spprintf(&normalized_path, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, path);
}
} else {
return FAILURE;
}
} else {
normalized_path = estrdup(path);
}

handle = DL_LOAD(normalized_path);

efree(normalized_path);

handle = DL_LOAD(path);
if (!handle) {
#ifndef ZEND_WIN32
fprintf(stderr, "Failed loading %s: %s\n", path, DL_ERROR());
Expand Down

0 comments on commit aa52639

Please sign in to comment.