Page MenuHomePhabricator

SQL error message on submitting job
Open, Needs TriagePublic

Description

Upon submitting job 6783 (a test on a few pages I recently edited), the following was displayed at the top of the page:

ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AND `wiki` = 'enwiki'' at line 1 SQL: SELECT * FROM `externallinks_user` WHERE `user_link_id` IN () AND `wiki` = 'enwiki';

This is possibly caused by me messing up my oauth configuration (I clicked on the run single page, got prompted to add oauth for editing from my account, canceled, and then was redirected to that oauth page every time I loaded the runpage (even for not running a single one)). To try and resolve that, I also canceled the view basic information grant on Special:OAuthManageMyGrants, which didn't fix the issue. I've since accepted the edit grant, but it hasn't prompted for the basic information one again, so perhaps that grant being revoked is what triggered this issue.

Event Timeline

I've noticed that the error message only shows when the requested url is not yet in the log file. That is the error disappears if you have changed the url-status from live to dead. The log file is shown at the bottom of the page. It is always empty when the error appears. Maybe this information can help to solve the problem.

I'm the creator of the duplicate task T267958 that was merged with this one.

I've search the source code for the frase externallinks_user WHERE user_link_id IN which appears in the error message. I found it in the function loadLogUsers of the file pagefunctions.php,

As far as I can see the array $toFetch might be empty when the parameter $res is defined for the first time which then causes the error. A solution might be to check if the array is empty.

I imagine something like this:

if( !empty( $toFetch ) ) {
    $res =
        $dbObject->queryDB( "SELECT * FROM `externallinks_user` WHERE `user_link_id` IN (" . implode( ", ", $toFetch ) . ") AND `wiki` = '" . WIKIPEDIA . "';");
    if( $res ) while( $result = mysqli_fetch_assoc( $res ) ) {
        $userCache[$result['user_link_id']] = $result;
    }
}

in stead of:

$res =
	$dbObject->queryDB( "SELECT * FROM `externallinks_user` WHERE `user_link_id` IN (" . implode( ", ", $toFetch ) .") AND `wiki` = '" . WIKIPEDIA . "';");
if( $res ) while( $result = mysqli_fetch_assoc( $res ) ) {
	$userCache[$result['user_link_id']] = $result;
}

I have no experience in changing the source code so I hope somebody else has the time. If not I will try myself with the help of this guide in a couple of days.

@Weblars I've created a pull request here

@Weblars it's now been merged

Thank you for the help, @Nintendofan885.

I've confirmed this morning that the error message that was the reason for creating this task is now gone. Yesterday it was still there, but of course it takes a little time for the repository at toolforge.org to be updated.

I've now made a fork of the repository at github,.com, so hopefully in the future I can make my own pull requests.