Skip to content

Commit f7e2d37

Browse files
committed
Fixed View::dispatch and improved File::size
- View::dispatch: it was possible to fire the dispatch views more than once if an exception occurred. - Inphinit\Experimental\File::size: Curl uses headers in FILE protocol, content-length can returns value with white-spaces or note (depends on the PHP version (or if you are using PHP or HHVM), there are no guarantees in the format so the space check is optional)
1 parent 8573758 commit f7e2d37

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Experimental/File.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class File extends \Inphinit\File
1818
* @param int $init
1919
* @param int $end
2020
* @param bool $lines
21+
* @throws \Inphinit\Experimental\Exception
2122
* @return string
2223
*/
2324
public static function portion($path, $init = 0, $end = 1024, $lines = false)
@@ -52,6 +53,7 @@ public static function portion($path, $init = 0, $end = 1024, $lines = false)
5253
* Determines whether the file is binary
5354
*
5455
* @param string $path
56+
* @throws \Inphinit\Experimental\Exception
5557
* @return bool
5658
*/
5759
public static function isBinary($path)
@@ -76,6 +78,7 @@ public static function isBinary($path)
7678
* Return `false` if file is not found
7779
*
7880
* @param string $path
81+
* @throws \Inphinit\Experimental\Exception
7982
* @return string|bool
8083
*/
8184
public static function size($path)
@@ -93,8 +96,8 @@ public static function size($path)
9396

9497
$ch = null;
9598

96-
if (preg_match('#content-length:\s+?(\d+)#i', $headers, $matches)) {
97-
return $matches[1];
99+
if (preg_match('#content-length:(\s+?|)(\d+)#i', $headers, $matches)) {
100+
return $matches[2];
98101
}
99102

100103
return false;

src/Inphinit/Viewing/View.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ public static function forceRender()
3535
*/
3636
public static function dispatch()
3737
{
38+
if (self::$force) {
39+
return null;
40+
}
41+
3842
self::forceRender();
3943

4044
if (self::$views) {
41-
foreach (self::$views as $value) {
45+
foreach (self::$views as &$value) {
4246
$value && self::render($value[0], $value[1]);
4347
}
44-
45-
self::$views = null;
4648
}
4749
}
4850

0 commit comments

Comments
 (0)