Deprecation notices

'Deprecation' notice...

adding your own code to SilverStripe 3, you might encounter a warning of the following nature:

[User Deprecated] SomeFunction is deprecated. Use SomeOtherFunction instead.

Although annoying at times,  this really is a good thing: it makes updating your code to the newest standards a whole lot easier! So I guess that adding deprecation notices is something I should do for my own modules as well, whenever I have changed methods that other code might hook onto or classes that others might use. So how does that work?

Adding your own...

Responsible for all this is the Deprecation class. It will generate these messages for each functions that call its nottice() method, like here in the DataObjectDecorator class:

public function __construct() {
	Deprecation::notice('3.0', 'Use DataExtension instead.');

This will generate the warning for every SilverStripe version up and above 3.0.0. - if your (test) environment is set to show these warnings that is. If you want to be able be to use SilverStripe in between. find the following in Sapphire _config.php: 

// If you don't want to see deprecation errors for the new APIs, change this to 3.0.0-dev.

 This will tell the Deprecation class that we're now on SilverStripe 3.0.0.  Any notifications for 3.0 and below will be displayed. Setting the value to 3.0.0-dev, as the comment suggest, will suppress all '3.0' notices like the one above,  but it won't suppress notices generated for SilverStripe 2.5 plus, if there are any...




But that, of course, is a hack (why ever do I mention these things?).


Het versturen van reacties is uitgeschakeld.

RSS feed voor reacties op deze pagina