• xertion

    (@xertion)


    Hello guys.
    A new client of mine left their old developer and now when their host is upgrading to PHP 5.3 they’ve got some big problems with their site.

    The big problem seems to be a list that prints all posts using “The Loop”. The code for this is here https://pastebin.com/QpVeEL2d

    For some reason when using PHP 5.3 the_post() returns not only posts from all categories (as it should) but also PAGES and even revisions/autosaves from posts. (ex: links to /3267-revision-3/).

    I’m also having problem with a slider that uses the_post() to gather images and print them. This slider shows titles of pages and posts instead of the images when using PHP 5.3.

    Anyone have any idea why this is happening?

    I’ve set up the website on two servers. It’s THE SAME database and COPIED files. The only difference is that one server is using PHP 5.3 and the other one is using PHP 5.2.

    https://www.jobbjet.se/ (PHP 5.2; working version!)

    https://devlopese.jobbjet.se/ (PHP 5.3; have not changed baseURL so if you navigate it will redirect you)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter xertion

    (@xertion)

    Is there any more information that you need to be able to help me? No one else is having these kind of troubles with PHP 5.3?

    Reuben

    (@greuben)

    Are you using custom queries? if yes? the code?

    Thread Starter xertion

    (@xertion)

    As I stated in the first message, there was another developer who created the website itself and now I’ve taken over the site since the company dont work with him anymore.

    The code for the list is in the pastebin that I linked, what do you mean by any other custom queries? There’s not much more out of the ordinary in the index.php file.

    Thread Starter xertion

    (@xertion)

    I did some more research and I returned the SQL query that The Loop was sending to the database to retrieve the posts.

    The query was
    SELECT SQL_CALC_FOUND_ROWS distinct jj_posts.* FROM jj_posts WHERE 1=1 ORDER BY jj_posts.post_date DESC LIMIT 0, 10

    It returns revisions and also pages. Why is this?

    Thread Starter xertion

    (@xertion)

    I noticed that “WHERE 1=1″ seems to be the problem. The correct would be WHERE post_status=”publish” AND post_type=”post”.

    Someone told me that by default the query sends these “WHERE’s” but something on the site seems to be removing it.

    Is this true? Does the query by default send those WHERE parameters? Also, what could remove it? And why would it only be removed at PHP 5.3 and not at PHP 5.2? =/

    Thread Starter xertion

    (@xertion)

    I found the query of the PHP 5.2 site. It’s the following:

    “SELECT SQL_CALC_FOUND_ROWS distinct jj_posts.* FROM jj_posts LEFT JOIN jj_term_relationships ON (jj_posts.ID = jj_term_relationships.object_id) LEFT JOIN jj_term_taxonomy ON jj_term_taxonomy.term_taxonomy_id = jj_term_relationships.term_taxonomy_id WHERE 1=1 AND jj_posts.post_type = ‘post’ AND (jj_posts.post_status = ‘publish’) AND NOT EXISTS (SELECT * FROM jj_term_relationships JOIN jj_term_taxonomy ON jj_term_taxonomy.term_taxonomy_id = jj_term_relationships.term_taxonomy_id WHERE jj_term_relationships.object_id = jj_posts.ID AND jj_term_taxonomy.taxonomy = ‘category’ AND jj_term_taxonomy.term_id IN (23) ) ORDER BY jj_posts.post_date DESC LIMIT 0, 10”

    How can PHP 5.3 change all that to one line?
    “SELECT SQL_CALC_FOUND_ROWS distinct jj_posts.* FROM jj_posts WHERE 1=1 ORDER BY jj_posts.post_date DESC LIMIT 0, 10”

    Reuben

    (@greuben)

    Disable all plugins and see if it has changed

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘the_post() returns pages and autosaves with PHP 5.3’ is closed to new replies.