Skip to content

Instantly share code, notes, and snippets.

@splitbrain
Created June 29, 2022 16:50
Show Gist options
  • Select an option

  • Save splitbrain/c6f1ac33d64b5290a841fbb9d1ded47e to your computer and use it in GitHub Desktop.

Select an option

Save splitbrain/c6f1ac33d64b5290a841fbb9d1ded47e to your computer and use it in GitHub Desktop.
Fix #3698
<?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>";
}
}
@maigretsshadow
Copy link
Copy Markdown

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?

@splitbrain
Copy link
Copy Markdown
Author

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.

@maigretsshadow
Copy link
Copy Markdown

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