Am 16.07.2013 14:36, schrieb basti:
> hello @all,
>
> I try to use the Extension:BlogPage with Postgres.
> This depents on VoteNY extension an there is my problem.
> All SQL-files I have port to pgsql.
>
> ./extensions/VoteNY/VoteClass.php line 182 ff. generate the following query
>
> SELECT vote_value FROM "Vote" WHERE vote_page_id = '0' AND username =
> 'Admin' LIMIT 1
>
> but it must generate a query like
>
> SELECT vote_value FROM mediawiki.Vote WHERE vote_page_id = '0' AND
> username = 'Admin' LIMIT 1
>
> The " are too mutch, and the schemata must added.
>
> How can I fix this.
> Thanks.
>
> Regards,
> Basti
>
> _______________________________________________
> MediaWiki-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

I have found the error, but I don't know how to solve it.
There is a Problem with the Postgres "serach Path" in the plugin.

On the database site there is only one schema "mediawiki".
The $wgDBuser has the default schema "mediawiki" on server site.
(Use "SHOW search_path;" in SQL console to check this.)

$wgDBmwschema = "mediawiki"; and
$wgDBtype     = "postgres";  are also set in LocalSettings.php

The Wiki-DEBUG output say "Schema "mediawiki" already in the search path".

There is always the same Error on Database site:

SELECT COUNT(*) AS VoteCount FROM "Vote" WHERE vote_page_id = '0'

Postgres log:

FEHLER: Relation »Vote« existiert nicht LINE 1: ...Vote::count Admin */
COUNT(*) AS VoteCount FROM "Vote" WH... ^ “.
(in english: Relation »Vote« does not exist)

When I change in VoteNY/VoteClass.php it runs.

function UserAlreadyVoted() {
    $dbr = wfGetDB( DB_SLAVE );
    $s = $dbr->selectRow(
# Here add Postgres schema
        'mediawiki.vote',
        array( 'vote_value' ),
        array(
            'vote_page_id' => $this->PageID,
            'username' => $this->Username
         ),
        __METHOD__
    );
# Exit for debug
    exit("UserAlreadyVoted() done");
    
    if( $s === false ) {
        return false;
    } else {
        return $s->vote_value;
    }
}

I have done also some changes in VoteNY/Hooks.php

public static function addTable( $updater ) {
    $dir = dirname( __FILE__ );

/** change to use Postgres **/
    $dbr = wfGetDB( DB_SLAVE );
    if ($dbr->getType() == "postgres") {
        $file = "$dir/vote.postgres.sql";
    }
    else {
        $file = "$dir/vote.sql";
    }
    /** check if table exists,
        else the update.php won't run because Postgres exit with Error
    **/
    if (!$dbr->tableExists('vote')) {
        $updater->addExtensionUpdate( array( 'addTable', 'Vote', $file,
true ) );
    }
/** end of changes **/

    return true;
}

vote.postgres.sql

-- Postgres Version

-- set Schemata for debug, normally done by
includes/db/DatabasePostgres.sql ?
SET search_path = mediawiki;

CREATE TABLE vote (
  -- Internal ID to identify between different vote tags on different pages
  vote_id SERIAL NOT NULL PRIMARY KEY,
  -- Username (if any) of the person who voted
  username varchar(255) NOT NULL default '0',
  -- User ID of the person who voted
  vote_user_id integer NOT NULL default '0',
  -- ID of the page where the vote tag is in
  vote_page_id integer NOT NULL default '0',
  -- Value of the vote (ranging from 1 to 5)
  vote_value char(1) NOT NULL default '',
  -- Timestamp when the vote was cast
  vote_date timestamp without time zone NOT NULL,
  -- IP address of the user who voted
  vote_ip varchar(45) NOT NULL default ''
);

CREATE INDEX vote_page_id_index ON vote (vote_page_id);
CREATE INDEX valueidx ON vote (vote_value);
CREATE INDEX usernameidx ON vote (username);
CREATE INDEX vote_date ON vote (vote_date);
--EOF

So it seems that includes/db/DatabasePostgres.sql isn't use by this
Plugin or
something else is goning wrong that the database connection doesn't
nothing about the schema.

Regards,
basti


_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to