-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Civix could (or should?) offer in-line-replacements for dropped deprecated functions #296
Comments
There are literally thousands of functions in CiviCRM and any one of them could be called from an extension, so I don't know how realistic it is to do something like that for every function we deprecate out of core. I do encourage people to copy core functions to extensions rather than to call core functions, other than the api & a few specific classes that are clearly supported. What Tim did suggest was a tool to find deprecated functions (much like our IDEs provide). Note that the recommended syntax for these functions is to use the PseudoConstant class - ie Having said all that - the |
I see your point. On the other hand, we maintain over a hundred extensions, so we need a more or less standardised approach - one where we have a set of in-line replacements for each deprecated function in a common component, so the actual update is a search&replace kind of affair - otherwise this is not manageable for us. IMHO, the location of the replacement code could be in:
I can understand that you're uneasy with 3., and if you say that it's not happening, we'll probably focus on 2. |
Thanks @bjendres! I'd vote for some kind of implementation in Civix (identification or doing recommended replacements or doing legacy-style replacements) as long as CiviCRM Core will go on removing deprecated functionality in minor releases, which is forcing extension developers to adapt to deprecations with at least the next security update of CiviCRM Core after removal of code. |
Hmm - it's worth noting that this will have been putting out deprecated notices for a long time if you had your php allowing these to show - we have over time removed a considerable number of internal core functions - but we do commit to not changing those functions that we support for external use - ie in this case the supported alternatve has been around since 2014 and the So iI'm sure we would be OK with a PR to add a mixin for It's also worth noting that unit tests fail when they hit these deprecations so if you had been running CI over these extensions you would have had to fix them years ago - which also feels like a better use of time. |
I think we're in agreement about the problem but not the solution. Deprecation notices are buried in the Civi logs which has a poor signal-to-noise ratio. Many deprecation notices (at least historically) are triggered by the core code itself. It's difficult to find the ones that need action taken. I suspect that if there was better visibility on use of deprecated functions, that would satisfy everyone's needs. CiviCRM has always been hard to statically analyze - its autoloader is quirky and the CMS integration makes it worse. I haven't looked at Bradley's PHPStan for Civi work but I suspect if it was easy for folks to generate reports of deprecated functions in extensions this need would be far less urgent. |
@MegaphoneJon don't the deprecation notices show up for you when you navigate the site (on dev instances) - because as long as your error reporting permits (which is should on dev sites) they should (they show up red in the UI for me although I normally pick them up through unit tests) |
@eileenmcnaughton Sometimes, but a) Smarty notices make it hard to spot deprecation notices, b) more often than not, deprecation notices are happening during non-interactive code execution - CiviMail, CiviRules, etc. |
Ok - it would be good if civi-generated deprecation notices bubbled up to system check errors - deprecations are pretty easy to find in an IDE - but people have to be looking. |
@bjendres Good topic. The thread has gone a few ways, so I'll just post some thoughts in no particular order:
|
CiviCRM core dropped the (long deprecated)
CRM_Core_OptionGroup::getValue
with version5.60
, which caused a bit of havoc for us (see e.g. here). Sure, we could've replaced this a long time ago, but then again there was no deadline... so it never ended up at the top of anyone's list.What we did, is to add a drop-in replacement functions in the extension's code, so the act of making the extension compatible is really easy, see here. We put the code into our CustomDataHelper, which is essentially a poor man's
civix
mixin (plus some other stuff).I think, a far better place for the implementation of such drop-in function replacements would be
civix
.It could even apply the replacement of deprecated functions within the
civix
upgrade process.@totten what do you think?
The text was updated successfully, but these errors were encountered: