⚠️ Deprecated Functions
Complete list of deprecated XOOPS functions, methods, and patterns with their modern replacements.
Overview
This document lists functions and patterns that are deprecated in XOOPS 2.5.x and will be removed in XOOPS 2026. Update your code to use the modern alternatives.
flowchart LR
A[Deprecated Function] --> B{Still Works?}
B -->|Yes| C[Shows Warning]
B -->|No| D[Fatal Error]
C --> E[Update Code]
D --> E
E --> F[Modern Alternative]
Global Functions
Handler Functions
| Deprecated | Replacement | Since |
xoops_getHandler() | $helper->getHandler() | 2.5.9 |
xoops_getModuleHandler() | $helper->getHandler() | 2.5.9 |
xoops_getActiveModules() | ModuleHandler::getActiveModules() | 2.5.10 |
// ❌ Deprecated
$handler = xoops_getModuleHandler('item', 'mymodule');
// ✅ Modern
$helper = \XoopsModules\MyModule\Helper::getInstance();
$handler = $helper->getHandler('Item');
Utility Functions
| Deprecated | Replacement | Since |
xoops_trim() | trim() | 2.5.0 |
xoops_substr() | mb_substr() | 2.5.0 |
xoops_convert_encoding() | mb_convert_encoding() | 2.5.0 |
formatTimestamp() | date() or Carbon | 2.5.9 |
xoops_makepass() | random_bytes() | 2.5.10 |
// ❌ Deprecated
$trimmed = xoops_trim($string);
$sub = xoops_substr($string, 0, 100);
// ✅ Modern
$trimmed = trim($string);
$sub = mb_substr($string, 0, 100, 'UTF-8');
XoopsObject Methods
Variable Methods
| Deprecated | Replacement | Since |
getVar('field', 's') | getVar('field', 'show') | 2.5.0 |
getVar('field', 'f') | getVar('field', 'form') | 2.5.0 |
getVar('field', 'n') | getVar('field', 'none') | 2.5.0 |
// ❌ Deprecated short format
$title = $item->getVar('title', 's');
// ✅ Modern explicit format
$title = $item->getVar('title', 'show');
// Or for editing
$title = $item->getVar('title', 'edit');
Constructor Pattern
// ❌ Deprecated PHP 4 style
class MyObject extends XoopsObject
{
function MyObject() // PHP 4 constructor
{
$this->XoopsObject();
}
}
// ✅ Modern PHP 7+ style
class MyObject extends XoopsObject
{
public function __construct()
{
parent::__construct();
}
}
Database Methods
Direct Query Methods
| Deprecated | Replacement | Since |
$xoopsDB->query() (raw SQL) | Prepared statements | 2.5.10 |
$xoopsDB->queryF() | $xoopsDB->query() with escaping | 2.5.10 |
mysql_* functions | PDO or mysqli | PHP 7.0 |
// ❌ Deprecated - SQL injection risk
$sql = "SELECT * FROM " . $xoopsDB->prefix('items') .
" WHERE id = " . $_GET['id'];
$result = $xoopsDB->query($sql);
// ✅ Modern - Using Criteria
$criteria = new \Criteria('id', (int)$_GET['id']);
$items = $handler->getObjects($criteria);
// ✅ Modern - Prepared statement (2026)
$stmt = $db->prepare("SELECT * FROM items WHERE id = ?");
$stmt->execute([(int)$_GET['id']]);
| Deprecated | Replacement | Since |
new XoopsFormTextArea($caption, $name, $value, $rows, $cols) | Use named parameters | 2026 |
// ❌ Deprecated positional parameters
$textarea = new XoopsFormTextArea('Content', 'content', '', 10, 60);
// ✅ Modern with config array (recommended for clarity)
$editor = new XoopsFormEditor('Content', 'content', [
'name' => 'content',
'value' => '',
'rows' => 10,
'cols' => 60,
'width' => '100%',
'height' => '400px'
]);
Token Methods
// ❌ Deprecated
if (!$GLOBALS['xoopsSecurity']->check()) { ... }
// ✅ Modern (XMF)
use Xmf\Request;
if (!Request::checkToken()) {
redirect_header('index.php', 3, 'Invalid token');
}
Security Functions
Password Hashing
| Deprecated | Replacement | Since |
md5($password) | password_hash() | 2.5.9 |
crypt($password) | password_hash() | 2.5.9 |
// ❌ Deprecated - Insecure
$hash = md5($password);
// ✅ Modern
$hash = password_hash($password, PASSWORD_DEFAULT);
$valid = password_verify($input, $hash);
// ❌ Deprecated
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$name = isset($_POST['name']) ? $myts->htmlSpecialChars($_POST['name']) : '';
// ✅ Modern (XMF Request)
use Xmf\Request;
$id = Request::getInt('id', 0, 'GET');
$name = Request::getString('name', '', 'POST');
Template Variables
Global Variables
| Deprecated | Replacement | Since |
$xoopsTpl global | Dependency injection | 2026 |
$xoopsUser global | UserHandler service | 2026 |
$xoopsDB global | Database service | 2026 |
// ❌ Deprecated globals
global $xoopsTpl, $xoopsUser, $xoopsDB;
// ✅ Modern (2.5.x)
$helper = \XoopsModules\MyModule\Helper::getInstance();
$xoopsTpl = $GLOBALS['xoopsTpl'];
// ✅ Modern (2026) - Dependency injection
public function __construct(
private readonly TemplateEngine $template,
private readonly UserInterface $user,
private readonly Connection $db
) {}
Class Autoloading
Manual Includes
// ❌ Deprecated manual includes
require_once XOOPS_ROOT_PATH . '/modules/mymodule/class/item.php';
require_once XOOPS_ROOT_PATH . '/modules/mymodule/class/category.php';
// ✅ Modern PSR-4 autoloading
use XoopsModules\MyModule\Item;
use XoopsModules\MyModule\Category;
$item = new Item();
Reference Returns
// ❌ Deprecated - Reference returns
function &getInstance()
{
static $instance;
if (!isset($instance)) {
$instance = new self();
}
return $instance;
}
// ✅ Modern - No reference needed
public static function getInstance(): self
{
static $instance;
return $instance ??= new self();
}
Template Syntax
Smarty 2 Syntax
{* ❌ Deprecated Smarty 2 section syntax *}
<{section name=i loop=$items}>
<{$items[i].title}>
<{/section}>
{* ✅ Modern Smarty 3+ foreach syntax *}
<{foreach item=item from=$items}>
<{$item.title}>
<{/foreach}>
Migration Checklist
Use this checklist when updating code:
Removal Timeline
timeline
title Deprecation Timeline
2.5.9 : Functions deprecated
: Warnings added
2.5.11 : More warnings
: Strict mode available
2026 : Functions removed
: Breaking changes
: PSR compliance required
xoops #deprecated #migration #reference #legacy