Page MenuHomePhabricator

Feature Request: Quick Statements Batch Editing Functionality
Open, Needs TriagePublic

Description

Quick Statements instance installed as part of Wkibase "bundle" docker image is only partly functional.
It allows adding data with "New batch" functionality. All "user-related" functionality, e.g. "Last batches" do not work.

Apparently the software reports issues with accessing database (surfacing as an error trying to read credentials, but the underlying database tables are also not present in provided images).

parse_ini_file(/data/project/root/replica.my.cnf): failed to open stream: No such file or directory in /var/www/html/magnustools/public_html/php/ToolforgeCommon.php on line 162

The issue is likely stemming from the fact that Quick Statements have been created in the WMF Tool Labs environment, and they're not fully ready to be used outside of it.

This would potentially also require providing credential to a "bot" account for use by Quickstatements so that the feature will work "out of the box"

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Addshore closed this task as Resolved.EditedOct 30 2019, 1:59 PM
Addshore assigned this task to Tarrow.
Addshore added subscribers: Tarrow, Addshore.

@Tarrow fixed this / made sure quickstatements worked in the run up to wikidatacon

https://github.com/wmde/wikibase-docker/pulls?q=is%3Apr+is%3Aclosed

Hi,

any updates on this issue?

This issue is resolved and has been for some time.
Are you experiencing issues?

Hi,

Yes. It is working now. The batch mode doesn't work though.

I think this is not solved. After setting up a new install using the docker images, i still get

<br />
<b>Warning</b>:  parse_ini_file(/data/project/root/replica.my.cnf): failed to open stream: No such file or directory in <b>/var/www/html/magnustools/public_html/php/ToolforgeCommon.php</b> on line <b>162</b><br />
<br />
<b>Fatal error</b>:  Uncaught Error: Class 'mysqli' not found in /var/www/html/magnustools/public_html/php/ToolforgeCommon.php:179
Stack trace:
#0 /var/www/html/magnustools/public_html/php/common.php(35): ToolforgeCommon-&gt;openDBtool('__quickstatemen...', 'tools.labsdb', '')
#1 /var/www/html/quickstatements/public_html/quickstatements.php(198): openToolDB('quickstatements...')
#2 /var/www/html/quickstatements/public_html/api.php(133): QuickStatements-&gt;getDB()
#3 {main}
  thrown in <b>/var/www/html/magnustools/public_html/php/ToolforgeCommon.php</b> on line <b>179</b><br />

when accessing "user-related functionality" like "last batches".

Any of the SQL functionality has never (so far) been supported in these docker images.

Following up on this, since I've been digging deep into quickstatements and magnustools..... I can't tell how this is supposed to have ever worked. After jumping through some hoops with getting the database connection established via magnustools (That's a discussion for another day, but suffice to say I've forked his repo)

Inside quickstatements/public_html/api.php there's a block of code at line 276:

if ( $submit ) {
        $batchname = get_request ( 'batchname' , '' ) ;
        $site = get_request ( 'site' , '' ) ;

        if ( $site != '' ) $qs->config->site = $site ;
        $user_id = $qs->getUserIDfromNameAndToken ( $username , $token ) ;
        if ( !isset($user_id) ) {
                unset ( $out['data'] ) ;
                fin ( "User name and token do not match" ) ;
        }
        $batch_id = $qs->addBatch ( $out['data']['commands'] , $user_id , $batchname , $site ) ;
        unset ( $out['data'] ) ;
        if ( $batch_id === false ) {
                $out['status'] = $qs->last_error_message ;
        } else {
                $out['batch_id'] = $batch_id ;
        }
}

The relevant bit here is $qs->addBatch which is meant to add the batch to the MySQL database for later retrieval, but the $import variable is not set due to a submit value not being passed to api.php. Ever.

I would love to get a copy of the code as it exists on https://quickstatements.toolforge.org/#/ to compare, because this, as it's written simply doesn't work.

I guess in tools there is a preconfigured database access to store these things. This file

/data/project/root/replica.my.cnf

is currently not included (in the docker images or in local installations).

is currently not included (in the docker images or in local installations).

This is currently not included deliberately.
Thus this is a "feature request" for the docker images to setup support for this.

Also wikibase-docker is no longer maintained.
Please see the announcement for new images https://lists.wikimedia.org/hyperkitty/list/wikibaseug@lists.wikimedia.org/thread/WW4LZJINT3PIG3DOYKTXIWVP3WAKWXCT/
Along with docs https://www.mediawiki.org/wiki/Wikibase/Docker

Tarrow renamed this task from Quick Statements not fully functional in Wikibase docker bundle image to Feature Request: Quick Statements Batch Editing Functionality.Dec 3 2021, 10:49 AM
Tarrow removed Tarrow as the assignee of this task.
Tarrow updated the task description. (Show Details)

I looked into that for a bit. One gets pretty far in creating the file qs is looking for, e.g.

docker-php-ext-enable mysqli
mkdir -p /data/project/nobody/
echo "[client]
user=user
password=2CSN5qtbziqpgfmmM4YqVkLUUJJN" > /data/project/nobody/replica.my.cnf

then create a docker db container called tools.labsdb and create the databases

Create database user__quickstatements_p;
Create database user__quickstatements_p;
CREATE USER 'user'@'%' IDENTIFIED BY '2CSN5qtbziqpgfmmM4YqVkLUUJJN';
GRANT ALL PRIVILEGES ON user__quickstatements_p . * TO 'user'@'%';
GRANT ALL PRIVILEGES ON user__quickstatements_auth . * TO 'user'@'%';

Then import the schema from @aot29 https://github.com/MaRDI4NFDI/docker-quickstatements/blob/master/quickstatements/schema.sql to the respective tables.
This lets you create batches, but they are never executed. Maybe there is a job or so that needs to be started.
I am not sure how to continue from here. Does this cronjob run a PHP script, or is that the rust part?