2014-05-28 19:24 阅读 67


I just upgraded a blog I host to WordPress 3.9.1. On that blog, I use the Patchwork theme. Following that, the blog stopped working. I couldn't see any serverside PHP errors - that's likely due to a misconfiguration of my logging. On the browser side, I could see I was getting HTTP 500 with Chrome's Developer Tools.

I eventually realized the problem came from this method in the Patchwork theme:

function patchwork_posted_on() {
    printf( __( 'Posted on <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'patchwork' ),
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
        esc_attr( sprintf( __( 'View all posts by %s', 'patchwork' ), get_the_author() ) ),
        esc_html( get_the_author() )

I haven't done a lot of PHP in a while so I'm struggling to see what's wrong with it. Considering it worked with Wordpress 3.9.0 and it doesn't work anymore, I am tempted to say that one of the methods here has been deprecated.

Does anyone have an idea?

--- EDIT ---

I didn't write the theme and it hasn't been updated in a very long time so the issue must come from a change either in wordpress that breaks the theme or in another plugin I could have updated.

Also, the error that I get is that the post page gets generated all the way up to the title and then when it's about to print Posted on ... By ... it dies. That is in fact what led me to investigate whatever was being called at that point.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dougu2036 dougu2036 2014-07-13 14:27

    From what I can gather, get_the_date() is the one creating the problem. I can still find pages at wordpress describing it but it is not in the function index.

    I updated my code to use get_the_time only:

    echo __('<!--:en-->By <!--:--><!--:fr-->Par <!--:-->'.'<a class="url fn n" href="'.esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ).'" title="Voir tous les articles de '.esc_html( get_the_author() ).'" rel="author">'.esc_html( get_the_author() ).'</a><!--:en--> on '.get_the_time('F j, Y').'<!--:--><!--:fr--> le '.get_the_time('j F Y').'<!--:-->' );

    BTW, since then, I had the issue on another blog - separate wordpress on the same PHP server.

    点赞 评论 复制链接分享
  • duannian3494 duannian3494 2014-06-05 03:20

    You're likely hitting the PHP memory limit.

    There's nothing wrong with patchwork_posted_on() function, it does not use any deprecated methods.

    点赞 评论 复制链接分享