From bdc1e2302ce57f6763c50d03bf987261f34f1d2b Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Sun, 6 Jan 2013 14:46:49 +0100 Subject: Adding test for bug #63462 --- tests/classes/bug63462.phpt | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/classes/bug63462.phpt diff --git a/tests/classes/bug63462.phpt b/tests/classes/bug63462.phpt new file mode 100644 index 0000000000..dc5edbd5e1 --- /dev/null +++ b/tests/classes/bug63462.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test script to verify that magic methods should be called only once when accessing an unset property. +--CREDITS-- +Marco Pivetta +--XFAIL-- +Bug 63462 is not yet fixed +--FILE-- +publicProperty, + $this->protectedProperty, + $this->privateProperty + ); + } + + function __get($name) { + echo '__get ' . $name . "\n"; + return $this->$name; + } + + function __set($name, $value) { + echo '__set ' . $name . "\n"; + $this->$name = $value; + } + + function __isset($name) { + echo '__isset ' . $name . "\n"; + return isset($this->$name); + } +} + +$test = new Test(); + +$test->nonExisting; +$test->publicProperty; +$test->protectedProperty; +$test->privateProperty; +isset($test->nonExisting); +isset($test->publicProperty); +isset($test->protectedProperty); +isset($test->privateProperty); +$test->nonExisting = 'value'; +$test->publicProperty = 'value'; +$test->protectedProperty = 'value'; +$test->privateProperty = 'value'; + +?> + +--EXPECTF-- +__get nonExisting +Notice: Undefined index: nonExisting in %__set__get_006.php on line %d +__get publicProperty +Notice: Undefined index: publicProperty in %__set__get_006.php on line %d +__get protectedProperty +Notice: Undefined index: protectedProperty in %__set__get_006.php on line %d +__get privateProperty +Notice: Undefined index: privateProperty in %__set__get_006.php on line %d +__isset nonExisting +__isset publicProperty +__isset protectedProperty +__isset privateProperty +__set nonExisting +__set publicProperty +__set protectedProperty +__set privateProperty -- cgit v1.2.1 From 4a3bf25e3ffa71d8d65df686c27903d7c9fafee6 Mon Sep 17 00:00:00 2001 From: Martin Jansen Date: Mon, 24 Dec 2012 11:11:28 +0100 Subject: Add a timestamp to the mail log. This patch is loosely based on the one in bug #52126 but instead of using a UNIX timestamp it uses the date format also being used by error_log et al. --- ext/standard/mail.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 25766818f6..c8fd55e821 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -21,10 +21,12 @@ #include #include #include +#include #include "php.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" #include "ext/standard/basic_functions.h" +#include "ext/date/php_date.h" #if HAVE_SYSEXITS_H #include @@ -246,8 +248,15 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char return val; \ if (mail_log && *mail_log) { - char *tmp; - int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + char *tmp, *date_str; + time_t curtime; + + time(&curtime); + date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1 TSRMLS_CC); + + int l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", date_str, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + + efree(date_str); if (hdr) { php_mail_log_crlf_to_spaces(tmp); -- cgit v1.2.1 From 371372714dcac655f53a53ef4d45ad02916b4f4a Mon Sep 17 00:00:00 2001 From: Martin Jansen Date: Sun, 6 Jan 2013 08:59:10 +0100 Subject: Add unit test for mail.log ini setting. --- ext/standard/tests/mail/mail_log.phpt | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ext/standard/tests/mail/mail_log.phpt diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt new file mode 100644 index 0000000000..86346ec307 --- /dev/null +++ b/ext/standard/tests/mail/mail_log.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test mail() function : mail.log ini setting +--INI-- +sendmail_path=tee /tmp/mail.out >/dev/null +mail.log = /tmp/mail.log +--SKIPIF-- + +--FILE-- + 0); +clearstatcache(); + +echo file_get_contents($logfile); +?> +Done +--CLEAN-- + +--EXPECTF-- +bool(true) +bool(true) +bool(true) +[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1 +Done -- cgit v1.2.1 From a951693cfb17b8d84de4882f47ba6f7d6a776556 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Sun, 6 Jan 2013 15:13:32 +0100 Subject: News entry for bug #52126 --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 1ad954a098..cfd2aa3dbc 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ PHP NEWS (Nikita Popov) . Add Generator::throw() method. (Nikita Popov) . Bug #23955: allow specifying Max-Age attribute in setcookie() (narfbg, Lars) + . Bug #52126: timestamp for mail.log (Martin Jansen, Lars) - cURL: . Added new functions curl_escape, curl_multi_setopt, curl_multi_strerror -- cgit v1.2.1