Help: setting a property on page save?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Help: setting a property on page save?

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
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
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Help: setting a property on page save?

John Doe-27
What is your end goal?

On Tue, Dec 4, 2018 at 6:52 PM FreedomFighterSparrow <
[hidden email]> wrote:

> 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
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Help: setting a property on page save?

FreedomFighterSparrow
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


On 5.12.2018 2:04, John wrote:

> What is your end goal?
>
> On Tue, Dec 4, 2018 at 6:52 PM FreedomFighterSparrow <
> [hidden email]> wrote:
>
>> 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
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Help: setting a property on page save?

Brad Jorsch (Anomie)
In reply to this post by FreedomFighterSparrow
On Tue, Dec 4, 2018 at 6:52 PM FreedomFighterSparrow <
[hidden email]> wrote:

> - 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?


> 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
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Help: setting a property on page save?

FreedomFighterSparrow
Hey Brad, thanks for replying!

 >> 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.

 >> 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


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l