Wiki Category Links

From HaFrWiki
Jump to: navigation, search

When a page with a redirector is changed the Categories on that page disappear. To correct this problem some SQL is needed. This page gives background information on pages links and categories.
At the SQL Category tab a SQL summary containing a solution.

Involved tables and structure

Table CategoryLinks

CategoryLinks
Field Type Attrib Description Example
cl_from int(8) Unsigned Id equal to the pageId 1583
cl_to varchar(255) Binary CategoryName to link to Private
cl_sortkey varchar(86) Binary CategoryName to sort-on Index
cl_timestamp TimeStamp(14) Timestamp Time/date stamp 20060603125034

Table Page

Page (Not full structure given)
Field Type Attrib Description Example
page_id int(8) Unsigned Unique Page Id 1583
page_namespace int(11)   Namespace 14
page_title varchar(255) Binary Name of the page Index

Table PageLinks

PageLinks (Not full structure given)
Field Type Attrib Description Example
pl_from int(8) Unique Id equal to PageId 1583 1583
pl_namespace int(11)   Number of the Namespace 10 14
pl_title varchar(256) Binary Name of the page CatAZ Index

Mediawiki Namespaces

Variables Alternate syntax Name, linked to list of all pages Notes
{{ns:-2}} {{ns:Media}} "Media" pseudo-namespace for images and other files
{{ns:-1}} {{ns:Special}} "Special" pseudo-namespace for special pages (list: Special:Specialpages)
{{ns:-0}} {{ns:Main}} main main namespace, no prefix,
{{ns:1}} {{ns:Talk}} Talk see Help:Talk page for this and the following odd-numbered namespaces
{{ns:2}} {{ns:User}} User logged-in users (list: Special:Listusers)
{{ns:3}} {{ns:User_talk}} User talk  
{{ns:4}} {{ns:Project}} HaFrWiki the project namespace for matters about the project
{{ns:5}} {{ns:Project_talk}} HaFrWiki talk  
{{ns:6}} {{ns:Image}} File images and other uploaded filespage]]s (list: Special:Imagelist)
{{ns:7}} {{ns:Image_talk}} File talk  
{{ns:8}} {{ns:MediaWiki}} MediaWiki system messages (list: Special:Allmessages)
{{ns:9}} {{ns:MediaWiki_talk}} MediaWiki talk  
{{ns:10}} {{ns:Template}} Template the default namespace for templates:
{{ns:11}} {{ns:Template_talk}} Template talk  
{{ns:12}} {{ns:Help}} Help typically used for the MediaWiki User's Guide,
{{ns:13}} {{ns:Help_talk}} Help talk  
{{ns:14}} {{ns:Category}} Category each page (list: Special:Categories) represents a category of pages,
{{ns:15}} {{ns:Category_talk}} Category talk  

SQL Category

To find the page number of the Article.

SELECT  * 
FROM    page
WHERE   page_title =  'You''re_beautiful';

This will give:

page_id    page_namespace  page_title        Etc.
XXXX                    0  You're_beautiful  Etc.

Now insert 2 record into the CategoryLinks table.

cl_from    cl_to     cl_sortkey           cl_timestamp
   XXXX    Index     You're beautiful     20060708223318
   XXXX    Music     You're beautiful     20060708223409

NB: Important the Category page is cached. To see the result, first clear the cache and refresh the Category page.