mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/11183] Remove $load_extensions and weird dl() calls
PHPBB3-11183
This commit is contained in:
parent
957508c8b1
commit
195014867a
8 changed files with 23 additions and 125 deletions
|
@ -67,18 +67,6 @@ if (!defined('PHPBB_INSTALLED'))
|
|||
exit;
|
||||
}
|
||||
|
||||
// Load Extensions
|
||||
// dl() is deprecated and disabled by default as of PHP 5.3.
|
||||
if (!empty($load_extensions) && function_exists('dl'))
|
||||
{
|
||||
$load_extensions = explode(',', $load_extensions);
|
||||
|
||||
foreach ($load_extensions as $extension)
|
||||
{
|
||||
@dl(trim($extension));
|
||||
}
|
||||
}
|
||||
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
|
||||
|
|
|
@ -57,19 +57,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha
|
|||
|
||||
static public function is_available()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
if (@extension_loaded('gd'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!function_exists('can_load_dll'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
|
||||
}
|
||||
|
||||
return can_load_dll('gd');
|
||||
return @extension_loaded('gd');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,19 +46,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha
|
|||
|
||||
static public function is_available()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
if (@extension_loaded('gd'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!function_exists('can_load_dll'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
|
||||
}
|
||||
|
||||
return can_load_dll('gd');
|
||||
return @extension_loaded('gd');
|
||||
}
|
||||
|
||||
static public function get_name()
|
||||
|
|
|
@ -15,27 +15,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we are able to load a specified PHP module and do so if possible
|
||||
*/
|
||||
function can_load_dll($dll)
|
||||
{
|
||||
// SQLite2 is a tricky thing, from 5.0.0 it requires PDO; if PDO is not loaded we must state that SQLite is unavailable
|
||||
// as the installer doesn't understand that the extension has a prerequisite.
|
||||
//
|
||||
// On top of this sometimes the SQLite extension is compiled for a different version of PDO
|
||||
// by some Linux distributions which causes phpBB to bomb out with a blank page.
|
||||
//
|
||||
// Net result we'll disable automatic inclusion of SQLite support
|
||||
//
|
||||
// See: r9618 and #56105
|
||||
if ($dll == 'sqlite')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && function_exists('dl') && @dl($dll . '.' . PHP_SHLIB_SUFFIX)) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of available DBMS with some data, if a DBMS is specified it will only
|
||||
* return data for that DBMS and will load its extension if necessary.
|
||||
|
@ -159,18 +138,15 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
|
||||
if (!@extension_loaded($dll))
|
||||
{
|
||||
if (!can_load_dll($dll))
|
||||
if ($return_unavailable)
|
||||
{
|
||||
if ($return_unavailable)
|
||||
{
|
||||
$available_dbms[$db_name]['AVAILABLE'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($available_dbms[$db_name]);
|
||||
}
|
||||
continue;
|
||||
$available_dbms[$db_name]['AVAILABLE'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($available_dbms[$db_name]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$any_db_support = true;
|
||||
}
|
||||
|
@ -520,17 +496,14 @@ function adjust_language_keys_callback($matches)
|
|||
*
|
||||
* @param array $data Array containing the database connection information
|
||||
* @param string $dbms The name of the DBAL class to use
|
||||
* @param array $load_extensions Array of additional extensions that should be loaded
|
||||
* @param bool $debug If the debug constants should be enabled by default or not
|
||||
* @param bool $debug_test If the DEBUG_TEST constant should be added
|
||||
* NOTE: Only for use within the testing framework
|
||||
*
|
||||
* @return string The output to write to the file
|
||||
*/
|
||||
function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false, $debug_test = false)
|
||||
function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test = false)
|
||||
{
|
||||
$load_extensions = implode(',', $load_extensions);
|
||||
|
||||
$config_data = "<?php\n";
|
||||
$config_data .= "// phpBB 3.1.x auto-generated configuration file\n// Do not change anything in this file!\n";
|
||||
|
||||
|
@ -543,7 +516,6 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug =
|
|||
'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']),
|
||||
'table_prefix' => $data['table_prefix'],
|
||||
'acm_type' => 'phpbb_cache_driver_file',
|
||||
'load_extensions' => $load_extensions,
|
||||
);
|
||||
|
||||
foreach ($config_data_array as $key => $value)
|
||||
|
|
|
@ -476,7 +476,6 @@ class phpbb_questionnaire_phpbb_data_provider
|
|||
|
||||
$result['dbms'] = $dbms;
|
||||
$result['acm_type'] = $acm_type;
|
||||
$result['load_extensions'] = $load_extensions;
|
||||
$result['user_agent'] = 'Unknown';
|
||||
$result['dbms_version'] = $db->sql_server_info(true);
|
||||
|
||||
|
|
|
@ -73,17 +73,6 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type))
|
|||
die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update.");
|
||||
}
|
||||
|
||||
// Load Extensions
|
||||
if (!empty($load_extensions) && function_exists('dl'))
|
||||
{
|
||||
$load_extensions = explode(',', $load_extensions);
|
||||
|
||||
foreach ($load_extensions as $extension)
|
||||
{
|
||||
@dl(trim($extension));
|
||||
}
|
||||
}
|
||||
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
|
||||
|
@ -2716,10 +2705,10 @@ function change_database_data(&$no_updates, $version)
|
|||
|
||||
// Create config value for displaying last subject on forum list
|
||||
if (!isset($config['display_last_subject']))
|
||||
{
|
||||
{
|
||||
$config->set('display_last_subject', '1');
|
||||
}
|
||||
|
||||
|
||||
$no_updates = false;
|
||||
|
||||
if (!isset($config['assets_version']))
|
||||
|
@ -2752,7 +2741,7 @@ function change_database_data(&$no_updates, $version)
|
|||
// After we have calculated the timezones we can delete user_dst column from user table.
|
||||
$db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
|
||||
}
|
||||
|
||||
|
||||
if (!isset($config['site_home_url']))
|
||||
{
|
||||
$config->set('site_home_url', '');
|
||||
|
|
|
@ -271,14 +271,6 @@ class install_install extends module
|
|||
'S_LEGEND' => false,
|
||||
));
|
||||
|
||||
/**
|
||||
* Better not enabling and adding to the loaded extensions due to the specific requirements needed
|
||||
if (!@extension_loaded('mbstring'))
|
||||
{
|
||||
can_load_dll('mbstring');
|
||||
}
|
||||
*/
|
||||
|
||||
$passed['mbstring'] = true;
|
||||
if (@extension_loaded('mbstring'))
|
||||
{
|
||||
|
@ -382,17 +374,14 @@ class install_install extends module
|
|||
{
|
||||
if (!@extension_loaded($dll))
|
||||
{
|
||||
if (!can_load_dll($dll))
|
||||
{
|
||||
$template->assign_block_vars('checks', array(
|
||||
'TITLE' => $lang['DLL_' . strtoupper($dll)],
|
||||
'RESULT' => '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>',
|
||||
$template->assign_block_vars('checks', array(
|
||||
'TITLE' => $lang['DLL_' . strtoupper($dll)],
|
||||
'RESULT' => '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>',
|
||||
|
||||
'S_EXPLAIN' => false,
|
||||
'S_LEGEND' => false,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
'S_EXPLAIN' => false,
|
||||
'S_LEGEND' => false,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('checks', array(
|
||||
|
@ -873,22 +862,7 @@ class install_install extends module
|
|||
$written = false;
|
||||
|
||||
// Create a list of any PHP modules we wish to have loaded
|
||||
$load_extensions = array();
|
||||
$available_dbms = get_available_dbms($data['dbms']);
|
||||
$check_exts = array_merge(array($available_dbms[$data['dbms']]['MODULE']), $this->php_dlls_other);
|
||||
|
||||
foreach ($check_exts as $dll)
|
||||
{
|
||||
if (!@extension_loaded($dll))
|
||||
{
|
||||
if (!can_load_dll($dll))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$load_extensions[] = $dll . '.' . PHP_SHLIB_SUFFIX;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a lock file to indicate that there is an install in progress
|
||||
$fp = @fopen($phpbb_root_path . 'cache/install_lock', 'wb');
|
||||
|
@ -902,7 +876,7 @@ class install_install extends module
|
|||
@chmod($phpbb_root_path . 'cache/install_lock', 0777);
|
||||
|
||||
// Time to convert the data provided into a config file
|
||||
$config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER'], $load_extensions);
|
||||
$config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER']);
|
||||
|
||||
// Attempt to write out the config file directly. If it works, this is the easiest way to do it ...
|
||||
if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path))
|
||||
|
@ -1368,7 +1342,7 @@ class install_install extends module
|
|||
WHERE config_name = 'dbms_version'",
|
||||
);
|
||||
|
||||
if (@extension_loaded('gd') || can_load_dll('gd'))
|
||||
if (@extension_loaded('gd'))
|
||||
{
|
||||
$sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
|
||||
SET config_value = 'phpbb_captcha_gd'
|
||||
|
|
|
@ -199,7 +199,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
$this->do_request('create_table', $data);
|
||||
|
||||
$this->do_request('config_file', $data);
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true));
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], true, true));
|
||||
|
||||
$this->do_request('final', $data);
|
||||
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
|
||||
|
|
Loading…
Add table
Reference in a new issue