News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Notices are not displayed in my own actions

Started by GreenRacket, September 20, 2018, 06:24:43 AM

Previous topic - Next topic

GreenRacket

I'm trying to display all errors and warnings/notices in my custom actions, however they just aren't displayed. If I add this to index.php


<?php
error_reporting
(E_ALL);
ini_set('display_errors'1);
echo 
$asdf;


The notice for the undefined variable are displayed just fine:
Notice: Undefined variable: asdf in /Applications/MAMP/htdocs/*****/index.php on line 39

But if I echo an undefined variable in my own custom action (NP.php) no notice is displayed

The custom action is added in index.php:

<?php
$actionArray 
= array(
    ...
    
'np' => array('NP.php''NP'),


The start of the code in NP.php


<?php
echo $asdf2;


(no notice is displayed)

This is what phpinfo() says regarding errors in NP.php


display_errors On
display_startup_errors On
error_append_string no value
error_log /Applications/MAMP/logs/php_error.log
error_prepend_string no value
error_reporting 32767
html_errors On
ignore_repeated_errors Off
log_errors On
log_errors_max_len 1024
track_errors On
xmlrpc_error_number 0
xmlrpc_errors Off


Ideally I would like to just be able to add the error reporting in NP.php to display errors/notices but that doesn't seem to work at all, even for the errors. If I add this to NP.php (and remove the error reporting in index.php)...

<?php
error_reporting
(E_ALL);
ini_set('display_errors'1);
asdf

... no error is displayed. Just a blank 500-page. However, the error is logged.

Thanks for any help!

vbgamer45

SMF has it's own error handler which hides those errors from being displayed they might get logged in your forums error log.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

GreenRacket

Quote from: vbgamer45 on September 20, 2018, 08:58:48 AM
SMF has it's own error handler which hides those errors from being displayed they might get logged in your forums error log.

Ah. I see. Thanks for the reply. The errors sure ends up in the forums error log.

Is it possible to, temporarily, bypass the error handler and make the errors show on the page? It would be helpful while developing.

vbgamer45

I think you can comment out on the index.php

// Register an error handler.
set_error_handler('error_handler');
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

GreenRacket

Quote from: vbgamer45 on September 20, 2018, 10:25:35 AM
I think you can comment out on the index.php

// Register an error handler.
set_error_handler('error_handler');


It worked like a charm. Thanks!

Advertisement: