Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some critical errors #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1613,3 +1613,14 @@ function imap2_utf8(string $string)
return imap_utf8($string);
}
}

/* For testing
// A side-effectless version (functions only) of Roundcube's bootstrap.php
require __DIR__ . '/rcube_bootstrap.php';
require __DIR__ . '/roundcubemail/program/lib/Roundcube/rcube.php';
require __DIR__ . '/roundcubemail/program/lib/Roundcube/rcube_mime_decode.php';
require __DIR__ . '/roundcubemail/program/lib/Roundcube/rcube_charset.php';
require __DIR__ . '/roundcubemail/program/lib/Roundcube/rcube_string_replacer.php';
require __DIR__ . '/roundcubemail/program/lib/Roundcube/rcube_imap_generic.php';
require __DIR__ . '/roundcubemail/program/lib/Roundcube/rcube_result_index.php';
*/
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"zbateson/mail-mime-parser": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "^6.5"
"phpunit/phpunit": "^6.5",
"phpstan/phpstan": "^1.10",
"pear/auth_sasl": "^1.1"
},
"suggest": {
"ext-mbstring": "For best support/performance",
Expand Down
12 changes: 6 additions & 6 deletions src/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function check($imap)
return imap_check($imap);
}

trigger_error(Errors::invalidImapConnection(debug_backtrace(), 1), E_USER_WARNING);
trigger_error(Errors::invalidImapConnection(debug_backtrace(), 1, false), E_USER_WARNING);

return false;
}
Expand Down Expand Up @@ -245,13 +245,13 @@ public static function createMailbox($imap, $mailbox)

public static function renameMailbox($imap, $from, $to)
{
if (is_a($imap, Connection::class)) {
$client = $imap->getClient();

return $client->createFolder($mailbox);
if (!is_a($imap, Connection::class)) {
return Errors::invalidImapConnection(debug_backtrace(), 1, false);
}

return imap_createmailbox($imap, $mailbox);
$client = $imap->getClient();

return $client->renameFolder($from, $to);
Comment on lines 246 to +254
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure here.
Please fix it again if it is incorrect.

}

public static function deleteMailbox($imap, $mailbox)
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function rfc822WriteHeaders($string)

public static function utf7Decode($string)
{
return mb_convert_decoding($string, "UTF7-IMAP", "UTF-8");
return mb_convert_encoding($string, "UTF7-IMAP", "UTF-8");
}

public static function utf7Encode($string)
Expand Down
4 changes: 2 additions & 2 deletions src/Roundcube/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

namespace Javanile\Imap2\Roundcube;

use Javanile\Imap2\ErrorException;
use Javanile\Imap2\rcube;
use ErrorException;
use rcube;

/**
* Character sets conversion functionality
Expand Down
8 changes: 4 additions & 4 deletions src/Roundcube/ImapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

namespace Javanile\Imap2\Roundcube;

use Javanile\Imap2\Auth_SASL;
use Javanile\Imap2\Exception;
use Javanile\Imap2\GSSAPIContext;
use Javanile\Imap2\KRB5CCache;
use Auth_SASL;
use Exception;
use GSSAPIContext;
use KRB5CCache;
use Javanile\Imap2\rcube_message_header;
use Javanile\Imap2\rcube_result_index;
use Javanile\Imap2\rcube_result_thread;
Expand Down
4 changes: 2 additions & 2 deletions src/Roundcube/Mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

namespace Javanile\Imap2\Roundcube;

use Javanile\Imap2\rcube;
use Javanile\Imap2\rcube_mime_decode;
use rcube;
use rcube_mime_decode;

/**
* Class for parsing MIME messages
Expand Down
2 changes: 1 addition & 1 deletion src/Roundcube/ResultIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Javanile\Imap2\Roundcube;

use Javanile\Imap2\Offset;
use Javanile\Imap2\rcube_imap_generic;
use rcube_imap_generic;

/**
* Class for accessing IMAP's SORT/SEARCH/ESEARCH result
Expand Down
6 changes: 3 additions & 3 deletions src/Roundcube/ResultThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
namespace Javanile\Imap2\Roundcube;

use Javanile\Imap2\Offset;
use Javanile\Imap2\rcube_imap_generic;
use Javanile\Imap2\rcube_result_index;
use rcube_imap_generic;
use rcube_result_index;

/**
* Class for accessing IMAP's THREAD result
Expand Down Expand Up @@ -427,7 +427,7 @@ public function get_parameters($param=null)
*/
public function sort($index)
{
$this->sort_order = $index->get_parameters('ORDER');
$this->order = $index->get_parameters('ORDER');

if (empty($this->raw_data)) {
return;
Expand Down
12 changes: 6 additions & 6 deletions src/Roundcube/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

namespace Javanile\Imap2\Roundcube;

use Javanile\Imap2\DateTime;
use Javanile\Imap2\DateTimeZone;
use Javanile\Imap2\Exception;
use Javanile\Imap2\rcube;
use Javanile\Imap2\rcube_charset;
use Javanile\Imap2\rcube_string_replacer;
use DateTime;
use DateTimeZone;
use Exception;
use rcube;
use rcube_charset;
use rcube_string_replacer;

/**
* Utility class providing common functions
Expand Down