11
Peekay
Re: Deprecated method replacements?
  • 2010/8/3 12:07

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


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.

12
trabis
Re: Deprecated method replacements?
  • 2010/8/3 18:35

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


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.

13
Catzwolf
Re: Deprecated method replacements?
  • 2010/8/4 0:25

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


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) .

14
redheadedrod
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.


15
trabis
Re: Deprecated method replacements?
  • 2010/8/4 12:46

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


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.

16
ghia
Re: Deprecated method replacements?
  • 2010/8/4 12:48

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


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.

17
Peekay
Re: Deprecated method replacements?
  • 2010/8/4 16:02

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


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.

18
Catzwolf
Re: Deprecated method replacements?
  • 2010/8/4 16:39

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


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

19
Peekay
Re: Deprecated method replacements?
  • 2010/8/4 16:43

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


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.

20
Catzwolf
Re: Deprecated method replacements?
  • 2010/8/4 17:44

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


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.

Login

Who's Online

179 user(s) are online (106 user(s) are browsing Support Forums)


Members: 0


Guests: 179


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits