• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

XenWord Development in January 2016

Status
Not open for further replies.

LPH

Flight Director
Flight Instructor
Work began on XenWord during the month of June 2013 and the first release was made public on January 18, 2014. The 93rd release was uploaded on December 31, 2015; the 10th alpha release of XenWord 3.0.

XenWord 3.0, the first of the Jefferson series, is a huge undertaking. Files are being rewritten, moved, and code is being optimized to make room for new integration features. The significant error in altering core tables in early releases is also finally being addressed in 3.0.

Work in December was very productive and I look forward to continuing to improve the bridge in 2016. The changelog details the improvements, feature enhancements, and bug fixes.

I am currently working on the comments and category-thread mapping options. @RLL is working on the avatars. @Gracie is working on documentation.

The success of this project is a reflection of all the great feedback. Thank you and happy new year.
 

LPH

Flight Director
Flight Instructor
Due to the mistakes in XenWord 3.0.0.10, work on 3.0.1.01 started today. This fixes the obvious errors in the path/to/plugin/XenForo/index.php file. The jump to 3.0.1 is due to the significant changes in storing and retrieving thread_id and forum_id.

For now, follow this thread for necessary changes in 3.0.0.10.

XenWord 3.0.1.01 was released. This contains important bug fixes.
 
Last edited:

LPH

Flight Director
Flight Instructor
Changed the file class-xenword-add-threadid.php such that the Threads column in the /wp-admin/edit.php post list is now sortable.

Sortable Threads Column.png
 

LPH

Flight Director
Flight Instructor
Just finished figuring out how to write the thread_id and post_id for a comment to the WordPress commentmeta table. This is an important step to removing the alter table for comments currently in the plugin activator method.

PHP:
    /**
    * Writes the post_id and thread_id to the _commentmeta table
    * based on the comment_id
    * 
    * @param $comment_id
    *
    * @since 3.0.1.02
    *        Initial release
    *        
    * @throws XenForo_Exception
    */
    public function add_meta( $comment_id ) {

        global $XF;

        // the XenForo post ID corresponding to the comment
        $xf_post_id = $XF->insertion_id;

        if ( isset( $xf_post_id ) ) {
            update_comment_meta( $comment_id, 'post_id', $xf_post_id );
        }

        // Get the comment array for comment_id
        $comments = get_comment( $comment_id, ARRAY_A );

        // Get the XenForo thread_id from the comment post ID
        $thread_id = XenWord::getThreadIdForPost( $comments['comment_post_ID'] );

        if ( isset ( $thread_id ) ) {
            update_comment_meta( $comment_id, 'thread_id', $thread_id );
        }
    }

Now it is time for sleep ;)
 

LPH

Flight Director
Flight Instructor
The success for the past few days has been only a few lines, adding the comment meta information for comments made before the installation of XenWord. This appears to work well.

PHP:
        /**
        * Update commentmeta information from older XenWord releases using XF_post_ID?
        *
        * Very important for backwards compatibility
        *
        */
        $args = array( 'post_id' => $post_id, );
        $comments = get_comments($args);

        foreach( $comments as $comment ) {
            if ( $comment->XF_post_ID != '0' ) {
                update_comment_meta( $comment->comment_ID, 'post_id', $comment->XF_post_ID );
            }
        }

Now, the work in Comments.php are not going well. The array_diff that I'm attempting hasn't been cooperating. Here is the idea:

Code:
// Make sure all comments from WordPress have a post_id in the comment meta data

// Get all XenForo posts by the thread_id 

// Get all XenForo posts with a corresponding comment meta

     // Build array of XF posts 

// Use array_diff() to remove XF posts already with comment meta from the comment array (leaving XF posts without comment)

// Write the posts to wp_new_comment($commentdata)
 

LPH

Flight Director
Flight Instructor
Caching support may be working properly in 3.0.1.04. This version is installed on three different environments including this site and appears to support WP Super Cache. I have not tested other caching plugins.

@RLL and I spent the afternoon looking at the Comments.php file. We decided at the end that the variable names were way too cryptic and confusing. We decided they needed to be changed.
 

LPH

Flight Director
Flight Instructor
Worked on the widgets just a little bit. In particular, the latest threads widget and fixing the CSS of the login widget. The options were put into the login widget for turning on/off the social logins. Avatars, forum title, and post date were added to the latest threads widget.

Screen Shot 2016-01-18 at 6.56.01 PM.png
 

LPH

Flight Director
Flight Instructor
Spent the day running around in circles. XenForo members are created properly in WordPress 4.4, even the role synchronization code that I added today is working properly. However, once I upgrade the development server to WordPress 4.5 then the XF members are not written to the database. I'm going to eat dinner then come back to address this code again.

PS. Yes, you read that correctly - user role synchronization is working under WP 4.4 with XenWord 3.0.1.04. :D

One particularly nasty bug was fixed today. Banned users are now no longer given permission to write comments.

To fix your copy, go to line 55 of class-xenword-wordpress-comments.php and replace with the following.

PHP:
if ( $thread_id !== false && $thread_id !== null && $visitor['is_banned'] != 1 ) {

The is_banned is now honored and a WordPress comment is not written when the user has been banned from XenForo.
 

LPH

Flight Director
Flight Instructor
WordPress developers continue to make changes that greatly influence this plugin. As of WordPress 4.5, the get_currentuserinfo() pluggable function is deprecated. This is why 3.0.1.04 is only good for up through WordPress 4.4.

I'm going to start tonight on XenWord 3.0.2.01 for WordPress 4.5 compatibility.
 

LPH

Flight Director
Flight Instructor
New code was written and works for WordPress 4.5. The issue now stands how to make XenWord available for WordPress 4.4 then 4.5 when it is released since two different pluggable functions are being used.

PHP:
if ( ! function_exists( 'wp_get_current_user' ) ) :

/**
 * This replacement function will no longer work after WordPress 4.5
 * The pluggable function was deprecated in WP 4.5
 *
 * @return void|boolean
 *
 * @since 2.5.1.03
 *        Added apply_filter to match WP get_currentuserinfo()
 *
 * @since 3.0.2.01
 *        wp_get_current_user instead of get_currentuserinfo()
 */

function wp_get_current_user() {
    global $current_user;

    if ( ! empty( $current_user ) ) {
        if ( $current_user instanceof WP_User ) {
            return $current_user;
        }

        // Upgrade stdClass to WP_User
        if ( is_object( $current_user ) && isset( $current_user->ID ) ) {
            $cur_id       = $current_user->ID;
            $current_user = null;
            wp_set_current_user( $cur_id );
            return $current_user;
        }

        // $current_user has a junk value. Force to WP_User with ID 0.
        $current_user = null;
        wp_set_current_user( 0 );
        return $current_user;
    }

    if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
        wp_set_current_user( 0 );
        return $current_user;
    }

    $visitor = XenWord::getVisitor();

    $user_id = $visitor['user_id'];

    // Conditional for no XenForo user is logged in
    if ( $user_id == 0 ) {
        $current_user = null;
        wp_set_current_user( 0 );
        return $current_user;
    }

    /**
     * Filter the current user.
     *
     * The default filters use this to determine the current user from the
     * request's cookies, if available.
     *
     * Returning a value of false will effectively short-circuit setting
     * the current user.
     *
     * @since 3.9.0
     *
     * @param int|bool $user_id User ID if one has been determined, false otherwise.
     */
    $user_id = apply_filters( 'determine_current_user', false );
    if ( ! $user_id ) {
        wp_set_current_user( 0 );
        return $current_user;
    }

    $current_user = get_userdata( $user_id );

    wp_set_current_user( $user_id );

    wp_validate_auth_cookie($cookie = '', $scheme = '');

    // Check to determine if adding XF users to WP database
    XenWord_XF_Users::check_options();

    return $current_user;
}

endif;
 
Status
Not open for further replies.
Top