Page MenuHomePhabricator

maintenance/updateSpecialPages.php tries to INSERT invalid values
Closed, ResolvedPublic

Description

Author: nies.david

Description:
Error Log

My system setting is: 1.13alpha (r35900), PHP 5.2.0, PostgreSQL 8.1.11.

When I try to run the maintenance script "updateSpecialPages.php" (on the shell), I get the following error output:

Ancientpages
Warning: pg_query(): Query failed: ERROR: syntax error at or near "," at character 154 in /home/david/www/david.theparticulars.org/htdocs/w/includes/DatabasePostgres.php on line 557
got 4 rows in 0.03s
BrokenRedirects got 0 rows in 0.01s
Deadendpages
Warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "TPO_Weblog" in /home/david/www/david.theparticulars.org/htdocs/w/includes/DatabasePostgres.php on line 557
got 1 rows in 0.02s
Disambiguations got 0 rows in 0.07s
DoubleRedirects got 0 rows in 0.01s
Listredirects
Warning: pg_query(): Query failed: ERROR: syntax error at or near "," at character 149 in /home/david/www/david.theparticulars.org/htdocs/w/includes/DatabasePostgres.php on line 557
(...)

which goes on. I omitted it because of its length, but you can find the whole output in my attachment (err.txt).


Version: 1.13.x
Severity: normal

Attached:

Details

Reference
bz14414

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:08 PM
bzimport set Reference to bz14414.
bzimport added a subscriber: Unknown Object (MLST).

nies.david wrote:

Debug output ($wgDebugLogfile)

Attached:

nies.david wrote:

I added the whole debug output ($wgDebugLogFile) in the attached file "Debug output ($wgDebugLogfile)"

overlordq wrote:

When I ran the query I had problems with the following special pages:

Uncategorizedcategories
Uncategorizedpages
Uncategorizedimages
Uncategorizedtemplates
Unusedimages

Withoutinterwiki

This is likely due to my test wiki being relatively empty.

For the first one, Uncategorizedcategories, you get the following query:

SELECT

        'Uncategorizedcategories' as type,
        page_namespace AS namespace,
        page_title AS title,
        page_title AS value
FROM page
LEFT JOIN categorylinks ON page_id=cl_from
WHERE cl_from IS NULL AND page_namespace=14 AND page_is_redirect=0
 ORDER BY value  LIMIT 1000  OFFSET 0

The problem is the page_title AS value. In the ::recache function of QueryPage.php it uses the value field as an insert into the querycache.

INSERT /* UncategorizedCategoriesPage::recache */ INTO querycache (qc_type,qc_namespace,qc_title,qc_value) VALUES ('Uncategorizedcategories','14','Rainbow_Tables','Rainbow_Tables')

Looking at tables.sql, qc_value should be an unsigned integer but the getSQL() function of SpecialUncategorizedpages.php is feeding it the page_title as seen above. Just a hazarding a guess but this is likely the cause for the other errors as well.

This however should effect MySQL as well, so either MySQL is silently accepting a text field as an integer or MySQL is doing something else weird.

overlordq wrote:

for the hellofit on MySQL:

mysql> SELECT * FROM querycache;
Empty set (0.01 sec)

mysql> INSERT INTO querycache (qc_type,qc_namespace,qc_title,qc_value) VALUES ('Uncategorizedcategories','14','Rainbow_Tables','Rainbow_Tables');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SELECT * FROM querycache;
+-------------------------+----------+--------------+----------------+

qc_typeqc_valueqc_namespaceqc_title

+-------------------------+----------+--------------+----------------+

Uncategorizedcategories014Rainbow_Tables

+-------------------------+----------+--------------+----------------+
1 row in set (0.01 sec)

So at least in MySQL's (non-strict) behavior it'll silently accept this invalid input and substitute a zero.

But enabling strict mode will throw an error:

mysql> SET SESSION sql_mode=STRICT_ALL_TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO querycache (qc_type,qc_namespace,qc_title,qc_value) VALUES ('Uncategorizedcategories','14','Rainbow_Tables','Rainbow_Tables');

ERROR 1366 (HY000): Incorrect integer value: 'Rainbow_Tables' for column 'qc_value' at row 1

So, renaming the bug since it isn't limited to PG, it's just PG by default throws an error.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.