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) { ...@@ -28,7 +28,7 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
$message = qa_lang('misc/form_security_reload'); $message = qa_lang('misc/form_security_reload');
} else { } else {
$recalc = new Q2A_Recalc_RecalcMain(qa_post_text('state')); $recalc = new \Q2A\Recalc\RecalcMain(qa_post_text('state'));
$stoptime = time() + 3; $stoptime = time() + 3;
while ($recalc->performStep() && time() < $stoptime) { while ($recalc->performStep() && time() < $stoptime) {
......
...@@ -545,7 +545,7 @@ function qa_recalc_perform_step(&$state) ...@@ -545,7 +545,7 @@ function qa_recalc_perform_step(&$state)
case 'docachetrim_process': case 'docachetrim_process':
case 'docacheclear_process': case 'docacheclear_process':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats(); $cacheStats = $cacheDriver->getStats();
$limit = min($cacheStats['files'], 20); $limit = min($cacheStats['files'], 20);
...@@ -648,7 +648,7 @@ function qa_recalc_stage_length($operation) ...@@ -648,7 +648,7 @@ function qa_recalc_stage_length($operation)
case 'docachetrim_process': case 'docachetrim_process':
case 'docacheclear_process': case 'docacheclear_process':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats(); $cacheStats = $cacheDriver->getStats();
$length = $cacheStats['files']; $length = $cacheStats['files'];
break; break;
......
...@@ -1612,7 +1612,7 @@ function qa_db_upgrade_tables() ...@@ -1612,7 +1612,7 @@ function qa_db_upgrade_tables()
// Perform any necessary recalculations, as determined by upgrade steps // Perform any necessary recalculations, as determined by upgrade steps
foreach (array_keys($keyrecalc) as $state) { foreach (array_keys($keyrecalc) as $state) {
$recalc = new Q2A_Recalc_RecalcMain($state); $recalc = new \Q2A\Recalc\RecalcMain($state);
while ($recalc->getState()) { while ($recalc->getState()) {
set_time_limit(60); set_time_limit(60);
......
...@@ -1803,7 +1803,7 @@ switch ($adminsection) { ...@@ -1803,7 +1803,7 @@ switch ($adminsection) {
break; break;
case 'caching': case 'caching':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$qa_content['error'] = $cacheDriver->getError(); $qa_content['error'] = $cacheDriver->getError();
$cacheStats = $cacheDriver->getStats(); $cacheStats = $cacheDriver->getStats();
......
...@@ -69,7 +69,7 @@ if ($recalcnow) { ...@@ -69,7 +69,7 @@ if ($recalcnow) {
<?php <?php
$recalc = new Q2A_Recalc_RecalcMain($state); $recalc = new \Q2A\Recalc\RecalcMain($state);
while ($recalc->getState()) { while ($recalc->getState()) {
set_time_limit(60); set_time_limit(60);
...@@ -78,7 +78,7 @@ if ($recalcnow) { ...@@ -78,7 +78,7 @@ if ($recalcnow) {
while ($recalc->performStep() && time() < $stoptime) 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(); flush();
sleep(1); // ... then rest for one sleep(1); // ... then rest for one
......
...@@ -41,7 +41,7 @@ $pagestate = qa_get_state(); ...@@ -41,7 +41,7 @@ $pagestate = qa_get_state();
// Get information about this question // Get information about this question
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheKey = "question:$questionid"; $cacheKey = "question:$questionid";
$useCache = $userid === null && $cacheDriver->isEnabled() && !qa_is_http_post() && empty($pagestate); $useCache = $userid === null && $cacheDriver->isEnabled() && !qa_is_http_post() && empty($pagestate);
$saveCache = false; $saveCache = false;
......
...@@ -524,7 +524,7 @@ function qa_db_single_select($selectspec) ...@@ -524,7 +524,7 @@ function qa_db_single_select($selectspec)
{ {
// check for cached results // check for cached results
if (isset($selectspec['caching'])) { if (isset($selectspec['caching'])) {
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheKey = 'query:' . $selectspec['caching']['key']; $cacheKey = 'query:' . $selectspec['caching']['key'];
if ($cacheDriver->isEnabled()) { if ($cacheDriver->isEnabled()) {
......
...@@ -21,7 +21,6 @@ namespace Q2A\Database; ...@@ -21,7 +21,6 @@ namespace Q2A\Database;
use PDO; use PDO;
use PDOException; use PDOException;
use PDOStatement; use PDOStatement;
use Q2A_Storage_CacheFactory;
class DbConnection class DbConnection
{ {
...@@ -260,7 +259,7 @@ class DbConnection ...@@ -260,7 +259,7 @@ class DbConnection
{ {
// check for cached results // check for cached results
if (isset($selectspec['caching'])) { if (isset($selectspec['caching'])) {
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheKey = 'q2a.query:' . $selectspec['caching']['key']; $cacheKey = 'q2a.query:' . $selectspec['caching']['key'];
if ($cacheDriver->isEnabled()) { if ($cacheDriver->isEnabled()) {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,16 +16,17 @@ ...@@ -20,16 +16,17 @@
More about this license: http://www.question2answer.org/license.php 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 use Exception;
header('Location: ../../');
exit;
}
abstract class Q2A_Recalc_AbstractFinalStep extends Q2A_Recalc_AbstractStep abstract class AbstractFinalStep extends AbstractStep
{ {
protected $isFinalStep = true; protected $isFinalStep = true;
/**
* @throws Exception
*/
public function doStep() public function doStep()
{ {
throw new Exception('Do not process the completion step.'); throw new Exception('Do not process the completion step.');
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,16 @@ ...@@ -20,19 +16,16 @@
More about this license: http://www.question2answer.org/license.php 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 namespace Q2A\Recalc;
header('Location: ../../');
exit;
}
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 $state;
protected $isFinalStep = false; protected $isFinalStep = false;
public function __construct(Q2A_Recalc_State $state) public function __construct(State $state)
{ {
$this->state = $state; $this->state = $state;
} }
...@@ -67,12 +60,9 @@ abstract class Q2A_Recalc_AbstractStep ...@@ -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(); $class = $state->getOperationClass();
if (class_exists($class)) { return $class === null ? null : new $class($state);
return new $class($state);
}
return null;
} }
} }
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class BlobsMoveComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsMoveComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class BlobsToDB extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDB extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class BlobsToDBMove extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDBMove extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class BlobsToDisk extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDisk extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class BlobsToDiskMove extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_BlobsToDiskMove extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class CacheClear extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheClear extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class CacheClearComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheClearComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,17 +16,13 @@ ...@@ -20,17 +16,13 @@
More about this license: http://www.question2answer.org/license.php 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 class CacheClearProcess extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheClearProcess extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats(); $cacheStats = $cacheDriver->getStats();
$limit = min($cacheStats['files'], 20); $limit = min($cacheStats['files'], 20);
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class CacheTrim extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheTrim extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,12 +16,8 @@ ...@@ -20,12 +16,8 @@
More about this license: http://www.question2answer.org/license.php 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 class CacheTrimProcess extends CacheClearProcess
header('Location: ../../');
exit;
}
class Q2A_Recalc_CacheTrimProcess extends Q2A_Recalc_CacheClear_Process
{ {
} }
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class DeleteHidden extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHidden extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class DeleteHiddenAnswers extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenAnswers extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($posts)) { if (empty($posts)) {
$this->state->transition('dodeletehidden_questions'); $this->state->transition('dodeletehidden_questions');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class DeleteHiddenComments extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenComments extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($posts)) { if (empty($posts)) {
$this->state->transition('dodeletehidden_answers'); $this->state->transition('dodeletehidden_answers');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class DeleteHiddenComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class DeleteHiddenQuestions extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_DeleteHiddenQuestions extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($posts)) { if (empty($posts)) {
$this->state->transition('dodeletehidden_complete'); $this->state->transition('dodeletehidden_complete');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcCategories extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategories extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcCategoriesBackPaths extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesBackPaths extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($categoryids)) { if (empty($categoryids)) {
$this->state->transition('dorecalccategories_complete'); $this->state->transition('dorecalccategories_complete');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcCategoriesComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcCategoriesPostCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesPostCount extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcCategoriesPostUpdate extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesPostUpdate extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($postids)) { if (empty($postids)) {
$this->state->transition('dorecalccategories_recount'); $this->state->transition('dorecalccategories_recount');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcCategoriesRecount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcCategoriesRecount extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($categoryids)) { if (empty($categoryids)) {
$this->state->transition('dorecalccategories_backpaths'); $this->state->transition('dorecalccategories_backpaths');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -56,10 +52,7 @@ ...@@ -56,10 +52,7 @@
[but these are not entirely redundant since they can contain historical information no longer in ^posts] [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 namespace Q2A\Recalc;
header('Location: ../../');
exit;
}
require_once QA_INCLUDE_DIR . 'db/recalc.php'; require_once QA_INCLUDE_DIR . 'db/recalc.php';
require_once QA_INCLUDE_DIR . 'db/post-create.php'; require_once QA_INCLUDE_DIR . 'db/post-create.php';
...@@ -71,7 +64,7 @@ require_once QA_INCLUDE_DIR . 'app/options.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-create.php';
require_once QA_INCLUDE_DIR . 'app/post-update.php'; require_once QA_INCLUDE_DIR . 'app/post-update.php';
class Q2A_Recalc_RecalcMain class RecalcMain
{ {
protected $state; protected $state;
...@@ -80,7 +73,7 @@ class Q2A_Recalc_RecalcMain ...@@ -80,7 +73,7 @@ class Q2A_Recalc_RecalcMain
*/ */
public function __construct($state) public function __construct($state)
{ {
$this->state = new Q2A_Recalc_State($state); $this->state = new \Q2A\Recalc\State($state);
} }
public function getState() public function getState()
...@@ -90,7 +83,7 @@ class Q2A_Recalc_RecalcMain ...@@ -90,7 +83,7 @@ class Q2A_Recalc_RecalcMain
public function performStep() public function performStep()
{ {
$step = Q2A_Recalc_AbstractStep::factory($this->state); $step = AbstractStep::factory($this->state);
if (!$step || $step->isFinalStep()) { if (!$step || $step->isFinalStep()) {
$this->state->setState(); $this->state->setState();
...@@ -111,7 +104,7 @@ class Q2A_Recalc_RecalcMain ...@@ -111,7 +104,7 @@ class Q2A_Recalc_RecalcMain
*/ */
public function getMessage() public function getMessage()
{ {
$step = Q2A_Recalc_AbstractStep::factory($this->state); $step = AbstractStep::factory($this->state);
return $step ? $step->getMessage() : ''; return $step ? $step->getMessage() : '';
} }
} }
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcPoints extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPoints extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcPointsComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPointsComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcPointsRecalc extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPointsRecalc extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecalcPointsUserCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecalcPointsUserCount extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecountPosts extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPosts extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class RecountPostsACount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsACount extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($postids)) { if (empty($postids)) {
qa_db_unupaqcount_update(); qa_db_unupaqcount_update();
$this->state->transition('dorecountposts_complete'); $this->state->transition('dorecountposts_complete');
return false; return false;
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecountPostsComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RecountPostsPostCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsPostCount extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class RecountPostsVoteCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RecountPostsVoteCount extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($postids)) { if (empty($postids)) {
$this->state->transition('dorecountposts_acount'); $this->state->transition('dorecountposts_acount');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RefillEvents extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RefillEvents extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RefillEventsComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RefillEventsComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class RefillEventsQCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_RefillEventsQCount extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,24 +16,20 @@ ...@@ -20,24 +16,20 @@
More about this license: http://www.question2answer.org/license.php 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;
}
require_once QA_INCLUDE_DIR . 'app/events.php'; require_once QA_INCLUDE_DIR . 'app/events.php';
require_once QA_INCLUDE_DIR . 'app/updates.php'; require_once QA_INCLUDE_DIR . 'app/updates.php';
require_once QA_INCLUDE_DIR . 'util/sort.php'; require_once QA_INCLUDE_DIR . 'util/sort.php';
class Q2A_Recalc_RefillEventsRefill extends Q2A_Recalc_AbstractStep class RefillEventsRefill extends AbstractStep
{ {
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);
if (!count($questionids)) { if (empty($questionids)) {
$this->state->transition('dorefillevents_complete'); $this->state->transition('dorefillevents_complete');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class ReindexContent extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContent extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class ReindexContentPageReindex extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContentPageReindex extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($pages)) { if (empty($pages)) {
$this->state->transition('doreindexcontent_postcount'); $this->state->transition('doreindexcontent_postcount');
return false; return false;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class ReindexContentPostCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContentPostCount extends Q2A_Recalc_AbstractStep
{ {
public function doStep() public function doStep()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class ReindexContentPostReindex extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexContentPostReindex extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($posts)) { if (empty($posts)) {
qa_db_truncate_indexes($this->state->next); qa_db_truncate_indexes($this->state->next);
$this->state->transition('doreindexposts_wordcount'); $this->state->transition('doreindexposts_wordcount');
return false; return false;
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,13 +16,9 @@ ...@@ -20,13 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 class ReindexPostsComplete extends AbstractFinalStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexPostsComplete extends Q2A_Recalc_AbstractFinalStep
{ {
public function getMessage() public function getMessage()
{ {
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,19 +16,15 @@ ...@@ -20,19 +16,15 @@
More about this license: http://www.question2answer.org/license.php 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 class ReindexPostsWordCount extends AbstractStep
header('Location: ../../');
exit;
}
class Q2A_Recalc_ReindexPostsWordCount extends Q2A_Recalc_AbstractStep
{ {
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);
if (!count($wordids)) { if (empty($wordids)) {
qa_db_tagcount_update(); // this is quick so just do it here qa_db_tagcount_update(); // this is quick so just do it here
$this->state->transition('doreindexposts_complete'); $this->state->transition('doreindexposts_complete');
return false; return false;
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,12 +16,9 @@ ...@@ -20,12 +16,9 @@
More about this license: http://www.question2answer.org/license.php 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 namespace Q2A\Recalc;
header('Location: ../../');
exit;
}
class Q2A_Recalc_State class State
{ {
public $state; public $state;
public $operation; public $operation;
...@@ -34,48 +27,48 @@ class Q2A_Recalc_State ...@@ -34,48 +27,48 @@ class Q2A_Recalc_State
public $done; public $done;
private $classes = array( private $classes = array(
'doreindexcontent' => 'ReindexContent', 'doreindexcontent' => '\Q2A\Recalc\ReindexContent',
'doreindexcontent_pagereindex' => 'ReindexContentPageReindex', 'doreindexcontent_pagereindex' => '\Q2A\Recalc\ReindexContentPageReindex',
'doreindexcontent_postcount' => 'ReindexContentPostCount', 'doreindexcontent_postcount' => '\Q2A\Recalc\ReindexContentPostCount',
'doreindexcontent_postreindex' => 'ReindexContentPostReindex', 'doreindexcontent_postreindex' => '\Q2A\Recalc\ReindexContentPostReindex',
'doreindexposts_wordcount' => 'ReindexPostsWordCount', 'doreindexposts_wordcount' => '\Q2A\Recalc\ReindexPostsWordCount',
'dorecountposts' => 'RecountPosts', 'dorecountposts' => '\Q2A\Recalc\RecountPosts',
'dorecountposts_postcount' => 'RecountPostsPostCount', 'dorecountposts_postcount' => '\Q2A\Recalc\RecountPostsPostCount',
'dorecountposts_votecount' => 'RecountPostsVoteCount', 'dorecountposts_votecount' => '\Q2A\Recalc\RecountPostsVoteCount',
'dorecountposts_acount' => 'RecountPostsAcount', 'dorecountposts_acount' => '\Q2A\Recalc\RecountPostsACount',
'dorecalcpoints' => 'RecalcPoints', 'dorecalcpoints' => '\Q2A\Recalc\RecalcPoints',
'dorecalcpoints_usercount' => 'RecalcPointsUserCount', 'dorecalcpoints_usercount' => '\Q2A\Recalc\RecalcPointsUserCount',
'dorecalcpoints_recalc' => 'RecalcPointsRecalc', 'dorecalcpoints_recalc' => '\Q2A\Recalc\RecalcPointsRecalc',
'dorefillevents' => 'RefillEvents', 'dorefillevents' => '\Q2A\Recalc\RefillEvents',
'dorefillevents_qcount' => 'RefillEventsQcount', 'dorefillevents_qcount' => '\Q2A\Recalc\RefillEventsQCount',
'dorefillevents_refill' => 'RefillEventsRefill', 'dorefillevents_refill' => '\Q2A\Recalc\RefillEventsRefill',
'dorecalccategories' => 'RecalcCategories', 'dorecalccategories' => '\Q2A\Recalc\RecalcCategories',
'dorecalccategories_postcount' => 'RecalcCategoriesPostCount', 'dorecalccategories_postcount' => '\Q2A\Recalc\RecalcCategoriesPostCount',
'dorecalccategories_postupdate' => 'RecalcCategoriesPostUpdate', 'dorecalccategories_postupdate' => '\Q2A\Recalc\RecalcCategoriesPostUpdate',
'dorecalccategories_recount' => 'RecalcCategoriesRecount', 'dorecalccategories_recount' => '\Q2A\Recalc\RecalcCategoriesRecount',
'dorecalccategories_backpaths' => 'RecalcCategoriesBackPaths', 'dorecalccategories_backpaths' => '\Q2A\Recalc\RecalcCategoriesBackPaths',
'dodeletehidden' => 'DeleteHidden', 'dodeletehidden' => '\Q2A\Recalc\DeleteHidden',
'dodeletehidden_comments' => 'DeleteHiddenComments', 'dodeletehidden_comments' => '\Q2A\Recalc\DeleteHiddenComments',
'dodeletehidden_answers' => 'DeleteHiddenAnswers', 'dodeletehidden_answers' => '\Q2A\Recalc\DeleteHiddenAnswers',
'dodeletehidden_questions' => 'DeletehiddenQuestions', 'dodeletehidden_questions' => '\Q2A\Recalc\DeleteHiddenQuestions',
'doblobstodisk' => 'BlobsToDisk', 'doblobstodisk' => '\Q2A\Recalc\BlobsToDisk',
'doblobstodisk_move' => 'BlobsToDiskMove', 'doblobstodisk_move' => '\Q2A\Recalc\BlobsToDiskMove',
'doblobstodb' => 'BlobsToDB', 'doblobstodb' => '\Q2A\Recalc\BlobsToDB',
'doblobstodb_move' => 'BlobsToDBMove', 'doblobstodb_move' => '\Q2A\Recalc\BlobsToDBMove',
'docachetrim' => 'CacheTrim', 'docachetrim' => '\Q2A\Recalc\CacheTrim',
'docacheclear' => 'CacheClear', 'docacheclear' => '\Q2A\Recalc\CacheClear',
'docachetrim_process' => 'CacheClearProcess', 'docachetrim_process' => '\Q2A\Recalc\CacheClearProcess',
'docacheclear_process' => 'CacheClearProcess', 'docacheclear_process' => '\Q2A\Recalc\CacheClearProcess',
'doreindexposts_complete' => 'ReindexPostsComplete', 'doreindexposts_complete' => '\Q2A\Recalc\ReindexPostsComplete',
'dorecountposts_complete' => 'RecountPostsComplete', 'dorecountposts_complete' => '\Q2A\Recalc\RecountPostsComplete',
'dorecalcpoints_complete' => 'RecalcPointsComplete', 'dorecalcpoints_complete' => '\Q2A\Recalc\RecalcPointsComplete',
'dorefillevents_complete' => 'RefillEventsComplete', 'dorefillevents_complete' => '\Q2A\Recalc\RefillEventsComplete',
'dorecalccategories_complete' => 'RecalcCategoriesComplete', 'dorecalccategories_complete' => '\Q2A\Recalc\RecalcCategoriesComplete',
'dodeletehidden_complete' => 'DeleteHiddenComplete', 'dodeletehidden_complete' => '\Q2A\Recalc\DeleteHiddenComplete',
'doblobstodisk_complete' => 'BlobsMoveComplete', 'doblobstodisk_complete' => '\Q2A\Recalc\BlobsMoveComplete',
'doblobstodb_complete' => 'BlobsMoveComplete', 'doblobstodb_complete' => '\Q2A\Recalc\BlobsMoveComplete',
'docacheclear_complete' => 'CacheClearComplete', 'docacheclear_complete' => '\Q2A\Recalc\CacheClearComplete',
); );
/** /**
...@@ -104,7 +97,7 @@ class Q2A_Recalc_State ...@@ -104,7 +97,7 @@ class Q2A_Recalc_State
public function getOperationClass() 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() public function allDone()
...@@ -174,7 +167,7 @@ class Q2A_Recalc_State ...@@ -174,7 +167,7 @@ class Q2A_Recalc_State
case 'docachetrim_process': case 'docachetrim_process':
case 'docacheclear_process': case 'docacheclear_process':
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver(); $cacheDriver = \Q2A\Storage\CacheFactory::getCacheDriver();
$cacheStats = $cacheDriver->getStats(); $cacheStats = $cacheDriver->getStats();
return $cacheStats['files']; return $cacheStats['files'];
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,10 +16,12 @@ ...@@ -20,10 +16,12 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
namespace Q2A\Storage;
/** /**
* Interface for caching drivers. * 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. * Get the cached data for the supplied key. Data can be any format but is usually an array.
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,16 +16,18 @@ ...@@ -20,16 +16,18 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
namespace Q2A\Storage;
/** /**
* Caches data (typically from database queries) to the filesystem. * Caches data (typically from database queries) to the filesystem.
*/ */
class Q2A_Storage_CacheFactory class CacheFactory
{ {
private static $cacheDriver = null; private static $cacheDriver = null;
/** /**
* Get the appropriate cache handler. * Get the appropriate cache handler.
* @return Q2A_Storage_CacheDriver The cache handler. * @return CacheDriver The cache handler.
*/ */
public static function getCacheDriver() public static function getCacheDriver()
{ {
...@@ -45,12 +43,12 @@ class Q2A_Storage_CacheFactory ...@@ -45,12 +43,12 @@ class Q2A_Storage_CacheFactory
switch($driver) switch($driver)
{ {
case 'memcached': case 'memcached':
self::$cacheDriver = new Q2A_Storage_MemcachedDriver($config); self::$cacheDriver = new MemcachedDriver($config);
break; break;
case 'filesystem': case 'filesystem':
default: default:
self::$cacheDriver = new Q2A_Storage_FileCacheDriver($config); self::$cacheDriver = new FileCacheDriver($config);
break; break;
} }
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,10 +16,12 @@ ...@@ -20,10 +16,12 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
namespace Q2A\Storage;
/** /**
* Caches data (typically from database queries) to the filesystem. * 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 $enabled = false;
private $keyPrefix = ''; private $keyPrefix = '';
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ 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 This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -20,10 +16,12 @@ ...@@ -20,10 +16,12 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
namespace Q2A\Storage;
/** /**
* Caches data (typically from database queries) in memory using Memcached. * 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 $memcached;
private $enabled = false; 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