1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/16345] Small improvements

PHPBB3-16346
This commit is contained in:
rubencm
2020-06-07 02:15:35 +00:00
parent 3cceeb45bf
commit 774c609c4a
284 changed files with 1380 additions and 835 deletions

View File

@@ -33,6 +33,8 @@ class bbcode
var $template_bitfield;
protected $template_filename;
/**
* Constructor
*/
@@ -149,7 +151,7 @@ class bbcode
*/
function bbcode_cache_init()
{
global $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_container, $phpbb_filesystem;
global $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_container;
if (empty($this->template_filename))
{
@@ -702,4 +704,5 @@ class bbcode
return $return;
}
}

View File

@@ -61,7 +61,7 @@ define('ACL_YES', 1);
define('ACL_NO', -1);
// Login error codes
define('LOGIN_CONTINUE', 1);
//define('LOGIN_CONTINUE', 1);
define('LOGIN_BREAK', 2);
define('LOGIN_SUCCESS', 3);
define('LOGIN_SUCCESS_CREATE_PROFILE', 20);
@@ -122,8 +122,8 @@ define('POST_ANNOUNCE', 2);
define('POST_GLOBAL', 3);
// Lastread types
define('TRACK_NORMAL', 0);
define('TRACK_POSTED', 1);
//define('TRACK_NORMAL', 0);
//define('TRACK_POSTED', 1);
// Notify methods
define('NOTIFY_EMAIL', 0);

View File

@@ -915,7 +915,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
/**
* Get topic tracking info by using already fetched info
*/
function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $global_announce_list = false)
function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time)
{
global $user;
@@ -959,7 +959,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
/**
* Get topic tracking info from db (for cookie based tracking only this function is used)
*/
function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false)
function get_complete_topic_tracking($forum_id, $topic_ids)
{
global $config, $user, $request;
@@ -3216,8 +3216,6 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
*/
function phpbb_filter_root_path($errfile)
{
global $phpbb_filesystem;
static $root_path;
if (empty($root_path))
@@ -4098,25 +4096,6 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
return;
}
/**
* Check and display the SQL report if requested.
*
* @param \phpbb\request\request_interface $request Request object
* @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\db\driver\driver_interface $db Database connection
*
* @deprecated 3.3.1 (To be removed: 4.0.0-a1); use controller helper's display_sql_report()
*/
function phpbb_check_and_display_sql_report(\phpbb\request\request_interface $request, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db)
{
global $phpbb_container;
/** @var \phpbb\controller\helper $controller_helper */
$controller_helper = $phpbb_container->get('controller.helper');
$controller_helper->display_sql_report();
}
/**
* Generate the debug output string
*
@@ -4316,19 +4295,6 @@ function exit_handler()
exit;
}
/**
* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float)
*
* @param string $input A numeric string.
*
* @return int|float Integer $input if $input fits integer,
* float $input otherwise.
*/
function phpbb_to_numeric($input)
{
return ($input > PHP_INT_MAX) ? (float) $input : (int) $input;
}
/**
* Get the board contact details (e.g. for emails)
*

View File

@@ -707,6 +707,7 @@ function validate_range($value_ary, &$error)
/**
* Inserts new config display_vars into an exisiting display_vars array
* at the given position.
* Used by extensions.
*
* @param array $display_vars An array of existing config display vars
* @param array $add_config_vars An array of new config display vars

View File

@@ -978,7 +978,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
}
$approved_posts = 0;
$post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array();
$post_ids = $poster_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array();
$sql = 'SELECT post_id, poster_id, post_visibility, post_postcount, topic_id, forum_id
FROM ' . POSTS_TABLE . '
@@ -1518,7 +1518,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// $post_reported should be empty by now, if it's not it contains
// posts that are falsely flagged as reported
foreach ($post_reported as $post_id => $void)
foreach (array_keys($post_reported) as $post_id)
{
$post_ids[] = $post_id;
}
@@ -1623,7 +1623,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// $post_attachment should be empty by now, if it's not it contains
// posts that are falsely flagged as having attachments
foreach ($post_attachment as $post_id => $void)
foreach (array_keys($post_attachment) as $post_id)
{
$post_ids[] = $post_id;
}
@@ -1696,7 +1696,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$where_sql";
$result = $db->sql_query($sql);
$forum_data = $forum_ids = $post_ids = $last_post_id = $post_info = array();
$forum_data = $forum_ids = $post_ids = $post_info = array();
while ($row = $db->sql_fetchrow($result))
{
if ($row['forum_type'] == FORUM_LINK)
@@ -2031,7 +2031,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
if (count($delete_topics))
{
$delete_topic_ids = array();
foreach ($delete_topics as $topic_id => $void)
foreach (array_keys($delete_topics) as $topic_id)
{
unset($topic_data[$topic_id]);
$delete_topic_ids[] = $topic_id;
@@ -2605,7 +2605,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
* @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids)
* @param int $topic_id Restrict the log entries to the given topic_id
* @param int $user_id Restrict the log entries to the given user_id
* @param int $log_time Only get log entries newer than the given timestamp
* @param int $limit_days Only get log entries newer than the given timestamp
* @param string $sort_by SQL order option, e.g. 'l.log_time DESC'
* @param string $keywords Will only return log entries that have the keywords in log_operation or log_data
*

View File

@@ -847,3 +847,37 @@ function phpbb_delete_user_pms($user_id)
return phpbb_delete_users_pms(array($user_id));
}
/**
* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float)
*
* @param string $input A numeric string.
*
* @return int|float Integer $input if $input fits integer,
* float $input otherwise.
*
* @deprecated 3.2.10 (To be removed 4.0.0)
*/
function phpbb_to_numeric($input)
{
return ($input > PHP_INT_MAX) ? (float) $input : (int) $input;
}
/**
* Check and display the SQL report if requested.
*
* @param \phpbb\request\request_interface $request Request object
* @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\db\driver\driver_interface $db Database connection
*
* @deprecated 3.3.1 (To be removed: 4.0.0-a1); use controller helper's display_sql_report()
*/
function phpbb_check_and_display_sql_report(\phpbb\request\request_interface $request, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db)
{
global $phpbb_container;
/** @var \phpbb\controller\helper $controller_helper */
$controller_helper = $phpbb_container->get('controller.helper');
$controller_helper->display_sql_report();
}

View File

@@ -320,7 +320,7 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po
* Generates a text with approx. the specified length which contains the specified words and their context
*
* @param string $text The full text from which context shall be extracted
* @param string $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
* @param array $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
* @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value
*
* @return string Context of the specified words separated by "..."
@@ -845,7 +845,6 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class
$relative_url = substr($relative_url, 0, $split);
}
}
// if the last character of the url is a punctuation mark, exclude it from the url
$last_char = ($relative_url) ? $relative_url[strlen($relative_url) - 1] : $url[strlen($url) - 1];
@@ -1344,7 +1343,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $message, $matches, PREG_PATTERN_ORDER);
$replace = array();
foreach ($matches[0] as $num => $capture)
foreach (array_keys($matches[0]) as $num)
{
$index = $matches[1][$num];

View File

@@ -767,7 +767,7 @@ function generate_forum_nav(&$forum_data_ary)
return;
}
$navlinks_parents = $forum_template_data = array();
$navlinks_parents = array();
// Get forum parents
$forum_parents = get_forum_parents($forum_data_ary);

View File

@@ -535,7 +535,6 @@ function phpbb_mcp_sorting($mode, &$sort_days_val, &$sort_key_val, &$sort_dir_va
$sort_key_val = $request->variable('sk', $default_key);
$sort_dir_val = $request->variable('sd', $default_dir);
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
switch ($type)
{
@@ -684,7 +683,7 @@ function phpbb_mcp_sorting($mode, &$sort_days_val, &$sort_key_val, &$sort_dir_va
* @param string $table The table to find the ids in
* @param string $sql_id The ids relevant column name
* @param array $acl_list A list of permissions the user need to have
* @param mixed $singe_forum Limit to one forum id (int) or the first forum found (true)
* @param mixed $single_forum Limit to one forum id (int) or the first forum found (true)
*
* @return mixed False if no ids were able to be retrieved, true if at least one id left.
* Additionally, this value can be the forum_id assigned if $single_forum was set.

View File

@@ -327,7 +327,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
{
$empty_forums = array_merge($empty_forums, array_diff($ids, $not_empty_forums));
foreach ($empty_forums as $void => $forum_id)
foreach ($empty_forums as $forum_id)
{
$update_sql[$forum_id][] = 'forum_last_post_id = 0';
$update_sql[$forum_id][] = "forum_last_post_subject = ''";
@@ -838,7 +838,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms
global $user, $db, $template, $auth;
global $phpbb_root_path, $phpbb_dispatcher, $phpEx;
$topic_ids = $forum_ids = $draft_rows = array();
$topic_ids = $draft_rows = array();
// Load those drafts not connected to forums/topics
// If forum_id == 0 AND topic_id == 0 then this is a PM draft
@@ -1619,7 +1619,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
$data_ary['topic_title'] = truncate_string($data_ary['topic_title'], 120);
// Collect some basic information about which tables and which rows to update/insert
$sql_data = $topic_row = array();
$sql_data = array();
$poster_id = ($mode == 'edit') ? $data_ary['poster_id'] : (int) $user->data['user_id'];
// Retrieve some additional information if not present
@@ -2098,7 +2098,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
$space_taken = $files_added = 0;
$orphan_rows = array();
foreach ($data_ary['attachment_data'] as $pos => $attach_row)
foreach ($data_ary['attachment_data'] as $attach_row)
{
$orphan_rows[(int) $attach_row['attach_id']] = array();
}
@@ -2120,7 +2120,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
$db->sql_freeresult($result);
}
foreach ($data_ary['attachment_data'] as $pos => $attach_row)
foreach ($data_ary['attachment_data'] as $attach_row)
{
if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']]))
{

View File

@@ -455,7 +455,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
}
else
{
$user_rules = $zebra = $check_rows = array();
$zebra = $check_rows = array();
$user_ids = $memberships = array();
// First of all, grab all rules and retrieve friends/foes
@@ -551,7 +551,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
// It is allowed to execute actions more than once, except placing messages into folder
$folder_action = $message_removed = false;
foreach ($msg_ary as $pos => $rule_ary)
foreach ($msg_ary as $rule_ary)
{
if ($folder_action && $rule_ary['action'] == ACTION_PLACE_INTO_FOLDER)
{
@@ -1598,7 +1598,7 @@ function get_folder_status($folder_id, $folder)
*/
function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
{
global $db, $auth, $config, $user, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $request;
global $db, $auth, $config, $user, $phpbb_container, $phpbb_dispatcher, $request;
$attachment_storage = $phpbb_container->get('storage.attachment');
@@ -1827,7 +1827,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
$space_taken = $files_added = 0;
$orphan_rows = array();
foreach ($data_ary['attachment_data'] as $pos => $attach_row)
foreach ($data_ary['attachment_data'] as $attach_row)
{
$orphan_rows[(int) $attach_row['attach_id']] = array();
}
@@ -1850,7 +1850,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
$db->sql_freeresult($result);
}
foreach ($data_ary['attachment_data'] as $pos => $attach_row)
foreach ($data_ary['attachment_data'] as $attach_row)
{
if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']]))
{

View File

@@ -180,7 +180,7 @@ function user_update_name($old_name, $new_name)
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.
* @param array $cp_data custom profile fields, see custom_profile::build_insert_sql_array
* @param array $notifications_data The notifications settings for the new user
* @return the new user's ID.
* @return int The new user's ID.
*/
function user_add($user_row, $cp_data = false, $notifications_data = null)
{
@@ -1610,7 +1610,8 @@ function validate_num($num, $optional = false, $min = 0, $max = 1E99)
/**
* Validate Date
* @param String $string a date in the dd-mm-yyyy format
* @param string $date_string a date in the dd-mm-yyyy format
* @param bool $optional
* @return boolean
*/
function validate_date($date_string, $optional = false)
@@ -1646,7 +1647,6 @@ function validate_date($date_string, $optional = false)
return false;
}
/**
* Validate Match
*
@@ -2216,7 +2216,7 @@ function phpbb_style_is_active($style_id)
*/
function avatar_delete($mode, $row, $clean_db = false)
{
global $config, $phpbb_container;
global $phpbb_container;
$storage = $phpbb_container->get('storage.avatar');
@@ -2576,7 +2576,7 @@ function group_correct_avatar($group_id, $old_entry)
try
{
$this->storage->rename($old_filename, $new_filename);
$storage->rename($old_filename, $new_filename);
$sql = 'UPDATE ' . GROUPS_TABLE . '
SET group_avatar = \'' . $db->sql_escape($new_entry) . "'

View File

@@ -29,8 +29,6 @@ if (version_compare(PHP_VERSION, '7.1.3', '<'))
{
die('You are running an unsupported PHP version. Please upgrade to PHP 7.1.3 or higher before trying to install or update to phpBB 3.3');
}
// Register globals and magic quotes have been dropped in PHP 5.4 so no need for extra checks
// In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems
// because we show E_WARNING errors and do not set a default timezone.