mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/12479] Remove deprecated functions
PHPBB-12479
This commit is contained in:
parent
1449706da9
commit
6395639345
6 changed files with 112 additions and 574 deletions
|
@ -19,196 +19,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash the password
|
||||
*
|
||||
* @deprecated 3.1.0-a2 (To be removed: 4.0.0)
|
||||
*
|
||||
* @param string $password Password to be hashed
|
||||
*
|
||||
* @return string|bool Password hash or false if something went wrong during hashing
|
||||
*/
|
||||
function phpbb_hash($password)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/* @var $passwords_manager \phpbb\passwords\manager */
|
||||
$passwords_manager = $phpbb_container->get('passwords.manager');
|
||||
return $passwords_manager->hash($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for correct password
|
||||
*
|
||||
* @deprecated 3.1.0-a2 (To be removed: 4.0.0)
|
||||
*
|
||||
* @param string $password The password in plain text
|
||||
* @param string $hash The stored password hash
|
||||
*
|
||||
* @return bool Returns true if the password is correct, false if not.
|
||||
*/
|
||||
function phpbb_check_hash($password, $hash)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/* @var $passwords_manager \phpbb\passwords\manager */
|
||||
$passwords_manager = $phpbb_container->get('passwords.manager');
|
||||
return $passwords_manager->check($password, $hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminates useless . and .. components from specified path.
|
||||
*
|
||||
* Deprecated, use storage helper class instead
|
||||
*
|
||||
* @param string $path Path to clean
|
||||
* @return string Cleaned path
|
||||
*
|
||||
* @deprecated 3.1.0 (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_clean_path($path)
|
||||
{
|
||||
return \phpbb\filesystem\helper::clean_path($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick a timezone
|
||||
*
|
||||
* @param string $default A timezone to select
|
||||
* @param boolean $truncate Shall we truncate the options text
|
||||
*
|
||||
* @return string Returns the options for timezone selector only
|
||||
*
|
||||
* @deprecated 3.1.0 (To be removed: 4.0.0)
|
||||
*/
|
||||
function tz_select($default = '', $truncate = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
return phpbb_timezone_select($user, $default, $truncate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache moderators. Called whenever permissions are changed
|
||||
* via admin_permissions. Changes of usernames and group names
|
||||
* must be carried through for the moderators table.
|
||||
*
|
||||
* @deprecated 3.1.0 (To be removed: 4.0.0)
|
||||
* @return void
|
||||
*/
|
||||
function cache_moderators()
|
||||
{
|
||||
global $db, $cache, $auth, $phpbb_container;
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes moderators and administrators from foe lists.
|
||||
*
|
||||
* @deprecated 3.1.0 (To be removed: 4.0.0)
|
||||
* @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore
|
||||
* @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore
|
||||
* @return void
|
||||
*/
|
||||
function update_foes($group_id = false, $user_id = false)
|
||||
{
|
||||
global $db, $auth;
|
||||
return phpbb_update_foes($db, $auth, $group_id, $user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user rank title and image
|
||||
*
|
||||
* @param int $user_rank the current stored users rank id
|
||||
* @param int $user_posts the users number of posts
|
||||
* @param string &$rank_title the rank title will be stored here after execution
|
||||
* @param string &$rank_img the rank image as full img tag is stored here after execution
|
||||
* @param string &$rank_img_src the rank image source is stored here after execution
|
||||
*
|
||||
* @deprecated 3.1.0-RC5 (To be removed: 4.0.0)
|
||||
*
|
||||
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
|
||||
*/
|
||||
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
if (!function_exists('phpbb_get_user_rank'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
$rank_data = phpbb_get_user_rank(array('user_rank' => $user_rank), $user_posts);
|
||||
$rank_title = $rank_data['title'];
|
||||
$rank_img = $rank_data['img'];
|
||||
$rank_img_src = $rank_data['img_src'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve contents from remotely stored file
|
||||
*
|
||||
* @deprecated 3.1.2 Use file_downloader instead
|
||||
*/
|
||||
function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
// Get file downloader and assign $errstr and $errno
|
||||
/* @var $file_downloader \phpbb\file_downloader */
|
||||
$file_downloader = $phpbb_container->get('file_downloader');
|
||||
|
||||
$file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout);
|
||||
$errstr = $file_downloader->get_error_string();
|
||||
$errno = $file_downloader->get_error_number();
|
||||
|
||||
return $file_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add log entry
|
||||
*
|
||||
* string $mode The mode defines which log_type is used and from which log the entry is retrieved
|
||||
* int $forum_id Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise
|
||||
* int $topic_id Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise
|
||||
* int $reportee_id Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise
|
||||
* string $log_operation Name of the operation
|
||||
* array $additional_data More arguments can be added, depending on the log_type
|
||||
*
|
||||
* @return int|bool Returns the log_id, if the entry was added to the database, false otherwise.
|
||||
*
|
||||
* @deprecated 3.1.0 (To be removed: 4.0.0)
|
||||
*/
|
||||
function add_log()
|
||||
{
|
||||
global $phpbb_log, $user;
|
||||
|
||||
$args = func_get_args();
|
||||
$mode = array_shift($args);
|
||||
|
||||
// This looks kind of dirty, but add_log has some additional data before the log_operation
|
||||
$additional_data = array();
|
||||
switch ($mode)
|
||||
{
|
||||
case 'admin':
|
||||
case 'critical':
|
||||
break;
|
||||
case 'mod':
|
||||
$additional_data['forum_id'] = array_shift($args);
|
||||
$additional_data['topic_id'] = array_shift($args);
|
||||
break;
|
||||
case 'user':
|
||||
$additional_data['reportee_id'] = array_shift($args);
|
||||
break;
|
||||
}
|
||||
|
||||
$log_operation = array_shift($args);
|
||||
$additional_data = array_merge($additional_data, $args);
|
||||
|
||||
$user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id'];
|
||||
$user_ip = (empty($user->ip)) ? '' : $user->ip;
|
||||
|
||||
return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration option's value.
|
||||
*
|
||||
|
@ -330,125 +140,6 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
|
|||
return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? \phpbb\request\request_interface::COOKIE : \phpbb\request\request_interface::REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tables of a database
|
||||
*
|
||||
* @deprecated 3.1.0 (To be removed: 4.0.0)
|
||||
*/
|
||||
function get_tables($db)
|
||||
{
|
||||
throw new BadFunctionCallException('function removed from phpBB core, use db_tools service instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Global function for chmodding directories and files for internal use
|
||||
*
|
||||
* This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions.
|
||||
* The function determines owner and group from common.php file and sets the same to the provided file.
|
||||
* The function uses bit fields to build the permissions.
|
||||
* The function sets the appropiate execute bit on directories.
|
||||
*
|
||||
* Supported constants representing bit fields are:
|
||||
*
|
||||
* CHMOD_ALL - all permissions (7)
|
||||
* CHMOD_READ - read permission (4)
|
||||
* CHMOD_WRITE - write permission (2)
|
||||
* CHMOD_EXECUTE - execute permission (1)
|
||||
*
|
||||
* NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions.
|
||||
*
|
||||
* @param string $filename The file/directory to be chmodded
|
||||
* @param int $perms Permissions to set
|
||||
*
|
||||
* @return bool true on success, otherwise false
|
||||
*
|
||||
* @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::phpbb_chmod() instead
|
||||
*/
|
||||
function phpbb_chmod($filename, $perms = CHMOD_READ)
|
||||
{
|
||||
global $phpbb_filesystem;
|
||||
|
||||
try
|
||||
{
|
||||
$phpbb_filesystem->phpbb_chmod($filename, $perms);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a file/directory is writable
|
||||
*
|
||||
* This function calls the native is_writable() when not running under
|
||||
* Windows and it is not disabled.
|
||||
*
|
||||
* @param string $file Path to perform write test on
|
||||
* @return bool True when the path is writable, otherwise false.
|
||||
*
|
||||
* @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::is_writable() instead
|
||||
*/
|
||||
function phpbb_is_writable($file)
|
||||
{
|
||||
global $phpbb_filesystem;
|
||||
|
||||
return $phpbb_filesystem->is_writable($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a path ($path) is absolute or relative
|
||||
*
|
||||
* @param string $path Path to check absoluteness of
|
||||
* @return boolean
|
||||
*
|
||||
* @deprecated 3.2.0-dev use \phpbb\filesystem\helper::is_absolute_path() instead
|
||||
*/
|
||||
function phpbb_is_absolute($path)
|
||||
{
|
||||
return \phpbb\filesystem\helper::is_absolute_path($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper for realpath
|
||||
*
|
||||
* @deprecated 3.2.0-dev use \phpbb\filesystem\helper::realpath() instead
|
||||
*/
|
||||
function phpbb_realpath($path)
|
||||
{
|
||||
return \phpbb\filesystem\helper::realpath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine which plural form we should use.
|
||||
* For some languages this is not as simple as for English.
|
||||
*
|
||||
* @param int $rule ID of the plural rule we want to use, see https://area51.phpbb.com/docs/dev/3.3.x/language/plurals.html
|
||||
* @param int|float $number The number we want to get the plural case for. Float numbers are floored.
|
||||
* @return int The plural-case we need to use for the number plural-rule combination
|
||||
*
|
||||
* @deprecated 3.2.0-dev (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_get_plural_form($rule, $number)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/** @var \phpbb\language\language $language */
|
||||
$language = $phpbb_container->get('language');
|
||||
return $language->get_plural_form($number, $rule);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Always true
|
||||
* @deprecated 3.2.0-dev
|
||||
*/
|
||||
function phpbb_pcre_utf8_support()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a variable to the given type.
|
||||
*
|
||||
|
@ -461,142 +152,6 @@ function set_var(&$result, $var, $type, $multibyte = false)
|
|||
$type_cast_helper->set_var($result, $var, $type, $multibyte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Attachments
|
||||
*
|
||||
* @deprecated 3.2.0-a1 (To be removed: 4.0.0)
|
||||
*
|
||||
* @param string $mode can be: post|message|topic|attach|user
|
||||
* @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids
|
||||
* @param bool $resync set this to false if you are deleting posts or topics
|
||||
*/
|
||||
function delete_attachments($mode, $ids, $resync = true)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/** @var \phpbb\attachment\manager $attachment_manager */
|
||||
$attachment_manager = $phpbb_container->get('attachment.manager');
|
||||
$num_deleted = $attachment_manager->delete($mode, $ids, $resync);
|
||||
|
||||
unset($attachment_manager);
|
||||
|
||||
return $num_deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete attached file
|
||||
*
|
||||
* @deprecated 3.2.0-a1 (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/** @var \phpbb\attachment\manager $attachment_manager */
|
||||
$attachment_manager = $phpbb_container->get('attachment.manager');
|
||||
$unlink = $attachment_manager->unlink($filename, $mode, $entry_removed);
|
||||
unset($attachment_manager);
|
||||
|
||||
return $unlink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display reasons
|
||||
*
|
||||
* @deprecated 3.2.0-dev (To be removed: 4.0.0)
|
||||
*/
|
||||
function display_reasons($reason_id = 0)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
$phpbb_container->get('phpbb.report.report_reason_list_provider')->display_reasons($reason_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Attachment - filedata is generated here
|
||||
* Uses upload class
|
||||
*
|
||||
* @deprecated 3.2.0-a1 (To be removed: 4.0.0)
|
||||
*
|
||||
* @param string $form_name The form name of the file upload input
|
||||
* @param int $forum_id The id of the forum
|
||||
* @param bool $local Whether the file is local or not
|
||||
* @param string $local_storage The path to the local file
|
||||
* @param bool $is_message Whether it is a PM or not
|
||||
* @param array $local_filedata A filespec object created for the local file
|
||||
*
|
||||
* @return array File data array
|
||||
*/
|
||||
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/** @var \phpbb\attachment\manager $attachment_manager */
|
||||
$attachment_manager = $phpbb_container->get('attachment.manager');
|
||||
$file = $attachment_manager->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata);
|
||||
unset($attachment_manager);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for php's checkdnsrr function.
|
||||
*
|
||||
* @param string $host Fully-Qualified Domain Name
|
||||
* @param string $type Resource record type to lookup
|
||||
* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME
|
||||
* Other types may work or may not work
|
||||
*
|
||||
* @return bool|null true if entry found,
|
||||
* false if entry not found,
|
||||
* null if this function is not supported by this environment
|
||||
*
|
||||
* Since null can also be returned, you probably want to compare the result
|
||||
* with === true or === false,
|
||||
*
|
||||
* @deprecated 3.3.0-b2 (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_checkdnsrr($host, $type = 'MX')
|
||||
{
|
||||
return checkdnsrr($host, $type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper for inet_ntop()
|
||||
*
|
||||
* Converts a packed internet address to a human readable representation
|
||||
* inet_ntop() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.
|
||||
*
|
||||
* @param string $in_addr A 32bit IPv4, or 128bit IPv6 address.
|
||||
*
|
||||
* @return mixed false on failure,
|
||||
* string otherwise
|
||||
*
|
||||
* @deprecated 3.3.0-b2 (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_inet_ntop($in_addr)
|
||||
{
|
||||
return inet_ntop($in_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for inet_pton()
|
||||
*
|
||||
* Converts a human readable IP address to its packed in_addr representation
|
||||
* inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.
|
||||
*
|
||||
* @param string $address A human readable IPv4 or IPv6 address.
|
||||
*
|
||||
* @return false|string false if address is invalid,
|
||||
* in_addr representation of the given address otherwise (string)
|
||||
*
|
||||
* @deprecated 3.3.0-b2 (To be removed: 4.0.0)
|
||||
*/
|
||||
function phpbb_inet_pton($address)
|
||||
{
|
||||
return inet_pton($address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashes an email address to a big integer
|
||||
*
|
||||
|
@ -829,25 +384,6 @@ 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse cfg file
|
||||
* @param string $filename
|
||||
|
@ -909,27 +445,3 @@ function parse_cfg_file($filename, $lines = false)
|
|||
|
||||
return $parsed_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps an url into a simple html page. Used to display attachments in IE.
|
||||
* this is a workaround for now; might be moved to template system later
|
||||
* direct any complaints to 1 Microsoft Way, Redmond
|
||||
*
|
||||
* @deprecated: 3.3.0-dev (To be removed: 4.0.0)
|
||||
*/
|
||||
function wrap_img_in_html($src, $title)
|
||||
{
|
||||
echo '<!DOCTYPE html>';
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
echo '<meta charset="utf-8">';
|
||||
echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
|
||||
echo '<title>' . $title . '</title>';
|
||||
echo '</head>';
|
||||
echo '<body>';
|
||||
echo '<div>';
|
||||
echo '<img src="' . $src . '" alt="' . $title . '" />';
|
||||
echo '</div>';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ class filespec
|
|||
* @param bool $overwrite If set to true, an already existing file will be overwritten
|
||||
* @param bool $skip_image_check If set to true, the check for the file to be a valid image is skipped
|
||||
* @param string|bool $chmod Permission mask for chmodding the file after a successful move.
|
||||
* The mode entered here reflects the mode defined by {@link phpbb_chmod()}
|
||||
* The mode entered here reflects the mode defined by {@link \phpbb\filesystem\filesystem::phpbb_chmod()}
|
||||
*
|
||||
* @return bool True if file was moved, false if not
|
||||
* @access public
|
||||
|
|
|
@ -344,8 +344,9 @@ class plupload
|
|||
}
|
||||
|
||||
$tmp_file = $this->temporary_filepath($upload['tmp_name']);
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
if (!phpbb_is_writable($this->temporary_directory) || !move_uploaded_file($upload['tmp_name'], $tmp_file))
|
||||
if (!$filesystem->is_writable($this->temporary_directory) || !move_uploaded_file($upload['tmp_name'], $tmp_file))
|
||||
{
|
||||
$this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED');
|
||||
}
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group slow
|
||||
*/
|
||||
class phpbb_functions_get_remote_file extends phpbb_test_case
|
||||
{
|
||||
public function test_version_phpbb_com()
|
||||
{
|
||||
global $phpbb_container;
|
||||
$phpbb_container = new phpbb_mock_container_builder();
|
||||
$phpbb_container->set('file_downloader', new \phpbb\file_downloader());
|
||||
|
||||
$hostname = 'version.phpbb.com';
|
||||
|
||||
if (!checkdnsrr($hostname, 'A'))
|
||||
{
|
||||
$this->markTestSkipped(sprintf(
|
||||
'Could not find a DNS record for hostname %s. ' .
|
||||
'Assuming network is down.',
|
||||
$hostname
|
||||
));
|
||||
}
|
||||
|
||||
$errstr = $errno = null;
|
||||
$file = get_remote_file($hostname, '/phpbb', '30x.txt', $errstr, $errno);
|
||||
|
||||
$this->assertNotEquals(
|
||||
0,
|
||||
strlen($file),
|
||||
'Failed asserting that the response is not empty.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'',
|
||||
$errstr,
|
||||
'Failed asserting that the error string is empty.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
0,
|
||||
$errno,
|
||||
'Failed asserting that the error number is 0 (i.e. no error occurred).'
|
||||
);
|
||||
|
||||
$lines = explode("\n", $file);
|
||||
|
||||
$this->assertGreaterThanOrEqual(
|
||||
2,
|
||||
count($lines),
|
||||
'Failed asserting that the version file has at least two lines.'
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'3.',
|
||||
$lines[0],
|
||||
"Failed asserting that the first line of the version file starts with '3.'"
|
||||
);
|
||||
|
||||
$this->assertNotSame(
|
||||
false,
|
||||
filter_var($lines[1], FILTER_VALIDATE_URL),
|
||||
'Failed asserting that the second line of the version file is a valid URL.'
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('http', $lines[1]);
|
||||
$this->assertStringContainsString('phpbb.com', $lines[1], '', true);
|
||||
}
|
||||
}
|
|
@ -172,19 +172,63 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case
|
|||
|
||||
if ($additional3 != null)
|
||||
{
|
||||
add_log($mode, $required1, $additional1, $additional2, $additional3);
|
||||
$additional_data = [
|
||||
'forum_id' => $required1,
|
||||
'topic_id' => $additional1,
|
||||
$additional3,
|
||||
];
|
||||
$phpbb_log->add($mode, $user_id, '', $additional2, false, $additional_data);
|
||||
}
|
||||
else if ($additional2 != null)
|
||||
{
|
||||
add_log($mode, $required1, $additional1, $additional2);
|
||||
if ($mode == 'user')
|
||||
{
|
||||
$additional_data = [
|
||||
'reportee_id' => $required1,
|
||||
$additional2,
|
||||
];
|
||||
$log_operation = $additional1;
|
||||
}
|
||||
else if ($mode == 'mod')
|
||||
{
|
||||
$additional_data = [
|
||||
'forum_id' => $required1,
|
||||
'topic_id' => $additional1,
|
||||
];
|
||||
$log_operation = $additional2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log_operation = $required1;
|
||||
$additional_data = [
|
||||
$additional1,
|
||||
$additional2,
|
||||
];
|
||||
}
|
||||
$phpbb_log->add($mode, $user_id, '', $log_operation, false, $additional_data);
|
||||
}
|
||||
else if ($additional1 != null)
|
||||
{
|
||||
add_log($mode, $required1, $additional1);
|
||||
if ($mode == 'user')
|
||||
{
|
||||
$additional_data = [
|
||||
'reportee_id' => $required1,
|
||||
];
|
||||
$log_operation = $additional1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log_operation = $required1;
|
||||
$additional_data = [
|
||||
$additional1,
|
||||
];
|
||||
}
|
||||
|
||||
$phpbb_log->add($mode, $user_id, '', $log_operation, false, $additional_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log($mode, $required1);
|
||||
$phpbb_log->add($mode, $user_id, '', $required1);
|
||||
}
|
||||
|
||||
$result = $db->sql_query('SELECT user_id, log_type, log_operation, log_data, reportee_id, forum_id, topic_id
|
||||
|
|
|
@ -224,4 +224,65 @@ class version_helper_remote_test extends \phpbb_test_case
|
|||
|
||||
$this->assertEquals($expected_return, $return);
|
||||
}
|
||||
|
||||
public function test_version_phpbb_com()
|
||||
{
|
||||
$file_downloader = new \phpbb\file_downloader();
|
||||
|
||||
$hostname = 'version.phpbb.com';
|
||||
|
||||
if (!checkdnsrr($hostname, 'A'))
|
||||
{
|
||||
$this->markTestSkipped(sprintf(
|
||||
'Could not find a DNS record for hostname %s. ' .
|
||||
'Assuming network is down.',
|
||||
$hostname
|
||||
));
|
||||
}
|
||||
|
||||
$file = $file_downloader->get($hostname, '/phpbb', '30x.txt');
|
||||
$errstr = $file_downloader->get_error_string();
|
||||
$errno = $file_downloader->get_error_number();
|
||||
|
||||
$this->assertNotEquals(
|
||||
0,
|
||||
strlen($file),
|
||||
'Failed asserting that the response is not empty.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'',
|
||||
$errstr,
|
||||
'Failed asserting that the error string is empty.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
0,
|
||||
$errno,
|
||||
'Failed asserting that the error number is 0 (i.e. no error occurred).'
|
||||
);
|
||||
|
||||
$lines = explode("\n", $file);
|
||||
|
||||
$this->assertGreaterThanOrEqual(
|
||||
2,
|
||||
count($lines),
|
||||
'Failed asserting that the version file has at least two lines.'
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'3.',
|
||||
$lines[0],
|
||||
"Failed asserting that the first line of the version file starts with '3.'"
|
||||
);
|
||||
|
||||
$this->assertNotSame(
|
||||
false,
|
||||
filter_var($lines[1], FILTER_VALIDATE_URL),
|
||||
'Failed asserting that the second line of the version file is a valid URL.'
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('http', $lines[1]);
|
||||
$this->assertStringContainsString('phpbb.com', $lines[1], '', true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue