WordPress.org

Ready to get started?Download WordPress

Forums

[closed] [UPDATE Error]wp-includes/query.php array line 2390 (29 posts)

  1. unrelatedmedia
    Member
    Posted 3 years ago #

    Since the update on my local host I recieved the following errors:
    Warning: explode() expects parameter 2 to be string, array given in C:\wamp\www\wp theme\wp-includes\query.php on line 2390
    and
    Warning: in_array() expects parameter 2 to be array, null given in C:\wamp\www\wp theme\wp-includes\query.php on line 2399

    Now, I don't know if it actually fixed anything but I edited the file to force an array and it seemed to remove the errors well enough. I don't know of any adverse affects to doing this yet.

    var_dump($q['post_status']);
    			$statuswheres = array();
    			$q_status = $q['post_status'];//explode(',', $q['post_status']);
    			$r_status = array();
    			$p_status = array();
    			$e_status = array();
    			if ( $q['post_status'] == 'any' ) {
    				foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
    					$e_status[] = "$wpdb->posts.post_status <> '$status'";
    			} else {
    				foreach ( get_post_stati() as $status ) {
    					if ( in_array( $status, array($q_status) ) ) {//previously ## if ( in_array( $status, $q_status ) ) {

    I added the dump as a check to see just what is being retrieved. For some reason the original update file recieved the post variable as an array, not a string to use explode() on. This forced the initial $q_status to recieve an error when attempting to build an array using the explode() because explode() expects a string to break apart, not an array...which is what it was recieving.

    As such, the $q_status array wasn't being set. To further the oddity, the in_array() on line 2399 was being fed $q_status which was a string, not an the expected array.

    Can someone tell me if my temporary solution is, in fact, a solution or if I should expect it to cause errors down the road?

  2. Casper
    Member
    Posted 3 years ago #

    I get that exact same error as well, just upgraded to 3.1.3.

    Will follow along here, and post if I find any solution that doesn't involve touching the core.

  3. Adam Harley
    Member
    Posted 3 years ago #

    This is being discussed on Trac #17556 and will be fixed in 3.1.4. As far as I understand it, a change was backported that depended on one that wasn't.

  4. Casper
    Member
    Posted 3 years ago #

    Hmm, seems like the core team is aware of it - Trac ticket. Milestone is 3.1.4.

    For anyone else having this problem:
    You can hide this warning with a flag in your .htaccess to suppress warnings & errors:
    php_flag display_errors off

    Note: you probably want to keep this on in your development environment, but on your live site you should hide errors for security measures.

  5. turkeyphant
    Member
    Posted 3 years ago #

    Same error here. What's the eta for 3.1.4?

  6. ericr23
    Member
    Posted 3 years ago #

    I got a similar error after I manually upgraded only the changed files. Manually upgrading all of the 3.1.3 package files (some of which were in fact changed but not listed as such) fixed it.

  7. jackmcdade
    Member
    Posted 3 years ago #

    Same here after an auto-update.

  8. Tim Moore
    Moderator
    Posted 3 years ago #

    We likely won't see 3.1.4 for this, but you can use the following plugin to clear up the error: http://wordpress.org/extend/plugins/hotfix/

  9. Daya
    Member
    Posted 3 years ago #

    In English :
    You can correct this error ;) Edit the file query.php on directory wp-includes of WordPress :
    replace :

    if ( isset($q['post_status']) && $q['post_status'] != '' ) {
    			$statuswheres = array();
    			$q_status = explode(',', $q['post_status']);

    by it :

    if ( ! empty( $q['post_status'] ) ) {
    			$statuswheres = array();
    			$q_status = $q['post_status'];
    			if ( ! is_array( $q_status ) )
    				$q_status = explode(',', $q_status);

    In French / en Français :
    Vous pouvez corriger cette erreur ;) Editez le fichier query.php dans le dossier wp-includes de WordPress :
    remplacez :

    if ( isset($q['post_status']) && $q['post_status'] != '' ) {
    			$statuswheres = array();
    			$q_status = explode(',', $q['post_status']);

    par ça :

    if ( ! empty( $q['post_status'] ) ) {
    			$statuswheres = array();
    			$q_status = $q['post_status'];
    			if ( ! is_array( $q_status ) )
    				$q_status = explode(',', $q_status);

    Enjoy xD

  10. hugoBrizuela
    Member
    Posted 3 years ago #

    I had the same problem.
    Maya addressed the issue in a very ellegant way.
    Thanks Maya.

  11. Donald McIntyre
    Member
    Posted 3 years ago #

    Daya, merci beaucoup!!

    Warning: explode() expects parameter 2 to be string, array given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2390

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

    Warning: in_array() expects parameter 2 to be array, null given in /home/donmcint/linkedbees.com/wp-includes/query.php on line 2399

  12. unrelatedmedia
    Member
    Posted 3 years ago #

    Now, both Daya and I use the same principle to solve the problem, with 2 different approaches. The question remains - does this actually solve the issue or have any adverse effects?

  13. ron jesser
    Member
    Posted 3 years ago #

    @Tim- that plug-in worked perfectly. Thanks!

  14. sunnre
    Member
    Posted 3 years ago #

    Could there potentionally be a problem with using Daya's solution?

  15. INTERBOOST
    Member
    Posted 3 years ago #

  16. JustinFYI
    Member
    Posted 3 years ago #

    The hotfix plugin resolved it for me as well (http://wordpress.org/extend/plugins/hotfix/). Thanks Tim.

  17. ravenousravendesign
    Member
    Posted 3 years ago #

    I had the same problem too while trying to add new media. Hot fix fixed it. awesome!

  18. chaski
    Member
    Posted 3 years ago #

    HotFix worked for me also. Thanks so much.

  19. pszeinert
    Member
    Posted 3 years ago #

    I've had Hotfix installed on three of my sites since it was version 0.1 (now 0.5) and I have never had a chance to test it. Within 2 minutes of the above issue being brought to my attention, I had found this thread and wondered why Hotfix had not worked for me.

    ...then I checked and realized it was installed but not activated. Now everything is as it should be.

    Hotfix is the number one recommendation anytime someone asks what plugins I use. No site should run without it.

  20. haydenhancock
    Member
    Posted 3 years ago #

    The Hotfix worked for me as well.

  21. designoahu
    Member
    Posted 3 years ago #

    Hotfix didn't work for me, but Daya's code did. Thank you Daya!

  22. wedhaaf
    Member
    Posted 3 years ago #

    Strange.

    I've update my live site to version 3.1.3. It has no problems in Media Library. But when I used this 3.1.3 in development stage as new installation, it does show the errors.

  23. dotwebs
    Member
    Posted 3 years ago #

    Daya's solutions works for me. Thanks Daya!

    Sunnre:

    Could there potentionally be a problem with using Daya's solution?

    I shouldn't think so but if you're worried, back up the original query.php file just in case.

  24. sperry
    Member
    Posted 3 years ago #

    Thanks Daya! This worked for me too.

  25. gmikeb
    Member
    Posted 3 years ago #

    Thank you Daya! Your solution was perfect for me!

  26. unrelatedmedia
    Member
    Posted 3 years ago #

    currently running Hotfix on some live sites without issue. I will leave this issue open for now, as there appears to be a need. It may also prove useful should anyone encounter any issues with any of the fixes listed.

    If anyone is keeping an eye on the WordPress trunk and sees this fixed for the next update please post here to let the community know!

  27. Omegakenshin
    Member
    Posted 3 years ago #

    Daya! Thanks a lot!!
    *hugs* really need this ^^

  28. Alex Israel
    Member
    Posted 3 years ago #

    Daya!
    xcellent post, worked like a charm :)

  29. Andrew Nacin
    Lead Developer
    Posted 3 years ago #

    I'm going to close this thread.

    The Hotfix plugin should solve all issues: http://wordpress.org/extend/plugins/hotfix/

    If it doesn't, then I wouldn't be surprised if you have something else going on and you should open a new thread.

    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.