Code improvements and fixes (mostly unused variables and methods)

pull/251/head
Aleksander Machniak 10 years ago
parent 07280e7643
commit 9e4246d957

@ -290,7 +290,7 @@ class rcmail_install
$out = $seen = array();
// iterate over the current configuration
foreach ($this->config as $prop => $value) {
foreach (array_keys($this->config) as $prop) {
if ($replacement = $this->replaced_config[$prop]) {
$out['replaced'][] = array('prop' => $prop, 'replacement' => $replacement);
$seen[$replacement] = true;

@ -408,7 +408,7 @@ if (!extension_loaded('mbstring'))
if (!function_exists('idn_to_utf8'))
{
function idn_to_utf8($domain, $flags=null)
function idn_to_utf8($domain)
{
static $idn, $loaded;
@ -430,7 +430,7 @@ if (!function_exists('idn_to_utf8'))
if (!function_exists('idn_to_ascii'))
{
function idn_to_ascii($domain, $flags=null)
function idn_to_ascii($domain)
{
static $idn, $loaded;

@ -61,9 +61,6 @@ class rcube_base_replacer
*/
public static function absolute_url($path, $base_url)
{
$host_url = $base_url;
$abs_path = $path;
// check if path is an absolute URL
if (preg_match('/^[fhtps]+:\/\//', $path)) {
return $path;
@ -74,6 +71,9 @@ class rcube_base_replacer
return $path;
}
$host_url = $base_url;
$abs_path = $path;
// cut base_url to the last directory
if (strrpos($base_url, '/') > 7) {
$host_url = substr($base_url, 0, strpos($base_url, '/', 7));
@ -89,7 +89,8 @@ class rcube_base_replacer
$path = preg_replace('/^\.\//', '', $path);
if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) {
foreach ($matches as $a_match) {
$cnt = count($matches);
while ($cnt--) {
if ($pos = strrpos($base_url, '/')) {
$base_url = substr($base_url, 0, $pos);
}

@ -175,7 +175,6 @@ class rcube_charset
static $iconv_options = null;
static $mbstring_list = null;
static $mbstring_sch = null;
static $conv = null;
$to = empty($to) ? RCUBE_CHARSET : $to;
$from = self::parse_charset($from);

@ -909,7 +909,7 @@ class rcube_contacts extends rcube_addressbook
$name, $gid, $this->user_id
);
return $this->db->affected_rows() ? $name : false;
return $this->db->affected_rows($sql_result) ? $name : false;
}
@ -983,7 +983,7 @@ class rcube_contacts extends rcube_addressbook
$group_id
);
return $this->db->affected_rows();
return $this->db->affected_rows($sql_result);
}

@ -33,7 +33,7 @@ class rcube_content_filter extends php_user_filter
return true;
}
function filter($in, $out, &$consumed, $closing)
function filter($in, $out, &$consumed)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$this->buffer .= $bucket->data;

@ -171,7 +171,7 @@ class rcube_db_oracle extends rcube_db
$mode = $this->in_transaction ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
if ($result) {
foreach ($args as $param => $arg) {
foreach (array_keys($args) as $param) {
oci_bind_by_name($result, $param, $args[$param], -1, SQLT_LNG);
}
}
@ -587,7 +587,7 @@ class rcube_db_oracle extends rcube_db
$this->debug('ROLLBACK TRANSACTION');
if ($result = @oci_rollback($this->dbh)) {
if (@oci_rollback($this->dbh)) {
$this->in_transaction = false;
}
else {

@ -1108,7 +1108,8 @@ class rcube_imap_generic
// folder name with spaces. Let's try to handle this situation
if (!is_array($items) && ($pos = strpos($response, '(')) !== false) {
$response = substr($response, $pos);
$items = $this->tokenizeResponse($response, 1);
$items = $this->tokenizeResponse($response, 1);
if (!is_array($items)) {
return $result;
}
@ -1704,7 +1705,6 @@ class rcube_imap_generic
$encoding = $encoding ? trim($encoding) : 'US-ASCII';
$algorithm = $algorithm ? trim($algorithm) : 'REFERENCES';
$criteria = $criteria ? 'ALL '.trim($criteria) : 'ALL';
$data = '';
list($code, $response) = $this->execute($return_uid ? 'UID THREAD' : 'THREAD',
array($algorithm, $encoding, $criteria));

@ -124,9 +124,7 @@ class rcube_imap_search_job /* extends Stackable */
private $charset;
private $sort_field;
private $threading;
private $searchset;
private $result;
private $pagesize = 100;
public function __construct($folder, $str, $charset = null, $sort_field = null, $threading=false)
{

@ -64,7 +64,6 @@ class rcube_ldap extends rcube_addressbook
private $base_dn = '';
private $groups_base_dn = '';
private $group_url;
private $group_data;
private $group_search_cache;
private $cache;
@ -775,7 +774,7 @@ class rcube_ldap extends rcube_addressbook
// get all entries of this page and post-filter those that really match the query
$search = mb_strtolower($value);
foreach ($ldap_data as $i => $entry) {
foreach ($ldap_data as $entry) {
$rec = $this->_ldap2result($entry);
foreach ($fields as $f) {
foreach ((array)$rec[$f] as $val) {
@ -1531,7 +1530,6 @@ class rcube_ldap extends rcube_addressbook
return $ldap_data;
}
/**
* Returns unified attribute name (resolving aliases)
*/
@ -1562,17 +1560,6 @@ class rcube_ldap extends rcube_addressbook
return count(array_intersect(array_keys($this->group_types), $classes)) > 0;
}
/**
* Prints debug info to the log
*/
private function _debug($str)
{
if ($this->debug) {
rcube::write_log('ldap', $str);
}
}
/**
* Activate/deactivate debug mode
*
@ -1587,7 +1574,6 @@ class rcube_ldap extends rcube_addressbook
}
}
/**
* Setter for the current group
*/
@ -1990,7 +1976,7 @@ class rcube_ldap extends rcube_addressbook
$filter = strtr("(|(member=$contact_dn)(uniqueMember=$contact_dn)$add_filter)", array('\\' => '\\\\'));
$ldap_data = $this->ldap->search($base_dn, $filter, 'sub', array('dn', $name_attr));
if ($res === false) {
if ($ldap_data === false) {
return array();
}

@ -550,12 +550,6 @@ class rcube_message
else if ($mimetype == 'multipart/alternative'
&& is_array($structure->parts) && count($structure->parts) > 1
) {
$plain_part = null;
$html_part = null;
$print_part = null;
$related_part = null;
$attach_part = null;
// get html/plaintext parts, other add to attachments list
foreach ($structure->parts as $p => $sub_part) {
$sub_mimetype = $sub_part->mimetype;

@ -127,7 +127,7 @@ class rcube_spellcheck_atd extends rcube_spellcheck_engine
$result = new SimpleXMLElement($response);
}
catch (Exception $e) {
$thid->error = "Unexpected response from server: " . $store;
$this->error = "Unexpected response from server: " . $response;
return array();
}

@ -414,9 +414,10 @@ class rcube_vcard
* Find index with the '$type' attribute
*
* @param string Field name
*
* @return int Field index having $type set
*/
private function get_type_index($field, $type = 'pref')
private function get_type_index($field)
{
$result = 0;
if ($this->raw[$field]) {

@ -31,4 +31,32 @@ class Framework_BaseReplacer extends PHPUnit_Framework_TestCase
$this->assertSame('<A href="http://shouldbethislink.com">Test URL</A>', $response);
}
/**
* Data for absolute_url() test
*/
function data_absolute_url()
{
return array(
array('', 'http://test', 'http://test/'),
array('http://test', 'http://anything', 'http://test'),
array('cid:test', 'http://anything', 'cid:test'),
array('/test', 'http://test', 'http://test/test'),
array('./test', 'http://test', 'http://test/test'),
array('../test1', 'http://test/test2', 'http://test1'),
array('../test1', 'http://test/test2/', 'http://test/test1'),
);
}
/**
* Test absolute_url()
* @dataProvider data_absolute_url
*/
function test_absolute_url($path, $base, $expected)
{
$replacer = new rcube_base_replacer('test');
$result = $replacer->absolute_url($path, $base);
$this->assertSame($expected, $result);
}
}

Loading…
Cancel
Save