Unverified Commit 1a9496fd by Scott Committed by GitHub

Merge pull request #625 from pupi1985/patch-106

Fixed some error 500 issues on the new recalc approach
parents f3cdc317 35ce3a4d
......@@ -28,7 +28,7 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
$message = qa_lang('misc/form_security_reload');
} else {
$recalc = new Q2A_Recalc_RecalcMain(qa_post_text('state'));
$recalc = new \Q2A\Recalc\RecalcMain(qa_post_text('state'));
$stoptime = time() + 3;
while ($recalc->performStep() && time() < $stoptime) {
......
......@@ -545,7 +545,7 @@ function qa_recalc_perform_step(&$state)
case 'docachetrim_process':
case 'docacheclear_process':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats();
$limit = min($cacheStats['files'], 20);
......@@ -648,7 +648,7 @@ function qa_recalc_stage_length($operation)
case 'docachetrim_process':
case 'docacheclear_process':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats();
$length = $cacheStats['files'];
break;
......
......@@ -1612,7 +1612,7 @@ function qa_db_upgrade_tables()
// Perform any necessary recalculations, as determined by upgrade steps
foreach (array_keys($keyrecalc) as $state) {
$recalc = new Q2A_Recalc_RecalcMain($state);
$recalc = new \Q2A\Recalc\RecalcMain($state);
while ($recalc->getState()) {
set_time_limit(60);
......
......@@ -1803,7 +1803,7 @@ switch ($adminsection) {
break;
case 'caching':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$qa_content['error'] = $cacheDriver->getError();
$cacheStats = $cacheDriver->getStats();
......
......@@ -69,7 +69,7 @@ if ($recalcnow) {
<?php
$recalc = new Q2A_Recalc_RecalcMain($state);
$recalc = new \Q2A\Recalc\RecalcMain($state);
while ($recalc->getState()) {
set_time_limit(60);
......@@ -78,7 +78,7 @@ if ($recalcnow) {
while ($recalc->performStep() && time() < $stoptime)
;
echo qa_html($recalc->getMessage) . str_repeat(' ', 1024) . "<br>\n";
echo qa_html($recalc->getMessage()) . str_repeat(' ', 1024) . "<br>\n";
flush();
sleep(1); // ... then rest for one
......
......@@ -41,7 +41,7 @@ $pagestate = qa_get_state();
// Get information about this question
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheKey = "question:$questionid";
$useCache = $userid === null && $cacheDriver->isEnabled() && !qa_is_http_post() && empty($pagestate);
$saveCache = false;
......
......@@ -524,7 +524,7 @@ function qa_db_single_select($selectspec)
{
// check for cached results
if (isset($selectspec['caching'])) {
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheKey = 'query:' . $selectspec['caching']['key'];
if ($cacheDriver->isEnabled()) {
......
......@@ -21,7 +21,6 @@ namespace Q2A\Database;
use PDO;
use PDOException;
use PDOStatement;
use Q2A_Storage_CacheFactory;
class DbConnection
{
......@@ -260,7 +259,7 @@ class DbConnection
{
// check for cached results
if (isset($selectspec['caching'])) {
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheKey = 'q2a.query:' . $selectspec['caching']['key'];
if ($cacheDriver->isEnabled()) {
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/AbstractFinalStep.php
Description: Base class for final step classes in the recalc processes.
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
......@@ -20,16 +16,17 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
use Exception;
abstract class Q2A_Recalc_AbstractFinalStep extends Q2A_Recalc_AbstractStep
abstract class AbstractFinalStep extends AbstractStep
{
protected $isFinalStep = true;
/**
* @throws Exception
*/
public function doStep()
{
throw new Exception('Do not process the completion step.');
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/AbstractStep.php
Description: Base class for step classes in the recal processes.
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
......@@ -20,19 +16,16 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
namespace Q2A\Recalc;
require_once QA_INCLUDE_DIR . 'app/format.php'; //required for qa_number_format()
require_once QA_INCLUDE_DIR . 'app/format.php'; //required for qa_number_format()
abstract class Q2A_Recalc_AbstractStep
abstract class AbstractStep
{
protected $state;
protected $isFinalStep = false;
public function __construct(Q2A_Recalc_State $state)
public function __construct(State $state)
{
$this->state = $state;
}
......@@ -67,12 +60,9 @@ abstract class Q2A_Recalc_AbstractStep
));
}
public static function factory(Q2A_Recalc_State $state)
public static function factory(State $state)
{
$class = $state->getOperationClass();
if (class_exists($class)) {
return new $class($state);
}
return null;
return $class === null ? null : new $class($state);
}
}
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/BlobsToDiskComplete.php
Description: Recalc class for the end of the blobs to disk process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsMoveComplete extends Q2A_Recalc_AbstractFinalStep
class BlobsMoveComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/BlobsToDB.php
Description: Recalc class for the start of the blobs to database process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDB extends Q2A_Recalc_AbstractStep
class BlobsToDB extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/BlobsToDBMove.php
Description: Recalc processing class for the blobs to database process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDBMove extends Q2A_Recalc_AbstractStep
class BlobsToDBMove extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/BlobsToDisk.php
Description: Recalc class for the start of the blobs to disk process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDisk extends Q2A_Recalc_AbstractStep
class BlobsToDisk extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/BlobsToDiskMove.php
Description: Recalc processing class for the blobs to disk process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDiskMove extends Q2A_Recalc_AbstractStep
class BlobsToDiskMove extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/CacheClear.php
Description: Recalc class for the start of the cache clear process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheClear extends Q2A_Recalc_AbstractStep
class CacheClear extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/CacheClearComplete.php
Description: Recalc class for the end of the cache clear process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheClearComplete extends Q2A_Recalc_AbstractFinalStep
class CacheClearComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/CacheClearProcess.php
Description: Recalc processing class for the cache clear process.
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
......@@ -20,17 +16,13 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheClearProcess extends Q2A_Recalc_AbstractStep
class CacheClearProcess extends AbstractStep
{
public function doStep()
{
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats();
$limit = min($cacheStats['files'], 20);
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/CacheTrim.php
Description: Recalc class for the start of the cache trim process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheTrim extends Q2A_Recalc_AbstractStep
class CacheTrim extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/CacherTrimProcess.php
Description: Recalc processing class for the cache trim process.
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
......@@ -20,12 +16,8 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheTrimProcess extends Q2A_Recalc_CacheClear_Process
class CacheTrimProcess extends CacheClearProcess
{
}
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/DeleteHidden.php
Description: Recalc class for the start of the delete hidden process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHidden extends Q2A_Recalc_AbstractStep
class DeleteHidden extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/DeleteHiddenAnswers.php
Description: Recalc processing class for the delete hidden process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenAnswers extends Q2A_Recalc_AbstractStep
class DeleteHiddenAnswers extends AbstractStep
{
public function doStep()
{
$posts = qa_db_posts_get_for_deleting('A', $this->state->next, 1);
if (!count($posts)) {
if (empty($posts)) {
$this->state->transition('dodeletehidden_questions');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/DeleteHiddenComments.php
Description: Recalc processing class for the delete hidden process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenComments extends Q2A_Recalc_AbstractStep
class DeleteHiddenComments extends AbstractStep
{
public function doStep()
{
$posts = qa_db_posts_get_for_deleting('C', $this->state->next, 1);
if (!count($posts)) {
if (empty($posts)) {
$this->state->transition('dodeletehidden_answers');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/DeleteHiddenComplete.php
Description: Recalc class for the end of the delete hidden process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenComplete extends Q2A_Recalc_AbstractFinalStep
class DeleteHiddenComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/DeleteHiddenQuestions.php
Description: Recalc processing class for the delete hidden process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenQuestions extends Q2A_Recalc_AbstractStep
class DeleteHiddenQuestions extends AbstractStep
{
public function doStep()
{
$posts = qa_db_posts_get_for_deleting('Q', $this->state->next, 1);
if (!count($posts)) {
if (empty($posts)) {
$this->state->transition('dodeletehidden_complete');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcCategories.php
Description: Recalc class for the start of the recalc categories process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategories extends Q2A_Recalc_AbstractStep
class RecalcCategories extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcCategoriesBackPaths.php
Description: Recalc processing class for the recalc categories process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesBackPaths extends Q2A_Recalc_AbstractStep
class RecalcCategoriesBackPaths extends AbstractStep
{
public function doStep()
{
$categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10);
if (!count($categoryids)) {
if (empty($categoryids)) {
$this->state->transition('dorecalccategories_complete');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcCategoriesComplete.php
Description: Recalc class for the end of the recalc categories process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesComplete extends Q2A_Recalc_AbstractFinalStep
class RecalcCategoriesComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcCategoriesPostCount.php
Description: Recalc processing class for the recalc categories process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesPostCount extends Q2A_Recalc_AbstractStep
class RecalcCategoriesPostCount extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcCategoriesPostUpdate.php
Description: Recalc processing class for the recalc categories process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesPostUpdate extends Q2A_Recalc_AbstractStep
class RecalcCategoriesPostUpdate extends AbstractStep
{
public function doStep()
{
$postids = qa_db_posts_get_for_recategorizing($this->state->next, 100);
if (!count($postids)) {
if (empty($postids)) {
$this->state->transition('dorecalccategories_recount');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcCategoriesRecount.php
Description: Recalc processing class for the recalc categories process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesRecount extends Q2A_Recalc_AbstractStep
class RecalcCategoriesRecount extends AbstractStep
{
public function doStep()
{
$categoryids = qa_db_categories_get_for_recalcs($this->state->next, 10);
if (!count($categoryids)) {
if (empty($categoryids)) {
$this->state->transition('dorecalccategories_backpaths');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcPoints.php
Description: Main recalculation class.
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
......@@ -56,10 +52,7 @@
[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;
}
namespace Q2A\Recalc;
require_once QA_INCLUDE_DIR . 'db/recalc.php';
require_once QA_INCLUDE_DIR . 'db/post-create.php';
......@@ -71,7 +64,7 @@ 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';
class Q2A_Recalc_RecalcMain
class RecalcMain
{
protected $state;
......@@ -80,7 +73,7 @@ class Q2A_Recalc_RecalcMain
*/
public function __construct($state)
{
$this->state = new Q2A_Recalc_State($state);
$this->state = new \Q2A\Recalc\State($state);
}
public function getState()
......@@ -90,7 +83,7 @@ class Q2A_Recalc_RecalcMain
public function performStep()
{
$step = Q2A_Recalc_AbstractStep::factory($this->state);
$step = AbstractStep::factory($this->state);
if (!$step || $step->isFinalStep()) {
$this->state->setState();
......@@ -111,7 +104,7 @@ class Q2A_Recalc_RecalcMain
*/
public function getMessage()
{
$step = Q2A_Recalc_AbstractStep::factory($this->state);
$step = AbstractStep::factory($this->state);
return $step ? $step->getMessage() : '';
}
}
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcPoints.php
Description: Recalc class for the start of the recalc points process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPoints extends Q2A_Recalc_AbstractStep
class RecalcPoints extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcPointsComplete.php
Description: Recalc class for the end of the recalc points process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPointsComplete extends Q2A_Recalc_AbstractFinalStep
class RecalcPointsComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcPointsRecalc.php
Description: Recalc processing class for the recalc points process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPointsRecalc extends Q2A_Recalc_AbstractStep
class RecalcPointsRecalc extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecalcPointsUserCount.php
Description: Recalc processing class for the recalc points process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPointsUserCount extends Q2A_Recalc_AbstractStep
class RecalcPointsUserCount extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecountPosts.php
Description: Recalc class for the start of the recount posts process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPosts extends Q2A_Recalc_AbstractStep
class RecountPosts extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecountPostsACount.php
Description: Recalc processing class for the recount posts process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsACount extends Q2A_Recalc_AbstractStep
class RecountPostsACount extends AbstractStep
{
public function doStep()
{
$postids = qa_db_posts_get_for_recounting($this->state->next, 1000);
if (!count($postids)) {
if (empty($postids)) {
qa_db_unupaqcount_update();
$this->state->transition('dorecountposts_complete');
return false;
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecountPostsComplete.php
Description: Recalc class for the end of the recount posts process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsComplete extends Q2A_Recalc_AbstractFinalStep
class RecountPostsComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecountPostsPostCount.php
Description: Recalc processing class for the recount posts process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsPostCount extends Q2A_Recalc_AbstractStep
class RecountPostsPostCount extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RecountPostsVoteCount.php
Description: Recalc processing class for the recount posts process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsVoteCount extends Q2A_Recalc_AbstractStep
class RecountPostsVoteCount extends AbstractStep
{
public function doStep()
{
$postids = qa_db_posts_get_for_recounting($this->state->next, 1000);
if (!count($postids)) {
if (empty($postids)) {
$this->state->transition('dorecountposts_acount');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RefillEvents.php
Description: Recalc class for the start of the refill events process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RefillEvents extends Q2A_Recalc_AbstractStep
class RefillEvents extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RefillEventsComplete.php
Description: Recalc class for the end of the refill events process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RefillEventsComplete extends Q2A_Recalc_AbstractFinalStep
class RefillEventsComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RefillEventsQCount.php
Description: Recalc processing class for the refill events process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_RefillEventsQCount extends Q2A_Recalc_AbstractStep
class RefillEventsQCount extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/RefillEventsRefill.php
Description: Recalc processing class for the refill events process.
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
......@@ -20,24 +16,20 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
namespace Q2A\Recalc;
require_once QA_INCLUDE_DIR . 'app/events.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
require_once QA_INCLUDE_DIR . 'util/sort.php';
class Q2A_Recalc_RefillEventsRefill extends Q2A_Recalc_AbstractStep
class RefillEventsRefill extends AbstractStep
{
public function doStep()
{
$questionids = qa_db_qs_get_for_event_refilling($this->state->next, 1);
if (!count($questionids)) {
if (empty($questionids)) {
$this->state->transition('dorefillevents_complete');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/ReindexContent.php
Description: Recalc class for the start of the reindex content process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContent extends Q2A_Recalc_AbstractStep
class ReindexContent extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/ReindexContentPageReindex.php
Description: Recalc processing class for the reindex content process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContentPageReindex extends Q2A_Recalc_AbstractStep
class ReindexContentPageReindex extends AbstractStep
{
public function doStep()
{
$pages = qa_db_pages_get_for_reindexing($this->state->next, 10);
if (!count($pages)) {
if (empty($pages)) {
$this->state->transition('doreindexcontent_postcount');
return false;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/ReindexContentPostCount.php
Description: Recalc processing class for the reindex content process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContentPostCount extends Q2A_Recalc_AbstractStep
class ReindexContentPostCount extends AbstractStep
{
public function doStep()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/ReindexContentPostReindex.php
Description: Recalc processing class for the reindex content process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContentPostReindex extends Q2A_Recalc_AbstractStep
class ReindexContentPostReindex extends AbstractStep
{
public function doStep()
{
$posts = qa_db_posts_get_for_reindexing($this->state->next, 10);
if (!count($posts)) {
if (empty($posts)) {
qa_db_truncate_indexes($this->state->next);
$this->state->transition('doreindexposts_wordcount');
return false;
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/ReindexPostsComplete.php
Description: Recalc class for the end of the reindex posts process.
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
......@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexPostsComplete extends Q2A_Recalc_AbstractFinalStep
class ReindexPostsComplete extends AbstractFinalStep
{
public function getMessage()
{
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/ReindexContentWordCount.php
Description: Recalc processing class for the reindex content process.
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
......@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Recalc;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexPostsWordCount extends Q2A_Recalc_AbstractStep
class ReindexPostsWordCount extends AbstractStep
{
public function doStep()
{
$wordids = qa_db_words_prepare_for_recounting($this->state->next, 1000);
if (!count($wordids)) {
if (empty($wordids)) {
qa_db_tagcount_update(); // this is quick so just do it here
$this->state->transition('doreindexposts_complete');
return false;
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Recalc/State.php
Description: Class holding state of the current recalculation process.
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
......@@ -20,12 +16,9 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
namespace Q2A\Recalc;
class Q2A_Recalc_State
class State
{
public $state;
public $operation;
......@@ -34,48 +27,48 @@ class Q2A_Recalc_State
public $done;
private $classes = array(
'doreindexcontent' => 'ReindexContent',
'doreindexcontent_pagereindex' => 'ReindexContentPageReindex',
'doreindexcontent_postcount' => 'ReindexContentPostCount',
'doreindexcontent_postreindex' => 'ReindexContentPostReindex',
'doreindexposts_wordcount' => 'ReindexPostsWordCount',
'dorecountposts' => 'RecountPosts',
'dorecountposts_postcount' => 'RecountPostsPostCount',
'dorecountposts_votecount' => 'RecountPostsVoteCount',
'dorecountposts_acount' => 'RecountPostsAcount',
'dorecalcpoints' => 'RecalcPoints',
'dorecalcpoints_usercount' => 'RecalcPointsUserCount',
'dorecalcpoints_recalc' => 'RecalcPointsRecalc',
'dorefillevents' => 'RefillEvents',
'dorefillevents_qcount' => 'RefillEventsQcount',
'dorefillevents_refill' => 'RefillEventsRefill',
'dorecalccategories' => 'RecalcCategories',
'dorecalccategories_postcount' => 'RecalcCategoriesPostCount',
'dorecalccategories_postupdate' => 'RecalcCategoriesPostUpdate',
'dorecalccategories_recount' => 'RecalcCategoriesRecount',
'dorecalccategories_backpaths' => 'RecalcCategoriesBackPaths',
'dodeletehidden' => 'DeleteHidden',
'dodeletehidden_comments' => 'DeleteHiddenComments',
'dodeletehidden_answers' => 'DeleteHiddenAnswers',
'dodeletehidden_questions' => 'DeletehiddenQuestions',
'doblobstodisk' => 'BlobsToDisk',
'doblobstodisk_move' => 'BlobsToDiskMove',
'doblobstodb' => 'BlobsToDB',
'doblobstodb_move' => 'BlobsToDBMove',
'docachetrim' => 'CacheTrim',
'docacheclear' => 'CacheClear',
'docachetrim_process' => 'CacheClearProcess',
'docacheclear_process' => 'CacheClearProcess',
'doreindexposts_complete' => 'ReindexPostsComplete',
'dorecountposts_complete' => 'RecountPostsComplete',
'dorecalcpoints_complete' => 'RecalcPointsComplete',
'dorefillevents_complete' => 'RefillEventsComplete',
'dorecalccategories_complete' => 'RecalcCategoriesComplete',
'dodeletehidden_complete' => 'DeleteHiddenComplete',
'doblobstodisk_complete' => 'BlobsMoveComplete',
'doblobstodb_complete' => 'BlobsMoveComplete',
'docacheclear_complete' => 'CacheClearComplete',
'doreindexcontent' => '\Q2A\Recalc\ReindexContent',
'doreindexcontent_pagereindex' => '\Q2A\Recalc\ReindexContentPageReindex',
'doreindexcontent_postcount' => '\Q2A\Recalc\ReindexContentPostCount',
'doreindexcontent_postreindex' => '\Q2A\Recalc\ReindexContentPostReindex',
'doreindexposts_wordcount' => '\Q2A\Recalc\ReindexPostsWordCount',
'dorecountposts' => '\Q2A\Recalc\RecountPosts',
'dorecountposts_postcount' => '\Q2A\Recalc\RecountPostsPostCount',
'dorecountposts_votecount' => '\Q2A\Recalc\RecountPostsVoteCount',
'dorecountposts_acount' => '\Q2A\Recalc\RecountPostsACount',
'dorecalcpoints' => '\Q2A\Recalc\RecalcPoints',
'dorecalcpoints_usercount' => '\Q2A\Recalc\RecalcPointsUserCount',
'dorecalcpoints_recalc' => '\Q2A\Recalc\RecalcPointsRecalc',
'dorefillevents' => '\Q2A\Recalc\RefillEvents',
'dorefillevents_qcount' => '\Q2A\Recalc\RefillEventsQCount',
'dorefillevents_refill' => '\Q2A\Recalc\RefillEventsRefill',
'dorecalccategories' => '\Q2A\Recalc\RecalcCategories',
'dorecalccategories_postcount' => '\Q2A\Recalc\RecalcCategoriesPostCount',
'dorecalccategories_postupdate' => '\Q2A\Recalc\RecalcCategoriesPostUpdate',
'dorecalccategories_recount' => '\Q2A\Recalc\RecalcCategoriesRecount',
'dorecalccategories_backpaths' => '\Q2A\Recalc\RecalcCategoriesBackPaths',
'dodeletehidden' => '\Q2A\Recalc\DeleteHidden',
'dodeletehidden_comments' => '\Q2A\Recalc\DeleteHiddenComments',
'dodeletehidden_answers' => '\Q2A\Recalc\DeleteHiddenAnswers',
'dodeletehidden_questions' => '\Q2A\Recalc\DeleteHiddenQuestions',
'doblobstodisk' => '\Q2A\Recalc\BlobsToDisk',
'doblobstodisk_move' => '\Q2A\Recalc\BlobsToDiskMove',
'doblobstodb' => '\Q2A\Recalc\BlobsToDB',
'doblobstodb_move' => '\Q2A\Recalc\BlobsToDBMove',
'docachetrim' => '\Q2A\Recalc\CacheTrim',
'docacheclear' => '\Q2A\Recalc\CacheClear',
'docachetrim_process' => '\Q2A\Recalc\CacheClearProcess',
'docacheclear_process' => '\Q2A\Recalc\CacheClearProcess',
'doreindexposts_complete' => '\Q2A\Recalc\ReindexPostsComplete',
'dorecountposts_complete' => '\Q2A\Recalc\RecountPostsComplete',
'dorecalcpoints_complete' => '\Q2A\Recalc\RecalcPointsComplete',
'dorefillevents_complete' => '\Q2A\Recalc\RefillEventsComplete',
'dorecalccategories_complete' => '\Q2A\Recalc\RecalcCategoriesComplete',
'dodeletehidden_complete' => '\Q2A\Recalc\DeleteHiddenComplete',
'doblobstodisk_complete' => '\Q2A\Recalc\BlobsMoveComplete',
'doblobstodb_complete' => '\Q2A\Recalc\BlobsMoveComplete',
'docacheclear_complete' => '\Q2A\Recalc\CacheClearComplete',
);
/**
......@@ -104,7 +97,7 @@ class Q2A_Recalc_State
public function getOperationClass()
{
return isset($this->classes[$this->operation]) ? 'Q2A_Recalc_' . $this->classes[$this->operation] : null;
return isset($this->classes[$this->operation]) ? $this->classes[$this->operation] : null;
}
public function allDone()
......@@ -174,7 +167,7 @@ class Q2A_Recalc_State
case 'docachetrim_process':
case 'docacheclear_process':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
$cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats();
return $cacheStats['files'];
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Storage/FileCache.php
Description: Interface for drivers of caching system.
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
......@@ -20,10 +16,12 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Storage;
/**
* Interface for caching drivers.
*/
interface Q2A_Storage_CacheDriver
interface CacheDriver
{
/**
* Get the cached data for the supplied key. Data can be any format but is usually an array.
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Storage/CacheManager.php
Description: Handler for caching system.
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
......@@ -20,16 +16,18 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Storage;
/**
* Caches data (typically from database queries) to the filesystem.
*/
class Q2A_Storage_CacheFactory
class CacheFactory
{
private static $cacheDriver = null;
/**
* Get the appropriate cache handler.
* @return Q2A_Storage_CacheDriver The cache handler.
* @return CacheDriver The cache handler.
*/
public static function getCacheDriver()
{
......@@ -45,12 +43,12 @@ class Q2A_Storage_CacheFactory
switch($driver)
{
case 'memcached':
self::$cacheDriver = new Q2A_Storage_MemcachedDriver($config);
self::$cacheDriver = new MemcachedDriver($config);
break;
case 'filesystem':
default:
self::$cacheDriver = new Q2A_Storage_FileCacheDriver($config);
self::$cacheDriver = new FileCacheDriver($config);
break;
}
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Storage/FileCacheDriver.php
Description: File-based driver for caching system.
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
......@@ -20,10 +16,12 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Storage;
/**
* Caches data (typically from database queries) to the filesystem.
*/
class Q2A_Storage_FileCacheDriver implements Q2A_Storage_CacheDriver
class FileCacheDriver implements CacheDriver
{
private $enabled = false;
private $keyPrefix = '';
......
......@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/Q2A/Storage/MemcachedDriver.php
Description: Memcached-based driver for caching system.
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
......@@ -20,10 +16,12 @@
More about this license: http://www.question2answer.org/license.php
*/
namespace Q2A\Storage;
/**
* Caches data (typically from database queries) in memory using Memcached.
*/
class Q2A_Storage_MemcachedDriver implements Q2A_Storage_CacheDriver
class MemcachedDriver implements CacheDriver
{
private $memcached;
private $enabled = false;
......
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