Skip to content

Commit 90f0a77

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
2 parents d72a4d1 + 96cc419 commit 90f0a77

File tree

3 files changed

+192
-1
lines changed

3 files changed

+192
-1
lines changed

ext/ftp/php_ftp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,9 @@ PHP_FUNCTION(ftp_nb_get)
968968
RETURN_LONG(PHP_FTP_FAILED);
969969
}
970970

971-
php_stream_close(outstream);
971+
if (ret == PHP_FTP_FINISHED){
972+
php_stream_close(outstream);
973+
}
972974

973975
RETURN_LONG(ret);
974976
}

ext/ftp/tests/ftp_nb_continue.phpt

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
--TEST--
2+
Testing whether ftp_nb_continue() fetches more data
3+
--SKIPIF--
4+
<?php
5+
require 'skipif.inc';
6+
?>
7+
--FILE--
8+
<?php
9+
require 'server.inc';
10+
11+
$file = "mediumfile.txt";
12+
13+
$ftp = ftp_connect('127.0.0.1', $port);
14+
ftp_login($ftp, 'user', 'pass');
15+
if (!$ftp) die("Couldn't connect to the server");
16+
17+
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $file;
18+
touch($local_file);
19+
20+
$r = ftp_nb_get($ftp, $local_file, $file, FTP_BINARY);
21+
while ($r == FTP_MOREDATA) {
22+
$r = ftp_nb_continue($ftp);
23+
}
24+
ftp_close($ftp);
25+
26+
echo file_get_contents($local_file);
27+
?>
28+
--CLEAN--
29+
<?php
30+
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "mediumfile.txt");
31+
?>
32+
--EXPECT--
33+
This is line 0 of the test data.
34+
This is line 1 of the test data.
35+
This is line 2 of the test data.
36+
This is line 3 of the test data.
37+
This is line 4 of the test data.
38+
This is line 5 of the test data.
39+
This is line 6 of the test data.
40+
This is line 7 of the test data.
41+
This is line 8 of the test data.
42+
This is line 9 of the test data.
43+
This is line 10 of the test data.
44+
This is line 11 of the test data.
45+
This is line 12 of the test data.
46+
This is line 13 of the test data.
47+
This is line 14 of the test data.
48+
This is line 15 of the test data.
49+
This is line 16 of the test data.
50+
This is line 17 of the test data.
51+
This is line 18 of the test data.
52+
This is line 19 of the test data.
53+
This is line 20 of the test data.
54+
This is line 21 of the test data.
55+
This is line 22 of the test data.
56+
This is line 23 of the test data.
57+
This is line 24 of the test data.
58+
This is line 25 of the test data.
59+
This is line 26 of the test data.
60+
This is line 27 of the test data.
61+
This is line 28 of the test data.
62+
This is line 29 of the test data.
63+
This is line 30 of the test data.
64+
This is line 31 of the test data.
65+
This is line 32 of the test data.
66+
This is line 33 of the test data.
67+
This is line 34 of the test data.
68+
This is line 35 of the test data.
69+
This is line 36 of the test data.
70+
This is line 37 of the test data.
71+
This is line 38 of the test data.
72+
This is line 39 of the test data.
73+
This is line 40 of the test data.
74+
This is line 41 of the test data.
75+
This is line 42 of the test data.
76+
This is line 43 of the test data.
77+
This is line 44 of the test data.
78+
This is line 45 of the test data.
79+
This is line 46 of the test data.
80+
This is line 47 of the test data.
81+
This is line 48 of the test data.
82+
This is line 49 of the test data.
83+
This is line 50 of the test data.
84+
This is line 51 of the test data.
85+
This is line 52 of the test data.
86+
This is line 53 of the test data.
87+
This is line 54 of the test data.
88+
This is line 55 of the test data.
89+
This is line 56 of the test data.
90+
This is line 57 of the test data.
91+
This is line 58 of the test data.
92+
This is line 59 of the test data.
93+
This is line 60 of the test data.
94+
This is line 61 of the test data.
95+
This is line 62 of the test data.
96+
This is line 63 of the test data.
97+
This is line 64 of the test data.
98+
This is line 65 of the test data.
99+
This is line 66 of the test data.
100+
This is line 67 of the test data.
101+
This is line 68 of the test data.
102+
This is line 69 of the test data.
103+
This is line 70 of the test data.
104+
This is line 71 of the test data.
105+
This is line 72 of the test data.
106+
This is line 73 of the test data.
107+
This is line 74 of the test data.
108+
This is line 75 of the test data.
109+
This is line 76 of the test data.
110+
This is line 77 of the test data.
111+
This is line 78 of the test data.
112+
This is line 79 of the test data.
113+
This is line 80 of the test data.
114+
This is line 81 of the test data.
115+
This is line 82 of the test data.
116+
This is line 83 of the test data.
117+
This is line 84 of the test data.
118+
This is line 85 of the test data.
119+
This is line 86 of the test data.
120+
This is line 87 of the test data.
121+
This is line 88 of the test data.
122+
This is line 89 of the test data.
123+
This is line 90 of the test data.
124+
This is line 91 of the test data.
125+
This is line 92 of the test data.
126+
This is line 93 of the test data.
127+
This is line 94 of the test data.
128+
This is line 95 of the test data.
129+
This is line 96 of the test data.
130+
This is line 97 of the test data.
131+
This is line 98 of the test data.
132+
This is line 99 of the test data.
133+
This is line 100 of the test data.
134+
This is line 101 of the test data.
135+
This is line 102 of the test data.
136+
This is line 103 of the test data.
137+
This is line 104 of the test data.
138+
This is line 105 of the test data.
139+
This is line 106 of the test data.
140+
This is line 107 of the test data.
141+
This is line 108 of the test data.
142+
This is line 109 of the test data.
143+
This is line 110 of the test data.
144+
This is line 111 of the test data.
145+
This is line 112 of the test data.
146+
This is line 113 of the test data.
147+
This is line 114 of the test data.
148+
This is line 115 of the test data.
149+
This is line 116 of the test data.
150+
This is line 117 of the test data.
151+
This is line 118 of the test data.
152+
This is line 119 of the test data.
153+
This is line 120 of the test data.
154+
This is line 121 of the test data.
155+
This is line 122 of the test data.
156+
This is line 123 of the test data.
157+
This is line 124 of the test data.
158+
This is line 125 of the test data.
159+
This is line 126 of the test data.
160+
This is line 127 of the test data.
161+
This is line 128 of the test data.
162+
This is line 129 of the test data.
163+
This is line 130 of the test data.
164+
This is line 131 of the test data.
165+
This is line 132 of the test data.
166+
This is line 133 of the test data.
167+
This is line 134 of the test data.
168+
This is line 135 of the test data.
169+
This is line 136 of the test data.
170+
This is line 137 of the test data.
171+
This is line 138 of the test data.
172+
This is line 139 of the test data.
173+
This is line 140 of the test data.
174+
This is line 141 of the test data.
175+
This is line 142 of the test data.
176+
This is line 143 of the test data.
177+
This is line 144 of the test data.
178+
This is line 145 of the test data.
179+
This is line 146 of the test data.
180+
This is line 147 of the test data.
181+
This is line 148 of the test data.
182+
This is line 149 of the test data.

ext/ftp/tests/server.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,13 @@ if ($pid) {
368368
}
369369
fputs($s, "226 Closing data Connection.\r\n");
370370
break;
371+
case "mediumfile":
372+
fputs($s, "150 File status okay; about to open data connection.\r\n");
373+
for($i = 0; $i < 150; $i++){
374+
fputs($fs, "This is line $i of the test data.\n");
375+
}
376+
fputs($s, "226 Closing data Connection.\r\n");
377+
371378
default:
372379
fputs($s, "550 {$matches[1]}: No such file or directory \r\n");
373380
break;

0 commit comments

Comments
 (0)