500 errors after posting ads, no mater which version

Hello I am experiencing 500 errors from atleast 9 months, after posting ads.
I was with 3.8, upraded later with 3.8.1., then 3.9 and yesterday 4.1.0
with all versions the same. I have basic plugins that come with veronica and last version of veronica theme

Today I cleaned the 200 MB log from january 2020 ( last time i cleaned it ). And again tested so I can send you exact errors after posting ad. The ad is posted but instead redirecting the user to search showing the add I get 500 error.

What I see in the error log after posting an ad is this:
[04-Aug-2020 14:08:12 Europe/Sofia] PHP Warning: current() expects parameter 1 to be array, null given in /oc-includes/osclass/emails.php on line 855
[04-Aug-2020 14:08:12 Europe/Sofia] PHP Fatal error: Cannot declare class PHPMailer, because the name is already in use in /oc-includes/vendor/phpmailer/phpmailer/class.phpmailer.php on line 28
[04-Aug-2020 14:09:37 Europe/Sofia] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /oc-includes/osclass/helpers/hSearch.php on line 342
[04-Aug-2020 14:10:51 Europe/Sofia] PHP Warning: current() expects parameter 1 to be array, null given in /oc-includes/osclass/emails.php on line 855
[04-Aug-2020 14:10:51 Europe/Sofia] PHP Fatal error: Cannot declare class PHPMailer, because the name is already in use in /oc-includes/vendor/phpmailer/phpmailer/class.phpmailer.php on line 28

P.S. Is it possible to make after post redirect to open the add directly instead of search ?!

I am not shure if the problem is related with the theme or not, please excuse me if is the wrong category to post my topic

To redirect after posting, put in your functions.php file of theme this code:

if (!function_exists('bender_redirect_to_item')) {
    function bender_redirect_to_item($item) {
        if ($item) {
            View::newInstance()->_exportVariableToView("item", Item::newInstance()->findByPrimaryKey($item['pk_i_id']));
            osc_redirect_to(osc_item_url());
        }
    }
    osc_add_hook('posted_item', 'bender_redirect_to_item');
}

Replace bender_ by prefix of theme that you have using.

1 Like

Wont that conflict with the current redirect by default ? ( loop redirects or something ?! )

I am using veronika theme - MB themes ( ossclasspoint com )

Edit: Well i couldnt wait for an answer. I was curious so I tested it.
MAN God BLESS YOU! You just solved me a problem I hated so much for months!
THANK YOU VERRY MUCH! THANK YOU!

It also hides the 500 error. The 500 error is not solved but atleast the users will use the website properly until the error is fixed.

Best regards

1 Like