[QuickStatements] allow the creation of properties

Issue #113 resolved
Frog23 created an issue

It is currently not possible to create new properties using QS. For wikidata.org, this is not an issue, as property creation is limited to admins and follows formal rules. However with the integration of QS in the wikibase docker image, there is now an increasing amount of wikibase repositories where automated property creation with QS is a useful approach.

Extending QS to support the creation of properties is fairly simple. In quickstatements.php after the section

} else if ( $first == 'CREATE' ) {
    $cmd = array ( 'action'=>'create' , 'type'=>'item' ) ;
    if ( $comment != '' ) $cmd['summary'] = $comment ;

currently at line 1194, the following code block needs to be included:

} else if ( $first == 'CREATE_PROPERTY' and count ( $cols ) >= 2) {             
    $cmd = array ( 'action'=>'create' , 'type'=>'property' , 'data'=>'' ) ;
    $datatype = trim($cols[1]) ;
    $cmd['data'] = array ( 'datatype'=>$datatype );
    if ( $comment != '' ) $cmd['summary'] = $comment ;

There are certainly ways to improve this, like checking if the datatypes are valid or in the correct case (the API is case sensitive in this regard, all types are lowercase with the exception of “commonsMedia“)

Creating a new property using QuickStatements would then look like this (for the lines 2-4 see also issue #112 ):

CREATE_PROPERTY|string
LAST|Len|"QS Property"
LAST|Den|"a property that was created using QuickStatements"
LAST|Aen|"QuickStatements Property"
LAST|P1450|en:"some text describing the content"

This is the workaround we have added to our QuickStatements installation but we thought that other Wikibase instances with QS might also benefit from such a change.

Comments (5)

  1. Frog23 reporter
    • edited description

    Sorry, the initial posting contained an error. I have now fixed and simplified the workaround above.

  2. Frog23 reporter
    • edited description

    apparently I made some mistakes when prettifying the code to post it here. It is fixed now. Sorry about this.

  3. Log in to comment