Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’ve also had the same issue with v1.3.9. I was able to narrow down the exact line the issue is happening on inside the plugin and have sent this over to the developers.

    I also added a hook (‘add_filter’) to my themes functions.php that corrects the issue. The fix works well for my specific use case but might have hidden side effects so I haven’t uploaded it here. Let me know if you’d like more details.

    In the meantime, downgrading the plugin as @manishwebosmotic has is likely the best course of action.

    Plugin Contributor IAmAdamTaylor

    (@ad_taylor)

    Hi @millermedianow

    Brilliant, that’s resolved the issue ??

    Thanks for adding me as a contributor too!

    Plugin Contributor IAmAdamTaylor

    (@ad_taylor)

    Hi,

    Thanks for the reply. I’ve updated to the latest version of the plugin and the issue still persists. I’ll try and give a step by step way to recreate the issue on a fresh install:

    1. After setting up WordPress, install the plugin (1.3.9)
    2. Go to Pages and create a new page named ‘Top Level Page’ (ID:7)
    3. Create another page named PTC Page (ID:9) and set its parent to Top Level Page
    4. Create one final page named PTC Child Page (ID:11) and set its parent to PTC Page
    5. Edit PTC Page and add password protection and turn on PTC

    With a fresh install, you will also need to add a debug statement to reveal the error. I was getting a PHP Warning because I had deleted the ‘Hello world!’ post (ID:1) that WordPress automatically creates for you.

    Add these debug statements to the _inc/helpers.php file

    
    static function processPosts($post)
        {
            echo '<pre>'; 
            var_dump( 'Param passed: ', $post ); 
            echo '</pre>';
            
            if ( is_int($post) or !is_object($post) )
                $post = get_post($post);
    
            echo '<pre>'; 
            var_dump( 'After get_post: ', $post ); 
            echo '</pre>';
    
            if ( !self::isPasswordProtected($post) )
                return false;
    
            if ( get_post_meta($post->ID, 'protect_children', true)  )
                return $post;
    
            return false;
        }
    

    Now view the PTC Page on the front-end. You will see on the first pass, which is the foreach loop, it checks Top Level Page and correctly detects that this is not a password protected page.

    This is when it falls through to the second part of the isEnabled function which cannot correctly handle arrays. The ‘Param passed’ log shows the post parent IDs as an array and the ‘After get_post’ log shows that the post has been incorrectly found as the ‘Hello world!’ post ID:1.

    For anyone who has deleted the ‘Hello world!’ post, as I had, the get_post call will return null instead, leading to the following line get_post_meta($post->ID, ... to cause a PHP Warning because $post is no longer an object.

    As mentioned before, this can be mitigated by not letting the loop fall through to the second part of the isEnabled check.

    • This reply was modified 2 years, 10 months ago by IAmAdamTaylor.
    Thread Starter IAmAdamTaylor

    (@ad_taylor)

    That sounds great – thank you again for your continued work on this plugin.

    I look forward to the next release.

Viewing 4 replies - 1 through 4 (of 4 total)