diff options
author | Derick Rethans <github@derickrethans.nl> | 2013-01-06 15:10:16 +0000 |
---|---|---|
committer | Derick Rethans <github@derickrethans.nl> | 2013-01-06 15:10:16 +0000 |
commit | 98331c89a178add153f9f30484f59300499fc742 (patch) | |
tree | 73bc5831b0e7140968a3663ebca887fe95e5b060 | |
parent | 4ff088d061ed3d4e15d38d0ed3f2fd10346c634c (diff) | |
parent | a951693cfb17b8d84de4882f47ba6f7d6a776556 (diff) | |
download | php-git-98331c89a178add153f9f30484f59300499fc742.tar.gz |
Merge branch 'PHP-5.5' of git.php.net:/php-src into PHP-5.5
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/standard/mail.c | 13 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_log.phpt | 48 | ||||
-rw-r--r-- | tests/classes/bug63462.phpt | 71 |
4 files changed, 131 insertions, 2 deletions
@@ -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 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 <stdlib.h> #include <ctype.h> #include <stdio.h> +#include <time.h> #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 <sysexits.h> @@ -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); 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-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +date_default_timezone_set("UTC"); + +$logfile = ini_get("mail.log"); +if (file_exists($logfile)) { + unlink($logfile); +} +touch($logfile); +clearstatcache(); + +$to = "test@example.com"; +$subject = "mail.log test"; +$message = "Testing mail.log"; +$headers = "X-Test: 1"; + +var_dump(filesize($logfile) == 0); +clearstatcache(); + +var_dump(mail($to, $subject, $message, $headers)); + +var_dump(filesize($logfile) > 0); +clearstatcache(); + +echo file_get_contents($logfile); +?> +Done +--CLEAN-- +<?php +unlink("/tmp/mail.log"); +unlink("/tmp/mail.out"); +?> +--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 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 <ocramius@gmail.com> +--XFAIL-- +Bug 63462 is not yet fixed +--FILE-- +<?php +class Test { + public $publicProperty; + protected $protectedProperty; + private $privateProperty; + + public function __construct() { + unset( + $this->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 |