• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

PukiWiki


Commit MetaInfo

Revision46036e1878d8a02fa83465b69a6b9c54ccf1a524 (tree)
Time2016-02-08 02:26:50
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/374 Fix recording username logic

* Recoard username and fullname for each post
* If fullname is empty, use username as his/her fullname
* Take backup if username differs from previous post

Change Summary

Incremental Difference

--- a/lib/backup.php
+++ b/lib/backup.php
@@ -49,14 +49,14 @@ function make_backup($page, $is_delete, $wikitext)
4949 $need_backup_by_time = $lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle;
5050 if (!$need_backup_by_time) {
5151 // Backup file is saved recently, but the author may differ.
52- $last_content = get_source($page, FALSE, TRUE);
52+ $last_content = get_source($page, TRUE, TRUE);
5353 $m = array();
54- if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/m', $last_content, $m)) {
55- $prev_author = $m[2];
56- $simple_author =preg_replace('/^[^:]:/', '', $prev_author);
57- if ($simple_author !== $auth_user) {
58- $is_author_differ = true;
59- }
54+ $prev_author = null;
55+ if (preg_match('/^#author\("([^"]+)","([^"]*)","([^"]*)"\)/m', $last_content, $m)) {
56+ $prev_author = preg_replace('/^[^:]+:/', '', $m[2]);
57+ }
58+ if ($prev_author !== $auth_user) {
59+ $is_author_differ = true;
6060 }
6161 }
6262 if ($need_backup_by_time || $is_author_differ || $is_delete)
--- a/lib/file.php
+++ b/lib/file.php
@@ -171,7 +171,12 @@ function add_author_info($wikitext)
171171 {
172172 global $auth_user, $auth_user_fullname, $auth_type, $ldap_user_account;
173173 $author = preg_replace('/"/', '', $auth_user);
174- $displayname = preg_replace('/"/', '', $auth_user_fullname);
174+ $fullname = $auth_user_fullname;
175+ if (!$fullname && $author) {
176+ // Fullname is empty, use $author as its fullname
177+ $fullname = preg_replace('/^[^:]*:/', '', $author);
178+ }
179+ $displayname = preg_replace('/"/', '', $fullname);
175180 $user_prefix = '';
176181 switch ($auth_type) {
177182 case AUTH_TYPE_BASIC: