WordPress.org

Ready to get started?Download WordPress

Forums

WordPress HTTPS (SSL)
[resolved] [Plugin: WordPress HTTPS] Trying to get property of non-object (9 posts)

  1. PeterK2003
    Member
    Posted 3 years ago #

    PHP Notice:
    Trying to get property of non-object in C:\\Program Files\\Apache
    Software
    Foundation\\Apache2.2\\htdocs\\wp-content\\plugins\\wordpress-https\\wordpress-https.php
    on line 232

    We are seeing a lot these entries in out error logs. Anyone else?

  2. kitchin
    Member
    Posted 3 years ago #

    The code around line 232 is very buggy, in addition to causing that warning. If you just want to stop the warning, change
    $post = $post->ID;
    to
    $post and $post = $post->ID;

    If you want to fix the buggy code, and know how to read this, you can patch it. If you are using a shared SSL server, there other bugs, I can post that somewhere else. Here is the old and new code, around line 232.

    [please use a Pastebin to post large chunks of code, following forum etiquette]

  3. kitchin
    Member
    Posted 3 years ago #

    Sorry, that code is wrong. I will post a fix.

  4. PeterK2003
    Member
    Posted 3 years ago #

    Thanks, I will appreciate the update to the plugin.

  5. kitchin
    Member
    Posted 3 years ago #

    This is better, still a work in progress. I will post the whole file when done. Line 213.

    [please use a Pastebin to post large chunks of code, following forum etiquette]

    Sorry, pastebin coming up.

  6. kitchin
    Member
    Posted 3 years ago #

  7. kitchin
    Member
    Posted 3 years ago #

    The original one-line fix above is still good enough to quiet the warning, though. I will clean up the rest of my work and post it later if people want to try it.

  8. PeterK2003
    Member
    Posted 3 years ago #

    Thanks, I am not in a big hurry so I'll wait till the code makes it way into a new release.

    Thanks again.

  9. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    Kitchin,

    I really didn't want to spend time doing this, but I thought it appropriate.

    $url_path = str_replace(parse_url($this->https_url, PHP_URL_PATH), '', $url_path); // wrong, https_url already stripped of path
    The path in the https_url is being stripped from the path found by the regular expression. Not https_url itself. The entire block you commented out works fine.

    if ($url_path == '/') { // wrong, external links can match this
    That doesn't matter because the code that changes the link to HTTPS is this:
    $buffer = str_replace($html, str_replace($this->http_url, $this->https_url, $html), $buffer);
    Which obviously will not affect external URL's.

    $force_ssl_admin= defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN && is_admin(); // new code
    Why would you want to force every link to a post/page in the admin panel to be HTTPS regardless of what the user selected just because they're forcing their admin panel to be HTTPS? The idea is for the link changing to be intelligent and only change links to HTTPS that have been forced to do so.

    I'm not really sure where you were going with any of your changes other than the one line that suppresses the error, which I will implement in the next update. If the code does not appear to be working for you, please create a topic with specific examples of it not working so that I can review the 'buggyness' in action.

    Thanks,
    Mike

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic