Aleksander Machniak
2014-11-16 9e4246d9571481fe7b80227b1e23dc013771c5af
Code improvements and fixes (mostly unused variables and methods)
14 files modified
89 ■■■■ changed files
program/include/rcmail_install.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/bootstrap.php 4 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_base_replacer.php 9 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_charset.php 1 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_contacts.php 4 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_content_filter.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_db_oracle.php 4 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap_generic.php 4 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap_search.php 2 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_ldap.php 18 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_message.php 6 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_spellcheck_atd.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_vcard.php 3 ●●●● patch | view | raw | blame | history
tests/Framework/BaseReplacer.php 28 ●●●●● patch | view | raw | blame | history
program/include/rcmail_install.php
@@ -290,7 +290,7 @@
    $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;
program/lib/Roundcube/bootstrap.php
@@ -408,7 +408,7 @@
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_ascii'))
{
    function idn_to_ascii($domain, $flags=null)
    function idn_to_ascii($domain)
    {
        static $idn, $loaded;
program/lib/Roundcube/rcube_base_replacer.php
@@ -61,9 +61,6 @@
     */
    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;
@@ -73,6 +70,9 @@
        if (strpos($path, 'cid:') === 0) {
            return $path;
        }
        $host_url = $base_url;
        $abs_path = $path;
        // cut base_url to the last directory
        if (strrpos($base_url, '/') > 7) {
@@ -89,7 +89,8 @@
            $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);
                    }
program/lib/Roundcube/rcube_charset.php
@@ -175,7 +175,6 @@
        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);
program/lib/Roundcube/rcube_contacts.php
@@ -909,7 +909,7 @@
            $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 @@
            $group_id
        );
        return $this->db->affected_rows();
        return $this->db->affected_rows($sql_result);
    }
program/lib/Roundcube/rcube_content_filter.php
@@ -33,7 +33,7 @@
        return true;
    }
    function filter($in, $out, &$consumed, $closing)
    function filter($in, $out, &$consumed)
    {
        while ($bucket = stream_bucket_make_writeable($in)) {
            $this->buffer .= $bucket->data;
program/lib/Roundcube/rcube_db_oracle.php
@@ -171,7 +171,7 @@
        $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 @@
        $this->debug('ROLLBACK TRANSACTION');
        if ($result = @oci_rollback($this->dbh)) {
        if (@oci_rollback($this->dbh)) {
            $this->in_transaction = false;
        }
        else {
program/lib/Roundcube/rcube_imap_generic.php
@@ -1108,7 +1108,8 @@
            // 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 @@
        $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));
program/lib/Roundcube/rcube_imap_search.php
@@ -124,9 +124,7 @@
    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)
    {
program/lib/Roundcube/rcube_ldap.php
@@ -64,7 +64,6 @@
    private $base_dn        = '';
    private $groups_base_dn = '';
    private $group_url;
    private $group_data;
    private $group_search_cache;
    private $cache;
@@ -775,7 +774,7 @@
            // 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 @@
        return $ldap_data;
    }
    /**
     * Returns unified attribute name (resolving aliases)
     */
@@ -1563,17 +1561,6 @@
    }
    /**
     * Prints debug info to the log
     */
    private function _debug($str)
    {
        if ($this->debug) {
            rcube::write_log('ldap', $str);
        }
    }
    /**
     * Activate/deactivate debug mode
     *
     * @param boolean $dbg True if LDAP commands should be logged
@@ -1586,7 +1573,6 @@
            $this->ldap->config_set('debug', $dbg);
        }
    }
    /**
     * Setter for the current group
@@ -1990,7 +1976,7 @@
        $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();
        }
program/lib/Roundcube/rcube_message.php
@@ -550,12 +550,6 @@
        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;
program/lib/Roundcube/rcube_spellcheck_atd.php
@@ -127,7 +127,7 @@
            $result = new SimpleXMLElement($response);
        }
        catch (Exception $e) {
            $thid->error = "Unexpected response from server: " . $store;
            $this->error = "Unexpected response from server: " . $response;
            return array();
        }
program/lib/Roundcube/rcube_vcard.php
@@ -414,9 +414,10 @@
     * 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]) {
tests/Framework/BaseReplacer.php
@@ -31,4 +31,32 @@
        $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);
    }
}