mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-30 11:11:23 +02:00
Merge pull request #5812 from rxu/ticket/16288
[ticket/16288] PHP 8 compatibility
This commit is contained in:
commit
1b7c42bf53
@ -22,6 +22,7 @@ if (!defined('IN_PHPBB'))
|
||||
class acp_main
|
||||
{
|
||||
var $u_action;
|
||||
private $php_ini;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
@ -684,14 +685,19 @@ class acp_main
|
||||
$template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002));
|
||||
}
|
||||
|
||||
$this->php_ini = $phpbb_container->get('php_ini');
|
||||
$func_overload = $this->php_ini->getNumeric('mbstring.func_overload');
|
||||
$encoding_translation = $this->php_ini->getString('mbstring.encoding_translation');
|
||||
$http_input = $this->php_ini->getString('mbstring.http_input');
|
||||
$http_output = $this->php_ini->getString('mbstring.http_output');
|
||||
if (extension_loaded('mbstring'))
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_MBSTRING_LOADED' => true,
|
||||
'S_MBSTRING_FUNC_OVERLOAD_FAIL' => (intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)),
|
||||
'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => (@ini_get('mbstring.encoding_translation') != 0),
|
||||
'S_MBSTRING_HTTP_INPUT_FAIL' => !in_array(@ini_get('mbstring.http_input'), array('pass', '')),
|
||||
'S_MBSTRING_HTTP_OUTPUT_FAIL' => !in_array(@ini_get('mbstring.http_output'), array('pass', '')),
|
||||
'S_MBSTRING_FUNC_OVERLOAD_FAIL' => $func_overload && ($func_overload & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)),
|
||||
'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => $encoding_translation && ($encoding_translation != 0),
|
||||
'S_MBSTRING_HTTP_INPUT_FAIL' => $http_input && !in_array($http_input, array('pass', '')),
|
||||
'S_MBSTRING_HTTP_OUTPUT_FAIL' => $http_output && !in_array($http_output, array('pass', '')),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ class ucp_pm
|
||||
|
||||
$template->assign_vars(array(
|
||||
'CUR_FOLDER_ID' => $folder_id,
|
||||
'CUR_FOLDER_NAME' => $folder_status['folder_name'],
|
||||
'CUR_FOLDER_NAME' => $folder_status ? $folder_status['folder_name'] : false,
|
||||
'NUM_NOT_MOVED' => $num_not_moved,
|
||||
'NUM_REMOVED' => $num_removed,
|
||||
'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '<a href="' . $this->u_action . '&folder=' . $folder_id . '&release=1">', '</a>'),
|
||||
@ -384,12 +384,12 @@ class ucp_pm
|
||||
'S_IN_OUTBOX' => ($folder_id == PRIVMSGS_OUTBOX) ? true : false,
|
||||
'S_IN_SENTBOX' => ($folder_id == PRIVMSGS_SENTBOX) ? true : false,
|
||||
|
||||
'FOLDER_STATUS' => $folder_status['message'],
|
||||
'FOLDER_MAX_MESSAGES' => $folder_status['max'],
|
||||
'FOLDER_CUR_MESSAGES' => $folder_status['cur'],
|
||||
'FOLDER_REMAINING_MESSAGES' => $folder_status['remaining'],
|
||||
'FOLDER_PERCENT' => $folder_status['percent'])
|
||||
);
|
||||
'FOLDER_STATUS' => $folder_status ? $folder_status['message'] : false,
|
||||
'FOLDER_MAX_MESSAGES' => $folder_status ? $folder_status['max'] : false,
|
||||
'FOLDER_CUR_MESSAGES' => $folder_status ? $folder_status['cur'] : false,
|
||||
'FOLDER_REMAINING_MESSAGES' => $folder_status ? $folder_status['remaining'] : false,
|
||||
'FOLDER_PERCENT' => $folder_status ? $folder_status['percent'] : false,
|
||||
));
|
||||
|
||||
if ($action == 'view_folder')
|
||||
{
|
||||
@ -405,7 +405,7 @@ class ucp_pm
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_VIEW_MESSAGE' => true,
|
||||
'L_RETURN_TO_FOLDER' => $user->lang('RETURN_TO', $folder_status['folder_name']),
|
||||
'L_RETURN_TO_FOLDER' => $user->lang('RETURN_TO', $folder_status ? $folder_status['folder_name'] : ''),
|
||||
'MSG_ID' => $msg_id,
|
||||
));
|
||||
|
||||
|
@ -405,7 +405,7 @@ class fulltext_native extends \phpbb\search\base
|
||||
}
|
||||
|
||||
// a group of words of which at least one word should be in every resulting post
|
||||
if ($word[0] == '(')
|
||||
if (isset($word[0]) && $word[0] == '(')
|
||||
{
|
||||
$word = array_unique(explode('|', substr($word, 1, -1)));
|
||||
}
|
||||
|
@ -384,7 +384,9 @@ class context
|
||||
if (is_array($key))
|
||||
{
|
||||
// Search array to get correct position
|
||||
list($search_key, $search_value) = @each($key);
|
||||
$search_key = key($key);
|
||||
$search_value = current($key);
|
||||
|
||||
foreach ($block as $i => $val_ary)
|
||||
{
|
||||
if ($val_ary[$search_key] === $search_value)
|
||||
@ -481,7 +483,8 @@ class context
|
||||
if (is_array($key))
|
||||
{
|
||||
// Search array to get correct position
|
||||
list($search_key, $search_value) = @each($key);
|
||||
$search_key = key($key);
|
||||
$search_value = current($key);
|
||||
|
||||
$key = null;
|
||||
foreach ($block as $i => $val_ary)
|
||||
|
@ -850,10 +850,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
|
||||
$this->set_flood_interval(0);
|
||||
|
||||
$this->login('disapprove_user');
|
||||
$post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
|
||||
$this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id'];
|
||||
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}");
|
||||
$this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
|
||||
|
||||
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}");
|
||||
self::assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text());
|
||||
|
||||
$this->logout();
|
||||
@ -1240,6 +1239,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
|
||||
'posts' => array(
|
||||
'Feeds #1 - Topic #3',
|
||||
),
|
||||
'attachments' => array(),
|
||||
));
|
||||
|
||||
$this->add_lang('viewtopic');
|
||||
|
@ -226,7 +226,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c
|
||||
|
||||
$link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
|
||||
$link_url = $link->getUri();
|
||||
$this->assertContains('viewtopic.php?f=' . $this->data['topic']['Reapprove Test Topic #2'], $link_url);
|
||||
$this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'], $link_url);
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}");
|
||||
$this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text());
|
||||
|
@ -193,6 +193,8 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
|
||||
*/
|
||||
public function test_first_last_post_info($mode, $retain_username, $expected_posts, $expected_topics, $expected_forums)
|
||||
{
|
||||
global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
|
||||
$this->assertFalse(user_delete($mode, 2, $retain_username));
|
||||
|
||||
$sql = 'SELECT post_id, poster_id, post_username
|
||||
|
@ -21,6 +21,11 @@ class phpbb_mock_fileupload
|
||||
public $error_prefix = '';
|
||||
public $valid_dimensions = true;
|
||||
|
||||
public $min_width = 0;
|
||||
public $min_height = 0;
|
||||
public $max_width = 0;
|
||||
public $max_height = 0;
|
||||
|
||||
public function valid_dimensions($filespec)
|
||||
{
|
||||
return $this->valid_dimensions;
|
||||
|
@ -21,6 +21,7 @@
|
||||
class phpbb_mock_session_testable extends \phpbb\session
|
||||
{
|
||||
private $_cookies = array();
|
||||
public $lang = [];
|
||||
|
||||
public function set_cookie($name, $data, $time, $httponly = true)
|
||||
{
|
||||
|
@ -21,6 +21,8 @@ class phpbb_mock_user
|
||||
{
|
||||
public $host = "testhost";
|
||||
public $page = array('root_script_path' => '/');
|
||||
public $style = [];
|
||||
public $data = [];
|
||||
|
||||
private $options = array();
|
||||
public function optionget($item)
|
||||
|
@ -100,13 +100,6 @@ class phpbb_path_helper_test extends phpbb_test_case
|
||||
null,
|
||||
'',
|
||||
),
|
||||
array(
|
||||
$this->phpbb_root_path . 'test.php',
|
||||
'//',
|
||||
null,
|
||||
null,
|
||||
'./../',
|
||||
),
|
||||
array(
|
||||
$this->phpbb_root_path . 'test.php',
|
||||
'//',
|
||||
@ -137,13 +130,6 @@ class phpbb_path_helper_test extends phpbb_test_case
|
||||
),
|
||||
|
||||
// No correction if the path is already prepend by the web root path
|
||||
array(
|
||||
'./../' . $this->phpbb_root_path . 'test.php',
|
||||
'//',
|
||||
null,
|
||||
null,
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'./../' . $this->phpbb_root_path . 'test.php',
|
||||
'//',
|
||||
|
@ -110,7 +110,7 @@ class phpbb_request_var_test extends phpbb_test_case
|
||||
);
|
||||
|
||||
$result = request_var($path, $default);
|
||||
$this->assertEquals($expected, $result, 'Testing deep access to multidimensional input arrays: ' . $path);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function deep_access()
|
||||
|
@ -200,6 +200,9 @@ abstract class phpbb_search_common_test_case extends phpbb_search_test_case
|
||||
$this->assertEquals($ok, $rv);
|
||||
if ($ok)
|
||||
{
|
||||
// If there are valid keywords, search->split_keywords perfoms array sort
|
||||
sort($split_words);
|
||||
|
||||
// only check criteria if the search is going to be performed
|
||||
$this->assert_array_content_equals($split_words, $this->search->get_split_words());
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
|
||||
'foo foo-',
|
||||
'all',
|
||||
true,
|
||||
array(1),
|
||||
array(1, 1),
|
||||
array(),
|
||||
array(),
|
||||
),
|
||||
@ -203,7 +203,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
|
||||
'foo- foo',
|
||||
'all',
|
||||
true,
|
||||
array(1),
|
||||
array(1, 1),
|
||||
array(),
|
||||
array(),
|
||||
),
|
||||
@ -219,7 +219,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
|
||||
'foo-bar-foo',
|
||||
'all',
|
||||
true,
|
||||
array(1, 2),
|
||||
array(1, 2, 1),
|
||||
array(),
|
||||
array(),
|
||||
),
|
||||
|
@ -52,7 +52,6 @@ abstract class phpbb_security_test_base extends phpbb_test_case
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
$user->lang = true;
|
||||
$user->browser = $this->server['HTTP_USER_AGENT'];
|
||||
$user->referer = '';
|
||||
$user->forwarded_for = '';
|
||||
|
@ -60,6 +60,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
||||
|
||||
protected function get_path_helper()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
if (!($this->path_helper instanceof \phpbb\path_helper))
|
||||
{
|
||||
$this->path_helper = new \phpbb\path_helper(
|
||||
@ -68,7 +70,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
||||
),
|
||||
new \phpbb\filesystem\filesystem(),
|
||||
$this->createMock('\phpbb\request\request'),
|
||||
$this->phpbb_root_path,
|
||||
$phpbb_root_path,
|
||||
'php'
|
||||
);
|
||||
}
|
||||
@ -109,7 +111,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
||||
|
||||
if ($expected_error !== false)
|
||||
{
|
||||
$this->setExpectedTriggerError(E_USER_WARNING, $user->lang[$expected_error]);
|
||||
$this->setExpectedTriggerError(E_USER_WARNING, $expected_error);
|
||||
}
|
||||
|
||||
$result = redirect($test, true, $disable_cd_check);
|
||||
|
@ -23,6 +23,12 @@
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>13</value>
|
||||
<value>bot</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_sessions">
|
||||
<column>session_id</column>
|
||||
|
@ -29,11 +29,20 @@
|
||||
<column>username_clean</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<row>
|
||||
<column>user_type</column>
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>bar</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>anonymous</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
||||
|
@ -304,11 +304,45 @@ abstract class phpbb_database_test_case extends TestCase
|
||||
return new phpbb_database_test_connection_manager($config);
|
||||
}
|
||||
|
||||
/** array_diff() does not corretly compare multidimensionsl arrays
|
||||
* This solution used for that https://www.codeproject.com/Questions/780780/PHP-Finding-differences-in-two-multidimensional-ar
|
||||
*/
|
||||
function array_diff_assoc_recursive($array1, $array2)
|
||||
{
|
||||
$difference = array();
|
||||
foreach ($array1 as $key => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
if (!isset($array2[$key]))
|
||||
{
|
||||
$difference[$key] = $value;
|
||||
}
|
||||
else if (!is_array($array2[$key]))
|
||||
{
|
||||
$difference[$key] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_diff = $this->array_diff_assoc_recursive($value, $array2[$key]);
|
||||
if (!empty($new_diff))
|
||||
{
|
||||
$difference[$key] = $new_diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!isset($array2[$key]) || $array2[$key] != $value)
|
||||
{
|
||||
$difference[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $difference;
|
||||
}
|
||||
|
||||
public function assert_array_content_equals($one, $two)
|
||||
{
|
||||
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
|
||||
// but one array_diff is not enough!
|
||||
if (count(array_diff($one, $two)) || count(array_diff($two, $one)))
|
||||
// one-way comparison is not enough!
|
||||
if (count($this->array_diff_assoc_recursive($one, $two)) || count($this->array_diff_assoc_recursive($two, $one)))
|
||||
{
|
||||
// get a nice error message
|
||||
$this->assertEquals($one, $two);
|
||||
|
@ -710,7 +710,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
|
||||
protected function remove_user_group($group_name, $usernames)
|
||||
{
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $user, $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
$config['coppa_enable'] = 0;
|
||||
@ -747,7 +747,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
|
||||
protected function add_user_group($group_name, $usernames, $default = false, $leader = false)
|
||||
{
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $user, $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
$config['coppa_enable'] = 0;
|
||||
@ -869,6 +869,8 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
{
|
||||
$this->add_lang($file);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$lang_path = __DIR__ . "/../../phpBB/language/en/$lang_file.php";
|
||||
|
@ -203,6 +203,10 @@ class version_helper_remote_test extends \phpbb_test_case
|
||||
{
|
||||
$this->file_downloader->set($input);
|
||||
|
||||
// version_helper->get_versions() doesn't return a value on VERSIONCHECK_FAIL but only throws exception
|
||||
// so the $return is undefined. Define it here
|
||||
$return = false;
|
||||
|
||||
if (!$valid_data)
|
||||
{
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user