( ! ) Warning: session_start(): open(/var/lib/php/session/sess_hr1va861r19au22uub7cunb966, O_RDWR) failed: No such file or directory (2) in /var/www/bitweaver/live/users/includes/bit_setup_inc.php on line 82
Call Stack
#TimeMemoryFunctionLocation
10.0000235064{main}( ).../index.php:0
20.0000237120require_once( '/var/www/bitweaver/live/kernel/includes/setup_inc.php' ).../index.php:16
30.01161911672BitSystem->scanPackages( ).../setup_inc.php:141
40.01302179952BitSystem->loadPackage( ).../BitSystem.php:1183
50.01302182984include_once( '/var/www/bitweaver/live/users/includes/bit_setup_inc.php' ).../BitSystem.php:1109
60.01332587232session_start ( ).../bit_setup_inc.php:82

( ! ) Warning: session_write_close(): open(/var/lib/php/session/sess_hr1va861r19au22uub7cunb966, O_RDWR) failed: No such file or directory (2) in /var/www/bitweaver/live/kernel/includes/classes/BitSystem.php on line 580
Call Stack
#TimeMemoryFunctionLocation
10.0000235064{main}( ).../index.php:0
20.03763616352include( '/var/www/bitweaver/live/wiki/includes/display_bitpage_inc.php' ).../index.php:50
30.04503669184BitSystem->display( ).../display_bitpage_inc.php:163
40.04533671880BitSystem->preDisplay( ).../BitSystem.php:505
50.04663686488session_write_close ( ).../BitSystem.php:580

( ! ) Warning: session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in /var/www/bitweaver/live/kernel/includes/classes/BitSystem.php on line 580
Call Stack
#TimeMemoryFunctionLocation
10.0000235064{main}( ).../index.php:0
20.03763616352include( '/var/www/bitweaver/live/wiki/includes/display_bitpage_inc.php' ).../index.php:50
30.04503669184BitSystem->display( ).../display_bitpage_inc.php:163
40.04533671880BitSystem->preDisplay( ).../BitSystem.php:505
50.04663686488session_write_close ( ).../BitSystem.php:580
Porting Articles To Blogs - bitweaver

Porting Articles To Blogs

Created by: Will, Last modification: 23 Aug 2007 (18:33 UTC)
NOTICE: This script is in development! You should proceed with caution with using this script. Always backup your site and test on a copy before working on a live site.


This script is a DRAFT, designed for converting bitweaver Articles content into Blog Posts content. One of the more important aspects of this script is that it changes the content_type_guid on all Articles content to bitblogposts. This has some serious consequences, the most important being that existing Article urls will no longer resolve! The ArticlesPackage will no longer identify old Articles. Instead the blog package will identify them as Blog Posts!

Another thing to be aware of is that Articles and Blog Posts handle their expiration dates quite differently. Article expiration is sort of controlled by Article Type (or Topic - not sure) and the Articles edit form. The topic decides whether Articles can or can not expire and the form decides when. The Article form by default loads with the expiration being One Year ahead.

Blog Posts by contrast only expire if the expiration date is greater than the publish date. Therefore individual blog posts can be set to never expire, where as Articles requires the Topic to enforce that.

As a crude way to deal with this we set all expiration dates to be the publish_date -1 — this will keep all articles from expiring. You may want to change this to make the expiration more sophisticated if you have deliberately expired Articles..

draft


<?php
// the blog these posts should be inserted into
$blog_content_id NULL;

// no need to touch any of the stuff below unless you want to change the
// import behaviour
require_once( 'bit_setup_inc.php' );
require_once( 
ARTICLES_PKG_PATH.'BitArticle.php' );
require_once( 
BLOGS_PKG_PATH.'BitBlogPost.php' );
if( 
$gBitSystem->isPackageActive'tags' )) {
    require_once( 
TAGS_PKG_PATH.'LibertyTag.php' );
}

$gBitSystem->verifyPermission'p_admin' );

if( 
$gBitSystem->isPackageActive'blogs' ) && $gBitSystem->isPackageActive'articles' )) {
    
// get the list of Articles
    
$art = new BitArticle();
    
$getHash['max_records'] = 99999;
    
$articlesHash $art->getList($getHash);

    foreach( 
$articlesHash as $article ) {
        
$bp = new BitBlogPost();

        
$feedback "Importing: ".$article['title'];

        
$post['content_id'] = $article['content_id'];
        
$post['publish_date'] = $article['publish_date'];

        if ( 
$article['expire_date'] > $article['publish_date'] ){
            
$article['expire_date'] = $article['publish_date'] - 1;
        }

        
$table BIT_DB_PREFIX."blog_posts";
        
$bp->mDb->StartTrans();
        
$post['post_id'] = $bp->mDb->GenID'blog_posts_post_id_seq' );
        
$bp->mPostId $post['post_id'];

        
//store the new post
        
if ( $result $bp->mDb->associateInsert$table$post ) ){

            
$query "UPDATE `".BIT_DB_PREFIX."liberty_content` lc SET content_type_guid='bitblogpost' WHERE content_type_guid='bitarticle'";

            
$result $bp->mDb->query$query );

            
// let's reload to get a full mInfo hash which is needed below
            
$bp->loadFALSE );

            
// if blog_content_id, then map the post to the relative blogs
            
if( !empty( $blog_content_id )){
                
$bp->storePostMap$bp->mContentId$blog_content_id );
            }

            
$feedback .= "\n- Post: SUCCESS - content_id: ".$post['content_id'];

        } else {
            
$feedback .= "\n- Post: ERROR:\n --- ".implode"\n --- "$bp->mErrors );
        }
        
$bp->mDb->CompleteTrans();

        
//vd(strtotime($post['date'])." - ".date("r", strtotime($post['date']))." - ".$post['date']);
        
vd$feedback );
    }
}
?>