Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1.     public static function onArticleDeleteComplete( WikiPage &$wikiPage, User &$user, $reason, $id ) {
  2.         // This is a temporary hack since the archive table does not correctly have the data we need.
  3.         // Once this is fixed this can go, and we can use the commented out code later in this method.
  4.         if ( $wikiPage->getTitle()->getNamespace() !== WB_NS_DATA ) {
  5.             return true;
  6.         }
  7.  
  8.         $dbw = wfGetDB( DB_MASTER );
  9.  
  10.         $archiveEntry = $dbw->selectRow(
  11.             'archive',
  12.             array(
  13.                 'ar_user',
  14.                 'ar_text_id',
  15.                 'ar_rev_id',
  16.                 'ar_timestamp',
  17.                 'ar_content_format',
  18.             ),
  19.             array(
  20.                 'ar_page_id' => $id,
  21.                 // 'ar_content_model' => CONTENT_MODEL_WIKIBASE_ITEM,
  22.             )
  23.         );
  24.  
  25.         if ( $archiveEntry !== false ) {
  26.             $textEntry = $dbw->selectRow(
  27.                 'text',
  28.                 'old_text',
  29.                 array( 'old_id' => $archiveEntry->ar_text_id )
  30.             );
  31.  
  32.             if ( $textEntry !== false ) {
  33.                 $itemHandler = ContentHandler::getForModelID( CONTENT_MODEL_WIKIBASE_ITEM );
  34.                 $itemContent = $itemHandler->unserializeContent( $textEntry->old_text/* , $archiveEntry->ar_content_format */ );
  35.                 $item = $itemContent->getItem();
  36.                 $change = \Wikibase\ItemDeletion::newFromItem( $item );
  37.  
  38.                 $change->setFields( array(
  39.                     'revision_id' => $archiveEntry->ar_rev_id,
  40.                     'user_id' => $archiveEntry->ar_user,
  41.                     'object_id' => $item->getId(),
  42.                     'time' => $archiveEntry->ar_timestamp,
  43.                 ) );
  44.  
  45.                 \Wikibase\ChangeNotifier::singleton()->handleChange( $change );
  46.             }
  47.         }
  48.  
  49.         return true;
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement