Commit 006e1162 by Scott

Coding style: add missing DocBlocks

parent 57262809
...@@ -57,8 +57,8 @@ function qa_admin_check_privileges(&$qa_content) ...@@ -57,8 +57,8 @@ function qa_admin_check_privileges(&$qa_content)
/** /**
* Return a sorted array of available languages, [short code] => [long name] * Return a sorted array of available languages, [short code] => [long name]
* @return array * @return array
*/ */
function qa_admin_language_options() function qa_admin_language_options()
{ {
......
...@@ -1289,12 +1289,12 @@ function qa_post_limit_exceeded() ...@@ -1289,12 +1289,12 @@ function qa_post_limit_exceeded()
/** /**
* Turns a numeric value and a unit (g/m/k) into bytes * Turns a numeric value and a unit (g/m/k) into bytes
* @param string $unit One of 'g', 'm', 'k'. It is case insensitive * @param string $unit One of 'g', 'm', 'k'. It is case insensitive
* @param int $value The value to turn into bytes * @param int $value The value to turn into bytes
* @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then the * @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then the
* original value is returned * original value is returned
*/ */
function convert_to_bytes($unit, $value) function convert_to_bytes($unit, $value)
{ {
$value = (int) $value; $value = (int) $value;
......
...@@ -37,6 +37,7 @@ class Container ...@@ -37,6 +37,7 @@ class Container
/** /**
* Return an object assigned to the given key. If the key is not found an exception is thrown. * Return an object assigned to the given key. If the key is not found an exception is thrown.
* @throws FatalErrorException
* @param string $key The key to look for * @param string $key The key to look for
* @return mixed * @return mixed
*/ */
......
...@@ -173,6 +173,7 @@ class DbConnection ...@@ -173,6 +173,7 @@ class DbConnection
/** /**
* Prepare and execute a SQL query, handling any failures. In debugging mode, track the queries and resources used. * Prepare and execute a SQL query, handling any failures. In debugging mode, track the queries and resources used.
* @throws SelectSpecException
* @param string $query * @param string $query
* @param array $params * @param array $params
* @return DbResult * @return DbResult
......
...@@ -68,10 +68,10 @@ class DbQueryHelper ...@@ -68,10 +68,10 @@ class DbQueryHelper
/** /**
* Substitute single '?' in a SQL query with multiple '?' for array parameters, and flatten parameter list accordingly. * Substitute single '?' in a SQL query with multiple '?' for array parameters, and flatten parameter list accordingly.
* @throws SelectSpecException
* @param string $query * @param string $query
* @param array $params * @param array $params
* @return array Query and flattened parameter list * @return array Query and flattened parameter list
* @throws SelectSpecException
*/ */
public function expandParameters($query, array $params = []) public function expandParameters($query, array $params = [])
{ {
...@@ -139,6 +139,7 @@ class DbQueryHelper ...@@ -139,6 +139,7 @@ class DbQueryHelper
* INSERT INTO..VALUES query for inserting multiple rows. * INSERT INTO..VALUES query for inserting multiple rows.
* If the first subparam is an array, the rest of the parameter groups should have the same * If the first subparam is an array, the rest of the parameter groups should have the same
* amount of elements, i.e. the output should be '(?, ?), (?, ?)' rather than '(?), (?, ?)'. * amount of elements, i.e. the output should be '(?, ?), (?, ?)' rather than '(?), (?, ?)'.
* @throws SelectSpecException
* @param array $subArray * @param array $subArray
* @param string $outQuery * @param string $outQuery
* @param array $outParams * @param array $outParams
......
...@@ -57,9 +57,8 @@ class Router ...@@ -57,9 +57,8 @@ class Router
/** /**
* Return the route definition that matches the given request. If none is found then null is * Return the route definition that matches the given request. If none is found then null is
* returned. * returned.
* * @throws MethodNotAllowedException
* @param string $request Request that will be looked for a match * @param string $request Request that will be looked for a match
*
* @return Route|null * @return Route|null
*/ */
public function match($request) public function match($request)
...@@ -88,9 +87,7 @@ class Router ...@@ -88,9 +87,7 @@ class Router
/** /**
* Build the final regular expression to match the request. This method replaces all the * Build the final regular expression to match the request. This method replaces all the
* parameters' placeholders with the given regular expression. * parameters' placeholders with the given regular expression.
*
* @param string $routePath Route that might have placeholders * @param string $routePath Route that might have placeholders
*
* @return string * @return string
*/ */
private function buildPathRegex($routePath) private function buildPathRegex($routePath)
...@@ -100,7 +97,6 @@ class Router ...@@ -100,7 +97,6 @@ class Router
/** /**
* Return the HTTP method of the current request. * Return the HTTP method of the current request.
*
* @return string * @return string
*/ */
public function getHttpMethod() public function getHttpMethod()
......
...@@ -25,10 +25,13 @@ abstract class AbstractFinalStep extends AbstractStep ...@@ -25,10 +25,13 @@ abstract class AbstractFinalStep extends AbstractStep
protected $isFinalStep = true; protected $isFinalStep = true;
/** /**
* Should not be called.
* @throws Exception * @throws Exception
* @return bool
*/ */
public function doStep() public function doStep()
{ {
throw new Exception('Do not process the completion step.'); throw new Exception('Do not process the completion step.');
return false;
} }
} }
...@@ -20,9 +20,16 @@ namespace Q2A\Recalc; ...@@ -20,9 +20,16 @@ namespace Q2A\Recalc;
abstract class AbstractStep abstract class AbstractStep
{ {
/** @var string */
protected $state; protected $state;
/** @var bool */
protected $isFinalStep = false; protected $isFinalStep = false;
/**
* Initialize a step.
* @param State $state
*/
public function __construct(State $state) public function __construct(State $state)
{ {
require_once QA_INCLUDE_DIR . 'app/format.php'; // for qa_format_number() require_once QA_INCLUDE_DIR . 'app/format.php'; // for qa_format_number()
...@@ -30,13 +37,25 @@ abstract class AbstractStep ...@@ -30,13 +37,25 @@ abstract class AbstractStep
$this->state = $state; $this->state = $state;
} }
/**
* Execute the step.
* @return bool
*/
abstract public function doStep(); abstract public function doStep();
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return ''; return '';
} }
/**
* Whether to stop processing.
* @return bool
*/
public function isFinalStep() public function isFinalStep()
{ {
return $this->isFinalStep; return $this->isFinalStep;
...@@ -45,12 +64,12 @@ abstract class AbstractStep ...@@ -45,12 +64,12 @@ abstract class AbstractStep
/** /**
* Return the translated language ID string replacing the progress and total in it. * Return the translated language ID string replacing the progress and total in it.
* *
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2) * @param string $langId Language string ID that contains 2 placeholders (^1 and ^2).
* @param int $progress Amount of processed elements * @param int $progress Amount of processed elements.
* @param int $total Total amount of elements * @param int $total Total amount of elements.
* *
* @return string Returns the language string ID with their placeholders replaced with * @return string Returns the language string ID with their placeholders replaced with
* the formatted progress and total numbers * the formatted progress and total numbers.
*/ */
protected function progressLang($langId, $progress, $total) protected function progressLang($langId, $progress, $total)
{ {
...@@ -60,6 +79,11 @@ abstract class AbstractStep ...@@ -60,6 +79,11 @@ abstract class AbstractStep
)); ));
} }
/**
* Factory method to instantiate the State.
* @param State $state
* @return AbstractStep|null
*/
public static function factory(State $state) public static function factory(State $state)
{ {
$class = $state->getOperationClass(); $class = $state->getOperationClass();
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsMoveComplete extends AbstractFinalStep class BlobsMoveComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/blobs_move_complete'); return qa_lang('admin/blobs_move_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDB extends AbstractStep class BlobsToDB extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('doblobstodb_move'); $this->state->transition('doblobstodb_move');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDBMove extends AbstractStep class BlobsToDBMove extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$blob = qa_db_get_next_blob_on_disk($this->state->next); $blob = qa_db_get_next_blob_on_disk($this->state->next);
...@@ -40,6 +44,10 @@ class BlobsToDBMove extends AbstractStep ...@@ -40,6 +44,10 @@ class BlobsToDBMove extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/blobs_move_moved', $this->state->done, $this->state->length); return $this->progressLang('admin/blobs_move_moved', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDisk extends AbstractStep class BlobsToDisk extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('doblobstodisk_move'); $this->state->transition('doblobstodisk_move');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class BlobsToDiskMove extends AbstractStep class BlobsToDiskMove extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$blob = qa_db_get_next_blob_in_db($this->state->next); $blob = qa_db_get_next_blob_in_db($this->state->next);
...@@ -41,6 +45,10 @@ class BlobsToDiskMove extends AbstractStep ...@@ -41,6 +45,10 @@ class BlobsToDiskMove extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/blobs_move_moved', $this->state->done, $this->state->length); return $this->progressLang('admin/blobs_move_moved', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheClear extends AbstractStep class CacheClear extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('docacheclear_process'); $this->state->transition('docacheclear_process');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheClearComplete extends AbstractFinalStep class CacheClearComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/caching_delete_complete'); return qa_lang('admin/caching_delete_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheClearProcess extends AbstractStep class CacheClearProcess extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
...@@ -37,6 +41,10 @@ class CacheClearProcess extends AbstractStep ...@@ -37,6 +41,10 @@ class CacheClearProcess extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/caching_delete_progress', $this->state->done, $this->state->length); return $this->progressLang('admin/caching_delete_progress', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class CacheTrim extends AbstractStep class CacheTrim extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('docachetrim_process'); $this->state->transition('docachetrim_process');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHidden extends AbstractStep class DeleteHidden extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('dodeletehidden_comments'); $this->state->transition('dodeletehidden_comments');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenAnswers extends AbstractStep class DeleteHiddenAnswers extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$posts = qa_db_posts_get_for_deleting('A', $this->state->next, 1); $posts = qa_db_posts_get_for_deleting('A', $this->state->next, 1);
...@@ -39,6 +43,10 @@ class DeleteHiddenAnswers extends AbstractStep ...@@ -39,6 +43,10 @@ class DeleteHiddenAnswers extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/hidden_answers_deleted', $this->state->done, $this->state->length); return $this->progressLang('admin/hidden_answers_deleted', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenComments extends AbstractStep class DeleteHiddenComments extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$posts = qa_db_posts_get_for_deleting('C', $this->state->next, 1); $posts = qa_db_posts_get_for_deleting('C', $this->state->next, 1);
...@@ -39,6 +43,10 @@ class DeleteHiddenComments extends AbstractStep ...@@ -39,6 +43,10 @@ class DeleteHiddenComments extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/hidden_comments_deleted', $this->state->done, $this->state->length); return $this->progressLang('admin/hidden_comments_deleted', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenComplete extends AbstractFinalStep class DeleteHiddenComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/delete_hidden_complete'); return qa_lang('admin/delete_hidden_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class DeleteHiddenQuestions extends AbstractStep class DeleteHiddenQuestions extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$posts = qa_db_posts_get_for_deleting('Q', $this->state->next, 1); $posts = qa_db_posts_get_for_deleting('Q', $this->state->next, 1);
...@@ -39,6 +43,10 @@ class DeleteHiddenQuestions extends AbstractStep ...@@ -39,6 +43,10 @@ class DeleteHiddenQuestions extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/hidden_questions_deleted', $this->state->done, $this->state->length); return $this->progressLang('admin/hidden_questions_deleted', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategories extends AbstractStep class RecalcCategories extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('dorecalccategories_postcount'); $this->state->transition('dorecalccategories_postcount');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesBackPaths extends AbstractStep class RecalcCategoriesBackPaths extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10); $categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10);
...@@ -37,6 +41,10 @@ class RecalcCategoriesBackPaths extends AbstractStep ...@@ -37,6 +41,10 @@ class RecalcCategoriesBackPaths extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/recalc_categories_backpaths', $this->state->done, $this->state->length); return $this->progressLang('admin/recalc_categories_backpaths', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesComplete extends AbstractFinalStep class RecalcCategoriesComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recalc_categories_complete'); return qa_lang('admin/recalc_categories_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesPostCount extends AbstractStep class RecalcCategoriesPostCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
qa_db_acount_update(); qa_db_acount_update();
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesPostUpdate extends AbstractStep class RecalcCategoriesPostUpdate extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$postids = qa_db_posts_get_for_recategorizing($this->state->next, 100); $postids = qa_db_posts_get_for_recategorizing($this->state->next, 100);
...@@ -39,6 +43,10 @@ class RecalcCategoriesPostUpdate extends AbstractStep ...@@ -39,6 +43,10 @@ class RecalcCategoriesPostUpdate extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/recalc_categories_updated', $this->state->done, $this->state->length); return $this->progressLang('admin/recalc_categories_updated', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcCategoriesRecount extends AbstractStep class RecalcCategoriesRecount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10); $categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10);
...@@ -39,6 +43,10 @@ class RecalcCategoriesRecount extends AbstractStep ...@@ -39,6 +43,10 @@ class RecalcCategoriesRecount extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/recalc_categories_recounting', $this->state->done, $this->state->length); return $this->progressLang('admin/recalc_categories_recounting', $this->state->done, $this->state->length);
......
...@@ -60,6 +60,7 @@ class RecalcMain ...@@ -60,6 +60,7 @@ class RecalcMain
/** /**
* Initialize the counts of resource usage. * Initialize the counts of resource usage.
* @param string $state
*/ */
public function __construct($state) public function __construct($state)
{ {
...@@ -76,11 +77,19 @@ class RecalcMain ...@@ -76,11 +77,19 @@ class RecalcMain
$this->state = new \Q2A\Recalc\State($state); $this->state = new \Q2A\Recalc\State($state);
} }
/**
* Get the state.
* @return string
*/
public function getState() public function getState()
{ {
return $this->state->getState(); return $this->state->getState();
} }
/**
* Do the recalculation.
* @return bool
*/
public function performStep() public function performStep()
{ {
$step = AbstractStep::factory($this->state); $step = AbstractStep::factory($this->state);
...@@ -99,7 +108,7 @@ class RecalcMain ...@@ -99,7 +108,7 @@ class RecalcMain
} }
/** /**
* Return a string which gives a user-viewable version of $state * Return a string which gives a user-viewable version of $state.
* @return string * @return string
*/ */
public function getMessage() public function getMessage()
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPoints extends AbstractStep class RecalcPoints extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('dorecalcpoints_usercount'); $this->state->transition('dorecalcpoints_usercount');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPointsComplete extends AbstractFinalStep class RecalcPointsComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recalc_points_complete'); return qa_lang('admin/recalc_points_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPointsRecalc extends AbstractStep class RecalcPointsRecalc extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$default_recalccount = 10; $default_recalccount = 10;
...@@ -46,6 +50,10 @@ class RecalcPointsRecalc extends AbstractStep ...@@ -46,6 +50,10 @@ class RecalcPointsRecalc extends AbstractStep
} }
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/recalc_points_recalced', $this->state->done, $this->state->length); return $this->progressLang('admin/recalc_points_recalced', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecalcPointsUserCount extends AbstractStep class RecalcPointsUserCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
qa_db_userpointscount_update(); // for progress update - not necessarily accurate qa_db_userpointscount_update(); // for progress update - not necessarily accurate
...@@ -28,6 +32,10 @@ class RecalcPointsUserCount extends AbstractStep ...@@ -28,6 +32,10 @@ class RecalcPointsUserCount extends AbstractStep
return false; return false;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recalc_points_usercount'); return qa_lang('admin/recalc_points_usercount');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPosts extends AbstractStep class RecountPosts extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('dorecountposts_postcount'); $this->state->transition('dorecountposts_postcount');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsACount extends AbstractStep class RecountPostsACount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$postids = qa_db_posts_get_for_recounting($this->state->next, 1000); $postids = qa_db_posts_get_for_recounting($this->state->next, 1000);
...@@ -39,6 +43,10 @@ class RecountPostsACount extends AbstractStep ...@@ -39,6 +43,10 @@ class RecountPostsACount extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/recount_posts_as_recounted', $this->state->done, $this->state->length); return $this->progressLang('admin/recount_posts_as_recounted', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsComplete extends AbstractFinalStep class RecountPostsComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recount_posts_complete'); return qa_lang('admin/recount_posts_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsPostCount extends AbstractStep class RecountPostsPostCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
qa_db_qcount_update(); qa_db_qcount_update();
...@@ -32,6 +36,10 @@ class RecountPostsPostCount extends AbstractStep ...@@ -32,6 +36,10 @@ class RecountPostsPostCount extends AbstractStep
return false; return false;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recalc_posts_count'); return qa_lang('admin/recalc_posts_count');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RecountPostsVoteCount extends AbstractStep class RecountPostsVoteCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$postids = qa_db_posts_get_for_recounting($this->state->next, 1000); $postids = qa_db_posts_get_for_recounting($this->state->next, 1000);
...@@ -38,6 +42,10 @@ class RecountPostsVoteCount extends AbstractStep ...@@ -38,6 +42,10 @@ class RecountPostsVoteCount extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/recount_posts_votes_recounted', $this->state->done, $this->state->length); return $this->progressLang('admin/recount_posts_votes_recounted', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEvents extends AbstractStep class RefillEvents extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('dorefillevents_qcount'); $this->state->transition('dorefillevents_qcount');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEventsComplete extends AbstractFinalStep class RefillEventsComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/refill_events_complete'); return qa_lang('admin/refill_events_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEventsQCount extends AbstractStep class RefillEventsQCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
qa_db_qcount_update(); qa_db_qcount_update();
...@@ -27,6 +31,10 @@ class RefillEventsQCount extends AbstractStep ...@@ -27,6 +31,10 @@ class RefillEventsQCount extends AbstractStep
return false; return false;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recalc_posts_count'); return qa_lang('admin/recalc_posts_count');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class RefillEventsRefill extends AbstractStep class RefillEventsRefill extends AbstractStep
{ {
/**
* Include some extra files.
* @param State $state
*/
public function __construct(State $state) public function __construct(State $state)
{ {
require_once QA_INCLUDE_DIR . 'app/events.php'; require_once QA_INCLUDE_DIR . 'app/events.php';
...@@ -29,6 +33,10 @@ class RefillEventsRefill extends AbstractStep ...@@ -29,6 +33,10 @@ class RefillEventsRefill extends AbstractStep
parent::__construct($state); parent::__construct($state);
} }
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$questionids = qa_db_qs_get_for_event_refilling($this->state->next, 1); $questionids = qa_db_qs_get_for_event_refilling($this->state->next, 1);
...@@ -124,6 +132,10 @@ class RefillEventsRefill extends AbstractStep ...@@ -124,6 +132,10 @@ class RefillEventsRefill extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/refill_events_refilled', $this->state->done, $this->state->length); return $this->progressLang('admin/refill_events_refilled', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContent extends AbstractStep class ReindexContent extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$this->state->transition('doreindexcontent_pagereindex'); $this->state->transition('doreindexcontent_pagereindex');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContentPageReindex extends AbstractStep class ReindexContentPageReindex extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$pages = qa_db_pages_get_for_reindexing($this->state->next, 10); $pages = qa_db_pages_get_for_reindexing($this->state->next, 10);
...@@ -56,6 +60,10 @@ class ReindexContentPageReindex extends AbstractStep ...@@ -56,6 +60,10 @@ class ReindexContentPageReindex extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/reindex_pages_reindexed', $this->state->done, $this->state->length); return $this->progressLang('admin/reindex_pages_reindexed', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContentPostCount extends AbstractStep class ReindexContentPostCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
qa_db_qcount_update(); qa_db_qcount_update();
...@@ -30,6 +34,10 @@ class ReindexContentPostCount extends AbstractStep ...@@ -30,6 +34,10 @@ class ReindexContentPostCount extends AbstractStep
return false; return false;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/recalc_posts_count'); return qa_lang('admin/recalc_posts_count');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexContentPostReindex extends AbstractStep class ReindexContentPostReindex extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$posts = qa_db_posts_get_for_reindexing($this->state->next, 10); $posts = qa_db_posts_get_for_reindexing($this->state->next, 10);
...@@ -58,6 +62,10 @@ class ReindexContentPostReindex extends AbstractStep ...@@ -58,6 +62,10 @@ class ReindexContentPostReindex extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/reindex_posts_reindexed', $this->state->done, $this->state->length); return $this->progressLang('admin/reindex_posts_reindexed', $this->state->done, $this->state->length);
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexPostsComplete extends AbstractFinalStep class ReindexPostsComplete extends AbstractFinalStep
{ {
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return qa_lang('admin/reindex_posts_complete'); return qa_lang('admin/reindex_posts_complete');
......
...@@ -20,6 +20,10 @@ namespace Q2A\Recalc; ...@@ -20,6 +20,10 @@ namespace Q2A\Recalc;
class ReindexPostsWordCount extends AbstractStep class ReindexPostsWordCount extends AbstractStep
{ {
/**
* Perform the recalculation.
* @return bool
*/
public function doStep() public function doStep()
{ {
$wordids = qa_db_words_prepare_for_recounting($this->state->next, 1000); $wordids = qa_db_words_prepare_for_recounting($this->state->next, 1000);
...@@ -39,6 +43,10 @@ class ReindexPostsWordCount extends AbstractStep ...@@ -39,6 +43,10 @@ class ReindexPostsWordCount extends AbstractStep
return true; return true;
} }
/**
* Get the current progress.
* @return string
*/
public function getMessage() public function getMessage()
{ {
return $this->progressLang('admin/reindex_posts_wordcounted', $this->state->done, $this->state->length); return $this->progressLang('admin/reindex_posts_wordcounted', $this->state->done, $this->state->length);
......
...@@ -73,41 +73,64 @@ class State ...@@ -73,41 +73,64 @@ class State
/** /**
* Initialize the counts of resource usage. * Initialize the counts of resource usage.
* @param string $state
*/ */
public function __construct($state) public function __construct($state)
{ {
$this->setState($state); $this->setState($state);
} }
/**
* Get the state.
* @return string
*/
public function getState() public function getState()
{ {
return $this->state; return $this->state;
} }
/**
* Set the state.
* @param string $state
* @return void
*/
public function setState($state = '') public function setState($state = '')
{ {
$this->state = $state; $this->state = $state;
list($this->operation, $this->length, $this->next, $this->done) = explode("\t", $state . "\t\t\t\t"); list($this->operation, $this->length, $this->next, $this->done) = explode("\t", $state . "\t\t\t\t");
} }
/**
* Update the state.
* @return void
*/
public function updateState() public function updateState()
{ {
$this->state = $this->operation . "\t" . $this->length . "\t" . $this->next . "\t" . $this->done; $this->state = $this->operation . "\t" . $this->length . "\t" . $this->next . "\t" . $this->done;
} }
/**
* Get the class that will handle this operation.
* @return string|null
*/
public function getOperationClass() public function getOperationClass()
{ {
return isset($this->classes[$this->operation]) ? $this->classes[$this->operation] : null; return isset($this->classes[$this->operation]) ? $this->classes[$this->operation] : null;
} }
/**
* Whether all steps are completed.
* @return bool
*/
public function allDone() public function allDone()
{ {
return $this->done >= $this->length; return $this->done >= $this->length;
} }
/** /**
* Change the $state to represent the beginning of a new $operation * Change the $state to represent the beginning of a new $operation.
* @param $newOperation * @param string $newOperation
* @return void
*/ */
public function transition($newOperation) public function transition($newOperation)
{ {
...@@ -120,7 +143,7 @@ class State ...@@ -120,7 +143,7 @@ class State
} }
/** /**
* Return how many steps there will be in recalculation $operation * Return how many steps there will be in recalculation operation.
* @return int * @return int
*/ */
private function stageLength() private function stageLength()
......
...@@ -30,4 +30,16 @@ ...@@ -30,4 +30,16 @@
</properties> </properties>
</rule> </rule>
<!-- Not part of normal usage, but kept for testing (default severity = 5) -->
<rule ref="Squiz.Commenting.FunctionComment">
<severity>0</severity>
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamName"/>
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/>
</rule>
</ruleset> </ruleset>
...@@ -43,4 +43,6 @@ ...@@ -43,4 +43,6 @@
</properties> </properties>
</rule> </rule>
<rule ref="Squiz.Commenting.DocCommentAlignment"></rule>
</ruleset> </ruleset>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment