Skip to content

Commit b5dad20

Browse files
committed
merge: header, PhpStackTrace
1 parent 9d72b9e commit b5dad20

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Peachpie.Library/Web.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,23 @@ static bool TryMatchHttpStatusHeader(ReadOnlySpan<char> header, out int code)
514514
/// </remarks>
515515
public static void header(Context ctx, string str, bool replace = true, int http_response_code = 0)
516516
{
517+
if (string.IsNullOrEmpty(str))
518+
{
519+
// empty arg, ignore
520+
//PhpException.InvalidArgument(nameof(str));
521+
return;
522+
}
523+
517524
var webctx = ctx.HttpPhpContext;
518-
if (webctx == null || string.IsNullOrEmpty(str) || webctx.HeadersSent)
525+
if (webctx == null)
526+
{
527+
// ignore on console app
528+
return;
529+
}
530+
531+
if (webctx.HeadersSent)
519532
{
533+
// header sent
520534
PhpException.Throw(PhpError.Notice, Resources.Resources.headers_has_been_sent);
521535
return;
522536
}

src/Peachpie.Runtime/Reflection/PhpStackTrace.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ public string TypeName
341341

342342
if (tinfo.IsPublic && tinfo.IsAbstract) // => public static
343343
{
344-
if (tinfo.Assembly.IsDefined(typeof(PhpExtensionAttribute)))
344+
var extensionAttrs = Attribute.GetCustomAttributes(tinfo.Assembly, typeof(PhpExtensionAttribute));
345+
if (extensionAttrs != null && extensionAttrs.Length != 0)
345346
{
346347
// library function
347348
return null;

0 commit comments

Comments
 (0)