recalc.php 21.2 KB
Newer Older
Scott committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<?php
/*
	Question2Answer by Gideon Greenspan and contributors
	http://www.question2answer.org/

	File: qa-include/qa-app-recalc.php
	Description: Managing database recalculations (clean-up operations) and status messages


	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/

/*
	A full list of redundant (non-normal) information in the database that can be recalculated:

	Recalculated in doreindexcontent:
	================================
	^titlewords (all): index of words in titles of posts
	^contentwords (all): index of words in content of posts
	^tagwords (all): index of words in tags of posts (a tag can contain multiple words)
	^posttags (all): index tags of posts
	^words (all): list of words used for indexes
	^options (title=cache_*): cached values for various things (e.g. counting questions)

	Recalculated in dorecountposts:
	==============================
	^posts (upvotes, downvotes, netvotes, hotness, acount, amaxvotes, flagcount): number of votes, hotness, answers, answer votes, flags

	Recalculated in dorecalcpoints:
	===============================
	^userpoints (all except bonus): points calculation for all users
	^options (title=cache_userpointscount):

	Recalculated in dorecalccategories:
	===================================
	^posts (categoryid): assign to answers and comments based on their antecedent question
	^posts (catidpath1, catidpath2, catidpath3): hierarchical path to category ids (requires QA_CATEGORY_DEPTH=4)
	^categories (qcount): number of (visible) questions in each category
	^categories (backpath): full (backwards) path of slugs to that category

	Recalculated in dorebuildupdates:
	=================================
	^sharedevents (all): per-entity event streams (see big comment in qa-db-favorites.php)
	^userevents (all): per-subscriber event streams

	[but these are not entirely redundant since they can contain historical information no longer in ^posts]
*/

	if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
		header('Location: ../');
		exit;
	}

Scott committed
64 65 66 67 68 69
	require_once QA_INCLUDE_DIR.'db/recalc.php';
	require_once QA_INCLUDE_DIR.'db/post-create.php';
	require_once QA_INCLUDE_DIR.'db/points.php';
	require_once QA_INCLUDE_DIR.'db/selects.php';
	require_once QA_INCLUDE_DIR.'db/admin.php';
	require_once QA_INCLUDE_DIR.'db/users.php';
Scott committed
70 71 72
	require_once QA_INCLUDE_DIR.'app/options.php';
	require_once QA_INCLUDE_DIR.'app/post-create.php';
	require_once QA_INCLUDE_DIR.'app/post-update.php';
Scott committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93


	function qa_recalc_perform_step(&$state)
/*
	Advance the recalculation operation represented by $state by a single step.
	$state can also be the name of a recalculation operation on its own.
*/
	{
		$continue=false;

		@list($operation, $length, $next, $done)=explode("\t", $state);

		switch ($operation) {
			case 'doreindexcontent':
				qa_recalc_transition($state, 'doreindexcontent_pagereindex');
				break;

			case 'doreindexcontent_pagereindex':
				$pages=qa_db_pages_get_for_reindexing($next, 10);

				if (count($pages)) {
Scott committed
94
					require_once QA_INCLUDE_DIR.'app/format.php';
Scott committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132

					$lastpageid=max(array_keys($pages));

					foreach ($pages as $pageid => $page)
						if (!($page['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
							$searchmodules=qa_load_modules_with('search', 'unindex_page');
							foreach ($searchmodules as $searchmodule)
								$searchmodule->unindex_page($pageid);

							$searchmodules=qa_load_modules_with('search', 'index_page');
							if (count($searchmodules)) {
								$indextext=qa_viewer_text($page['content'], 'html');

								foreach ($searchmodules as $searchmodule)
									$searchmodule->index_page($pageid, $page['tags'], $page['heading'], $page['content'], 'html', $indextext);
							}
						}

					$next=1+$lastpageid;
					$done+=count($pages);
					$continue=true;

				} else
					qa_recalc_transition($state, 'doreindexcontent_postcount');
				break;

			case 'doreindexcontent_postcount':
				qa_db_qcount_update();
				qa_db_acount_update();
				qa_db_ccount_update();

				qa_recalc_transition($state, 'doreindexcontent_postreindex');
				break;

			case 'doreindexcontent_postreindex':
				$posts=qa_db_posts_get_for_reindexing($next, 10);

				if (count($posts)) {
Scott committed
133
					require_once QA_INCLUDE_DIR.'app/format.php';
Scott committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269

					$lastpostid=max(array_keys($posts));

					qa_db_prepare_for_reindexing($next, $lastpostid);
					qa_suspend_update_counts();

					foreach ($posts as $postid => $post) {
						qa_post_unindex($postid);
						qa_post_index($postid, $post['type'], $post['questionid'], $post['parentid'], $post['title'], $post['content'],
							$post['format'], qa_viewer_text($post['content'], $post['format']), $post['tags'], $post['categoryid']);
					}

					$next=1+$lastpostid;
					$done+=count($posts);
					$continue=true;

				} else {
					qa_db_truncate_indexes($next);
					qa_recalc_transition($state, 'doreindexposts_wordcount');
				}
				break;

			case 'doreindexposts_wordcount':
				$wordids=qa_db_words_prepare_for_recounting($next, 1000);

				if (count($wordids)) {
					$lastwordid=max($wordids);

					qa_db_words_recount($next, $lastwordid);

					$next=1+$lastwordid;
					$done+=count($wordids);
					$continue=true;

				} else {
					qa_db_tagcount_update(); // this is quick so just do it here
					qa_recalc_transition($state, 'doreindexposts_complete');
				}
				break;

			case 'dorecountposts':
				qa_recalc_transition($state, 'dorecountposts_postcount');
				break;

			case 'dorecountposts_postcount':
				qa_db_qcount_update();
				qa_db_acount_update();
				qa_db_ccount_update();
				qa_db_unaqcount_update();
				qa_db_unselqcount_update();

				qa_recalc_transition($state, 'dorecountposts_votecount');
				break;

			case 'dorecountposts_votecount':
				$postids=qa_db_posts_get_for_recounting($next, 1000);

				if (count($postids)) {
					$lastpostid=max($postids);

					qa_db_posts_votes_recount($next, $lastpostid);

					$next=1+$lastpostid;
					$done+=count($postids);
					$continue=true;

				} else
					qa_recalc_transition($state, 'dorecountposts_acount');
				break;

			case 'dorecountposts_acount':
				$postids=qa_db_posts_get_for_recounting($next, 1000);

				if (count($postids)) {
					$lastpostid=max($postids);

					qa_db_posts_answers_recount($next, $lastpostid);

					$next=1+$lastpostid;
					$done+=count($postids);
					$continue=true;

				} else {
					qa_db_unupaqcount_update();
					qa_recalc_transition($state, 'dorecountposts_complete');
				}
				break;

			case 'dorecalcpoints':
				qa_recalc_transition($state, 'dorecalcpoints_usercount');
				break;

			case 'dorecalcpoints_usercount':
				qa_db_userpointscount_update(); // for progress update - not necessarily accurate
				qa_db_uapprovecount_update(); // needs to be somewhere and this is the most appropriate place
				qa_recalc_transition($state, 'dorecalcpoints_recalc');
				break;

			case 'dorecalcpoints_recalc':
				$recalccount=10;
				$userids=qa_db_users_get_for_recalc_points($next, $recalccount+1); // get one extra so we know where to start from next
				$gotcount=count($userids);
				$recalccount=min($recalccount, $gotcount); // can't recalc more than we got

				if ($recalccount>0) {
					$lastuserid=$userids[$recalccount-1];
					qa_db_users_recalc_points($next, $lastuserid);
					$done+=$recalccount;

				} else
					$lastuserid=$next; // for truncation

				if ($gotcount>$recalccount) { // more left to do
					$next=$userids[$recalccount]; // start next round at first one not recalculated
					$continue=true;

				} else {
					qa_db_truncate_userpoints($lastuserid);
					qa_db_userpointscount_update(); // quick so just do it here
					qa_recalc_transition($state, 'dorecalcpoints_complete');
				}
				break;

			case 'dorefillevents':
				qa_recalc_transition($state, 'dorefillevents_qcount');
				break;

			case 'dorefillevents_qcount':
				qa_db_qcount_update();
				qa_recalc_transition($state, 'dorefillevents_refill');
				break;

			case 'dorefillevents_refill':
				$questionids=qa_db_qs_get_for_event_refilling($next, 1);

				if (count($questionids)) {
Scott committed
270 271
					require_once QA_INCLUDE_DIR.'app/events.php';
					require_once QA_INCLUDE_DIR.'app/updates.php';
Scott committed
272
					require_once QA_INCLUDE_DIR.'util/sort.php';
Scott committed
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426

					$lastquestionid=max($questionids);

					foreach ($questionids as $questionid) {

					//	Retrieve all posts relating to this question

						list($question, $childposts, $achildposts)=qa_db_select_with_pending(
							qa_db_full_post_selectspec(null, $questionid),
							qa_db_full_child_posts_selectspec(null, $questionid),
							qa_db_full_a_child_posts_selectspec(null, $questionid)
						);

					//	Merge all posts while preserving keys as postids

						$posts=array($questionid => $question);

						foreach ($childposts as $postid => $post)
							$posts[$postid]=$post;

						foreach ($achildposts as $postid => $post)
							$posts[$postid]=$post;

					//	Creation and editing of each post

						foreach ($posts as $postid => $post) {
							$followonq=($post['basetype']=='Q') && ($postid!=$questionid);

							if ($followonq)
								$updatetype=QA_UPDATE_FOLLOWS;
							elseif ( ($post['basetype']=='C') && (@$posts[$post['parentid']]['basetype']=='Q') )
								$updatetype=QA_UPDATE_C_FOR_Q;
							elseif ( ($post['basetype']=='C') && (@$posts[$post['parentid']]['basetype']=='A') )
								$updatetype=QA_UPDATE_C_FOR_A;
							else
								$updatetype=null;

							qa_create_event_for_q_user($questionid, $postid, $updatetype, $post['userid'], @$posts[$post['parentid']]['userid'], $post['created']);

							if (isset($post['updated']) && !$followonq)
								qa_create_event_for_q_user($questionid, $postid, $post['updatetype'], $post['lastuserid'], $post['userid'], $post['updated']);
						}

					//	Tags and categories of question

						qa_create_event_for_tags($question['tags'], $questionid, null, $question['userid'], $question['created']);
						qa_create_event_for_category($question['categoryid'], $questionid, null, $question['userid'], $question['created']);

					//	Collect comment threads

						$parentidcomments=array();

						foreach ($posts as $postid => $post)
							if ($post['basetype']=='C')
								$parentidcomments[$post['parentid']][$postid]=$post;

					//	For each comment thread, notify all previous comment authors of each comment in the thread (could get slow)

						foreach ($parentidcomments as $parentid => $comments) {
							$keyuserids=array();

							qa_sort_by($comments, 'created');

							foreach ($comments as $comment) {
								foreach ($keyuserids as $keyuserid => $dummy)
									if ( ($keyuserid != $comment['userid']) && ($keyuserid != @$posts[$parentid]['userid']) )
										qa_db_event_create_not_entity($keyuserid, $questionid, $comment['postid'], QA_UPDATE_FOLLOWS, $comment['userid'], $comment['created']);

								if (isset($comment['userid']))
									$keyuserids[$comment['userid']]=true;
							}
						}
					}

					$next=1+$lastquestionid;
					$done+=count($questionids);
					$continue=true;

				} else
					qa_recalc_transition($state, 'dorefillevents_complete');
				break;

			case 'dorecalccategories':
				qa_recalc_transition($state, 'dorecalccategories_postcount');
				break;

			case 'dorecalccategories_postcount':
				qa_db_acount_update();
				qa_db_ccount_update();

				qa_recalc_transition($state, 'dorecalccategories_postupdate');
				break;

			case 'dorecalccategories_postupdate':
				$postids=qa_db_posts_get_for_recategorizing($next, 100);

				if (count($postids)) {
					$lastpostid=max($postids);

					qa_db_posts_recalc_categoryid($next, $lastpostid);
					qa_db_posts_calc_category_path($next, $lastpostid);

					$next=1+$lastpostid;
					$done+=count($postids);
					$continue=true;

				} else {
					qa_recalc_transition($state, 'dorecalccategories_recount');
				}
				break;

			case 'dorecalccategories_recount':
				$categoryids=qa_db_categories_get_for_recalcs($next, 10);

				if (count($categoryids)) {
					$lastcategoryid=max($categoryids);

					foreach ($categoryids as $categoryid)
						qa_db_ifcategory_qcount_update($categoryid);

					$next=1+$lastcategoryid;
					$done+=count($categoryids);
					$continue=true;

				} else {
					qa_recalc_transition($state, 'dorecalccategories_backpaths');
				}
				break;

			case 'dorecalccategories_backpaths':
				$categoryids=qa_db_categories_get_for_recalcs($next, 10);

				if (count($categoryids)) {
					$lastcategoryid=max($categoryids);

					qa_db_categories_recalc_backpaths($next, $lastcategoryid);

					$next=1+$lastcategoryid;
					$done+=count($categoryids);
					$continue=true;

				} else {
					qa_recalc_transition($state, 'dorecalccategories_complete');
				}
				break;

			case 'dodeletehidden':
				qa_recalc_transition($state, 'dodeletehidden_comments');
				break;

			case 'dodeletehidden_comments':
				$posts=qa_db_posts_get_for_deleting('C', $next, 1);

				if (count($posts)) {
Scott committed
427
					require_once QA_INCLUDE_DIR.'app/posts.php';
Scott committed
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444

					$postid=$posts[0];

					qa_post_delete($postid);

					$next=1+$postid;
					$done++;
					$continue=true;

				} else
					qa_recalc_transition($state, 'dodeletehidden_answers');
				break;

			case 'dodeletehidden_answers':
				$posts=qa_db_posts_get_for_deleting('A', $next, 1);

				if (count($posts)) {
Scott committed
445
					require_once QA_INCLUDE_DIR.'app/posts.php';
Scott committed
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462

					$postid=$posts[0];

					qa_post_delete($postid);

					$next=1+$postid;
					$done++;
					$continue=true;

				} else
					qa_recalc_transition($state, 'dodeletehidden_questions');
				break;

			case 'dodeletehidden_questions':
				$posts=qa_db_posts_get_for_deleting('Q', $next, 1);

				if (count($posts)) {
Scott committed
463
					require_once QA_INCLUDE_DIR.'app/posts.php';
Scott committed
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484

					$postid=$posts[0];

					qa_post_delete($postid);

					$next=1+$postid;
					$done++;
					$continue=true;

				} else
					qa_recalc_transition($state, 'dodeletehidden_complete');
				break;

			case 'doblobstodisk':
				qa_recalc_transition($state, 'doblobstodisk_move');
				break;

			case 'doblobstodisk_move':
				$blob=qa_db_get_next_blob_in_db($next);

				if (isset($blob)) {
Scott committed
485
					require_once QA_INCLUDE_DIR.'app/blobs.php';
Scott committed
486
					require_once QA_INCLUDE_DIR.'db/blobs.php';
Scott committed
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506

					if (qa_write_blob_file($blob['blobid'], $blob['content'], $blob['format']))
						qa_db_blob_set_content($blob['blobid'], null);

					$next=1+$blob['blobid'];
					$done++;
					$continue=true;

				} else
					qa_recalc_transition($state, 'doblobstodisk_complete');
				break;

			case 'doblobstodb':
				qa_recalc_transition($state, 'doblobstodb_move');
				break;

			case 'doblobstodb_move':
				$blob=qa_db_get_next_blob_on_disk($next);

				if (isset($blob)) {
Scott committed
507
					require_once QA_INCLUDE_DIR.'app/blobs.php';
Scott committed
508
					require_once QA_INCLUDE_DIR.'db/blobs.php';
Scott committed
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611

					$content=qa_read_blob_file($blob['blobid'], $blob['format']);
					qa_db_blob_set_content($blob['blobid'], $content);
					qa_delete_blob_file($blob['blobid'], $blob['format']);

					$next=1+$blob['blobid'];
					$done++;
					$continue=true;

				} else
					qa_recalc_transition($state, 'doblobstodb_complete');
				break;

			default:
				$state='';
				break;
		}

		if ($continue)
			$state=$operation."\t".$length."\t".$next."\t".$done;

		return $continue && ($done<$length);
	}


	function qa_recalc_transition(&$state, $operation)
/*
	Change the $state to represent the beginning of a new $operation
*/
	{
		$length=qa_recalc_stage_length($operation);
		$next=(QA_FINAL_EXTERNAL_USERS && ($operation=='dorecalcpoints_recalc')) ? '' : 0;
		$done=0;

		$state=$operation."\t".$length."\t".$next."\t".$done;
	}


	function qa_recalc_stage_length($operation)
/*
	Return how many steps there will be in recalculation $operation
*/
	{
		switch ($operation) {
			case 'doreindexcontent_pagereindex':
				$length=qa_db_count_pages();
				break;

			case 'doreindexcontent_postreindex':
				$length=qa_opt('cache_qcount')+qa_opt('cache_acount')+qa_opt('cache_ccount');
				break;

			case 'doreindexposts_wordcount':
				$length=qa_db_count_words();
				break;

			case 'dorecalcpoints_recalc':
				$length=qa_opt('cache_userpointscount');
				break;

			case 'dorecountposts_votecount':
			case 'dorecountposts_acount':
			case 'dorecalccategories_postupdate':
				$length=qa_db_count_posts();
				break;

			case 'dorefillevents_refill':
				$length=qa_opt('cache_qcount')+qa_db_count_posts('Q_HIDDEN');
				break;

			case 'dorecalccategories_recount':
			case 'dorecalccategories_backpaths':
				$length=qa_db_count_categories();
				break;

			case 'dodeletehidden_comments':
				$length=count(qa_db_posts_get_for_deleting('C'));
				break;

			case 'dodeletehidden_answers':
				$length=count(qa_db_posts_get_for_deleting('A'));
				break;

			case 'dodeletehidden_questions':
				$length=count(qa_db_posts_get_for_deleting('Q'));
				break;

			case 'doblobstodisk_move':
				$length=qa_db_count_blobs_in_db();
				break;

			case 'doblobstodb_move':
				$length=qa_db_count_blobs_on_disk();
				break;

			default:
				$length=0;
				break;
		}

		return $length;
	}

612 613

	/**
614 615
	 * Return the translated language ID string replacing the progress and total in it.
	 * @access private
616 617 618
	 * @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
	 * @param int $progress Amount of processed elements
	 * @param int $total Total amount of elements
619
	 *
620 621 622
	 * @return string Returns the language string ID with their placeholders replaced with
	 * the formatted progress and total numbers
	 */
623
	function qa_recalc_progress_lang($langId, $progress, $total)
624 625 626 627 628 629 630 631
	{
		return strtr(qa_lang($langId), array(
			'^1' => qa_format_number($progress),
			'^2' => qa_format_number($total)
		));
	}


Scott committed
632 633 634 635 636
	function qa_recalc_get_message($state)
/*
	Return a string which gives a user-viewable version of $state
*/
	{
637 638
		require_once QA_INCLUDE_DIR . 'app/format.php';

639
		@list($operation, $length, $next, $done) = explode("\t", $state);
Scott committed
640

641 642
		$done = (int) $done;
		$length = (int) $length;
Scott committed
643 644 645 646 647 648

		switch ($operation) {
			case 'doreindexcontent_postcount':
			case 'dorecountposts_postcount':
			case 'dorecalccategories_postcount':
			case 'dorefillevents_qcount':
649
				$message = qa_lang('admin/recalc_posts_count');
Scott committed
650 651 652
				break;

			case 'doreindexcontent_pagereindex':
653
				$message = qa_recalc_progress_lang('admin/reindex_pages_reindexed', $done, $length);
Scott committed
654 655 656
				break;

			case 'doreindexcontent_postreindex':
657
				$message = qa_recalc_progress_lang('admin/reindex_posts_reindexed', $done, $length);
658 659 660 661
				break;

			case 'doreindexposts_complete':
				$message = qa_lang('admin/reindex_posts_complete');
Scott committed
662 663 664
				break;

			case 'doreindexposts_wordcount':
665
				$message = qa_recalc_progress_lang('admin/reindex_posts_wordcounted', $done, $length);
Scott committed
666 667 668
				break;

			case 'dorecountposts_votecount':
669
				$message = qa_recalc_progress_lang('admin/recount_posts_votes_recounted', $done, $length);
Scott committed
670 671 672
				break;

			case 'dorecountposts_acount':
673
				$message = qa_recalc_progress_lang('admin/recount_posts_as_recounted', $done, $length);
Scott committed
674 675 676
				break;

			case 'dorecountposts_complete':
677
				$message = qa_lang('admin/recount_posts_complete');
Scott committed
678 679 680
				break;

			case 'dorecalcpoints_usercount':
681
				$message = qa_lang('admin/recalc_points_usercount');
Scott committed
682 683 684
				break;

			case 'dorecalcpoints_recalc':
685
				$message = qa_recalc_progress_lang('admin/recalc_points_recalced', $done, $length);
Scott committed
686 687 688
				break;

			case 'dorecalcpoints_complete':
689
				$message = qa_lang('admin/recalc_points_complete');
Scott committed
690 691 692
				break;

			case 'dorefillevents_refill':
693
				$message = qa_recalc_progress_lang('admin/refill_events_refilled', $done, $length);
Scott committed
694 695 696
				break;

			case 'dorefillevents_complete':
697
				$message = qa_lang('admin/refill_events_complete');
Scott committed
698 699 700
				break;

			case 'dorecalccategories_postupdate':
701
				$message = qa_recalc_progress_lang('admin/recalc_categories_updated', $done, $length);
Scott committed
702 703 704
				break;

			case 'dorecalccategories_recount':
705
				$message = qa_recalc_progress_lang('admin/recalc_categories_recounting', $done, $length);
Scott committed
706 707 708
				break;

			case 'dorecalccategories_backpaths':
709
				$message = qa_recalc_progress_lang('admin/recalc_categories_backpaths', $done, $length);
Scott committed
710 711 712
				break;

			case 'dorecalccategories_complete':
713
				$message = qa_lang('admin/recalc_categories_complete');
Scott committed
714 715 716
				break;

			case 'dodeletehidden_comments':
717
				$message = qa_recalc_progress_lang('admin/hidden_comments_deleted', $done, $length);
Scott committed
718 719 720
				break;

			case 'dodeletehidden_answers':
721
				$message = qa_recalc_progress_lang('admin/hidden_answers_deleted', $done, $length);
Scott committed
722 723 724
				break;

			case 'dodeletehidden_questions':
725
				$message = qa_recalc_progress_lang('admin/hidden_questions_deleted', $done, $length);
Scott committed
726 727 728
				break;

			case 'dodeletehidden_complete':
729
				$message = qa_lang('admin/delete_hidden_complete');
Scott committed
730 731 732 733
				break;

			case 'doblobstodisk_move':
			case 'doblobstodb_move':
734
				$message = qa_recalc_progress_lang('admin/blobs_move_moved', $done, $length);
Scott committed
735 736 737 738
				break;

			case 'doblobstodisk_complete':
			case 'doblobstodb_complete':
739
				$message = qa_lang('admin/blobs_move_complete');
Scott committed
740 741 742
				break;

			default:
743
				$message = '';
Scott committed
744 745 746 747 748 749 750 751 752
				break;
		}

		return $message;
	}


/*
	Omit PHP closing tag to help avoid accidental output
Gideon Greenspan committed
753
*/