Usage of Deprecated Code

  • Dear developers,

    over the past few years with several new versions, some components have accumulated that we have marked as deprecated. In the plugin store, there are still some packages that use components that have been deprecated since version 2.1. In order to be able to remove this old code, we would like to draw attention to relevant code and explain its migration.

    In this context, we would like to explicitly point out that we are already creating a migration guide while developing new versions. So there is already an overview of changes for version 5.5, especially a list of components that are deprecated or removed with version 5.5.

    Below, we have created an overview of some deprecated components that we would like to remove soon, but some of them are still used in packages in the plugin store.

    PHP

    AttachmentBBCode::setAttachmentList()/AttachmentBBCode::setObjectID()

    Since the introduction of the embedded objects API with version 2.1, which is not only used for attachments but also other embedded contents,

    AttachmentBBCode::setAttachmentList() and AttachmentBBCode::setObjectID() are not needed anymore because the values set via these methods are only used, if AttachmentBBCode cannot access an attachment via the embedded objects API.

    So, if the embedded objects API is used, calls of these two methods can be removed. Otherwise, the code should be migrated to the embedded objects API urgently.

    FileUtil::downloadFileFromHttp()

    FileUtil::downloadFileFromHttp() is deprecated since Version 2.0 and should, depending on the version of WoltLab Suite you support, be replaced with HTTPRequest or directly with Guzzle.

    BlogDatabaseObject/CALENDARDatabaseObject/GalleryDatabaseObject/FilebaseDatabaseObject/WBBDatabaseObject

    App-specific DatabaseObject classes are not needed anymore since version 2.1 because the app prefix for the database tables is determined by DatabaseObject itself. Instead of inheriting from the app-specific DatabaseObject classes, you can directly inherit from DatabaseObject.

    IEventListener

    IEventListener is deprecated since version 2.1 and should be replaced with IParameterizedEventListener or AbstractEventListener. With version 5.5, we will add new event classes, which we already explain in our migration guide for version 5.5.

    ClassUtil::isInstanceOf()

    ClassUtil::isInstanceOf() is deprecated since version 3.0 and should be replaced with is_subclass_of().

    appendSession and forceWCF Parameter for LinkHandler::getLink()

    The session parameter appendSession and forceWCF are only deleted from the parameter array of LinkHandler::getLink() since version 3.0 and are unused. Thus, they can be removed from the parameter array in method calls.

    Mail

    The Mail class is deprecated since version 3.0 and should be replaced with wcf\system\email\Email or wcf\system\email\SimpleEmail.

    UserProfile::getUserProfile() and UserProfile::getUserProfiles()

    UserProfile::getUserProfile() and UserProfile::getUserProfiles() are deprecated since version 3.0 and should be replaced with UserProfileRuntimeCache::getObject() and UserProfileRuntimeCache::getObjects(), respectively. Note that the return value of UserProfileRuntimeCache::getObjects() contains null entries for non-existing users.

    Event Listeners and Cronjobs without Names

    Since version 3.0, event listeners and cronjobs support the name attribute to identify the event listeners and cronjobs. Event listeners and cronjobs without explicit names should be replaced with event listeners and cronjobs with names.

    IStackableUserNotificationObject

    IStackableUserNotificationObject is deprecated since version 3.1 and is unused. Thus, the interface should not be implemented anymore.

    EntryDataHandler/EventDataHandler/ImageDataHandler/PostDataHandler/CommentDataHandler

    The DataHandler classes were replaced by matching RuntimeCache classes and should not be used anymore.

    Note: filebase\system\file\FileDataHandler will only be deprecated with version 5.5 and replaced by filebase\system\cache\runtime\FileRuntimeCache.

    UserNotificationHandler::deleteNotifications()

    UserNotificationHandler::deleteNotifications() is deprecated since version 2.1 and should be replaced with calls of UserNotificationHandler::markAsConfirmed() (with the same method signature).

    CryptoUtil methods

    CryptoUtil::secureCompare() is deprecated since version 5.2 and should be replaced with \hash_equals(). CryptoUtil::randomBytes() is deprecated since version 5.2 and should be replaced with \random_bytes(). CryptoUtil::randomInt() is deprecated since version 5.2 and should be replaced with \random_int().

    To encode security-relevant data, which were generated with \random_bytes(), for example, a constant time encoder should be used as of version 5.4.

    Callback

    The Callback class is deprecated since version 3.0 and should not be used anymore.

    Obsolete Page Components

    Since the overhaul of the pages and introduction of CMS pages with version 3.0, IBreadcrumbProvider, IHistorySavingObjectTypeProvider::getActivePageMenuItem(), ISearchableObjectType::getActiveMenuItem(), ITrackablePage, IUserOnlineLocation, and UserOnlineLocationHandler are deprecated and should not be used anymore.

    AbstractHtmlInputNodeProcessorListener Methods

    AbstractHtmlInputNodeProcessorListener::replaceLinksWithBBCode() and AbstractHtmlInputNodeProcessorListener::setObjectTitles() are deprecated since version 3.0 and should be replaced by AbstractHtmlInputNodeProcessorListener::replaceLinks().

    SearchIndexManager::add() and SearchIndexManager::update()

    SearchIndexManager::add() and SearchIndexManager::update() are deprecated since version 3.0 and should be replaced with SearchIndexManager::set().

    SystemException

    SystemException, although not officially deprecated, is no longer used by us in new code. Instead, we use exceptions from the SPL or our own exception classes. Therefore, as far as possible, SystemException should no longer be thrown in plugins. Since SystemException is still thrown by existing code, they may also need to be caught. However, it may be possible to catch all \Exception instead.

    JavaScript

    WCF_CLICK_EVENT

    WCF_CLICK_EVENT should be replaced by "click" in in JavaScript- and TypeScript code.

    WCF.ACP.Worker

    WCF.ACP.Worker is deprecated since version 3.1 and can easily be replaced with WoltLabSuite/Core/Acp/Ui/Worker.

    Templates

    $__wcfVersion

    The template variable $__wcfVersion to break browser caches is deprecated since version 2.1 and should be replaced with LAST_UPDATE_TIME.

    DateDiffModifierTemplatePlugin

    DateDiffModifierTemplatePlugin is deprecated since version 3.1 and should be replaced with DateIntervalFunctionTemplatePlugin.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!