Page MenuHomePhabricator

sql.php does not work with run.php
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • run php maintenance/run.php --wiki xxxx sql maintenance/postgres/tables-generated.sql

What happens?:

This following error is reported:

Warning: fopen(xvnet): Failed to open stream: No such file or directory in /opt/mediawiki/maintenance/sql.php on line 97
Unable to open input file

What should have happened instead?:

SQL tables get imported.

Software version (skip for WMF-hosted wikis like Wikipedia):
1.41.1

Other information (browser name/version, screenshots, etc.):

Event Timeline

Assuming this ticket is about the MediaWiki software. What is xvnet?

$ php maintenance/run.php sql
> SELECT VERSION();
stdClass Object
(
    [VERSION()] => 10.6.17-MariaDB-1:10.6.17+maria~ubu2204
)

The problem is coming from the argument order you're seemingly using, it's trying to open xvnet (which was presumably the parameter to the command?)

What happens if you run php maintenance/run.php --wiki=xxxx sql maintenance/postgres/tables-generated.sql?

@Reedy not working

/opt/mediawiki # php maintenance/run.php --wiki=meta sql maintenance/postgres/tables-generated.sql
Warning: fopen(sql): Failed to open stream: No such file or directory in /opt/mediawiki/maintenance/sql.php on line 97
Unable to open input file
/opt/mediawiki # php maintenance/run.php --wiki meta sql maintenance/postgres/tables-generated.sql
Warning: fopen(meta): Failed to open stream: No such file or directory in /opt/mediawiki/maintenance/sql.php on line 97
Unable to open input file

php maintenance/run.php sql --wiki=xxxx maintenance/postgres/tables-generated.sql

$ php maintenance/run.php --wiki=wiki sql
PHP Warning:  fopen(sql): Failed to open stream: No such file or directory in /var/www/wiki/mediawiki/core/maintenance/sql.php on line 98

Warning: fopen(sql): Failed to open stream: No such file or directory in /var/www/wiki/mediawiki/core/maintenance/sql.php on line 98
Unable to open input file
$ php maintenance/run.php sql --wiki=wiki
> 

Which is what matches the docs say to do:

$ php maintenance/run.php --help
Argument <script> is required!

Runner for maintenance scripts

Usage: php maintenance/run.php run.php [OPTION]... <script>

Script runner options:
    --conf <CONF>: Location of LocalSettings.php, if not default
    --globals: Output globals at the end of processing for debugging
    --memory-limit <MEMORY-LIMIT>: Set a specific memory limit for the
        script, "max" for no limit or "default" to avoid changing it
    --profiler <PROFILER>: Profiler output format (usually "text")
    --server <SERVER>: The protocol and server name to use in URLs, e.g.
        https://en.wikipedia.org. This is sometimes necessary because server
        name detection may fail in command line scripts.
    --wiki <WIKI>: For specifying the wiki ID

Arguments:
    <script>: The name of the maintenance script to run. Can be given as
        a class name or file path. The `.php` suffix is optional. Paths starting
        with `./` or `../` are interpreted to be relative to the current working
        directory. Other relative paths are interpreted relative to the
        maintenance script directory. Dots (.) are supported as namespace
        separators in class names. An extension name may be provided as a
        prefix, followed by a colon, e.g. "MyExtension:...", to indicate that
        the path or class name should be interpreted relative to the extension.

$ 

I will note the docs are confusing here:

Usage: php maintenance/run.php run.php [OPTION]... <script>

run.php twice... and then <script>

<script>: The name of the maintenance script to run.

But it makes more sense if you run it with sql

$ php maintenance/run.php sql --help

Send SQL queries to a MediaWiki database. Takes a file name containing SQL as
argument or runs interactively.

Usage: php maintenance/run.php sql [OPTION]...

Script runner options:
    --conf <CONF>: Location of LocalSettings.php, if not default
    --globals: Output globals at the end of processing for debugging
    --help (-h): Display this help message
    --memory-limit <MEMORY-LIMIT>: Set a specific memory limit for the
        script, "max" for no limit or "default" to avoid changing it
    --profiler <PROFILER>: Profiler output format (usually "text")
    --quiet (-q): Whether to suppress non-error output
    --server <SERVER>: The protocol and server name to use in URLs, e.g.
        https://en.wikipedia.org. This is sometimes necessary because server
        name detection may fail in command line scripts.
    --wiki <WIKI>: For specifying the wiki ID

Common options:
    --batch-size <BATCH-SIZE>: Run this many operations per batch,
        default: 100
    --dbgroupdefault <DBGROUPDEFAULT>: The default DB group to use.
    --dbpass <DBPASS>: The password to use for this script
    --dbuser <DBUSER>: The DB user to use for this script

Script specific options:
    --cluster <CLUSTER>: Use an external cluster by name
    --json: Output the results as JSON instead of PHP objects
    --query <QUERY>: Run a single query instead of running interactively
    --replicadb <REPLICADB>: Replica DB server to use instead of the
        primary DB (can be "any")
    --status: Return successful exit status only if the query succeeded
        (selected or altered rows), otherwise 1 for errors, 2 for no rows
    --wikidb <WIKIDB>: The database wiki ID to use if not the current
        one

ops it is working after moving --wiki after sql.
Thanks!