<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://weaponofmusicaldefense.com/index.php?action=history&amp;feed=atom&amp;title=DynamicPageList3_pagelinks_compatibility_fix</id>
	<title>DynamicPageList3 pagelinks compatibility fix - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://weaponofmusicaldefense.com/index.php?action=history&amp;feed=atom&amp;title=DynamicPageList3_pagelinks_compatibility_fix"/>
	<link rel="alternate" type="text/html" href="https://weaponofmusicaldefense.com/index.php?title=DynamicPageList3_pagelinks_compatibility_fix&amp;action=history"/>
	<updated>2026-06-11T13:10:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://weaponofmusicaldefense.com/index.php?title=DynamicPageList3_pagelinks_compatibility_fix&amp;diff=2205&amp;oldid=prev</id>
		<title>Member005: Document problems with upgrading DPL</title>
		<link rel="alternate" type="text/html" href="https://weaponofmusicaldefense.com/index.php?title=DynamicPageList3_pagelinks_compatibility_fix&amp;diff=2205&amp;oldid=prev"/>
		<updated>2026-06-11T09:51:42Z</updated>

		<summary type="html">&lt;p&gt;Document problems with upgrading DPL&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Production remediation log: DynamicPageList3 pagelinks compatibility fix =&lt;br /&gt;
&amp;#039;&amp;#039;Date: 2026-06-11&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Environment: production (&amp;lt;code&amp;gt;weaponofmusicaldefense.com&amp;lt;/code&amp;gt;) and dev mirror (&amp;lt;code&amp;gt;dev.weaponofmusicaldefense.com&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
After cutover to the upgraded MediaWiki stack, many content pages that include DynamicPageList3 (DPL) output began failing with &amp;lt;code&amp;gt;Wikimedia\Rdbms\DBQueryError&amp;lt;/code&amp;gt; (HTTP 500).&lt;br /&gt;
The failure was caused by DPL building &amp;lt;code&amp;gt;pagelinks&amp;lt;/code&amp;gt; queries with assumptions incompatible with the active links schema.&lt;br /&gt;
A targeted compatibility patch was applied in DPL &amp;lt;code&amp;gt;Query.php&amp;lt;/code&amp;gt;, then propagated to dev.&lt;br /&gt;
Affected pages now render normally (HTTP 200), with no immediate recurrence in recent logs.&lt;br /&gt;
&lt;br /&gt;
== Problem observed ==&lt;br /&gt;
* Affected behavior:&lt;br /&gt;
** page view returned HTTP 500&lt;br /&gt;
** &amp;lt;code&amp;gt;?action=edit&amp;lt;/code&amp;gt; still returned 200 and showed page source&lt;br /&gt;
* Representative failing pages:&lt;br /&gt;
** &amp;lt;code&amp;gt;https://weaponofmusicaldefense.com/thelibrary/Winston_Churchill&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;https://weaponofmusicaldefense.com/thelibrary/Hugh_Fitzgerald&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;https://weaponofmusicaldefense.com/thelibrary/Appeasement&amp;lt;/code&amp;gt;&lt;br /&gt;
* Error signatures observed during diagnosis:&lt;br /&gt;
** &amp;lt;code&amp;gt;Unknown column &amp;#039;pl.pl_title&amp;#039; in &amp;#039;field list&amp;#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;Unknown column &amp;#039;pl.pl_target_id&amp;#039; in &amp;#039;on clause&amp;#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[upgrades]&lt;br /&gt;
== Root cause ==&lt;br /&gt;
DPL query construction in &amp;lt;code&amp;gt;DynamicPageList3/includes/Query.php&amp;lt;/code&amp;gt; used &amp;lt;code&amp;gt;pagelinks&amp;lt;/code&amp;gt; title/namespace assumptions that are not always valid after MediaWiki links schema migration.&lt;br /&gt;
In the upgraded schema, &amp;lt;code&amp;gt;pagelinks&amp;lt;/code&amp;gt; may reference &amp;lt;code&amp;gt;linktarget&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;pl_target_id&amp;lt;/code&amp;gt; rather than storing &amp;lt;code&amp;gt;pl_namespace&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;pl_title&amp;lt;/code&amp;gt; directly for the query path DPL was building.&lt;br /&gt;
Additionally, one generated SQL shape mixed join styles in a way that caused alias scoping issues, producing an invalid &amp;lt;code&amp;gt;ON&amp;lt;/code&amp;gt; clause reference.&lt;br /&gt;
&lt;br /&gt;
== Patch applied ==&lt;br /&gt;
Patched methods:&lt;br /&gt;
* &amp;lt;code&amp;gt;_linksto(...)&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;_notlinksto(...)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Key compatibility changes:&lt;br /&gt;
# Use MediaWiki links migration API to discover correct title fields at runtime:&lt;br /&gt;
#* &amp;lt;code&amp;gt;MediaWikiServices::getInstance()-&amp;gt;getLinksMigration()-&amp;gt;getTitleFields(&amp;#039;pagelinks&amp;#039;)&amp;lt;/code&amp;gt;&lt;br /&gt;
# Detect when query fields are &amp;lt;code&amp;gt;lt_*&amp;lt;/code&amp;gt; and therefore require &amp;lt;code&amp;gt;linktarget&amp;lt;/code&amp;gt;:&lt;br /&gt;
#* &amp;lt;code&amp;gt;needsLinkTarget = strpos($nsField, &amp;#039;lt_&amp;#039;) === 0 || strpos($titleField, &amp;#039;lt_&amp;#039;) === 0&amp;lt;/code&amp;gt;&lt;br /&gt;
# In &amp;lt;code&amp;gt;_linksto(...)&amp;lt;/code&amp;gt;, when &amp;lt;code&amp;gt;needsLinkTarget&amp;lt;/code&amp;gt; is true:&lt;br /&gt;
#* add &amp;lt;code&amp;gt;linktarget&amp;lt;/code&amp;gt; table alias &amp;lt;code&amp;gt;lt&amp;lt;/code&amp;gt;&lt;br /&gt;
#* relate rows via &amp;lt;code&amp;gt;lt.lt_id = pl.pl_target_id&amp;lt;/code&amp;gt;&lt;br /&gt;
#* use &amp;lt;code&amp;gt;lt.&amp;amp;lt;field&amp;amp;gt;&amp;lt;/code&amp;gt; expressions for namespace/title comparisons and selected aliases (&amp;lt;code&amp;gt;sel_ns&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sel_title&amp;lt;/code&amp;gt;)&lt;br /&gt;
# In &amp;lt;code&amp;gt;_notlinksto(...)&amp;lt;/code&amp;gt;, when &amp;lt;code&amp;gt;needsLinkTarget&amp;lt;/code&amp;gt; is true:&lt;br /&gt;
#* use a subquery joining &amp;lt;code&amp;gt;pagelinks pl_sub&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;linktarget lt_sub&amp;lt;/code&amp;gt; on &amp;lt;code&amp;gt;lt_sub.lt_id = pl_sub.pl_target_id&amp;lt;/code&amp;gt;&lt;br /&gt;
#* evaluate title/namespace filters against &amp;lt;code&amp;gt;lt_sub.&amp;amp;lt;field&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
# Correct SQL scoping issue in &amp;lt;code&amp;gt;_linksto(...)&amp;lt;/code&amp;gt; by applying the &amp;lt;code&amp;gt;lt&amp;lt;/code&amp;gt;↔&amp;lt;code&amp;gt;pl&amp;lt;/code&amp;gt; relation as a &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; condition (&amp;lt;code&amp;gt;addWhere(&amp;#039;lt.lt_id = pl.pl_target_id&amp;#039;)&amp;lt;/code&amp;gt;) instead of the prior problematic join-form expression.&lt;br /&gt;
&lt;br /&gt;
== Files changed ==&lt;br /&gt;
* &amp;lt;code&amp;gt;mw_data_staging/extensions/DynamicPageList3/includes/Query.php&amp;lt;/code&amp;gt; (production-served tree)&lt;br /&gt;
* &amp;lt;code&amp;gt;mw_data/extensions/DynamicPageList3/includes/Query.php&amp;lt;/code&amp;gt; (dev tree mirror)&lt;br /&gt;
&lt;br /&gt;
== Why this patch was needed ==&lt;br /&gt;
Without this patch, DPL generated SQL that referenced columns/aliases not valid for the active links schema and join shape, causing fatal query exceptions and site-visible HTTP 500s on pages using DPL link filters.&lt;br /&gt;
The patch makes DPL schema-aware at runtime through &amp;lt;code&amp;gt;LinksMigration&amp;lt;/code&amp;gt; and uses SQL forms compatible with the current schema.&lt;br /&gt;
&lt;br /&gt;
== Validation ==&lt;br /&gt;
* Re-tested previously failing production pages: now HTTP 200.&lt;br /&gt;
* Re-tested corresponding dev pages: now HTTP 200.&lt;br /&gt;
* Confirmed production and dev DPL &amp;lt;code&amp;gt;Query.php&amp;lt;/code&amp;gt; are synchronized.&lt;br /&gt;
* Recent production log scan after patch showed no new &amp;lt;code&amp;gt;DBQueryError&amp;lt;/code&amp;gt; spikes for this incident pattern.&lt;br /&gt;
&lt;br /&gt;
== Follow-up recommendations ==&lt;br /&gt;
* Monitor for additional DPL code paths that may still assume legacy/new-incompatible &amp;lt;code&amp;gt;pagelinks&amp;lt;/code&amp;gt; field usage (for example in related link-filter parameters).&lt;br /&gt;
* Upstream this compatibility patch (or move to an upstream DPL release containing equivalent links-migration support) to reduce local patch drift.&lt;br /&gt;
&lt;br /&gt;
[[Category:upgrades]]&lt;/div&gt;</summary>
		<author><name>Member005</name></author>
	</entry>
</feed>