Discussion:
[Wikitech-l] Help: setting a property on page save?
FreedomFighterSparrow
2018-12-04 23:52:23 UTC
Permalink
I'm trying to solve the following situation: I need to know, for each
article,
the last time it was updated by an actual human. MediaWiki keeps track of
the
last update to the page, but doesn't take into account whether it was
performed
by a bot or a human.

Instead of querying the revision table every time, I thought of saving a
page
property and updating it on page save:
- Is the editor a human*?
- Yes: update the property.
- No: Do we already have a last real update date saved?
- Yes: do nothing (keep the last date)
- No: find the latest revision by a human and save the property


The most logical hook seemed to be 'PageContentSaveComplete' or maybe
'PageContentInsertComplete', as I only want to do this if the save actually
went through (if it is failed by something, we shouldn't update).
My problem is, I don't seem to have a way to set a property from there...

I really don't want to have to create my own table just for this.
Any ideas how to solve this? Maybe I'm going about it in a cockamamie way?

Thanks,
- Dror
John
2018-12-05 00:04:26 UTC
Permalink
What is your end goal?

On Tue, Dec 4, 2018 at 6:52 PM FreedomFighterSparrow <
Post by FreedomFighterSparrow
I'm trying to solve the following situation: I need to know, for each
article,
the last time it was updated by an actual human. MediaWiki keeps track of
the
last update to the page, but doesn't take into account whether it was
performed
by a bot or a human.
Instead of querying the revision table every time, I thought of saving a
page
- Is the editor a human*?
- Yes: update the property.
- No: Do we already have a last real update date saved?
- Yes: do nothing (keep the last date)
- No: find the latest revision by a human and save the property
The most logical hook seemed to be 'PageContentSaveComplete' or maybe
'PageContentInsertComplete', as I only want to do this if the save actually
went through (if it is failed by something, we shouldn't update).
My problem is, I don't seem to have a way to set a property from there...
I really don't want to have to create my own table just for this.
Any ideas how to solve this? Maybe I'm going about it in a cockamamie way?
Thanks,
- Dror
_______________________________________________
Wikitech-l mailing list
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
FreedomFighterSparrow
2018-12-05 17:00:29 UTC
Permalink
Hi John,
My goal is to display the "real" update timestamp instead of the regular
one, and also (later on) to query pages based on real neglect.

- Dror
Post by John
What is your end goal?
On Tue, Dec 4, 2018 at 6:52 PM FreedomFighterSparrow <
Post by FreedomFighterSparrow
I'm trying to solve the following situation: I need to know, for each
article,
the last time it was updated by an actual human. MediaWiki keeps track of
the
last update to the page, but doesn't take into account whether it was
performed
by a bot or a human.
Instead of querying the revision table every time, I thought of saving a
page
- Is the editor a human*?
- Yes: update the property.
- No: Do we already have a last real update date saved?
- Yes: do nothing (keep the last date)
- No: find the latest revision by a human and save the property
The most logical hook seemed to be 'PageContentSaveComplete' or maybe
'PageContentInsertComplete', as I only want to do this if the save actually
went through (if it is failed by something, we shouldn't update).
My problem is, I don't seem to have a way to set a property from there...
I really don't want to have to create my own table just for this.
Any ideas how to solve this? Maybe I'm going about it in a cockamamie way?
Thanks,
- Dror
_______________________________________________
Wikitech-l mailing list
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Brad Jorsch (Anomie)
2018-12-05 17:49:47 UTC
Permalink
On Tue, Dec 4, 2018 at 6:52 PM FreedomFighterSparrow <
Post by FreedomFighterSparrow
- Is the editor a human*?
That's not as straightforward a question as you might think. How will you
tell if the editor is a human rather than an unflagged bot? Or a human
blindly clicking "Save" on edits proposed by a program such as AWB?

You might also want to consider what happens if someone vandalizes a page
and then is reverted. Does either the vandalism or the revert really count
as an update?
Post by FreedomFighterSparrow
I really don't want to have to create my own table just for this.
The page_props table already exists for storing properties of pages. It
generally gets its values from the ParserOutput object for the page's
latest revision, although you could use the 'LinksUpdate' hook to influence
the actual database updates instead.

If you want to tag every revision, you could use a change tag. See
https://www.mediawiki.org/wiki/Manual:Tags for an overview.
--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation
FreedomFighterSparrow
2018-12-05 19:40:01 UTC
Permalink
Hey Brad, thanks for replying!
Post by Brad Jorsch (Anomie)
That's not as straightforward a question as you might think
It's actually rather easy in *my* use case, as I'm running a
closed-editing wiki.
The revert question is relevant though - while it's rare on our wiki, it
does happen. I'll have to give it some thought.
Post by Brad Jorsch (Anomie)
although you could use the 'LinksUpdate' hook to influence the
actual database updates instead

I could, but since there's no interface there, it looks like I have to
just push things into LinksUpdate::$mProperties, which pretty much
amounts to just INSERTING directly into the table myself, right? I see
that's what extension:PageImages does. Doable, but ugly (and fragile) in
the extreme, no? Especially as there's a @todo at the top to "make
members protected".
Not to say I won't do it if forced to ;-)

- Dror

Continue reading on narkive:
Loading...