Jump to content

ICT:System RESET - FIles and Asset Namespace: Difference between revisions

From Costa Sano MediaWiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
= System Reset – Files and Asset Namespace =
= System Reset – Assets, Files, and Cargo (DEV) =


This document defines the **standard, repeatable procedure** to fully clean the system during
This document defines the **authoritative cleanup procedure** for the development
Asset v2.x development.
environment of the Asset system (v2.x).


It is intended for **development and testing environments only**.
It reflects **real-world behavior** observed on:
All data (Assets and files) is assumed to be disposable.
* MediaWiki 1.45
* Cargo extension
* AlmaLinux
* MariaDB
* Development-only data (fully disposable)


This procedure MAY be executed multiple times during development.
This procedure is EXPECTED to be executed multiple times during development.


---
'''DO NOT use on production systems.'''


== 1. Preconditions ==
----
Before starting:


* You have shell access to the MediaWiki server
== 0. Scope and Principles ==
* You have phpMyAdmin access to the MariaDB/Cargo database
* MediaWiki is NOT in active use by other users
* Any files that must be preserved have been downloaded locally


Stop the wiki:
* All Asset data is test data
* No historical preservation is required
* Cleanup must be:
** deterministic
** fast
** repeatable
* SQL-level cleanup is ACCEPTABLE and PREFERRED in development


<pre>
----
<?php


$wgReadOnly = 'System maintenance in progress';
== 1. Enter Maintenance Mode ==


/* Existing configuration continues below */
Edit <code>LocalSettings.php</code> and add near the top:


</pre>
<syntaxhighlight lang="php">
$wgReadOnly = 'System maintenance in progress';
</syntaxhighlight>


This prevents user edits and uploads during cleanup.


---
----


== 2. Safeguard Files to Keep (if any) ==
== 2. Safeguard Files to Keep (if any) ==
If a small number of files must be preserved (e.g. Main Page images):


# Open each File page
If a small number of images must be preserved (e.g. Main Page images):
 
# Open each <code>File:</code> page
# Download the original file locally
# Download the original file locally
# Verify the local copy opens correctly
# Verify the local copy
 
After this step, ALL files on the server may be deleted.


After this step, all files on the server may be deleted.
----


---
== 3. Delete All Files (Filesystem) ==


== 3. Delete ALL Files (Filesystem Level) ==
On the MediaWiki server:
On the MediaWiki server, remove all stored files.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 53: Line 63:
Notes:
Notes:
* Do NOT delete the <code>images/</code> directory itself
* Do NOT delete the <code>images/</code> directory itself
* This removes all uploaded files, thumbnails, archives, and temp files
* This removes originals, thumbnails, archives, and temp files
 
----


---
== 4. Clean File Metadata (Database) ==


== 4. Clean File Metadata (Database Level) ==
Using phpMyAdmin on the MediaWiki database:
Using phpMyAdmin on the MariaDB server, execute the following SQL commands
on the MediaWiki database:


<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
Line 69: Line 79:
Result:
Result:
* Special:FileList becomes empty
* Special:FileList becomes empty
* File history is forgotten
* Filename history is forgotten
* Re-uploading previously used filenames is allowed
* Re-uploading old filenames is allowed


---
----


== 5. Run MediaWiki File Cleanup Script ==
== 5. Delete File Namespace Pages ==
On the MediaWiki server, run:


<syntaxhighlight lang="bash">
Deleting files does NOT delete <code>File:</code> pages.
php maintenance/cleanupImages.php
These pages must be removed explicitly.
</syntaxhighlight>


Purpose:
Standard namespace IDs:
* Removes residual inconsistencies
* File = 6
* Ensures MediaWiki state matches filesystem and database
* File talk = 7


---
Using phpMyAdmin (MediaWiki database):


== 6. Delete ALL Asset Pages (Namespace Cleanup) ==
<syntaxhighlight lang="sql">
DELETE FROM page WHERE page_namespace = 6;
DELETE FROM page WHERE page_namespace = 7;
</syntaxhighlight>


=== 6.1 Determine Asset Namespace ID ===
Then clean orphaned content:
In phpMyAdmin, run:


<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
SELECT ns_id, ns_name FROM mw_namespace;
DELETE FROM revision WHERE rev_page NOT IN (SELECT page_id FROM page);
DELETE FROM text WHERE old_id NOT IN (SELECT rev_text_id FROM revision);
</syntaxhighlight>
</syntaxhighlight>


Note the numeric <code>ns_id</code> corresponding to <code>Asset</code>.
----
(Example: 300 – actual value may differ.)


---
== 6. Delete Asset Namespace Pages ==


=== 6.2 Generate List of Asset Pages ===
Asset namespaces are custom and defined in <code>LocalSettings.php</code>.
On the MediaWiki server:


<syntaxhighlight lang="bash">
In this system:
php maintenance/getAllPages.php --namespace=3014 > /tmp/asset_pages.txt
* Asset namespace ID = 3014
</syntaxhighlight>
* Asset talk namespace ID = 3015


Replace <code>NS_ID</code> with the Asset namespace ID.
Using phpMyAdmin (MediaWiki database):


---
<syntaxhighlight lang="sql">
DELETE FROM page WHERE page_namespace = 3014;
DELETE FROM page WHERE page_namespace = 3015;
</syntaxhighlight>


=== 6.3 Delete Asset Pages in Bulk ===
Then clean orphaned content:
Run:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="sql">
php maintenance/deleteBatch.php /tmp/asset_pages.txt
DELETE FROM revision WHERE rev_page NOT IN (SELECT page_id FROM page);
DELETE FROM text WHERE old_id NOT IN (SELECT rev_text_id FROM revision);
</syntaxhighlight>
</syntaxhighlight>


Result:
Rationale:
* All pages in the Asset namespace are deleted
* MediaWiki 1.45 maintenance scripts for mass deletion are inconsistent
* Revisions and logs are handled correctly
* SQL cleanup is faster, clearer, and reliable for DEV resets
* No UI interaction required


---
----


== 7. Clean Cargo Asset Data ==
== 7. Clean Cargo Asset Data ==
Using phpMyAdmin on the Cargo database, execute:
 
Asset dashboards read from Cargo, not from pages.
 
Using phpMyAdmin on the Cargo database:


<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
Line 134: Line 148:


Result:
Result:
* No Asset data remains
* Dashboards become empty
* Dashboards return empty
* Sequence numbers reset
* Sequence numbers reset cleanly
* No ghost Asset rows remain
 
The dashboard PAGE itself must NOT be deleted.


---
----


== 8. Optional Hygiene Step ==
== 8. Optional Hygiene Step ==
After large deletions, optionally run:
 
After large SQL deletions, optionally run:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
php maintenance/refreshLinks.php
php maintenance/run.php refreshLinks
</syntaxhighlight>
</syntaxhighlight>


This is not mandatory but recommended after repeated resets.
This is not mandatory but recommended after repeated resets.


---
----


== 9. Verification Checklist ==
== 9. Verification Checklist ==
After completing all steps:
 
All of the following must be true:


* Special:FileList → empty
* Special:FileList → empty
* Special:AllPages (File namespace) → empty
* Special:AllPages (File) → empty
* Special:AllPages (Asset namespace) → empty
* Special:AllPages (Asset) → empty
* Asset dashboards → empty
* Asset dashboards → empty (no rows)
* Uploading a previously used filename → allowed
* Cargo <code>Assets</code> table → empty
 
If all checks pass, the system is in a '''true zero state'''.
 
----


If all checks pass, the system is in a **clean zero state**.
== 10. Exit Maintenance Mode ==


---
When cleanup is complete:
 
# Remove or comment out:
  <syntaxhighlight lang="php">
  // $wgReadOnly = 'System maintenance in progress';
  </syntaxhighlight>
# Reload the wiki
# Log in
# Re-upload preserved images (if any)
 
----
 
== 11. Usage Policy ==


== 10. Usage Policy ==
This reset procedure is:
This reset procedure is:
* APPROVED for development and testing
* APPROVED for development and testing
* EXPECTED to be reused during Asset v2.x stabilization
* FORBIDDEN on production systems
* FORBIDDEN on production systems
* EXPECTED to be executed repeatedly during Asset v2.x stabilization


---
----


''End of document''
''End of document''

Latest revision as of 17:30, 22 February 2026

System Reset – Assets, Files, and Cargo (DEV)

This document defines the **authoritative cleanup procedure** for the development environment of the Asset system (v2.x).

It reflects **real-world behavior** observed on:

  • MediaWiki 1.45
  • Cargo extension
  • AlmaLinux
  • MariaDB
  • Development-only data (fully disposable)

This procedure is EXPECTED to be executed multiple times during development.

DO NOT use on production systems.


0. Scope and Principles

  • All Asset data is test data
  • No historical preservation is required
  • Cleanup must be:
    • deterministic
    • fast
    • repeatable
  • SQL-level cleanup is ACCEPTABLE and PREFERRED in development

1. Enter Maintenance Mode

Edit LocalSettings.php and add near the top:

$wgReadOnly = 'System maintenance in progress';

This prevents user edits and uploads during cleanup.


2. Safeguard Files to Keep (if any)

If a small number of images must be preserved (e.g. Main Page images):

  1. Open each File: page
  2. Download the original file locally
  3. Verify the local copy

After this step, ALL files on the server may be deleted.


3. Delete All Files (Filesystem)

On the MediaWiki server:

rm -rf /var/www/mediawiki/images/*

Notes:

  • Do NOT delete the images/ directory itself
  • This removes originals, thumbnails, archives, and temp files

4. Clean File Metadata (Database)

Using phpMyAdmin on the MediaWiki database:

TRUNCATE TABLE image;
TRUNCATE TABLE oldimage;
TRUNCATE TABLE filearchive;

Result:

  • Special:FileList becomes empty
  • Filename history is forgotten
  • Re-uploading old filenames is allowed

5. Delete File Namespace Pages

Deleting files does NOT delete File: pages. These pages must be removed explicitly.

Standard namespace IDs:

  • File = 6
  • File talk = 7

Using phpMyAdmin (MediaWiki database):

DELETE FROM page WHERE page_namespace = 6;
DELETE FROM page WHERE page_namespace = 7;

Then clean orphaned content:

DELETE FROM revision WHERE rev_page NOT IN (SELECT page_id FROM page);
DELETE FROM text WHERE old_id NOT IN (SELECT rev_text_id FROM revision);

6. Delete Asset Namespace Pages

Asset namespaces are custom and defined in LocalSettings.php.

In this system:

  • Asset namespace ID = 3014
  • Asset talk namespace ID = 3015

Using phpMyAdmin (MediaWiki database):

DELETE FROM page WHERE page_namespace = 3014;
DELETE FROM page WHERE page_namespace = 3015;

Then clean orphaned content:

DELETE FROM revision WHERE rev_page NOT IN (SELECT page_id FROM page);
DELETE FROM text WHERE old_id NOT IN (SELECT rev_text_id FROM revision);

Rationale:

  • MediaWiki 1.45 maintenance scripts for mass deletion are inconsistent
  • SQL cleanup is faster, clearer, and reliable for DEV resets

7. Clean Cargo Asset Data

Asset dashboards read from Cargo, not from pages.

Using phpMyAdmin on the Cargo database:

TRUNCATE TABLE Assets;

Result:

  • Dashboards become empty
  • Sequence numbers reset
  • No ghost Asset rows remain

The dashboard PAGE itself must NOT be deleted.


8. Optional Hygiene Step

After large SQL deletions, optionally run:

php maintenance/run.php refreshLinks

This is not mandatory but recommended after repeated resets.


9. Verification Checklist

All of the following must be true:

  • Special:FileList → empty
  • Special:AllPages (File) → empty
  • Special:AllPages (Asset) → empty
  • Asset dashboards → empty (no rows)
  • Cargo Assets table → empty

If all checks pass, the system is in a true zero state.


10. Exit Maintenance Mode

When cleanup is complete:

  1. Remove or comment out:
  // $wgReadOnly = 'System maintenance in progress';
  1. Reload the wiki
  2. Log in
  3. Re-upload preserved images (if any)

11. Usage Policy

This reset procedure is:

  • APPROVED for development and testing
  • EXPECTED to be reused during Asset v2.x stabilization
  • FORBIDDEN on production systems

End of document