Top Hosting Forum

WebHosting Reviews Forum


preg_replace(): The /e modifier is deprecated ucp_register.p

PHPBB forum script Discussion. PHPBB Questions, Troubleshooting, Errors, Mods and so on..
Hosting Forum Description
PHPBB forum script Discussion. PHPBB Questions, Troubleshooting, Errors, Mods and so on..

preg_replace(): The /e modifier is deprecated ucp_register.p

Postby hostingforum » Thu Aug 01, 2024 6:16 pm

[STDERR] PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in includes/ucp/ucp_register.php on line 199\n

It happens on the registration form or during its submission.

replace on line 199:
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);

by:
$error = preg_replace_callback(
'#^([A-Z_]+)$#',
function ($matches) use ($user) {
return !empty($user->lang[$matches[1]]) ? $user->lang[$matches[1]] : $matches[1];
},
$error
);

Then i could see another error:

[STDERR] PHP Strict Standards: Non-static method custom_profile::build_insert_sql_array() should not be called statically in includes/functions_user.php on line 263\n

on that line replaced:
$db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));

by:
$customProfileInstance = new custom_profile();
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' .
$db->sql_build_array('INSERT', $customProfileInstance->build_insert_sql_array($cp_data));

BUT!:
later I have found an error with that replacement above, when i have tried to submit registration form with a custom (antispam field)
It apparently have been solved by inserting:
// Insert Custom Profile Fields
if ($cp_data !== false && sizeof($cp_data)) {
$cp_data['user_id'] = (int) $user_id;

if (!class_exists('custom_profile')) {
include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
}

$customProfileInstance = new custom_profile();
$insertData = $customProfileInstance->build_insert_sql_array($cp_data);

if ($insertData !== false && is_array($insertData)) {
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $insertData);
} else {
throw new Exception("Failed to build insert SQL array.");
}


between the line:
$user_id = $db->sql_nextid();

and:
$db->sql_query($sql);

(meaning do not replace these lines, but replace the code between that two lines)


Later there one more error in same file:

PHP Strict Standards: Non-static method custom_profile::build_insert_sql_array() should not be called statically in /includes/functions_user.php on line 277\n

This is untested, but possibly replace:
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' .
$db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));

by:
$customProfileInstance = new custom_profile();
$sqlArray = $db->sql_build_array('INSERT', $customProfileInstance->build_insert_sql_array($cp_data));
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $sqlArray;

it no longer producing an error on user registration submission



hostingforum
Site Admin
 
Posts: 673
Joined: Fri May 20, 2011 7:58 pm

Return to PHPBB

Who is online

Users browsing this forum: No registered users and 0 guests

.