Skip to content

Commit 98331c8

Browse files
committed
Merge branch 'PHP-5.5' of git.php.net:/php-src into PHP-5.5
2 parents 4ff088d + a951693 commit 98331c8

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
(Nikita Popov)
99
. Add Generator::throw() method. (Nikita Popov)
1010
. Bug #23955: allow specifying Max-Age attribute in setcookie() (narfbg, Lars)
11+
. Bug #52126: timestamp for mail.log (Martin Jansen, Lars)
1112

1213
- cURL:
1314
. Added new functions curl_escape, curl_multi_setopt, curl_multi_strerror

ext/standard/mail.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
#include <stdlib.h>
2222
#include <ctype.h>
2323
#include <stdio.h>
24+
#include <time.h>
2425
#include "php.h"
2526
#include "ext/standard/info.h"
2627
#include "ext/standard/php_string.h"
2728
#include "ext/standard/basic_functions.h"
29+
#include "ext/date/php_date.h"
2830

2931
#if HAVE_SYSEXITS_H
3032
#include <sysexits.h>
@@ -246,8 +248,15 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
246248
return val; \
247249

248250
if (mail_log && *mail_log) {
249-
char *tmp;
250-
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 : "");
251+
char *tmp, *date_str;
252+
time_t curtime;
253+
254+
time(&curtime);
255+
date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1 TSRMLS_CC);
256+
257+
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 : "");
258+
259+
efree(date_str);
251260

252261
if (hdr) {
253262
php_mail_log_crlf_to_spaces(tmp);

ext/standard/tests/mail/mail_log.phpt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Test mail() function : mail.log ini setting
3+
--INI--
4+
sendmail_path=tee /tmp/mail.out >/dev/null
5+
mail.log = /tmp/mail.log
6+
--SKIPIF--
7+
<?php
8+
if(substr(PHP_OS, 0, 3) == "WIN")
9+
die("skip Won't run on Windows");
10+
?>
11+
--FILE--
12+
<?php
13+
date_default_timezone_set("UTC");
14+
15+
$logfile = ini_get("mail.log");
16+
if (file_exists($logfile)) {
17+
unlink($logfile);
18+
}
19+
touch($logfile);
20+
clearstatcache();
21+
22+
$to = "test@example.com";
23+
$subject = "mail.log test";
24+
$message = "Testing mail.log";
25+
$headers = "X-Test: 1";
26+
27+
var_dump(filesize($logfile) == 0);
28+
clearstatcache();
29+
30+
var_dump(mail($to, $subject, $message, $headers));
31+
32+
var_dump(filesize($logfile) > 0);
33+
clearstatcache();
34+
35+
echo file_get_contents($logfile);
36+
?>
37+
Done
38+
--CLEAN--
39+
<?php
40+
unlink("/tmp/mail.log");
41+
unlink("/tmp/mail.out");
42+
?>
43+
--EXPECTF--
44+
bool(true)
45+
bool(true)
46+
bool(true)
47+
[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1
48+
Done

tests/classes/bug63462.phpt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
--TEST--
2+
Test script to verify that magic methods should be called only once when accessing an unset property.
3+
--CREDITS--
4+
Marco Pivetta <ocramius@gmail.com>
5+
--XFAIL--
6+
Bug 63462 is not yet fixed
7+
--FILE--
8+
<?php
9+
class Test {
10+
public $publicProperty;
11+
protected $protectedProperty;
12+
private $privateProperty;
13+
14+
public function __construct() {
15+
unset(
16+
$this->publicProperty,
17+
$this->protectedProperty,
18+
$this->privateProperty
19+
);
20+
}
21+
22+
function __get($name) {
23+
echo '__get ' . $name . "\n";
24+
return $this->$name;
25+
}
26+
27+
function __set($name, $value) {
28+
echo '__set ' . $name . "\n";
29+
$this->$name = $value;
30+
}
31+
32+
function __isset($name) {
33+
echo '__isset ' . $name . "\n";
34+
return isset($this->$name);
35+
}
36+
}
37+
38+
$test = new Test();
39+
40+
$test->nonExisting;
41+
$test->publicProperty;
42+
$test->protectedProperty;
43+
$test->privateProperty;
44+
isset($test->nonExisting);
45+
isset($test->publicProperty);
46+
isset($test->protectedProperty);
47+
isset($test->privateProperty);
48+
$test->nonExisting = 'value';
49+
$test->publicProperty = 'value';
50+
$test->protectedProperty = 'value';
51+
$test->privateProperty = 'value';
52+
53+
?>
54+
55+
--EXPECTF--
56+
__get nonExisting
57+
Notice: Undefined index: nonExisting in %__set__get_006.php on line %d
58+
__get publicProperty
59+
Notice: Undefined index: publicProperty in %__set__get_006.php on line %d
60+
__get protectedProperty
61+
Notice: Undefined index: protectedProperty in %__set__get_006.php on line %d
62+
__get privateProperty
63+
Notice: Undefined index: privateProperty in %__set__get_006.php on line %d
64+
__isset nonExisting
65+
__isset publicProperty
66+
__isset protectedProperty
67+
__isset privateProperty
68+
__set nonExisting
69+
__set publicProperty
70+
__set protectedProperty
71+
__set privateProperty

0 commit comments

Comments
 (0)