mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 11:58:51 +00:00
[ticket/12479] Remove unused functions and function aliases
PHPBB-12479
This commit is contained in:
parent
3e0637ad2e
commit
986b92f3b3
3 changed files with 1 additions and 172 deletions
|
@ -19,104 +19,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the autoloaders added by the extensions.
|
||||
*
|
||||
* @param string $phpbb_root_path Path to the phpbb root directory.
|
||||
*/
|
||||
function phpbb_load_extensions_autoloaders($phpbb_root_path)
|
||||
{
|
||||
$iterator = new \phpbb\finder\recursive_path_iterator(
|
||||
$phpbb_root_path . 'ext/',
|
||||
\RecursiveIteratorIterator::SELF_FIRST,
|
||||
\FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS
|
||||
);
|
||||
$iterator->setMaxDepth(2);
|
||||
|
||||
foreach ($iterator as $file_info)
|
||||
{
|
||||
if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2)
|
||||
{
|
||||
$filename = $file_info->getRealPath() . '/autoload.php';
|
||||
if (file_exists($filename))
|
||||
{
|
||||
require $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts query string (GET) parameters in request into hidden fields.
|
||||
*
|
||||
* Useful for forwarding GET parameters when submitting forms with GET method.
|
||||
*
|
||||
* It is possible to omit some of the GET parameters, which is useful if
|
||||
* they are specified in the form being submitted.
|
||||
*
|
||||
* sid is always omitted.
|
||||
*
|
||||
* @param \phpbb\request\request $request Request object
|
||||
* @param array $exclude A list of variable names that should not be forwarded
|
||||
* @return string HTML with hidden fields
|
||||
*
|
||||
* @deprecated 3.2.10 (To be removed 4.0.0)
|
||||
*/
|
||||
function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
|
||||
{
|
||||
$names = $request->variable_names(\phpbb\request\request_interface::GET);
|
||||
$hidden = '';
|
||||
foreach ($names as $name)
|
||||
{
|
||||
// Sessions are dealt with elsewhere, omit sid always
|
||||
if ($name == 'sid')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Omit any additional parameters requested
|
||||
if (!empty($exclude) && in_array($name, $exclude))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$escaped_name = phpbb_quoteattr($name);
|
||||
|
||||
// Note: we might retrieve the variable from POST or cookies
|
||||
// here. To avoid exposing cookies, skip variables that are
|
||||
// overwritten somewhere other than GET entirely.
|
||||
$value = $request->variable($name, '', true);
|
||||
$get_value = $request->variable($name, '', true, \phpbb\request\request_interface::GET);
|
||||
if ($value === $get_value)
|
||||
{
|
||||
$escaped_value = phpbb_quoteattr($value);
|
||||
$hidden .= "<input type='hidden' name=$escaped_name value=$escaped_value />";
|
||||
}
|
||||
}
|
||||
return $hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all PM(s) for a given user and delete the ones without references
|
||||
*
|
||||
* @param int $user_id ID of the user whose private messages we want to delete
|
||||
*
|
||||
* @return boolean False if there were no pms found, true otherwise.
|
||||
*
|
||||
* @deprecated 3.2.10 (To be removed 4.0.0)
|
||||
*/
|
||||
function phpbb_delete_user_pms($user_id)
|
||||
{
|
||||
$user_id = (int) $user_id;
|
||||
|
||||
if (!$user_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return phpbb_delete_users_pms(array($user_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float)
|
||||
*
|
||||
|
|
|
@ -1,73 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_build_hidden_fields_for_query_params_test extends phpbb_test_case
|
||||
{
|
||||
public function build_hidden_fields_for_query_params_test_data()
|
||||
{
|
||||
return array(
|
||||
// get
|
||||
// post
|
||||
// exclude
|
||||
// expected
|
||||
array(
|
||||
array('foo' => 'bar'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => 'b'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" /><input type='hidden' name=\"a\" value=\"b\" />",
|
||||
),
|
||||
array(
|
||||
array('a' => 'quote"', 'b' => '<less>'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"a\" value='quote\"' /><input type='hidden' name=\"b\" value=\"<less>\" />",
|
||||
),
|
||||
array(
|
||||
array('a' => "quotes'\""),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"a\" value=\"quotes'"\" />",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => 'b'),
|
||||
array('a' => 'c'),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
// strict equality check
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => '0'),
|
||||
array('a' => ''),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider build_hidden_fields_for_query_params_test_data
|
||||
*/
|
||||
public function test_build_hidden_fields_for_query_params($get, $post, $exclude, $expected)
|
||||
{
|
||||
$request = new phpbb_mock_request($get, $post);
|
||||
$result = phpbb_build_hidden_fields_for_query_params($request, $exclude);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
|
@ -97,7 +97,7 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case
|
|||
// Works as a workaround for tests
|
||||
$phpbb_container->set('attachment.manager', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage));
|
||||
|
||||
phpbb_delete_user_pms($delete_user);
|
||||
phpbb_delete_users_pms([$delete_user]);
|
||||
|
||||
$sql = 'SELECT msg_id
|
||||
FROM ' . PRIVMSGS_TABLE;
|
||||
|
|
Loading…
Add table
Reference in a new issue