Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Posts
    44
    Plugin Contributions
    1

    Default Object of class upload could not be converted to string ... in attributes_controller

    Just upgraded from 1.3.9 by fresh install and applying all customizations and language files as well as the CKEditor. When trying to edit prices of products in the attributes controller, page goes blank after hitting the update button.
    The error log is:
    Code:
    [12-Jul-2016 20:00:15] Request URI:/cart/admin/attributes_controller.php?action=update_product_attribute&attribute_page=1&products_filter=157, IP address: .............
    #1  trim(upload Object ([file] => attributes_image,[filename] => ,[destination] =>/home/company/public_html/cart/images/,[permissions] => 420,[extensions] => Array ([0] =>jpg,[1] => jpeg,[2] => gif,[3] => png,[4] => webp,[5] => flv,[6] => webm,[7] =>ogg),[tmp_filename] => ,[message_location] => direct)) called at [/home/company/public_html/cart/admin/includes/functions/general.php:441]
    #2  zen_not_null(upload Object ([file] => attributes_image,[filename] => ,[destination] =>/home/company/public_html/cart/images/,[permissions] => 420,[extensions] => Array ([0] =>jpg,[1] => jpeg,[2] => gif,[3] => png,[4] => webp,[5] => flv,[6] => webm,[7] =>ogg),[tmp_filename] => ,[message_location] => direct)) called at [/home/company/public_html/cart/admin/includes/classes/upload.php:61]
    #3  upload->parse() called at [/home/company/public_html/cart/admin/attributes_controller.php:445]
    
    [12-Jul-2016 20:00:15] PHP Catchable fatal error:  Object of class upload could not be converted to string in /home/company/public_html/cart/admin/includes/functions/general.php on line 441
    The reason seems to be that the function zen_not_null($value) in admin/includes/functions/general.php does not handle objects while we have this construct:
    Code:
    $attributes_image = new upload('attributes_image');
    on line 442 in admin/attributes_controller.php

    PHP Version 5.2.17 MySQL: 5.5.50

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Object of class upload could not be converted to string ... in attributes_control

    1. I'd strongly encourage you to get your server upgraded to a more modern version of PHP now that you're using a ZC version that supports it.

    2. The symptom you've reported is probably a bug, and probably only occurs when you don't have an image set on the attribute and aren't trying to actually upload a new one.
    Here's a bandage which I think will work for you:
    /admin/includes/classes/upload.php
    change line 58 from:
    Code:
    'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : ''));
    to:
    Code:
    'tmp_name' => (isset($GLOBALS[$this->file]) && is_string($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : ''));
    And then test by updating those attributes, preferably one with... and one without ... an attribute image ;)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Object of class upload could not be converted to string ... in attributes_control

    I've recently uploaded an attribute with and without an attribute image, but using a newer php version. While I haven't gone back (yet) to look at how the applicable file handling changed over the versions, are you thinking it to be a bug related to older PHP (reported to be compatible with this version of ZC), or a bug in general (not discovered when using php 5.6).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Object of class upload could not be converted to string ... in attributes_control

    In looking at the code I'm thinking it's a bug in general: if $_FILES isn't set (which *is* set when an actual upload exists, in modern PHP), then it looks for a very old HTTP_POST_FILES array (which won't exist in modern PHP), and then "else" is where the above code is failing ... because the tmp_name is getting set to a string value but is being passed a global object which happens to be named the same as the variable which is the instance of the upload class ... basically a circular loop. This class was inherited from osC back in 2003 and this particular section hasn't been touched but clearly needs an overhaul for modern use.

    That said, I'm very surprised this hasn't come up a million times already ... cuz it's not an issue unique to PHP 5.2 nor PHP 7.

    Maybe the OP has the deprecated "register_globals" enabled or something?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jan 2006
    Posts
    44
    Plugin Contributions
    1

    Default Re: Object of class upload could not be converted to string ... in attributes_control

    The quick-fix of DrByte did the job. Attributes image are disabled in admin so I tested only this alternative. Hopefully, I will manage to test with attributes images enabled in the next few days and I will let you know if any problems arise. The "register_globals" is off and I agree with DrByte that its really amazing that this bug-candidate hasn't come up a million times already.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Object of class upload could not be converted to string ... in attributes_control

    Quote Originally Posted by vasilt View Post
    The quick-fix of DrByte did the job. Attributes image are disabled in admin so I tested only this alternative. Hopefully, I will manage to test with attributes images enabled in the next few days and I will let you know if any problems arise. The "register_globals" is off and I agree with DrByte that its really amazing that this bug-candidate hasn't come up a million times already.
    Mind also posting the first 80-100 lines of the php results seen from the admin when the version link/button is pressed? Perhaps there is something there that could help the good Dr. identify why those issues didn't appear (assuming knowing the why is of importance).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Replies: 1
    Last Post: 24 Oct 2009, 09:09 PM
  2. PayPal Push Orders: Object of class shoppingCart could not be converted to string
    By honrheart in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 15 Oct 2009, 03:58 PM
  3. Object of class psigate_xml could not be converted to string
    By james739 in forum Addon Payment Modules
    Replies: 3
    Last Post: 19 Jun 2009, 04:20 PM
  4. Coupon Restrict: Object of class queryFactoryResult could not be converted to string
    By DodgeGirl in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 4 Mar 2009, 10:25 AM
  5. Object of class Directory could not be converted to string
    By jeking in forum General Questions
    Replies: 4
    Last Post: 17 Oct 2008, 09:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg