1 tilqicom Jul 19, 2012 18:19
3 tilqicom Jul 19, 2012 20:35
sam2kb wrote:
I believe it's a lot easier to replicate changes from one app to another.
Just hack the DB class of either app, create hooks for INSERT and UPDATE operations and duplicate the queries for another app.Of course you will need to sync the apps initially.
// note to myself
Add plugin hooks to DB class in b2evo v5
could you explain it further if it's a rather simple task ? or could you please pm me an offer for the job..
ps: no hurry
4 sam2kb Jul 19, 2012 21:52
Well, we don't even need to add new hooks. There's a way in b2evo to log all DB queries. So you initiate logging, and on script shutdown you analyze queries, and reproduce data altering queries like (insert, update, replace, delete) to the other app.
To be honest, I just realized that this is the wrong (very hard) way. Analyzing and parsing each query is not easy.
Instead, you should use these new hooks from b2evo v5 AfterObjectInsert, AfterObjectUpdate, AfterObjectDelete. This is simpler than working with raw queries. Here's the example
/**
* Event handler: called at the end of {@link DataObject::dbinsert() inserting an object in the database}.
*
* @param array Associative array of parameters
* - 'Object': the related Object (by reference)
* - 'type': class name of deleted Object (Chapter, File, Blog, Link, Comment, Slug etc.) (by reference)
*/
function AfterObjectInsert( & $params )
{
// use XML-RPC to do the changes in WP
load_funcs('xmlrpc/model/_xmlrpc.funcs.php');
$client = new xmlrpc_client('/xmlrpc.php', 'my-wp-host.com', 80);
if( $params['type'] == 'Item' )
{ // New post added in b2evo
$Item = & $params['Object'];
$title = $Item->get('title');
$content = $Item->get('title');
$client->[CONSTRUCT XML-RPC REQUEST WITH VALUES RECEIVED FROM THE OBJECT]
$client->[SEND XML-RPC REQUEST TO INSERT NEW POST]
}
}
I believe it's a lot easier to replicate changes from one app to another.
Just hack the DB class of either app, create hooks for INSERT and UPDATE operations and duplicate the queries for another app.
Of course you will need to sync the apps initially.
// note to myself
Add plugin hooks to DB class in b2evo v5