[QuickStatements] allow removal of alias

Issue #114 resolved
Frog23 created an issue

It is currently not possible to remove an specific alias using QuickStatements, while it is possible to do this using the API.

I modified the code of my local QS installation and with two minimal changes to quickstatements.php.

‌ 1. In the function runSingleCommand in the section } else if ( $command->action == 'remove' ) { add the following code at the end of the if block about $command->what (currently at line 1080)

                                  else if ( $command->what == 'alias' ) {
                    return $this->commandRemoveAlias ( $command, $i ) ;
                }

‌ 2. after the function commandAddAlias (currently at line 913) add

        protected function commandRemoveAlias ( $command , $i ) {
        // Paranoia TODO

        // Execute!
        $this->runAction ( array (
            'action' => 'wbsetaliases' ,
            //replaced with the line below because of https://bitbucket.org/magnusmanske/wikidata-todo/issues/112/quickstatements-changing-or-editing
            //'id' => $this->getPrefixedID ( $command->item ) ,
            'id' => $command->item ,
            'language' => $command->language ,
            'remove' => $command->value ,
            'summary' => '' ,
            'baserevid' => $i->j->lastrevid
        ) , $command ) ;
        if ( !$this->isBatchRun() ) $this->wd->updateItem ( $command->item ) ;
        return $command ;
    }

This is the same code as commandAddAlias, only the function name has been changed to commandRemoveAlias and instead of 'add' => $command->value , it is now 'remove' => $command->value , . (The code snippet above also contains the changes mentioned in #112).

To remove an alias, one can now use the QS syntax:

-Q4115189|Aen|"wrong alias"

Comments (2)

  1. Log in to comment