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
1c21830c
Commit
1c21830c
authored
Jan 24, 2018
by
Simon Champion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor the recalc functions into a class.
parent
f9f9d3bb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
15 deletions
+23
-15
recalc.php
qa-include/ajax/recalc.php
+6
-4
recalc.php
qa-include/app/recalc.php
+4
-0
RecalcMain.php
qa-include/app/recalc/RecalcMain.php
+0
-0
install.php
qa-include/db/install.php
+7
-6
admin-recalc.php
qa-include/pages/admin/admin-recalc.php
+5
-4
qa-app-recalc.php
qa-include/qa-app-recalc.php
+1
-1
No files found.
qa-include/ajax/recalc.php
View file @
1c21830c
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
*/
*/
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc
/RecalcMain
.php'
;
if
(
qa_get_logged_in_level
()
>=
QA_USER_LEVEL_ADMIN
)
{
if
(
qa_get_logged_in_level
()
>=
QA_USER_LEVEL_ADMIN
)
{
...
@@ -29,14 +29,16 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
...
@@ -29,14 +29,16 @@ 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
{
$
state
=
qa_post_text
(
'state'
);
$
recalc
=
new
Q2A_App_Recalc_Main
(
qa_post_text
(
'state'
)
);
$stoptime
=
time
()
+
3
;
$stoptime
=
time
()
+
3
;
while
(
qa_recalc_perform_step
(
$state
)
&&
time
()
<
$stoptime
)
{
while
(
$recalc
->
performStep
(
)
&&
time
()
<
$stoptime
)
{
// wait
// wait
}
}
$message
=
qa_recalc_get_message
(
$state
);
$message
=
$recalc
->
getMessage
();
$state
=
$recalc
->
getState
();
}
}
}
else
{
}
else
{
...
...
qa-include/app/recalc.php
View file @
1c21830c
...
@@ -60,6 +60,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
...
@@ -60,6 +60,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
exit
;
exit
;
}
}
if
(
defined
(
'QA_DEBUG_PERFORMANCE'
)
&&
QA_DEBUG_PERFORMANCE
)
{
trigger_error
(
'Included file '
.
basename
(
__FILE__
)
.
' is deprecated'
);
}
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'
;
require_once
QA_INCLUDE_DIR
.
'db/points.php'
;
require_once
QA_INCLUDE_DIR
.
'db/points.php'
;
...
...
qa-include/app/recalc/RecalcMain.php
0 → 100644
View file @
1c21830c
This diff is collapsed.
Click to expand it.
qa-include/db/install.php
View file @
1c21830c
...
@@ -78,7 +78,7 @@ function qa_db_table_definitions()
...
@@ -78,7 +78,7 @@ function qa_db_table_definitions()
* In MySQL versions prior to 5.0.3, VARCHAR(x) columns will be silently converted to TEXT where x>255
* In MySQL versions prior to 5.0.3, VARCHAR(x) columns will be silently converted to TEXT where x>255
* See box at top of /qa-include/app/recalc.php for a list of redundant (non-normal) information in the database
* See box at top of /qa-include/app/recalc
/RecalcMain
.php for a list of redundant (non-normal) information in the database
* Starting in version 1.2, we explicitly name keys and foreign key constraints, instead of allowing MySQL
* Starting in version 1.2, we explicitly name keys and foreign key constraints, instead of allowing MySQL
to name these by default. Our chosen names match the default names that MySQL would have assigned, and
to name these by default. Our chosen names match the default names that MySQL would have assigned, and
...
@@ -769,7 +769,7 @@ function qa_db_default_userfields_sql()
...
@@ -769,7 +769,7 @@ function qa_db_default_userfields_sql()
*/
*/
function
qa_db_upgrade_tables
()
function
qa_db_upgrade_tables
()
{
{
require_once
QA_INCLUDE_DIR
.
'app/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc
/RecalcMain
.php'
;
$definitions
=
qa_db_table_definitions
();
$definitions
=
qa_db_table_definitions
();
$keyrecalc
=
array
();
$keyrecalc
=
array
();
...
@@ -1611,16 +1611,17 @@ function qa_db_upgrade_tables()
...
@@ -1611,16 +1611,17 @@ function qa_db_upgrade_tables()
// Perform any necessary recalculations, as determined by upgrade steps
// Perform any necessary recalculations, as determined by upgrade steps
foreach
(
$keyrecalc
as
$state
=>
$dummy
)
{
foreach
(
array_keys
(
$keyrecalc
)
as
$state
)
{
while
(
$state
)
{
$recalc
=
new
Q2A_App_Recalc_Main
(
$state
);
while
(
$recalc
->
getState
())
{
set_time_limit
(
60
);
set_time_limit
(
60
);
$stoptime
=
time
()
+
2
;
$stoptime
=
time
()
+
2
;
while
(
qa_recalc_perform_step
(
$state
)
&&
(
time
()
<
$stoptime
))
while
(
$recalc
->
performStep
(
)
&&
(
time
()
<
$stoptime
))
;
;
qa_db_upgrade_progress
(
qa_recalc_get_message
(
$state
));
qa_db_upgrade_progress
(
$recalc
->
getMmessage
(
));
}
}
}
}
}
}
...
...
qa-include/pages/admin/admin-recalc.php
View file @
1c21830c
...
@@ -25,7 +25,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
...
@@ -25,7 +25,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc
/RecalcMain
.php'
;
// Check we have administrative privileges
// Check we have administrative privileges
...
@@ -71,15 +71,16 @@ if ($recalcnow) {
...
@@ -71,15 +71,16 @@ if ($recalcnow) {
<?php
<?php
while
(
$state
)
{
$recalc
=
new
Q2A_App_Recalc_Main
(
$state
);
while
(
$recalc
->
getState
())
{
set_time_limit
(
60
);
set_time_limit
(
60
);
$stoptime
=
time
()
+
2
;
// run in lumps of two seconds...
$stoptime
=
time
()
+
2
;
// run in lumps of two seconds...
while
(
qa_recalc_perform_step
(
$state
)
&&
time
()
<
$stoptime
)
while
(
$recalc
->
performStep
(
)
&&
time
()
<
$stoptime
)
;
;
echo
qa_html
(
qa_recalc_get_message
(
$state
)
)
.
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
...
...
qa-include/qa-app-recalc.php
View file @
1c21830c
...
@@ -12,4 +12,4 @@ if (defined('QA_DEBUG_PERFORMANCE') && QA_DEBUG_PERFORMANCE) {
...
@@ -12,4 +12,4 @@ if (defined('QA_DEBUG_PERFORMANCE') && QA_DEBUG_PERFORMANCE) {
trigger_error
(
'Included file '
.
basename
(
__FILE__
)
.
' is deprecated'
);
trigger_error
(
'Included file '
.
basename
(
__FILE__
)
.
' is deprecated'
);
}
}
require_once
QA_INCLUDE_DIR
.
'app/recalc.php'
;
require_once
QA_INCLUDE_DIR
.
'app/recalc
/RecalcMain
.php'
;
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