Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/283216
Change subject: Fixed handling for Approved Revs' $egApprovedRevsBlankIfUnapproved ...................................................................... Fixed handling for Approved Revs' $egApprovedRevsBlankIfUnapproved Change-Id: Icf8dc03b681ee5b2048df9d279795599ca1680eb --- M Cargo.hooks.php M CargoPageData.php 2 files changed, 30 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/16/283216/1 diff --git a/Cargo.hooks.php b/Cargo.hooks.php index 7fe1b93..098e50f 100644 --- a/Cargo.hooks.php +++ b/Cargo.hooks.php @@ -229,10 +229,14 @@ * Called by a hook in the Approved Revs extension. */ public static function onARRevisionUnapproved( $parser, $title ) { + global $egApprovedRevsBlankIfUnapproved; + $pageID = $title->getArticleID(); self::deletePageFromSystem( $pageID ); - // This is all we need - see onARRevisionApproved(), above. - CargoStore::$settings['origin'] = 'Approved Revs revision unapproved'; + if ( ! $egApprovedRevsBlankIfUnapproved ) { + // No point storing the Cargo data if it's blank. + CargoStore::$settings['origin'] = 'Approved Revs revision unapproved'; + } return true; } diff --git a/CargoPageData.php b/CargoPageData.php index 07661cf..c95ded3 100644 --- a/CargoPageData.php +++ b/CargoPageData.php @@ -46,7 +46,13 @@ return $tableSchema; } - public static function storeValuesForPage( $title ) { + /** + * The $setToBlank argument is a bit of a hack - used right now only + * for "blank if unapproved" with the Approved Revs extension, because + * that setting doesn't seem to take effect soon enough to get parsed + * as a blank page. + */ + public static function storeValuesForPage( $title, $setToBlank = false ) { global $wgCargoPageDataColumns; if ( $title == null ) { @@ -80,20 +86,26 @@ $pageDataValues['_creator'] = $wikiPage->getCreator(); } if ( in_array( CARGO_STORE_FULL_TEXT, $wgCargoPageDataColumns ) ) { - $article = new Article( $title ); - $pageDataValues['_fullText'] = $article->getContent(); + if ( $setToBlank ) { + $pageDataValues['_fullText'] = ''; + } else { + $article = new Article( $title ); + $pageDataValues['_fullText'] = $article->getContent(); + } } if ( in_array( CARGO_STORE_CATEGORIES, $wgCargoPageDataColumns ) ) { $pageCategories = array(); - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( - 'categorylinks', - 'cl_to', - array( 'cl_from' => $title->getArticleID() ), - __METHOD__ - ); - foreach ( $res as $row ) { - $pageCategories[] = $row->cl_to; + if ( !$setToBlank ) { + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( + 'categorylinks', + 'cl_to', + array( 'cl_from' => $title->getArticleID() ), + __METHOD__ + ); + foreach ( $res as $row ) { + $pageCategories[] = $row->cl_to; + } } $pageCategoriesString = implode( '|', $pageCategories ); -- To view, visit https://gerrit.wikimedia.org/r/283216 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icf8dc03b681ee5b2048df9d279795599ca1680eb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Cargo Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits