Page MenuHomePhabricator

SemanticMediaWiki: New page properties: "Last editor is" and "Is a new page".
Closed, ResolvedPublic

Description

Author: van.de.bugger

Description:
Implementation.

Please consider a patch. It implements two new special page properties:

  • Last editor is -- Page -- the page of the user who made the last hmm...
  • Is a new page -- Boolean -- true if it is a new page (with just one revision).

I just realized implementation could be a bit incorrect. I may store the person who made the last save, while intention is to store the person who made last revision. I have to recheck it.


Version: unspecified
Severity: enhancement

attachment SMW-last-editor+is-a-new-page.patch ignored as obsolete

Details

Reference
bz34359

Event Timeline

bzimport raised the priority of this task from to Needs Triage.
bzimport set Reference to bz34359.
bzimport created this task.Feb 12 2012, 9:22 PM

If you save a page without changing anything, no new revision will be created. You'd indeed still have to be careful not to store the user making the save that has no effect.

I'll review & apply your patch when you verified this behavior :)

van.de.bugger wrote:

Implementation, v2.

Ok, now it saves the author of the last revision.

Attached:

Created attachment 10000
10000!

Attached:

yay - I got attachment 10000 :)

I'll look at your patch now :)

Patch looks great, applied in r111333. Thanks! :)

van.de.bugger wrote:

Verified on r111334.

The current code does not seem to work quite right. I do not actually get either of the new properties, even after enabling them in LocalSettings. This might be a local issue for me that has other reasons.

However, in addition, it seems that the properties are set to the previous value since they are fetched before storing the (possibly new) page in MediaWiki. So the "last" editor is only the one that was last before saving, i.e., the one before the current one. For new pages, there should never be a value.

Also, it should be checked if the properties are stable when running the SMW_refreshData.php update script (same as using an update job, but easier to target a particular page). It could be that this does not work for '_NEWP'.

Nevertheless, great work, since these new properties will be very useful for maintenance (I imagine using _NEWP and _MDAT to make a list of candidate pages for spam fighting with the Delete Batch extension; many spam bots create pages that are never edited again for a long time).

van.de.bugger wrote:

I do not actually get either of the new properties, even after enabling them in LocalSettings.

Did you have a look into documentation?

Note: After enabling the property in existing SMW server, do not forget to
open Special:SMWAdmin page and push Initialize or upgrade tables button. See
also the help page Repairing SMW's data for further information on this.

Probably it will help.

However, in addition, it seems that the properties are set to the previous
value since they are fetched before storing the (possibly new) page in
MediaWiki.

Not sure how, but "Is a new page" works for me. I just created a new page and saved it -- "Is a new page" is true. Saving the page again with no changes does not change the property value. Saving a new revision changes the property value to false.

I made some follow up changes in r111407.

For some reason the "Is a new page" property refuses to show up for me, either as result of a query, on Special:Browse or via the RDF export. The property itself shows on special browse, but the value does not. I tried debugging this and looked at the difference between this property and another one of type boolean. At some point this is done:

$values = $data->getPropertyValues( $diProperty );

For a regular boolean property, $values will be an array with a SMWDIBool (or more, depending on how many you have set). For "Is a new page" the array is empty. So then I dumped the $data object to see what's in there, and the list where getPropertyValues is empty, until after getPropertyValues is called. wtf?? I looked at this for about 10 mins, and all I see is magically appearing data while nothing is modifying the field where it's stored.

We now have these properties. Since 1.7?