20200819::modification de texte directement dans mysql
De wiki_pcwiki2
Aller à la navigationAller à la recherche
KEYWORDS: MEDIAWIKI, PCWIKI2, MYSQL, 19/08/2020
Le 19/08/2020: Ça y est, j'ai trouvé (grâce à https://www.mediawiki.org/wiki/Topic:Rbin8g8iyfncdt2b) comment modifier directement du texte dans mediawiki. Cela me permet d'afficher sur une copie de pcwiki2 que l'on est sur une version non modifiable.
#!/bin/sh # mercredi 19 août 2020, 14:55:41 (UTC+0200) # Script permettant d upgrader pcwiki après une mise à jour # Ex: afficher dans la page d accueil sur quel serveur on est hébergé # NB: utilisation de FIFO (named pipe)
fnShowTables()
{
mysql -v --password=fromspace -h localhost wiki_pcwiki2 << EoF
show tables;
EoF
}
fnShowColumns()
{
strTable=$1
mysql -v --password=fromspace -h localhost wiki_pcwiki2 << EoF
show columns from ${strTable};
/*Attention, la syntaxe: 'from "${strTable}"' ne marche pas */
EoF
}
fnShowPage()
{
strPage=$1
mysql -v --password=fromspace -h localhost wiki_pcwiki2 << EoF
SELECT pcwiki2text.old_text
FROM pcwiki2page
INNER JOIN pcwiki2revision ON page_Latest = rev_id
INNER JOIN pcwiki2text ON rev_text_id = old_id
WHERE page_title="${strPage}"
and page_namespace=0
;
EoF
}
fnGetIdPage()
{
strPage=$1
strNamedPipe=/tmp/fifo.00
rm -f $strNamedPipe
mkfifo ${strNamedPipe} &>/dev/null
# On met le résultat de mysql dans un pipe nommé:
mysql --silent --password=fromspace -h localhost wiki_pcwiki2 << EoF > ${strNamedPipe} &
SELECT pcwiki2text.old_id
FROM pcwiki2page
INNER JOIN pcwiki2revision ON page_Latest = rev_id
INNER JOIN pcwiki2text ON rev_text_id = old_id
WHERE page_title="${strPage}"
AND
page_namespace=0
;
EoF
# Lecture du pipe nommé:
intFirstPage=$(cat ${strNamedPipe})
echo "FIRSTPAGE=$intFirstPage"
echo "****************************************************************"
mysql --password=fromspace -h localhost wiki_pcwiki2 << EoF
SELECT pcwiki2text.old_text
FROM pcwiki2text
WHERE old_id="${intFirstPage}";
EoF
}
fnUpdate()
{
intFirstPage=$1
mysql -v --password=fromspace -h localhost wiki_pcwiki2 << EoF
UPDATE pcwiki2text
SET old_text = REPLACE(old_text, '(Back on SRV08)', '
Copy on bois-dery::srvbd08 - Warning: consult only')
WHERE old_id="${intFirstPage}";
EoF
service apache2 restart
}
# MAIN
fnShowColumns "pcwiki2page"
fnShowColumns "pcwiki2text"
fnShowPage "Accueil"
fnGetIdPage "Accueil"
fnUpdate ${intFirstPage}