• Resolved Mostafa Shahiri

    (@mostafadeveloper)


    Hi

    I am creating a Woocommerce plugin that displays products with some details in a widget and it loads more products by using AJAX. All parameters and attributes of the products are loaded correctly, but I receive an unknown warning message:

    urlencode() expects parameter 1 to be string, array given in wp-includes\formatting.php on line 4790

    I don’t know why this message is created. I placed main function that fetches data from database in a class in a separated file. The name of this file is a something like class.pluginname-helper.php. I supposed this problem is related to the name of this file, so I tried to change name of this file, but it did not solve the problem. please help me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • That error will come from somewhere in your code. Finding it could be hard because there’s a good chance that it’s called somwhere along a very long train of functions calls.

    You need to do some debugging, so I’d suggest working thorugh your plugins code and seeing what you can comment out to temporarily disable it until you find out wich part is causing that error, then look into that code more to find out what’s happening. It won’t be a quick process, bot that’s what you need to do.

    • This reply was modified 5 years, 11 months ago by catacaustic.
    Moderator bcworkz

    (@bcworkz)

    Obviously something is passing an array instead of a string. Sometimes that’s enough of a clue. catacaustic’s comment out approach is a classic, tried and true approach. It’s also extremely tedious. I suggest setting the error handler of PHP to output a back trace so you have a better idea of the root cause. For example:
    https://stackoverflow.com/questions/1159216/how-can-i-get-php-to-produce-a-backtrace-upon-errors/1159235#1159235

    The output can still be confusing or even useless, but it’s often good information.

    Thread Starter Mostafa Shahiri

    (@mostafadeveloper)

    Thank you for your guidance. I hadn’t used tax_query in my code. When I changed my code by using tax_query, the problem was solved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘problem with urlencode warning’ is closed to new replies.