Page MenuHomePhabricator

Check on IP range in MediaWiki\Block\DatabaseBlock::newLoad triggers error in psql, breaks mediawiki.
Closed, InvalidPublic

Description

I recently updated our mediawiki to 1.34.0, which runs on a psql-database. (and it uses the LDAPStack for managing logins)
On the login page, I get an error, which in the psql-logs looks like

ERROR:  operator does not exist: integer ~~ text
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
wiki_user@wiki_db STATEMENT:  SELECT /* MediaWiki\Block\DatabaseBlock::newLoad  */ {things}  FROM "ipblocks" JOIN {some joins}  WHERE {some conditions} OR ((ipb_range_start  LIKE '2EE5%' ESCAPE '{backtick}' ) AND (ipb_range_start <= 2EE5A894') AND (ipb_range_end >= '2EE5A894'))

In the database, I found that ipb_range_start and ipb_range_end are of type integer, (As found by \d mediawiki.ipblocks)
Hence the error occurs because psql does not like implicit conversion of hex-strings to integers.

I am not sure why a query is produced that tests against hex-strings. The relevant code in DatabaseBlock does seem to explicitly convert to hex. I guess this conversion should not occur for psql, or the database structure should be updated somehow.

I am happy to provide any further details.

The full problematic statement is

SELECT /* MediaWiki\Block\DatabaseBlock::newLoad  */  ipb_id,ipb_address,ipb_timestamp,ipb_auto,ipb_anon_only,ipb_create_account,ipb_enable_autoblock,ipb_expiry,ipb_deleted,ipb_block_email,ipb_allow_usertalk,ipb_parent_block_id,ipb_sitewide,comment_ipb_reason.comment_text AS "ipb_reason_text",comment_ipb_reason.comment_data AS "ipb_reason_data",comment_ipb_reason.comment_id AS "ipb_reason_cid",actor_ipb_by.actor_user AS "ipb_by",actor_ipb_by.actor_name AS "ipb_by_text",ipb_by_actor  FROM "ipblocks" JOIN "comment" "comment_ipb_reason" ON ((comment_ipb_reason.comment_id = ipb_reason_id)) JOIN "actor" "actor_ipb_by" ON ((actor_ipb_by.actor_id = ipb_by_actor))   WHERE ipb_address IN ('46.229.168.143','46.229.168.143')  OR ((ipb_range_start  LIKE '2EE5%' ESCAPE '`' ) AND (ipb_range_start <= '2EE5A88F') AND (ipb_range_end >= '2EE5A88F'))

Event Timeline

This comment was removed by Wgevaert.

It seems that ipb_range_start and ipb_range_end have always been TEXT in psql, so I'm wondering why in our database it is registered as integer... I will take a look into it. We have never used any IP-blocking anyways.

I manually changed the type of these things to text and it fixed the problem.
Still wondering why it ended up as int in the fist place though...

Maybe you can close the issue now?

Umherirrender subscribed.

It is TEXT since the begin of the postgres schema in 6832afd9ea7d280e0e63648424de26e6ead6bf56

I see no missing database patch on a release and just make this invalid.