Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Ahead warp factor 1" -- Captain Kirk


devel / comp.lang.php / Re: set_error_handler(): duplicate error

SubjectAuthor
* set_error_handler(): duplicate erroralex
+- Re: set_error_handler(): duplicate errorIi Ii
`* Re: set_error_handler(): duplicate errorArno Welzel
 `* Re: set_error_handler(): duplicate erroralex
  +* Re: set_error_handler(): duplicate errorJerry Stuckle
  |+* Re: set_error_handler(): duplicate erroralex
  ||`* Re: set_error_handler(): duplicate errorJerry Stuckle
  || `- Re: set_error_handler(): duplicate errorArno Welzel
  |`- Re: set_error_handler(): duplicate errorArno Welzel
  `* Re: set_error_handler(): duplicate errorArno Welzel
   `* Re: set_error_handler(): duplicate erroralex
    `* Re: set_error_handler(): duplicate errorArno Welzel
     `* Re: set_error_handler(): duplicate erroralex
      +* Re: set_error_handler(): duplicate errorJ.O. Aho
      |`- Re: set_error_handler(): duplicate erroralex
      `- Re: set_error_handler(): duplicate errorArno Welzel

1
set_error_handler(): duplicate error

<s9ski4$42b$2@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=225&group=comp.lang.php#225

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!6+2AFoeh/3+CMByzLXk9vA.user.gioia.aioe.org.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: set_error_handler(): duplicate error
Date: Thu, 10 Jun 2021 11:04:04 +0200
Organization: Aioe.org NNTP Server
Lines: 27
Message-ID: <s9ski4$42b$2@gioia.aioe.org>
NNTP-Posting-Host: 6+2AFoeh/3+CMByzLXk9vA.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
X-Mozilla-News-Host: news://news.aioe.org:119
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Thu, 10 Jun 2021 09:04 UTC

<?php
//error_reporting(0);
set_error_handler(
static function (int $severity, string $message, string $file, int
$line): void {
throw new InternalErrorException($message, 0, $severity, $file,
$line);
}
);

xxx();

Output:

Fatal error: Uncaught Error: Call to undefined function xxx() in
/tmp/tmp.Ie1UVhkWcT/test.php on line 9

Error: Call to undefined function xxx() in /tmp/tmp.Ie1UVhkWcT/test.php
on line 9

Call Stack:
0.0001 392928 1. {main}() /tmp/tmp.Ie1UVhkWcT/test.php:0

Why error message showing is duplicate?
Furthermore, if uncommenting the error_reporting(0) instruction does not
show any errors.
is there a good compromise?

Re: set_error_handler(): duplicate error

<b10a8527-d102-4656-848c-e8acd16abfcan@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=227&group=comp.lang.php#227

  copy link   Newsgroups: comp.lang.php
X-Received: by 2002:ad4:576e:: with SMTP id r14mr9969896qvx.61.1623836367008; Wed, 16 Jun 2021 02:39:27 -0700 (PDT)
X-Received: by 2002:a25:a543:: with SMTP id h61mr5199150ybi.107.1623836366809; Wed, 16 Jun 2021 02:39:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.php
Date: Wed, 16 Jun 2021 02:39:26 -0700 (PDT)
In-Reply-To: <s9ski4$42b$2@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=193.40.120.146; posting-account=s3OxiwkAAABE2kqiXXKi7ZVC4Hsq_zQz
NNTP-Posting-Host: 193.40.120.146
References: <s9ski4$42b$2@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b10a8527-d102-4656-848c-e8acd16abfcan@googlegroups.com>
Subject: Re: set_error_handler(): duplicate error
From: ya12983@mail.com (Ii Ii)
Injection-Date: Wed, 16 Jun 2021 09:39:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 35
 by: Ii Ii - Wed, 16 Jun 2021 09:39 UTC

I have no idea, why it is like this.

alex kirjutas neljapäev, 10. juuni 2021 kl 12:04:11 UTC+3:
> <?php
> //error_reporting(0);
> set_error_handler(
> static function (int $severity, string $message, string $file, int
> $line): void {
> throw new InternalErrorException($message, 0, $severity, $file,
> $line);
> }
> );
>
> xxx();
>
> Output:
>
> Fatal error: Uncaught Error: Call to undefined function xxx() in
> /tmp/tmp.Ie1UVhkWcT/test.php on line 9
>
> Error: Call to undefined function xxx() in /tmp/tmp.Ie1UVhkWcT/test.php
> on line 9
>
> Call Stack:
> 0.0001 392928 1. {main}() /tmp/tmp.Ie1UVhkWcT/test.php:0
>
> Why error message showing is duplicate?
> Furthermore, if uncommenting the error_reporting(0) instruction does not
> show any errors.
> is there a good compromise?

Re: set_error_handler(): duplicate error

<iiu6nlForanU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=228&group=comp.lang.php#228

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Wed, 16 Jun 2021 13:48:06 +0200
Lines: 43
Message-ID: <iiu6nlForanU1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: individual.net UKyWZAumhVRLM5rDeZB5UwYSX76qCR4GPWurooPE3OHFD8dPfw
Cancel-Lock: sha1:CAFcb4FmfhM8KSvL7rhtG02LJAs=
In-Reply-To: <s9ski4$42b$2@gioia.aioe.org>
 by: Arno Welzel - Wed, 16 Jun 2021 11:48 UTC

alex:

> <?php
> //error_reporting(0);
> set_error_handler(
> static function (int $severity, string $message, string $file, int
> $line): void {
> throw new InternalErrorException($message, 0, $severity, $file,
> $line);
> }
> );
>
> xxx();
>
> Output:
>
> Fatal error: Uncaught Error: Call to undefined function xxx() in
> /tmp/tmp.Ie1UVhkWcT/test.php on line 9
>
> Error: Call to undefined function xxx() in /tmp/tmp.Ie1UVhkWcT/test.php
> on line 9
>
> Call Stack:
> 0.0001 392928 1. {main}() /tmp/tmp.Ie1UVhkWcT/test.php:0
>
> Why error message showing is duplicate?

I can't reproduce this. When I run this script with PHP 7.4 as CLI, I
only get the expected result:

PHP Fatal error: Uncaught Error: Call to undefined function xxx() in
D:\test-errorhandler.php:11
Stack trace:
#0 {main}
thrown in D:\test-errorhandler.php on line 11

Do you run the above script within a larger application which already
has some kind of error handling in place?

--
Arno Welzel
https://arnowelzel.de

Re: set_error_handler(): duplicate error

<sai4vp$11n3$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=229&group=comp.lang.php#229

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!QDJqk1g9u/o5wyA7AgO8zw.user.gioia.aioe.org.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Fri, 18 Jun 2021 14:53:14 +0200
Organization: Aioe.org NNTP Server
Lines: 46
Message-ID: <sai4vp$11n3$1@gioia.aioe.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
NNTP-Posting-Host: QDJqk1g9u/o5wyA7AgO8zw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Fri, 18 Jun 2021 12:53 UTC

Il 16/06/21 13:48, Arno Welzel ha scritto:
> I can't reproduce this.

????

> When I run this script with PHP 7.4 as CLI, I
> only get the expected result:
>
> PHP Fatal error: Uncaught Error: Call to undefined function xxx() in
> D:\test-errorhandler.php:11
> Stack trace:
> #0 {main}
> thrown in D:\test-errorhandler.php on line 11
>
> Do you run the above script within a larger application which already
> has some kind of error handling in place?

No.

$ php -v
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
tmp.MLHFJ8krVq$ cat test.php
<?php
set_error_handler(
static function (int $severity, string $message, string $file, int
$line): void {
throw new InternalErrorException($message, 0, $severity, $file,
$line);
}
);
xxx();
tmp.MLHFJ8krVq$ php test.php

Fatal error: Uncaught Error: Call to undefined function xxx() in
/tmp/tmp.MLHFJ8krVq/test.php on line 7

Error: Call to undefined function xxx() in /tmp/tmp.MLHFJ8krVq/test.php
on line 7

Call Stack:
0.0001 394848 1. {main}() /tmp/tmp.MLHFJ8krVq/test.php:0

Re: set_error_handler(): duplicate error

<sajj55$jqj$1@jstuckle.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=230&group=comp.lang.php#230

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: jstucklex@attglobal.net (Jerry Stuckle)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Fri, 18 Jun 2021 22:00:55 -0400
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <sajj55$jqj$1@jstuckle.eternal-september.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Jun 2021 02:01:09 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="acae666d126181bcca111ccdea9db830";
logging-data="20307"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KFkuRhci5J93IfbkZJ2RGSpUPsD/y9Do="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:vFnJgeQkG51RUPVvvIfRIvQ2jWg=
In-Reply-To: <sai4vp$11n3$1@gioia.aioe.org>
Content-Language: en-US
 by: Jerry Stuckle - Sat, 19 Jun 2021 02:00 UTC

On 6/18/2021 8:53 AM, alex wrote:
> Il 16/06/21 13:48, Arno Welzel ha scritto:
>> I can't reproduce this.
>
> ????
>
>> When I run this script with PHP 7.4 as CLI, I
>> only get the expected result:
>>
>> PHP Fatal error:  Uncaught Error: Call to undefined function xxx() in
>> D:\test-errorhandler.php:11
>> Stack trace:
>> #0 {main}
>>    thrown in D:\test-errorhandler.php on line 11
>>
>> Do you run the above script within a larger application which already
>> has some kind of error handling in place?
>
> No.
>
> $ php -v
> PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
> Copyright (c) The PHP Group
> Zend Engine v3.4.0, Copyright (c) Zend Technologies
>     with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
>     with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
> tmp.MLHFJ8krVq$ cat test.php
> <?php
> set_error_handler(
>     static function (int $severity, string $message, string $file, int
> $line): void {
>         throw new InternalErrorException($message, 0, $severity, $file,
> $line);
>     }
> );
> xxx();
> tmp.MLHFJ8krVq$ php test.php
>
> Fatal error: Uncaught Error: Call to undefined function xxx() in
> /tmp/tmp.MLHFJ8krVq/test.php on line 7
>
> Error: Call to undefined function xxx() in /tmp/tmp.MLHFJ8krVq/test.php
> on line 7
>
> Call Stack:
>     0.0001     394848   1. {main}() /tmp/tmp.MLHFJ8krVq/test.php:0
>

set_error_handler() requires a real function as its parameter, not
something dynamically defined.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Re: set_error_handler(): duplicate error

<sakvm9$168h$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=231&group=comp.lang.php#231

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!1oHfs+FeoV5z+LoZLTKQCg.user.gioia.aioe.org.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Sat, 19 Jun 2021 16:41:14 +0200
Organization: Aioe.org NNTP Server
Lines: 27
Message-ID: <sakvm9$168h$1@gioia.aioe.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <sajj55$jqj$1@jstuckle.eternal-september.org>
NNTP-Posting-Host: 1oHfs+FeoV5z+LoZLTKQCg.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Sat, 19 Jun 2021 14:41 UTC

Il 19/06/21 04:00, Jerry Stuckle ha scritto:
>
> set_error_handler() requires a real function as its parameter, not
> something dynamically defined.

class C {
static function f($severity, $message) {
throw new InternalErrorException($message);
}
}

set_error_handler('C::f');

xxx();

Output

Fatal error: Uncaught Error: Call to undefined function xxx() in
/tmp/tmp.F06vf0Q7H0/test.php on line 10

Error: Call to undefined function xxx() in /tmp/tmp.F06vf0Q7H0/test.php
on line 10

Call Stack:
0.0001 394552 1. {main}() /tmp/tmp.F06vf0Q7H0/test.php:0

Re: set_error_handler(): duplicate error

<salu6v$qr1$1@jstuckle.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=232&group=comp.lang.php#232

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: jstucklex@attglobal.net (Jerry Stuckle)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Sat, 19 Jun 2021 19:21:51 -0400
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <salu6v$qr1$1@jstuckle.eternal-september.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <sajj55$jqj$1@jstuckle.eternal-september.org>
<sakvm9$168h$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Jun 2021 23:22:08 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="70227fc48f1f683d5f6a67c447b1afd9";
logging-data="27489"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mK4O0t8IYyU1jdDsCP+E5FWU5mN5x7xo="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:MSncbfRgGK2SS+4dhQ6BPEL9Eh4=
In-Reply-To: <sakvm9$168h$1@gioia.aioe.org>
Content-Language: en-US
 by: Jerry Stuckle - Sat, 19 Jun 2021 23:21 UTC

On 6/19/2021 10:41 AM, alex wrote:
> Il 19/06/21 04:00, Jerry Stuckle ha scritto:
>>
>> set_error_handler() requires a real function as its parameter, not
>> something dynamically defined.
>
> class C {
>     static function f($severity, $message) {
>         throw new InternalErrorException($message);
>     }
> }
>
> set_error_handler('C::f');
>
> xxx();
>
> Output
>
> Fatal error: Uncaught Error: Call to undefined function xxx() in
> /tmp/tmp.F06vf0Q7H0/test.php on line 10
>
> Error: Call to undefined function xxx() in /tmp/tmp.F06vf0Q7H0/test.php
> on line 10
>
> Call Stack:
>     0.0001     394552   1. {main}() /tmp/tmp.F06vf0Q7H0/test.php:0
>
>

Normal operation. See the restrictions under set_error_handler(), namely

"The following error types cannot be handled with a user defined
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR, E_COMPILE_WARNING independent of where they were
raised, and most of E_STRICT raised in the file where
set_error_handler() is called. "

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Re: set_error_handler(): duplicate error

<ij8kteFp5ocU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=233&group=comp.lang.php#233

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Sun, 20 Jun 2021 12:51:26 +0200
Lines: 84
Message-ID: <ij8kteFp5ocU1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: individual.net qnBwmHCr8mMqaRoY4z7DqQWUWxUhWCDTVILEBeVXChFuo/pxqb
Cancel-Lock: sha1:5sA1BsCLIGAND/sN9oT20JD9PGs=
In-Reply-To: <sai4vp$11n3$1@gioia.aioe.org>
 by: Arno Welzel - Sun, 20 Jun 2021 10:51 UTC

alex:

> Il 16/06/21 13:48, Arno Welzel ha scritto:
>> I can't reproduce this.
>
> ????

When I run your script, I only get *one* error output, not two.

>> When I run this script with PHP 7.4 as CLI, I
>> only get the expected result:
>>
>> PHP Fatal error: Uncaught Error: Call to undefined function xxx() in
>> D:\test-errorhandler.php:11
>> Stack trace:
>> #0 {main}
>> thrown in D:\test-errorhandler.php on line 11
>>
>> Do you run the above script within a larger application which already
>> has some kind of error handling in place?
>
> No.
>
> $ php -v
> PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
> Copyright (c) The PHP Group
> Zend Engine v3.4.0, Copyright (c) Zend Technologies
> with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
> with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
> tmp.MLHFJ8krVq$ cat test.php
> <?php
> set_error_handler(
> static function (int $severity, string $message, string $file, int
> $line): void {
> throw new InternalErrorException($message, 0, $severity, $file,
> $line);
> }
> );
> xxx();
> tmp.MLHFJ8krVq$ php test.php
>
> Fatal error: Uncaught Error: Call to undefined function xxx() in
> /tmp/tmp.MLHFJ8krVq/test.php on line 7
>
> Error: Call to undefined function xxx() in /tmp/tmp.MLHFJ8krVq/test.php
> on line 7
>
> Call Stack:
> 0.0001 394848 1. {main}() /tmp/tmp.MLHFJ8krVq/test.php:0

Does not happen here:

$ php -v
PHP 7.4.20 (cli) (built: Jun 4 2021 21:24:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.20, Copyright (c), by Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

$ cat error-test.php
<?php
set_error_handler(
static function (int $severity, string $message, string $file, int
$line): void {
throw new InternalErrorException($message, 0, $severity, $file,
$line);
}
);
xxx();

$ php error-test.php

$ php error-test.php
PHP Fatal error: Uncaught Error: Call to undefined function xxx() in
/home/arno/error-test.php:7
Stack trace:
#0 {main}
thrown in /home/arno/error-test.php on line 7

So this is a local problem specific to your setup.

--
Arno Welzel
https://arnowelzel.de

Re: set_error_handler(): duplicate error

<ij8ligFp9b6U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=234&group=comp.lang.php#234

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Sun, 20 Jun 2021 13:02:40 +0200
Lines: 66
Message-ID: <ij8ligFp9b6U1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <sajj55$jqj$1@jstuckle.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: individual.net ofu9djPlnP2PLhoEObc28QFHJBZwVwGOoiSOdi6JxAWH3Zc8bi
Cancel-Lock: sha1:X0HXtV1HQzwdHPVEWpgys2K7wak=
In-Reply-To: <sajj55$jqj$1@jstuckle.eternal-september.org>
 by: Arno Welzel - Sun, 20 Jun 2021 11:02 UTC

Jerry Stuckle:

[...]
> set_error_handler() requires a real function as its parameter, not
> something dynamically defined.

set_error_handler() requires a *callable* not a function. An anonymous
function is just fine - as this *is* a callable. This applies to *every*
function in PHP which wants a callable and is quite handy to avoid
declaring new functions if you just need it once for a specific callback:

-------------------------------------------

<?php
$array = [
[ 'x' => 1, 'y' => 2 ],
[ 'x' => 6, 'y' => 1 ],
[ 'x' => 3, 'y' => 7 ],
];

usort(
$array,
function($a, $b) {
if ($a['x'] == $b['x']) {
return 0;
} else if ($a['x'] > $b['x']) {
return 1;
} else {
return -1;
}
}
);

print_r($array);

-------------------------------------------

Result:

Array
( [0] => Array
(
[x] => 1
[y] => 2
)

[1] => Array
(
[x] => 3
[y] => 7
)

[2] => Array
(
[x] => 6
[y] => 1
)

)

--
Arno Welzel
https://arnowelzel.de

Re: set_error_handler(): duplicate error

<ij8m13Fpc2cU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=235&group=comp.lang.php#235

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Sun, 20 Jun 2021 13:10:28 +0200
Lines: 87
Message-ID: <ij8m13Fpc2cU1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <sajj55$jqj$1@jstuckle.eternal-september.org>
<sakvm9$168h$1@gioia.aioe.org> <salu6v$qr1$1@jstuckle.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: individual.net kvS+/4g5eOebn9eg9pC9DwyoNK/f8kxoEEbBGtUtWR0EIkXmK1
Cancel-Lock: sha1:gj0qD+vVO5m+Cy2hvWWgsGC5sDc=
In-Reply-To: <salu6v$qr1$1@jstuckle.eternal-september.org>
 by: Arno Welzel - Sun, 20 Jun 2021 11:10 UTC

Jerry Stuckle:

> On 6/19/2021 10:41 AM, alex wrote:
>> Il 19/06/21 04:00, Jerry Stuckle ha scritto:
>>>
>>> set_error_handler() requires a real function as its parameter, not
>>> something dynamically defined.
>>
>> class C {
>>     static function f($severity, $message) {
>>         throw new InternalErrorException($message);
>>     }
>> }
>>
>> set_error_handler('C::f');
>>
>> xxx();
>>
>> Output
>>
>> Fatal error: Uncaught Error: Call to undefined function xxx() in
>> /tmp/tmp.F06vf0Q7H0/test.php on line 10
>>
>> Error: Call to undefined function xxx() in /tmp/tmp.F06vf0Q7H0/test.php
>> on line 10
>>
>> Call Stack:
>>     0.0001     394552   1. {main}() /tmp/tmp.F06vf0Q7H0/test.php:0
>>
>>
>
> Normal operation. See the restrictions under set_error_handler(), namely
>
> "The following error types cannot be handled with a user defined
> function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
> E_COMPILE_ERROR, E_COMPILE_WARNING independent of where they were
> raised, and most of E_STRICT raised in the file where
> set_error_handler() is called. "

Thanks for pointing this out.

Also see: <https://www.php.net/manual/en/function.set-error-handler.php>

This means, if such an error ocurrs - like calling an undefined function
- it will *not* be passed to the handler defined in set_error_handler().

So this works:

------------------------------

<?php
set_error_handler(
function(
int $severity,
string $message,
string $file,
int $line
): void {
throw new Exception('Error catched: '.$message);
}
);

$a = 1/0;

------------------------------

But this *not*, because calling an undefined function will *not* be
passed to the user error handler:

<?php
set_error_handler(
function(
int $severity,
string $message,
string $file,
int $line
): void {
throw new Exception('Error catched: '.$message);
}
);

xxx();

--
Arno Welzel
https://arnowelzel.de

Re: set_error_handler(): duplicate error

<saq9ua$1j8h$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=236&group=comp.lang.php#236

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!Y11QpVhWXa5uEVAJoLsJGg.user.gioia.aioe.org.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Mon, 21 Jun 2021 17:06:52 +0200
Organization: Aioe.org NNTP Server
Lines: 30
Message-ID: <saq9ua$1j8h$1@gioia.aioe.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <ij8kteFp5ocU1@mid.individual.net>
NNTP-Posting-Host: Y11QpVhWXa5uEVAJoLsJGg.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Mon, 21 Jun 2021 15:06 UTC

Il 20/06/21 12:51, Arno Welzel ha scritto:
> So this is a local problem specific to your setup.

But I would like to understand what it is.
Meanwhile, here's another curious thing.

<?php
echo $xxx;// one message (logical)
xxx();// two messages (not logical)

Output:

Notice: Undefined variable: xxx in /tmp/tmp.5vTeAJd7Py/test.php on line 2

Call Stack:
0.0001 391384 1. {main}() /tmp/tmp.5vTeAJd7Py/test.php:0

Fatal error: Uncaught Error: Call to undefined function xxx() in
/tmp/tmp.5vTeAJd7Py/test.php on line 3

Error: Call to undefined function xxx() in /tmp/tmp.5vTeAJd7Py/test.php
on line 3

Call Stack:
0.0001 391384 1. {main}() /tmp/tmp.5vTeAJd7Py/test.php:0

Re: set_error_handler(): duplicate error

<ijc1ehFen8qU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=237&group=comp.lang.php#237

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Mon, 21 Jun 2021 19:43:45 +0200
Lines: 65
Message-ID: <ijc1ehFen8qU1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <ij8kteFp5ocU1@mid.individual.net>
<saq9ua$1j8h$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 9dnAw7EQeeionubRf/+9uwslOQWELY5J4n0Rdq6SrnLWOPxbUY
Cancel-Lock: sha1:0UpTOKd2/zO0e4AbOaUIncNKgis=
In-Reply-To: <saq9ua$1j8h$1@gioia.aioe.org>
 by: Arno Welzel - Mon, 21 Jun 2021 17:43 UTC

alex:

> Il 20/06/21 12:51, Arno Welzel ha scritto:
>> So this is a local problem specific to your setup.
>
> But I would like to understand what it is.

After playing around a bit with the code:

Propably because you have "display_errors = On" in your php.ini.

In my php.ini I have:

display_errors = Off

But when I change this to:

display_errors = On

Tada! Now I also get every error twice:

---------

$ php error-test.php
PHP Fatal error: Uncaught Error: Call to undefined function xxx() in
/home/arno/error-test.php:9
Stack trace:
#0 {main}
thrown in /home/arno/error-test.php on line 9

Fatal error: Uncaught Error: Call to undefined function xxx() in
/home/arno/error-test.php:9
Stack trace:
#0 {main}
thrown in /home/arno/error-test.php on line 9

---------

And even if set_error_handler() will be used, it stays like this:

---------

$ php error-test.php
PHP Fatal error: Uncaught Exception: Error catched: Division by zero in
/home/arno/error-test.php:4
Stack trace:
#0 /home/arno/error-test.php(8): {closure}()
#1 {main}
thrown in /home/arno/error-test.php on line 4

Fatal error: Uncaught Exception: Error catched: Division by zero in
/home/arno/error-test.php:4
Stack trace:
#0 /home/arno/error-test.php(8): {closure}()
#1 {main}
thrown in /home/arno/error-test.php on line 4

---------

So my verdict: make sure you have "display_errors = Off" in your php.ini.

--
Arno Welzel
https://arnowelzel.de

Re: set_error_handler(): duplicate error

<sasr13$1n9p$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=238&group=comp.lang.php#238

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!Y11QpVhWXa5uEVAJoLsJGg.user.gioia.aioe.org.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Tue, 22 Jun 2021 16:10:44 +0200
Organization: Aioe.org NNTP Server
Lines: 69
Message-ID: <sasr13$1n9p$1@gioia.aioe.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <ij8kteFp5ocU1@mid.individual.net>
<saq9ua$1j8h$1@gioia.aioe.org> <ijc1ehFen8qU1@mid.individual.net>
NNTP-Posting-Host: Y11QpVhWXa5uEVAJoLsJGg.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: it-IT
 by: alex - Tue, 22 Jun 2021 14:10 UTC

Il 21/06/21 19:43, Arno Welzel ha scritto:
> alex:
>
>> Il 20/06/21 12:51, Arno Welzel ha scritto:
>>> So this is a local problem specific to your setup.
>>
>> But I would like to understand what it is.
>
> After playing around a bit with the code:
>
> Propably because you have "display_errors = On" in your php.ini.
>
> In my php.ini I have:
>
> display_errors = Off
>
> But when I change this to:
>
> display_errors = On
>
> Tada! Now I also get every error twice:

Exact.
When it is off, no errors are seen.
Bah...
Strange behavior: you can't get the right compromise.

> $ php error-test.php
> PHP Fatal error: Uncaught Error: Call to undefined function xxx() in
> /home/arno/error-test.php:9
> Stack trace:
> #0 {main}
> thrown in /home/arno/error-test.php on line 9
>
> Fatal error: Uncaught Error: Call to undefined function xxx() in
> /home/arno/error-test.php:9
> Stack trace:
> #0 {main}
> thrown in /home/arno/error-test.php on line 9
>
> ---------
>
> And even if set_error_handler() will be used, it stays like this:
>
> ---------
>
> $ php error-test.php
> PHP Fatal error: Uncaught Exception: Error catched: Division by zero in
> /home/arno/error-test.php:4
> Stack trace:
> #0 /home/arno/error-test.php(8): {closure}()
> #1 {main}
> thrown in /home/arno/error-test.php on line 4
>
> Fatal error: Uncaught Exception: Error catched: Division by zero in
> /home/arno/error-test.php:4
> Stack trace:
> #0 /home/arno/error-test.php(8): {closure}()
> #1 {main}
> thrown in /home/arno/error-test.php on line 4
>
> ---------
>
> So my verdict: make sure you have "display_errors = Off" in your php.ini.
>
>

So as already mentioned (if no error handler is implemented) I can't see
any errors :|

Re: set_error_handler(): duplicate error

<ijeggiFt7asU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=239&group=comp.lang.php#239

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Tue, 22 Jun 2021 18:13:05 +0200
Lines: 27
Message-ID: <ijeggiFt7asU1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <ij8kteFp5ocU1@mid.individual.net>
<saq9ua$1j8h$1@gioia.aioe.org> <ijc1ehFen8qU1@mid.individual.net>
<sasr13$1n9p$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net TpO2KuEtQ44tY928HqFoFgCowWUffgOeNIHaF1JsXpEBP6+Xf7
Cancel-Lock: sha1:wN3rOXudO+9t2R3QPKOW9ZGYzVU=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
In-Reply-To: <sasr13$1n9p$1@gioia.aioe.org>
Content-Language: en-US-large
 by: J.O. Aho - Tue, 22 Jun 2021 16:13 UTC

On 22/06/2021 16.10, alex wrote:

> So as already mentioned (if no error handler is implemented) I can't see
> any errors :|

php.ini:
error_log = syslog

if enabled, errors will be logged to the systems log system

example:
Jun 22 16:09:39 machine php: PHP Fatal error: Uncaught Error: Call to
undefined function xx() in /tmp/a.php:2
Jun 22 16:09:39 machine php: Stack trace:
Jun 22 16:09:39 machine php: #0 {main}
Jun 22 16:09:39 machine php: thrown in /tmp/a.php on line 2

file in question:
<?php
xx();

--

//Aho

Re: set_error_handler(): duplicate error

<ijg9dqF9084U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=240&group=comp.lang.php#240

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Wed, 23 Jun 2021 10:24:27 +0200
Lines: 18
Message-ID: <ijg9dqF9084U1@mid.individual.net>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <ij8kteFp5ocU1@mid.individual.net>
<saq9ua$1j8h$1@gioia.aioe.org> <ijc1ehFen8qU1@mid.individual.net>
<sasr13$1n9p$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: individual.net eytlMFa8tnH+xe/20bZLTweHWzwIIAPsfBkoSwpGpA9BHO7DNq
Cancel-Lock: sha1:TwSwPAwEie1EjxCERMd53mmdP68=
In-Reply-To: <sasr13$1n9p$1@gioia.aioe.org>
 by: Arno Welzel - Wed, 23 Jun 2021 08:24 UTC

alex:

> Il 21/06/21 19:43, Arno Welzel ha scritto:
[...]
>> So my verdict: make sure you have "display_errors = Off" in your php.ini.
>>
>>
>
> So as already mentioned (if no error handler is implemented) I can't see
> any errors :|

I talk about display_errors and NOT error_reporting!

--
Arno Welzel
https://arnowelzel.de

Re: set_error_handler(): duplicate error

<sav6a9$1f91$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=241&group=comp.lang.php#241

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!k5DdsEKJaHOnRFilL+gtrQ.user.gioia.aioe.org.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: set_error_handler(): duplicate error
Date: Wed, 23 Jun 2021 13:35:36 +0200
Organization: Aioe.org NNTP Server
Lines: 41
Message-ID: <sav6a9$1f91$1@gioia.aioe.org>
References: <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net>
<sai4vp$11n3$1@gioia.aioe.org> <ij8kteFp5ocU1@mid.individual.net>
<saq9ua$1j8h$1@gioia.aioe.org> <ijc1ehFen8qU1@mid.individual.net>
<sasr13$1n9p$1@gioia.aioe.org> <ijeggiFt7asU1@mid.individual.net>
NNTP-Posting-Host: k5DdsEKJaHOnRFilL+gtrQ.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Wed, 23 Jun 2021 11:35 UTC

Il 22/06/21 18:13, J.O. Aho ha scritto:
>
> On 22/06/2021 16.10, alex wrote:
>
>> So as already mentioned (if no error handler is implemented) I can't
>> see any errors :|
>
> php.ini:
> error_log = syslog
>
> if enabled, errors will be logged to the systems log system
>
>
> example:
> Jun 22 16:09:39 machine php: PHP Fatal error:  Uncaught Error: Call to
> undefined function xx() in /tmp/a.php:2
> Jun 22 16:09:39 machine php: Stack trace:
> Jun 22 16:09:39 machine php: #0 {main}
> Jun 22 16:09:39 machine php:   thrown in /tmp/a.php on line 2
>
> file in question:
> <?php
> xx();
>
>

<?php
var_dump(ini_get('error_log'));
xxx();
------------------
/tmp/tmp.PaOxmRpwmD/test.php:2:
string(6) "syslog"

Fatal error: Uncaught Error: Call to undefined function xxx() in
/tmp/tmp.PaOxmRpwmD/test.php on line 3

Error: Call to undefined function xxx() in /tmp/tmp.PaOxmRpwmD/test.php
on line 3

Call Stack:
0.0049 393400 1. {main}() /tmp/tmp.PaOxmRpwmD/test.php:0

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor