xoops forums

Peekay

XOOPS is my life!
Posted on: 2010/8/3 12:07
Peekay
Peekay (Show more)
XOOPS is my life!
Posts: 2335
Since: 2004/11/20
#11

Re: Deprecated method replacements?

Quote:
But doesn't depreciated mean, don't use these functions because they are going away?

Absolutely. AFAIK, someone creating a new module from scratch shouldn't use them.

The xoofoo site does show deprecated methods in some Xoops versions, but it doesn't show replacements... which is why I optimistically left gaps in the original post
A thread is for life. Not just for Christmas.

trabis

Core Developer
Posted on: 2010/8/3 18:35
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#12

Re: Deprecated method replacements?

If you look inside the code of the deprecated functions, you should get your answers
Example:
function makeTboxData4Show($text$smiley 0)
    {
        
$GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ "::" __FUNCTION__ ' is deprecated');
        
$text $this->htmlSpecialChars($text);
        return 
$text;
    }

If you see
$myts->makeTboxData4Show($text);
You should replace it with
$myts->htmlSpecialChars($text);

We are supporting the last 2 versions of Xoops:
2.3.x and 2.4.x

When we release 2.5 we will be supporting:
2.4.x and 2.5.x

All 2.3.x deprecated methods should be removed on 2.5.x, another good reason for getting modules moved to blue ASAP.

I say "should" and not "will" because this is my understanding. The core team will have to discuss it before implementation.

Catzwolf

Home away from home
Posted on: 2010/8/4 0:25
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#13

Re: Deprecated method replacements?

Plus, many of what are being called depreciated, In my eyes shouldn't be and many others actually while being called depreciated have no real alternatives. (Unless you do it yourself, which seems to fast becoming the motto of Xoops) .

redheadedrod

Home away from home
Posted on: 2010/8/4 2:28
redheadedrod
redheadedrod (Show more)
Home away from home
Posts: 1296
Since: 2008/2/26
#14

Re: Deprecated method replacements?

This makes me wonder why they became depreciated in the first place? Generally my impression is that things become depreciated because there is a better way of doing them.

trabis

Core Developer
Posted on: 2010/8/4 12:46
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#15

Re: Deprecated method replacements?

Quote:

Catzwolf wrote:
Plus, many of what are being called depreciated, In my eyes shouldn't be and many others actually while being called depreciated have no real alternatives. (Unless you do it yourself, which seems to fast becoming the motto of Xoops) .


Could you be specific? In my understanding there is only one class that fits your description, XoopsTree. There is an alternative, XoopsObjectTree, but it requires modules to use XoopsObject and XoopsObjectHandler, which forces some old modules to be completely rewritten.
XoopsObjectTree can also cause memory overload when used with $handler->getObjects() instead of $handler->getAll(). Since it is mainly used to populate categories dropdown boxes, it is very easy to call 1000 objects with description and other fields that are not required at all and exhaust memory. I would keep XoopsTree, yeah.

ghia

Community Support Member
Posted on: 2010/8/4 12:48
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#16

Re: Deprecated method replacements?

Quote:
This makes me wonder why they became depreciated in the first place?
Sometimes the function names does not fit no longer or the developer decided for new ones.

Peekay

XOOPS is my life!
Posted on: 2010/8/4 16:02
Peekay
Peekay (Show more)
XOOPS is my life!
Posts: 2335
Since: 2004/11/20
#17

Re: Deprecated method replacements?

OK, so based on the WIKI article, this is current:

Xoops 2.4.5

These methods are valid:

smiley()
makeClickable()
xoopsCodeDecode()
nl2Br()
addSlashes()
htmlSpecialChars()
undoHtmlSpecialChars()
displayTarea()
previewTarea()

These methods are deprecated. The replacement is shown:

makeTboxData4Save()
makeTareaData4Save()

Use instead: addSlashes()

makeTboxData4Show()
makeTboxData4Edit()
makeTareaData4InsideQuotes()
makeTareaData4Edit()

Use instead: htmlSpecialChars();

makeTareaData4Show()

Use instead: displayTarea();

makeTareaData4Preview()

Use instead: previewTarea();

makeTboxData4Preview()
makeTboxData4PreviewInForm()
makeTareaData4PreviewInForm()

use instead: htmlSpecialChars() combined with stripSlashesGPC()

Example usage:

$ts->htmlSpecialChars($ts->stripSlashesGPC($text));


That just leaves:

* MyTextSanitizer::codeSanitizer()

* MyTextSanitizer::sanitizeForDisplay()

* MyTextSanitizer::sanitizeForPreview()

* MyTextSanitizer::oopsStripSlashesGPC()

* MyTextSanitizer::oopsStripSlashesRT()

* MyTextSanitizer::oopsAddSlashes()

* MyTextSanitizer::oopsNl2Br()

If someone can provide replacements for those, then it's QED!
A thread is for life. Not just for Christmas.

Catzwolf

Home away from home
Posted on: 2010/8/4 16:39
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#18

Re: Deprecated method replacements?

Quote:
MyTextSanitizer::codeSanitizer()


There is no alternative to this.

Quote:
MyTextSanitizer::sanitizeForDisplay()


use MyTextSanitizer::displayTarea()

Quote:
MyTextSanitizer::sanitizeForPreview()


use MyTextSanitizer::previewTarea()

Quote:
MyTextSanitizer::oopsStripSlashesGPC()


stripslashes is regarded as deprecated as of php 5.3, but until the time useMyTextSanitizer::stripSlashesGPC()

Quote:
MyTextSanitizer::oopsStripSlashesRT()


same as above

Quote:
MyTextSanitizer::oopsAddSlashes()


MyTextSanitizer::addSlashes();

Quote:
MyTextSanitizer::oopsNl2Br()


MyTextSanitizer::nl2br();

use PHP native htmlspecialchars() rather than the one provided in $myts.

if you are not going to use XoopsObect class for dealing with saving to database, do not use addslashes use mysql_real_escape_string

Peekay

XOOPS is my life!
Posted on: 2010/8/4 16:43
Peekay
Peekay (Show more)
XOOPS is my life!
Posts: 2335
Since: 2004/11/20
#19

Re: Deprecated method replacements?

That's great catzwolf, many thanks indeed

Quote:
use PHP native htmlspecialchars() rather than the one provided in $myts.

Do you recommend this for all instances where htmlspecialchars is the replacement? Is there a problem with the sanitiser version?
A thread is for life. Not just for Christmas.

Catzwolf

Home away from home
Posted on: 2010/8/4 17:44
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#20

Re: Deprecated method replacements?

Quote:

Peekay wrote:
That's great catzwolf, many thanks indeed

Quote:
use PHP native htmlspecialchars() rather than the one provided in $myts.

Do you recommend this for all instances where htmlspecialchars is the replacement? Is there a problem with the sanitiser version?


Yes I do, I don't see the need of loading a entire class just to use one function, especially when the php equivalent has the exact same functionality.

I would have said the same about stripslashes and addslashes as well, but due to the different server set-ups, the actual $myts version is more appropriate. I cannot wait to see the back of these two functions, they have caused developers more headaches than they are worth.