Loading


Advertisement:

Author Topic: 500 Error when posting new ad with photo using PHP 7.1.2  (Read 1085 times)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
500 Error when posting new ad with photo using PHP 7.1.2
« on: March 01, 2017, 11:55:52 am »
Hi there,

just in case anyone else runs into the same error using Osclass 3.6.1 (still) I found a possible fix for sharing.

WHAT: When posting a new ad with one or more photo's (either Osclass logic or Pre-resize plugin) I got a 500 error and in the logfile it said:
Code: [Select]
Fatal error:  Uncaught Error: Cannot use string offset as an array in  .../osclass/ItemActions.php:1176
FIX: After making the following change the error no longer appears so must be good. On line 1164 in ItemActions.php change the line:
Code: [Select]
$aItem['photos'] = Params::getFiles('photos');into
Code: [Select]
$aItem['photos'][] = Params::getFiles('photos');
Maybe this is already fixed in Osclass 3.7.1, I haven't checked but it might not be since I am on latest PHP version 7.1.2 and I am pretty sure the error was not thrown using PHP 7.0.15.


Regards,
Eric

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #1 on: March 12, 2017, 01:40:51 pm »
Okay, I thought I had it fixed but even though the error 500 is gone with the added [] in ItemActions.php and the ad mentions I succesfully published a new ad it seems that the image(s) are NOT saved. Meaning, there IS a serious bug in a clean 3.7.1 install still as far as I can tell. I doubt it is PHP 7.1.2 related since as for comparisson, I run on same setup/server a succesful 3.6.1 development version with everything 100% working.

I will try to see why the images with new ads do not work on 3.7.1... if anybody already knows the issue I'd be happy to hear about it.
Will also do a forum search yet to be sure.


Regards,
Eric

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1776
  • osclass.work
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #2 on: March 12, 2017, 02:41:49 pm »
Hi SmaRTeY,

Which image library do you use? GD or imagick? Could be a bug in the library or PHP (they still have their own quirks), cannot say anything clever right now :(

A bit confusing:

Quote
> Okay, I thought I had it fixed but even though the error 500 is gone with the added [] in ItemActions.php and the ad mentions I succesfully published a new ad it seems that the image(s) are NOT saved

is above valid for 3.6.1, 3.7.1 or both? Because, next:

Quote
> I run on same setup/server a succesful 3.6.1 development version with everything 100% working.

So, is it specific to later versions, while 3.6.1 is working 100%, or 3.6.1 is also affected? There were just minor, almost irrelevant changes and optimizations related to images since that version, hardly a cause of error (but you never know).

Could be also a PHP compatibility issue, 7.1.x is moving towards 8.x, which will bring new changes here and there.

Regards

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #3 on: March 12, 2017, 04:10:37 pm »
I found the issue Dev101.

In my case (as mentioned on PHP latest 7.1.2 and Apache 2.4.25 with php-fpm and Opcache but APCu disabled)

So, when posting new ad WITH 1 or more images:
1) The 500 error (fatal php error) is fixed by adding the brackets [] as mentioned earlier.
2) Bender theme comes bundled with Fancybox:
Code: [Select]
/*! fancyBox v2.0.4 fancyapps.com | fancyapps.com/fancybox/#license */while Osclass assets folder comes with Fancybox:
Code: [Select]
/*! fancyBox v2.1.4 fancyapps.com | fancyapps.com/fancybox/#license */and I am using version:
Code: [Select]
/*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */Bender NEEDS 2.1.4 at minimum as in osclass/assets folder

The above helped me to get rid of the 500 error plus it finally showed the upload bar in item-post.php when trying to publish new ad.

However, it still didn't work, I was able to upload image(s) now and publish ad BUT images were not moved and were published without showing with ad published even though all went OK and message you get is Succes.

So next I started to compare code in ItemActions since this is where files get moved around when publishing new ads.
I have not pinned down the actual difference in code that got things working again but I will post my ItemActions.php here so others might benefit the same. Attached my current /oc-includes/osclass/ItemActions.php.


With this setup it works.

Regards,
Eric

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1776
  • osclass.work
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #4 on: March 12, 2017, 04:17:33 pm »
So, you have fixed the issue by updating Fancybox library + ItemActions modifications?

I am well aware of the obsolescence of the Fancybox, it gave me an issue on a demo website, as well. But, new versions 2.1.5+ are no longer free for commercial projects, and I have moved away from that library anyway in my production sites, anyway (don't really like it, interface is too limited and "slow" for modern users).

As I know you also use newer jQuery libs, it can make sense to upgrade everything, as well.

Regards

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #5 on: March 12, 2017, 04:18:54 pm »
Hi dev101,

GD version: bundled (2.1.0 compatible)
Imagick: 3.4.3 (got it form here: https://pecl.php.net/package/imagick

500 Error is PHP 7.1.2 related, I stumbled upon this error after upgrade of PHP 7.0.15 to 7.1.2.
Not showing upload bar is Bender shipped Fancybox version related.
No image showing with published ad and sucecss msg is ItemActions.php related.

Hi SmaRTeY,

Which image library do you use? GD or imagick? Could be a bug in the library or PHP (they still have their own quirks), cannot say anything clever right now :(

A bit confusing:

Quote
> Okay, I thought I had it fixed but even though the error 500 is gone with the added [] in ItemActions.php and the ad mentions I succesfully published a new ad it seems that the image(s) are NOT saved

is above valid for 3.6.1, 3.7.1 or both? Because, next:

Quote
> I run on same setup/server a succesful 3.6.1 development version with everything 100% working.

So, is it specific to later versions, while 3.6.1 is working 100%, or 3.6.1 is also affected? There were just minor, almost irrelevant changes and optimizations related to images since that version, hardly a cause of error (but you never know).

Could be also a PHP compatibility issue, 7.1.x is moving towards 8.x, which will bring new changes here and there.

Regards

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #6 on: March 12, 2017, 04:22:02 pm »
Correct, I am using JQuery 1.11.2 in my personal setup but in this case I did a FULL clean install of Osclass for starters.

After the Fancybox fix I just did a full copy of my assets/js folder and I copied the ItemActions.php since that one was working for me in 3.6.1 (also having some fixes compared to Original 3.7.1)

So, you have fixed the issue by updating Fancybox library + ItemActions modifications?

I am well aware of the obsolescence of the Fancybox, it gave me an issue on a demo website, as well. But, new versions 2.1.5+ are no longer free for commercial projects, and I have moved away from that library anyway in my production sites, anyway (don't really like it, interface is too limited and "slow" for modern users).

As I know you also use newer jQuery libs, it can make sense to upgrade everything, as well.

Regards

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1776
  • osclass.work
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #7 on: March 12, 2017, 04:41:23 pm »
I'll setup clean installation on 7.1.2 next few days and give it a go, could be related to PHP version and some compatibility fixes should be placed in that case.

Thanks for reporting this!
https://github.com/osclass/Osclass/issues/2139

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #8 on: March 12, 2017, 06:39:03 pm »
No problem :)

Anyway, for others reading this and downloading the ItemActions.php, if you don't know what you're doing better wait for Osclass update for PHP 7.1.2 and stay with max. PHP 7.0.15 and minimum PHP 5.6.

There's more change in this file which not only helped me fix the image upload but also contain some other minor changes of which you will just have to see if it affects your system negatively in any way ;)

I am running two development environments at the moment on identical server setup with 3.7.1 and 3.6.1 Osclass setup both in sub/sub folder and no .htaccess files for webserver performance reason. So my htaccess is put inside the Vhost config. Also I have config.php setup with debug enabled on screen and using 3.7.1 + Bender theme (with image upload fix) I get PHP Deprecated warnings with regard to the use of mcrypt functions when publishing a new ad but when I do same action using 3.6.1 + Bender and publish a new ad those deprecated warnings do not appear..... very strange! If someone has a clue what might be the difference for this I am all ears 8)

Aficionado

  • issues
  • Hero Member
  • *
  • Posts: 4758
  • Hardliner
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #9 on: March 12, 2017, 06:47:16 pm »
I have a lot of problems with 7.1 also with Wordpress. I don't know about Osclass.

So back to 7.0.15

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #10 on: March 12, 2017, 08:19:11 pm »
Hi Aficionado,

I do have Osclass running flawless at the moment (3.6.1 + personal changes) using PHP 7.1.2 and it does have some important fixes (php-fpm and others) making it worthwhile using compared to 7.0.15) But ofcourse your website should run flawless....well as flawless as possible 8)

I have a lot of problems with 7.1 also with Wordpress. I don't know about Osclass.

So back to 7.0.15

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #11 on: March 12, 2017, 08:21:42 pm »
*BRAINFART*
The difference questioned below is simply because I changed the error reporting myself in oc-load.php....

- shame -

I am running two development environments at the moment on identical server setup with 3.7.1 and 3.6.1 Osclass setup both in sub/sub folder and no .htaccess files for webserver performance reason. So my htaccess is put inside the Vhost config. Also I have config.php setup with debug enabled on screen and using 3.7.1 + Bender theme (with image upload fix) I get PHP Deprecated warnings with regard to the use of mcrypt functions when publishing a new ad but when I do same action using 3.6.1 + Bender and publish a new ad those deprecated warnings do not appear..... very strange! If someone has a clue what might be the difference for this I am all ears 8)

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1776
  • osclass.work
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #12 on: March 12, 2017, 08:37:11 pm »
mcrypt is in abandoning stage (or somthing, did not quite tracked recently), and there were no changes in the core recently about anything. Unless you use some plugin that relies upon it, Conejo mentioned some old payment plugin.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2441
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #13 on: March 12, 2017, 09:14:02 pm »
Well, Osclass 3.7.1 with only default plugin throws the deprecated warnings (hSecurity) even though Osclass itself might not actively use this function. The older Osclass PayPal plugin uses it.

I also found what needs change for hSecurity to update it to new standard:
http://php.net/manual/en/function.openssl-encrypt.php

Will see if I can change hSecurity myself just out of curiousity if I am able to rework that helper and get encryption updated for use in PayPal plugin I am using on my site.

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 1776
  • osclass.work
Re: 500 Error when posting new ad with photo using PHP 7.1.2
« Reply #14 on: March 12, 2017, 10:24:24 pm »
Confirmed, it is a bug with PHP 7.1.2

Code: [Select]
PHP Warning:  Illegal string offset 'a709e41d-4a2e-44a3-8ea5-1159c01fa6f6' in /osc371/oc-includes/AjaxUploader.php on line 54
PHP Fatal error:  Uncaught Error: Cannot use string offset as an array in /osc371/oc-includes/osclass/ItemActions.php:1175

Now, this could be a particular PHP version bug, wouldn't sweat just yet until they release 7.1.3 or so, and see if the bug persists.