This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

mwindey

  • *****
  • 478 posts
Whooops, There Was Some Error. Please Try To Add Offer Later.
« on: September 07, 2022, 12:56:26 PM »
Today i installed the new version 2.1.2 without modification and on every offer it says Whooops, There Was Some Error. Please Try To Add Offer Later.
I had this before but cannot remember how I've solved it.....

User receives mail there is a new offer and it shows also in instant messenger ..... Only problem is the error instead off green light saying offer is sent.

*

MB Themes

Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #1 on: September 07, 2022, 01:07:51 PM »
@mwindey
Check error logs as well as browser log (console)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #2 on: September 07, 2022, 01:58:43 PM »
@MB Themes

First i will check this out....

Line 323 from instant messenger / functions says
Code: [Select]
  $extension = strtolower(pathinfo(@$file['name'], PATHINFO_EXTENSION));

Debug log when trying to add bid gives error:


[07-Sep-2022 13:56:23 Europe/Brussels] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /home/u44173p136925/domains/wirly.be/public_html/oc-content/plugins/instant_messenger/functions.php:323
Stack trace:
#0 /home/u44173p136925/domains/wirly.be/public_html/oc-content/plugins/make_offer/index.php(176): im_insert_message()
#1 /home/u44173p136925/domains/wirly.be/public_html/oc-includes/osclass/classes/Plugins.php(42): mo_new_offer_manage()
#2 /home/u44173p136925/domains/wirly.be/public_html/oc-includes/osclass/helpers/hPlugins.php(34): Plugins::runHook()
#3 /home/u44173p136925/domains/wirly.be/public_html/oc-includes/osclass/controller/ajax.php(314): osc_run_hook()
#4 /home/u44173p136925/domains/wirly.be/public_html/index.php(146): CWebAjax->doModel()
#5 {main}
  thrown in /home/u44173p136925/domains/wirly.be/public_html/oc-content/plugins/instant_messenger/functions.php on line 323


When instant messenger is disabled in make offer it works but that is not how it should be.....
« Last Edit: September 07, 2022, 02:08:44 PM by mwindey »

*

MB Themes

Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #3 on: September 07, 2022, 02:19:41 PM »
Hate the PHP :D

above that line try to add:
Code: [Select]
  if(!is_array($file) || empty($file)) {
    return '';
  }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #4 on: September 07, 2022, 02:33:38 PM »
@MB Themes

PHP sucks  :D
Cleared browser and all caches i have. Inserted code and still same error....

Urgent time to learn ASP and leave this f**x***   :)

*

mwindey

  • *****
  • 478 posts
Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #5 on: September 07, 2022, 02:54:25 PM »
@MB Themes

SOLVED  ;) with a little help from stackoverflow....
Because of the use from PHP 8 there where some changes again ( it's hard to keep up these days)

Anyway the full code from that part in functions.php from instant messenger that is working correct is:

Code: [Select]
  // MANAGE FILE UPLOAD
  $allowed_extensions = (im_param('att_extension') <> '' ? im_param('att_extension') : 'jpg, jpeg, gif, png' );
  $allowed_extensions = array_map('strtolower', array_filter( array_map('trim', explode( ',', $allowed_extensions ) ) ) );
  if (!empty($file) || empty($file)) {
    return '';
  }
  $extension = strtolower(pathinfo(@$file['name'], PATHINFO_EXTENSION));

Thanks for the help  ;)

Marked as best answer by mwindey on September 08, 2022, 11:37:08 AM
*

MB Themes

Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #6 on: September 07, 2022, 04:21:18 PM »
@mwindey
Here, we could also add after function:
Code: [Select]
  if(!is_array($file)) {
    $file = array();
  }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #7 on: September 07, 2022, 04:57:43 PM »
@MB Themes

You mean instead of
Code: [Select]
  if (!empty($file) || empty($file)) {
    return '';
  }
OR  ??? 

(confused) :-\

*

MB Themes

Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #8 on: September 07, 2022, 05:55:37 PM »
They should not be in conflict.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #9 on: September 07, 2022, 06:04:37 PM »
@MB Themes,

My solution wasn't the right solution.... However it worked but NO mails were send to notice user he/she received an offer or message anymore.

The solution you gave is working perfectly now. Mails are send to user and make offer does not give any error anymore.

Code that works is in lines

Code: [Select]
// MANAGE MESSAGE INSERT INTO DATABASE
function im_insert_message($thread_id, $message, $type, $file, $notify = true ) {
  if(!is_array($file)) {
    $file = array();
  }
  if(im_param('only_logged') == 1 && !osc_is_web_user_logged_in()) {
    return false;
  }
 
  $thread = ModelIM::newInstance()->getThreadById( $thread_id );
  $item = Item::newInstance()->findByPrimaryKey( $thread['fk_i_item_id'] );

Again you have been a great help solving this.... Thanks  :-*

*

mwindey

  • *****
  • 478 posts
Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #10 on: September 08, 2022, 03:51:29 PM »
@MB Themes,

We still have some work in progress....
Since changing functions.php in instant messenger mails gets send to seller but instead of mo_notify_seller -  email_item_inquiry gets send which is the wrong email...

It is not a big problem but when a buyer is bidding without sending text the seller gets informed there is a new message waiting but not a message someone has placed a bid on the item.

Do you think we can make the file so that it recognizes if it is an offer or just a message someone is sending ???

 :-\ :-\

*

MB Themes

Re: Whooops, There Was Some Error. Please Try To Add Offer Later.
« Reply #11 on: September 08, 2022, 05:11:58 PM »
It should be just light integration to IM that isert message with not much details.
I actually never used that
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots