Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last execution time for "rebuildData.php" and "rebuildPropertyStatistics.php" #832

Closed
kghbln opened this issue Feb 19, 2015 · 8 comments
Closed
Labels
enhancement Alters an existing functionality or behaviour

Comments

@kghbln
Copy link
Member

kghbln commented Feb 19, 2015

In case one does not control the server on which the cron is setup for these two scripts there is no easy way to determine if they have actually been run successfully. Thus it will be nice to have date and time information somewhere on the wiki, perhaps on "Sepecial:SMWAdmin" saying e.g. "Last time successfully run on February 19, 2015, 05:15 am".

We have this for "rebuildConceptCache.php" on the respective concept pages and this is really useful.

@kghbln kghbln added the enhancement Alters an existing functionality or behaviour label Feb 19, 2015
@mwjames
Copy link
Contributor

mwjames commented Feb 19, 2015

OK this can be done fairly easy and all you need is something like:

  • Add 'maintenance-script-execution to the bottom of settings.php
$GLOBALS['smwgLogEventTypes'] = array(
    'sqlstore-query-execution' => false,
    'maintenance-script-execution' => true
  • Add a simple logger statement such as after $maintenanceHelper->reset();
$store->getLogger()->logToTable(
    'maintenance-script-execution', // smw event type
    'smw-maintenance-runner', // user
    'rebuildData', // target
    'rebuildData.php execution' // message in the log
);

and Special:Log (or index.php?title=Special:Log&type=smw) should show a log entry together with time/date of the execution. If you want the content of the options to appear in the log entry then you have to do a little bit more work and extend the rebuildData.php execution' message string.

Maybe if you only want to log specific runs, add a --with-log option to the script.

That's all you need

@kghbln
Copy link
Member Author

kghbln commented Jan 9, 2016

This turned into a disaster. However smwgLogEventTypes introduced with SMW 2.1 seems to have been removed in the meantime so this may have something to do with it.

@mwjames
Copy link
Contributor

mwjames commented Jan 9, 2016

This turned into a disaster. However smwgLogEventTypes introduced with SMW 2.1 seems to have been removed in the meantime so this may have something to do with it.

I kept the main class [0] ManualEntryLogger but I wasn't happy with the $store->getLogger()->logToTable thing so I removed it for now since this wasn't really helpful.

The maintenance script need to do something like:

use SMW\MediaWiki\ManualEntryLogger;

    public function execute() {
        ...

        if ( $this->hasOption( 'with-log' ) ) {
            $manualEntryLogger = new ManualEntryLogger ();
            $manualEntryLogger->registerLoggableEventTypes( array( 'maintenance-script' => true ) );

            $manualEntryLogger->log( 'maintenance-script', 'UserX', 'rebuildData', 'Some nifty comment about ...' );
        }

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/MediaWiki/ManualEntryLogger.php

@kghbln
Copy link
Member Author

kghbln commented Jan 9, 2016

PS: I haven't tested this, just wrote this off the top of my head while looking at [0].

Tried this including also adding the global to settings and a $this->addOption but I do not get the SMW-Log back. No PHP-issues though. Never mind for now. Let's just wait till logging is cool again.

@mwjames
Copy link
Contributor

mwjames commented Jan 9, 2016

My bad it needs registerLoggableEventTypes( array( 'maintenance-script' => true ) ); and then you get

image

@kghbln
Copy link
Member Author

kghbln commented Jan 9, 2016

Ah, this works, but we basically need all the other stuff back like 'NullLogger.php' etc. so we can have $manualEntryLogger->log( 'maintenance-script', 'Some nifty comment about ...' );

@mwjames
Copy link
Contributor

mwjames commented Jan 9, 2016

Ah, this works, but we basically need all the other stuff back like 'NullLogger.php' etc. so we can have

#1361 should do the trick.

mwjames added a commit that referenced this issue May 5, 2016
@mwjames mwjames closed this as completed May 5, 2016
@kghbln
Copy link
Member Author

kghbln commented May 5, 2016

Hey, that's cool! Sorry that I was not able to get this in even with help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Alters an existing functionality or behaviour
Projects
None yet
Development

No branches or pull requests

2 participants