torrentpier/library/ajax
Yury Pikhtarev 74a564d795
refactor(censor): migrate Censor class to singleton pattern ()
* refactor(censor): migrate Censor class to singleton pattern

- Convert TorrentPier\Censor to singleton pattern following Config class design
- Add global censor() helper function for consistent API access
- Replace all global $wordCensor declarations and usage across 12 files
- Implement automatic reload functionality in admin panel
- Add enhanced methods: isEnabled(), addWord(), getWordsCount(), reload()

Files updated:
- src/Legacy/Atom.php, src/Legacy/Post.php
- viewforum.php, posting.php, search.php, index.php, viewtopic.php, privmsg.php
- library/ajax/posts.php, library/includes/bbcode.php, library/includes/ucp/topic_watch.php
- admin/admin_words.php, library/includes/init_bb.php
- common.php (added global helper)
- UPGRADE_GUIDE.md (documentation)

Benefits:
- Single instance shared across application for better performance
- Memory efficient word loading only when censoring enabled
- Consistent API pattern matching config() singleton
- Automatic word reloading when admin updates censored words
- Enhanced developer experience with new utility methods

BREAKING CHANGE: None - full backward compatibility maintained.
The global $wordCensor variable continues to work as before.
New censor() function is the recommended approach going forward.

* refactor(censor): add enable check to censorString method

* refactor(dev): convert Dev class to singleton pattern ()

* refactor(dev): convert Dev class to singleton pattern

- Convert TorrentPier\Dev class from direct instantiation to singleton pattern
- Add getInstance() method and private constructor for singleton implementation
- Introduce new instance methods with improved naming:
  * getSqlDebugLog() (replaces getSqlLog())
  * checkSqlDebugAllowed() (replaces sqlDebugAllowed())
  * formatShortQuery() (replaces shortQuery())
- Add dev() global helper function for consistent access pattern
- Maintain full backward compatibility with existing static method calls
- Update all internal usage across 18 files to use new singleton pattern:
  * src/Ajax.php, src/Legacy/SqlDb.php
  * All Cache classes (APCu, File, Memcached, Redis, Sqlite, Common)
  * All Datastore classes (APCu, File, Memcached, Redis, Sqlite, Common)
  * library/includes/page_footer_dev.php
- Implement lazy initialization consistent with Config and Censor singletons
- Add comprehensive migration guide in UPGRADE_GUIDE.md

This refactoring improves resource management, provides consistent API patterns
across all singleton classes, and maintains zero breaking changes for existing code.

* refactor(dev): Added missing `\TorrentPier\Dev::init()`

---------

Co-authored-by: Roman Kelesidis <roman25052006.kelesh@gmail.com>
2025-06-18 10:38:23 +04:00
..
avatar.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
callseed.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
change_tor_status.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
change_torrent.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
change_user_opt.php misc(copyright): Updated copyright year () 2025-01-15 15:25:04 +03:00
change_user_rank.php misc(copyright): Updated copyright year () 2025-01-15 15:25:04 +03:00
edit_group_profile.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
edit_user_profile.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
ffprobe_info.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
group_membership.php misc(copyright): Updated copyright year () 2025-01-15 15:25:04 +03:00
index_data.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
manage_admin.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
manage_user.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
mod_action.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
passkey.php Revert "refactor: Moved classes from Legacy folder to src root ()" 2025-03-02 10:07:04 +03:00
post_mod_comment.php misc(copyright): Updated copyright year () 2025-01-15 15:25:04 +03:00
posts.php refactor(censor): migrate Censor class to singleton pattern () 2025-06-18 10:38:23 +04:00
sitemap.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
thanks.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
topic_tpl.php misc(copyright): Updated copyright year () 2025-01-15 15:25:04 +03:00
user_register.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
view_post.php feat: implement centralized Config class to replace global $bb_cfg array () 2025-06-18 01:19:49 +04:00
view_torrent.php Revert "refactor: Moved classes from Legacy folder to src root ()" 2025-03-02 10:07:04 +03:00