Skip to content

Commit

Permalink
Fix IMAP extension
Browse files Browse the repository at this point in the history
Summary:
Constants were missing, errors weren't being printed, login auth wasn't copying
the details in the correct direction.

Test Plan:

DiffCamp Revision: 177824
Reviewed By: hzhao
CC: hzhao, achao, hphp-diffs@lists
Revert Plan:
Ok
  • Loading branch information
macvicar committed Nov 3, 2010
1 parent 5b97805 commit d2f8861
Show file tree
Hide file tree
Showing 6 changed files with 3,236 additions and 2,368 deletions.
4 changes: 4 additions & 0 deletions bin/gen_constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
print "define('GLOBAL_SYMBOL_GLOBAL_VARIABLE', 0);\n";
print "define('GLOBAL_SYMBOL_STATIC_VARIABLE', 1);\n";
print "define('GLOBAL_SYMBOL_CLASS_STATIC', 2);\n";
print "define('GLOBAL_SYMBOL_DYNAMIC_CONSTANT', 3);\n";
print "define('GLOBAL_SYMBOL_FILE_INCLUDE', 4);\n";
print "define('GLOBAL_SYMBOL_REDECLARED_FUNCTION', 5);\n";
print "define('GLOBAL_SYMBOL_REDECLARED_CLASS', 6);\n";
51 changes: 47 additions & 4 deletions src/runtime/ext/ext_imap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ImapRequestData : public RequestEventHandler {
if (m_errorstack != NIL) {
/* output any remaining errors at their original error level */
for (ERRORLIST *ecur = m_errorstack; ecur != NIL; ecur = ecur->next) {
Logger::Verbose("%s (errflg=%ld)", ecur->text.data, ecur->errflg);
Logger::Warning("%s (errflg=%ld)", ecur->text.data, ecur->errflg);
}
mail_free_errorlist(&m_errorstack);
m_errorstack = NIL;
Expand All @@ -117,7 +117,7 @@ class ImapRequestData : public RequestEventHandler {
if (m_alertstack != NIL) {
/* output any remaining alerts at E_NOTICE level */
for (STRINGLIST *acur = m_alertstack; acur != NIL; acur = acur->next) {
Logger::Verbose("%s", acur->text.data);
Logger::Warning("%s", acur->text.data);
}
mail_free_stringlist(&m_alertstack);
m_alertstack = NIL;
Expand Down Expand Up @@ -157,6 +157,49 @@ IMPLEMENT_STATIC_REQUEST_LOCAL(ImapRequestData, s_imap_data);
static class imapExtension : public Extension {
public:
imapExtension() : Extension("imap") {}

virtual void moduleInit() {
mail_link(&unixdriver); /* link in the unix driver */
mail_link(&mhdriver); /* link in the mh driver */
/* According to c-client docs (internal.txt) this shouldn't be used. */
/* mail_link(&mxdriver); */
mail_link(&mmdfdriver); /* link in the mmdf driver */
mail_link(&newsdriver); /* link in the news driver */
mail_link(&philedriver); /* link in the phile driver */

mail_link(&imapdriver); /* link in the imap driver */
mail_link(&nntpdriver); /* link in the nntp driver */
mail_link(&pop3driver); /* link in the pop3 driver */
mail_link(&mbxdriver); /* link in the mbx driver */
mail_link(&tenexdriver); /* link in the tenex driver */
mail_link(&mtxdriver); /* link in the mtx driver */
mail_link(&dummydriver); /* link in the dummy driver */

auth_link(&auth_log); /* link in the log authenticator */
auth_link(&auth_md5); /* link in the cram-md5 authenticator */

#ifndef SKIP_IMAP_GSS
auth_link(&auth_gss); /* link in the gss authenticator */
#endif

auth_link(&auth_pla); /* link in the plain authenticator */

#ifndef SKIP_IMAP_SSL
ssl_onceonlyinit();
#endif

/* plug in our gets */
mail_parameters(NIL, SET_GETS, (void *) NIL);

/* set default timeout values */
void *timeout = (void *)RuntimeOption::SocketDefaultTimeout;

mail_parameters(NIL, SET_OPENTIMEOUT, timeout);
mail_parameters(NIL, SET_READTIMEOUT, timeout);
mail_parameters(NIL, SET_WRITETIMEOUT, timeout);
mail_parameters(NIL, SET_CLOSETIMEOUT, timeout);
}

} s_imap_extension;

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -575,9 +618,9 @@ void mm_login(NETMBX *mb, char *user, char *pwd, long trial) {
if (*mb->user) {
string_copy(user, mb->user, MAILTMPLEN);
} else {
IMAPG(user) = user;
string_copy(user, IMAPG(user).c_str(), MAILTMPLEN);
}
IMAPG(password) = pwd;
string_copy(pwd, IMAPG(password).c_str(), MAILTMPLEN);
}

void mm_dlog(char *str) {}
Expand Down
69 changes: 67 additions & 2 deletions src/system/gen/php/globals/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ const int64 k_CLOCK_MONOTONIC = 1LL;
const int64 k_CLOCK_PROCESS_CPUTIME_ID = 2LL;
const int64 k_CLOCK_REALTIME = 0LL;
const int64 k_CLOCK_THREAD_CPUTIME_ID = 3LL;
const int64 k_CL_EXPUNGE = 32768LL;
const int64 k_CODESET = 14LL;
const int64 k_CONNECTION_ABORTED = 1LL;
const int64 k_CONNECTION_NORMAL = 0LL;
const int64 k_CONNECTION_TIMEOUT = 2LL;
const int64 k_COUNT_NORMAL = 0LL;
const int64 k_COUNT_RECURSIVE = 1LL;
const int64 k_CP_MOVE = 2LL;
const int64 k_CP_UID = 1LL;
const int64 k_CREDITS_ALL = 4294967295LL;
const int64 k_CREDITS_DOCS = 16LL;
const int64 k_CREDITS_FULLPAGE = 32LL;
Expand Down Expand Up @@ -374,6 +377,12 @@ const int64 k_DOM_VALIDATION_ERR = 16LL;
const int64 k_DOM_WRONG_DOCUMENT_ERR = 4LL;
const int64 k_D_FMT = 131113LL;
const int64 k_D_T_FMT = 131112LL;
const int64 k_ENC7BIT = 0LL;
const int64 k_ENC8BIT = 1LL;
const int64 k_ENCBASE64 = 3LL;
const int64 k_ENCBINARY = 2LL;
const int64 k_ENCOTHER = 5LL;
const int64 k_ENCQUOTEDPRINTABLE = 4LL;
const int64 k_ENT_COMPAT = 2LL;
const int64 k_ENT_NOQUOTES = 0LL;
const int64 k_ENT_QUOTES = 3LL;
Expand Down Expand Up @@ -416,6 +425,11 @@ const int64 k_FNM_PATHNAME = 1LL;
const int64 k_FNM_PERIOD = 4LL;
const int64 k_FORCE_DEFLATE = 2LL;
const int64 k_FORCE_GZIP = 1LL;
const int64 k_FT_INTERNAL = 8LL;
const int64 k_FT_NOT = 4LL;
const int64 k_FT_PEEK = 2LL;
const int64 k_FT_PREFETCHTEXT = 32LL;
const int64 k_FT_UID = 1LL;
const int64 k_GD_BUNDLED = 1LL;
const StaticString k_GD_EXTRA_VERSION(LITSTR_INIT(""));
const int64 k_GD_MAJOR_VERSION = 2LL;
Expand Down Expand Up @@ -478,6 +492,10 @@ const int64 k_IMAGETYPE_TIFF_II = 7LL;
const int64 k_IMAGETYPE_TIFF_MM = 8LL;
const int64 k_IMAGETYPE_WBMP = 15LL;
const int64 k_IMAGETYPE_XBM = 16LL;
const int64 k_IMAP_CLOSETIMEOUT = 4LL;
const int64 k_IMAP_OPENTIMEOUT = 1LL;
const int64 k_IMAP_READTIMEOUT = 2LL;
const int64 k_IMAP_WRITETIMEOUT = 3LL;
const int64 k_IMG_ARC_CHORD = 1LL;
const int64 k_IMG_ARC_EDGED = 4LL;
const int64 k_IMG_ARC_NOFILL = 2LL;
Expand Down Expand Up @@ -526,6 +544,13 @@ const int64 k_INI_SCANNER_RAW = 1LL;
const int64 k_INI_SYSTEM = 4LL;
const int64 k_INI_USER = 1LL;
const int64 k_INTL_MAX_LOCALE_LEN = 80LL;
const int64 k_LATT_HASCHILDREN = 32LL;
const int64 k_LATT_HASNOCHILDREN = 64LL;
const int64 k_LATT_MARKED = 4LL;
const int64 k_LATT_NOINFERIORS = 1LL;
const int64 k_LATT_NOSELECT = 2LL;
const int64 k_LATT_REFERRAL = 16LL;
const int64 k_LATT_UNMARKED = 8LL;
const int64 k_LC_ALL = 6LL;
const int64 k_LC_COLLATE = 3LL;
const int64 k_LC_CTYPE = 0LL;
Expand Down Expand Up @@ -1180,6 +1205,7 @@ const double k_M_SQRT1_2 = 0.70710678118655002;
const double k_M_SQRT2 = 1.4142135623731;
const double k_M_SQRT3 = 1.7320508075689001;
const double k_M_SQRTPI = 1.7724538509054999;
const int64 k_NIL = 0LL;
const int64 k_NOEXPR = 327681LL;
const Variant k_NULL = null;
const int64 k_OCI_ASSOC = 1LL;
Expand Down Expand Up @@ -1237,6 +1263,15 @@ const int64 k_OPENSSL_PKCS1_PADDING = 1LL;
const int64 k_OPENSSL_SSLV23_PADDING = 2LL;
const int64 k_OPENSSL_VERSION_NUMBER = 9469999LL;
const StaticString k_OPENSSL_VERSION_TEXT(LITSTR_INIT("OpenSSL 0.9.8b 04 May 2006"));
const int64 k_OP_ANONYMOUS = 4LL;
const int64 k_OP_DEBUG = 1LL;
const int64 k_OP_EXPUNGE = 128LL;
const int64 k_OP_HALFOPEN = 64LL;
const int64 k_OP_PROTOTYPE = 32LL;
const int64 k_OP_READONLY = 2LL;
const int64 k_OP_SECURE = 256LL;
const int64 k_OP_SHORTCACHE = 8LL;
const int64 k_OP_SILENT = 16LL;
const int64 k_PATHINFO_BASENAME = 2LL;
const int64 k_PATHINFO_DIRNAME = 1LL;
const int64 k_PATHINFO_EXTENSION = 4LL;
Expand Down Expand Up @@ -1325,9 +1360,18 @@ const int64 k_PSFS_FLAG_FLUSH_INC = 1LL;
const int64 k_PSFS_FLAG_NORMAL = 0LL;
const int64 k_PSFS_PASS_ON = 2LL;
const int64 k_RADIXCHAR = 65536LL;
const int64 k_SA_ALL = 31LL;
const int64 k_SA_MESSAGES = 1LL;
const int64 k_SA_RECENT = 2LL;
const int64 k_SA_UIDNEXT = 8LL;
const int64 k_SA_UIDVALIDITY = 16LL;
const int64 k_SA_UNSEEN = 4LL;
const int64 k_SEEK_CUR = 1LL;
const int64 k_SEEK_END = 2LL;
const int64 k_SEEK_SET = 0LL;
const int64 k_SE_FREE = 2LL;
const int64 k_SE_NOPREFETCH = 4LL;
const int64 k_SE_UID = 1LL;
const int64 k_SIGABRT = 6LL;
const int64 k_SIGALRM = 14LL;
const int64 k_SIGBABY = 31LL;
Expand Down Expand Up @@ -1498,18 +1542,27 @@ const int64 k_SOL_SOCKET = 1LL;
const int64 k_SOL_TCP = 6LL;
const int64 k_SOL_UDP = 17LL;
const int64 k_SOMAXCONN = 128LL;
const int64 k_SORTARRIVAL = 1LL;
const int64 k_SORTCC = 5LL;
const int64 k_SORTDATE = 0LL;
const int64 k_SORTFROM = 2LL;
const int64 k_SORTSIZE = 6LL;
const int64 k_SORTSUBJECT = 3LL;
const int64 k_SORTTO = 4LL;
const int64 k_SORT_ASC = 4LL;
const int64 k_SORT_DESC = 3LL;
const int64 k_SORT_LOCALE_STRING = 5LL;
const int64 k_SORT_NUMERIC = 2LL;
const int64 k_SORT_NUMERIC = 1LL;
const int64 k_SORT_REGULAR = 0LL;
const int64 k_SORT_STRING = 1LL;
const int64 k_SORT_STRING = 2LL;
const int64 k_SO_BROADCAST = 6LL;
const int64 k_SO_DEBUG = 1LL;
const int64 k_SO_DONTROUTE = 5LL;
const int64 k_SO_ERROR = 4LL;
const int64 k_SO_FREE = 8LL;
const int64 k_SO_KEEPALIVE = 9LL;
const int64 k_SO_LINGER = 13LL;
const int64 k_SO_NOSERVER = 16LL;
const int64 k_SO_OOBINLINE = 10LL;
const int64 k_SO_RCVBUF = 8LL;
const int64 k_SO_RCVLOWAT = 18LL;
Expand Down Expand Up @@ -1601,11 +1654,23 @@ const int64 k_STREAM_USE_PATH = 1LL;
const int64 k_STR_PAD_BOTH = 2LL;
const int64 k_STR_PAD_LEFT = 0LL;
const int64 k_STR_PAD_RIGHT = 1LL;
const int64 k_ST_SET = 4LL;
const int64 k_ST_SILENT = 2LL;
const int64 k_ST_UID = 1LL;
const int64 k_SUNFUNCS_RET_DOUBLE = 2LL;
const int64 k_SUNFUNCS_RET_STRING = 1LL;
const int64 k_SUNFUNCS_RET_TIMESTAMP = 0LL;
const int64 k_THOUSEP = 65537LL;
const bool k_TRUE = true;
const int64 k_TYPEAPPLICATION = 3LL;
const int64 k_TYPEAUDIO = 4LL;
const int64 k_TYPEIMAGE = 5LL;
const int64 k_TYPEMESSAGE = 2LL;
const int64 k_TYPEMODEL = 7LL;
const int64 k_TYPEMULTIPART = 1LL;
const int64 k_TYPEOTHER = 8LL;
const int64 k_TYPETEXT = 0LL;
const int64 k_TYPEVIDEO = 6LL;
const int64 k_T_ABSTRACT = 345LL;
const int64 k_T_AND_EQUAL = 271LL;
const int64 k_T_ARRAY = 359LL;
Expand Down
Loading

0 comments on commit d2f8861

Please sign in to comment.