Created
June 29, 2022 16:50
-
-
Save splitbrain/c6f1ac33d64b5290a841fbb9d1ded47e to your computer and use it in GitHub Desktop.
Fix #3698
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Rename all files affected by https://github.com/splitbrain/dokuwiki/issues/3698 | |
* | |
* Upload this file to your DokuWiki root. It should be placed right next to the doku.php file. Then run | |
* call it in your browser at https://yourserver.com/yourwiki/turkishfix.php | |
* | |
* Delete the file once you're done | |
*/ | |
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/'); | |
require_once(DOKU_INC . 'inc/init.php'); | |
global $conf; | |
$path = $conf['savedir']; | |
$di = new RecursiveIteratorIterator( | |
new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS) | |
); | |
foreach ($di as $name => $fio) { | |
@set_time_limit(30); | |
$old = $fio->getPathname(); | |
$new = str_replace('%C4%B1', 'i', $old); | |
if ($old !== $new) { | |
rename($old, $new); | |
echo "$new<br>"; | |
} | |
} |
Hmm this runs on the whole data dir which unless you reconfigured it includes the media files. So it should have renamed media files, too.
Could the problem lie in the fact that the script only changes filenames and not directory names? I created extra namespaces for my media files, so the files itself lie in folders that - after running the script for a second time - still contain the Turkish "%C4%B1".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fix works like a charm, thanks a lot! The only problem now is that corresponding media files haven't yet been renamed and are thus not being displayed. I assume that I could use this script for that as well if I changed the path name accordingly, right?