Revision: 43704
Author: mkroetzsch
Date: 2008-11-19 11:40:23 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
New user-friendly interface for controlling incremental data rebuilding from
the web interface.
Modified Paths:
--------------
trunk/extensions/SemanticMediaWiki/includes/jobs/SMW_RefreshJob.php
trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
Modified: trunk/extensions/SemanticMediaWiki/includes/jobs/SMW_RefreshJob.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/jobs/SMW_RefreshJob.php
2008-11-19 09:08:49 UTC (rev 43703)
+++ trunk/extensions/SemanticMediaWiki/includes/jobs/SMW_RefreshJob.php
2008-11-19 11:40:23 UTC (rev 43704)
@@ -20,7 +20,7 @@
*/
class SMWRefreshJob extends Job {
- function __construct($title, $params = array('spos'=>1) ) {
+ function __construct($title, $params = array('spos'=>1, 'prog'=>0) ) {
parent::__construct( 'SMWRefreshJob', $title, $params);
}
@@ -45,4 +45,12 @@
wfProfileOut('SMWRefreshJob::run (SMW)');
return true;
}
+
+ /**
+ * Report the estimated progress status of this job as a number between
0 and 1 (0% to 100%).
+ * The progress refers to the state before processing this job.
+ */
+ public function getProgress() {
+ return
array_key_exists('prog',$this->params)?$this->params['prog']:0;
+ }
}
Modified:
trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
2008-11-19 09:08:49 UTC (rev 43703)
+++
trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
2008-11-19 11:40:23 UTC (rev 43704)
@@ -44,7 +44,19 @@
}
$this->setHeaders();
-
+
+ /**** Get status of refresh job, if any ****/
+ if ($smwgAdminRefreshStore) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $row = $dbr->selectRow( 'job', '*', array( 'job_cmd' =>
'SMWRefreshJob' ), __METHOD__ );
+ if ($row !== false) { // similar to Job::pop_type, but
without deleting the job
+ $title = Title::makeTitleSafe(
$row->job_namespace, $row->job_title);
+ $refreshjob = Job::factory( $row->job_cmd,
$title, Job::extractBlob( $row->job_params ), $row->job_id );
+ } else {
+ $refreshjob = NULL;
+ }
+ }
+
/**** Execute actions if any ****/
$action = $wgRequest->getText( 'action' );
@@ -68,17 +80,25 @@
flush();
return;
}
- } elseif ($smwgAdminRefreshStore && ($action=='refreshstore'))
{ // not accessible via UI yet, testing
- $dbw =& wfGetDB( DB_MASTER );
- // delete existing iteration jobs
- $dbw->delete( 'job', array( 'job_cmd' =>
'SMWRefreshJob' ), __METHOD__ );
- $affected = $dbw->affectedRows();
- $warning = ($affected > 0)?' Existing refresh jobs were
stopped when the new job was created; please be patient to let refreshing
finish or use the MediaWiki script runJobs.php to finish all jobs at once.':'';
- // and make a new one
- $title = Title::makeTitle(NS_SPECIAL, 'SMWAdmin');
- $newjob = new SMWRefreshJob($title, array('spos'=>1));
- $newjob->insert();
- $wgOut->addHTML("<p>Added new job for refreshing the
semantic data. All stored data will be rebuilt or repaired where
needed.$warning</p>");
+ } elseif ($smwgAdminRefreshStore && ($action=='refreshstore'))
{ // managing refresh jobs for the store
+ $sure = $wgRequest->getText( 'rfsure' );
+ if ($sure == 'yes') {
+ if ($refreshjob === NULL) { // careful, there
might be race conditions here
+ $title = Title::makeTitle(NS_SPECIAL,
'SMWAdmin');
+ $newjob = new SMWRefreshJob($title,
array('spos'=>1));
+ $newjob->insert();
+ $wgOut->addHTML("<p>A new update
process for refreshing the semantic data was started. All stored data will be
rebuilt or repaired where needed.</p>");
+ } else {
+ $wgOut->addHTML("<p>There is already an
update process running. Not creating another one.</p>");
+ }
+ } elseif ($sure == 'stop') {
+ $dbw =& wfGetDB( DB_MASTER );
+ // delete (all) existing iteration jobs
+ $dbw->delete( 'job', array( 'job_cmd' =>
'SMWRefreshJob' ), __METHOD__ );
+ $wgOut->addHTML("<p>All existing update
processes have been stopped.</p>");
+ } else {
+ $wgOut->addHTML("<p>To stop the running update
process, you must activate the checkbox to indicate that you are really
sure.</p>");
+ }
return;
}
@@ -91,27 +111,50 @@
$html .= '<form name="buildtables" action="" method="POST">' .
"\n" .
'<input type="hidden" name="action"
value="updatetables" />' . "\n";
$html .= '<h2>Preparing database for Semantic MediaWiki</h2>' .
"\n" .
- '<p>Semantic MediaWiki requires some minor
extensions to the MediaWiki database in
+ '<p>Semantic MediaWiki requires some extensions
to the MediaWiki database in
order to store the semantic data. The below
function ensures that your database is
set up properly. The changes made in this step
do not affect the rest of the
MediaWiki database, and can easily be undone if
desired. This setup function
can be executed multiple times without doing
any harm, but it is needed only once on
installation or upgrade.<p/>' . "\n";
- $html .= '<p>If the operation fails with obscure SQL errors,
the database user employed
+ $html .= '<p>If the operation fails with SQL errors, the
database user employed
by your wiki (check your LocalSettings.php)
probably does not have sufficient
permissions. Either grant this user additional
persmissions to create and delete
- tables, or temporarily enter the login of your
database root in LocalSettings.php.<p/>' .
+ tables, temporarily enter the login of your
database root in LocalSettings.php, or use the maintenance script
<tt>SMW_setup.php</tt> which can use the credentials of AdminSettings.php.<p/>'
.
"\n" . '<input type="hidden" name="udsure"
value="yes"/>' .
'<input type="submit" value="Initialise or
upgrade tables"/></form>' . "\n";
$html .= '<h2>Announce your wiki</h2>' . "\n" .
- '<p>SMW has a web service for announcing new
semantic wiki sites. This is used to maintain a list of public sites that use
SMW, mainly to help the <a
href="http://semantic-mediawiki.org/wiki/SMW_Project">SMW project</a> to get an
overview of typical uses of SMW. See the SMW homepage for <a
href="http://semantic-mediawiki.org/wiki/Registry">further information about
this service.</a>' .
+ '<p>SMW has a web service for announcing new
semantic wiki sites. This is used to maintain a list of public sites that use
SMW, mainly to help the <a
href="http://semantic-mediawiki.org/wiki/SMW_Project">SMW project</a> to get an
overview of typical uses of SMW. See the SMW homepage for <a
href="http://semantic-mediawiki.org/wiki/Registry">further information about
this service.</a></p>' .
'<p>Press the following button to submit your
wiki URL to that service. The service will not register wikis that are not
publicly accessible, and it will only store publicly accessible information.</p>
<form name="announcewiki"
action="http://semantic-mediawiki.org/wiki/Special:SMWRegistry" method="GET">' .
'<input type="hidden" name="url" value="' .
SMWExporter::expandURI('&wikiurl;') . '" />' .
'<input type="hidden" name="return"
value="Special:SMWAdmin" />' .
'<input type="submit" value="Announce
wiki"/></form>' . "\n";
+ if ($smwgAdminRefreshStore) {
+ $html .= '<h2>Repair and Upgrade</h2>' . "\n" .
+ '<p>It is possible to restore all SMW
data based on the current contents of the wiki. This can be useful to repair
broken data or to refresh the data if the internal format has changed due to
some software upgrade. The update is executed page by page and will not be
completed immediately. The following control shows if an update is in progress
and allows you to start or stop upates.</p>' .
+ '<form name="refreshwiki" action=""
method="POST">';
+ if ($refreshjob !== NULL) {
+ $prog = $refreshjob->getProgress();
+ $html .= "<p><b>An update is already in
progress.</b> It is normal that the update progresses only slowly. This reduces
server load. To finish an update more quickly, you can use the MediaWiki
maintenance script <tt>runJobs.php</tt> (use the option <tt>--maxjobs 2000</tt>
to restrict the number of updates done at once). Estimated progress of current
update:</p> " .
+ '<p><div style="float: left;
background: #DDDDDD; border: 1px solid grey; width: 300px; "><div
style="background: #AAF; width: ' .
+ round($prog*300) . 'px; height: 20px;
"> </div></div> ' . round($prog*100,4) . '%</p><br /><br />' .
+ '<input type="hidden" name="action"
value="refreshstore" />' .
+ '<input type="submit" value="Stop
ongoing update"/> ' .
+ ' <input type="checkbox" name="rfsure"
value="stop"/> Yes, I am sure. ' .
+ '</form>' . "\n";
+ } else {
+ $html .=
+ '<input type="hidden" name="action"
value="refreshstore" />' .
+ '<input type="hidden" name="rfsure"
value="yes"/>' .
+ '<input type="submit" value="Start
updating data"/>' .
+ '</form>' . "\n";
+ }
+ }
+
+
$html .= '<h2>Getting support</h2>' . "\n" .
'<p>Various resources might help you in case of
problems:</p>
<ul>
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs