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