# [PATCH] make "Call to a member function on a non-object" non-fatal

- Thread: https://externals.io/message/1931
- Original archive: https://news-web.php.net/php.internals/1931
- Started by Morten Poulsen on 2003-05-23T15:43:46+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1931 — Morten Poulsen — 2003-05-23T15:43:46+00:00

URL: https://externals.io/message/1931#1931

Hi,

The attached patch (against zend_execute.c 1.316.2.10) changes a "Call
to a member function on a non-object" from `E_ERROR` to `E_WARNING` so it
can be handled by a "user space" error handler.

Best regards,
Morten Poulsen

-- 
Morten Poulsen <morten+php@afdelingp.dk

---

## #1932 — Per Lundberg — 2003-05-23T16:00:33+00:00

URL: https://externals.io/message/1931#1932 · In reply to: #1931

> The attached patch (against zend_execute.c 1.316.2.10) changes a "Call
> to a member function on a non-object" from `E_ERROR` to `E_WARNING` so it
> can be handled by a "user space" error handler.

I think this patch is bad.  It distorts the control flow of a normal
program.  Calling member functions on a non-object is a serious error,
so the only real option IMO is dying, or throwing an exception.
--
Best regards,

Per Lundberg / Capio ApS
Phone: +46-18-4186040
Fax: +46-18-4186049
Web: http://www.nobolt.com

---

## #1934 — Derick Rethans — 2003-05-23T16:45:27+00:00

URL: https://externals.io/message/1931#1934 · In reply to: #1931

> The attached patch (against zend_execute.c 1.316.2.10) changes a "Call
> to a member function on a non-object" from `E_ERROR` to `E_WARNING` so it
> can be handled by a "user space" error handler.

It should fail, `E_ERROR` is just fine.

Derick

-- 
                                        "my other box is your windows PC"
-------------------------------------------------------------------------
 Derick Rethans                                 http://derickrethans.nl/ 
 International PHP Magazine                          http://php-mag.net/

---

## #1935 — Andrei Zmievski — 2003-05-23T16:48:00+00:00

URL: https://externals.io/message/1931#1935 · In reply to: #1932

> I think this patch is bad.  It distorts the control flow of a normal
> program.  Calling member functions on a non-object is a serious error,
> so the only real option IMO is dying, or throwing an exception.

I agree.

-Andrei
* I wish life had an UNDO function. *

---

## #1951 — Morten Poulsen — 2003-05-23T21:53:20+00:00

URL: https://externals.io/message/1931#1951 · In reply to: #1932

> I think this patch is bad.  It distorts the control flow of a normal
> program.  Calling member functions on a non-object is a serious error,
> so the only real option IMO is dying, or throwing an exception.

The patch might not be the right way to implement it. Calling a member
function on null happens from time to time, when programmers don't check
the return value of a library call. In a production environment it is
bad, not having the option to handle the error, therefore it is bad to
just die. Throwing an exception might be a nicer way, but isn't that
future?

Best regards,
Morten

-- 
Morten Poulsen <morten+php@afdelingp.dk

---

## #1952 — Andrei Zmievski — 2003-05-23T21:57:29+00:00

URL: https://externals.io/message/1931#1952 · In reply to: #1951

> The patch might not be the right way to implement it. Calling a member
> function on null happens from time to time, when programmers don't check
> the return value of a library call. In a production environment it is
> bad, not having the option to handle the error, therefore it is bad to
> just die. Throwing an exception might be a nicer way, but isn't that
> future?

Calling a member function on a null should not even happen in production
environment, if you architecture your application properly.

-Andrei

"The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" but "That's funny..." -- Isaac Asimov.

---

## #1954 — Morten Poulsen — 2003-05-23T22:08:22+00:00

URL: https://externals.io/message/1931#1954 · In reply to: #1952

> Calling a member function on a null should not even happen in production
> environment, if you architecture your application properly.

Correct. "Should not," but they do.

-- 
Morten Poulsen <morten+php@afdelingp.dk

---

## #1955 — Derick Rethans — 2003-05-23T22:42:40+00:00

URL: https://externals.io/message/1931#1955 · In reply to: #1954

> 
> > […]
> 
> Correct. "Should not," but they do.

We can not prevent everybody's mistakes. There are enough other ways to 
shoot yourself in the knee.

Derick

-- 
                                        "my other box is your windows PC"
-------------------------------------------------------------------------
 Derick Rethans                                 http://derickrethans.nl/ 
 International PHP Magazine                          http://php-mag.net/
