https://bugzilla.wikimedia.org/show_bug.cgi?id=67065

            Bug ID: 67065
           Summary: SQL casting error in Special:ProtectedPages
           Product: MediaWiki
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Database
          Assignee: [email protected]
          Reporter: [email protected]
       Web browser: ---
   Mobile Platform: ---

Created attachment 15728
  --> https://bugzilla.wikimedia.org/attachment.cgi?id=15728&action=edit
Fix for SQL casting error with Postgres

In Special:ProtectedPages, a text field is compared directly to an integer,
which moden versions of Postgres do not like. Error seen:

Query:
SELECT
pr_id,page_namespace,page_title,page_len,pr_type,pr_level,pr_expiry,pr_cascade,log_timestamp,log_user,log_comment,log_deleted
FROM "page","page_restrictions" LEFT JOIN "log_search" ON (ls_field = 'pr_id'
AND (ls_value = pr_id)) LEFT JOIN "logging" ON ((ls_log_id = log_id)) WHERE
(pr_expiry > '2014-06-25 01:59:54 GMT'OR pr_expiry IS NULL) AND
(page_id=pr_page) AND (pr_type='edit') ORDER BY pr_id LIMIT 51
Function: IndexPager::buildQueryInfo (ProtectedPagesPager)
Error: 42883 ERROR: operator does not exist: text = integer LINE 1:
..."log_search" ON (ls_field = 'pr_id' AND (ls_value = pr_id)) ... ^ HINT: No
operator matches the given name and argument type(s). You might need to add
explicit type casts.

Yes, Postgres is being pedantic, but it is weird that the where clause has a
proper cast right before it:

ON (ls_field = 'pr_id' AND (ls_value = pr_id))

The solution is to quote the pr_id. Diff attached.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to