One of the ideas rolling around in my head is an idea for a strict mode flag, a simple constant in settings.local.php. It would solve the problem of introducing error checking code or assertions that would break contrib modules. It would be used like this
function drupal_deprecated_function() {
assert('!defined(\'DRUPAL_STRICT\') || FALSE');
}
Drupal would ship as normal and by default the definition of DRUPAL_STRICT would be commented out. Somehow the core tests would always run with DRUPAL_STRICT set. Contrib module authors would be encouraged, but not required, to develop modules with Strict on.
There are other possibilities this opens and touches on. Thoughts?
Comments
Comment #2
Aki Tendo CreditAttribution: Aki Tendo commentedComment #3
cilefen CreditAttribution: cilefen commentedSee related #2575081: [policy, no patch] Use E_USER_DEPRECATED in Drupal 8 minor releases and #2488860: Bring phpunit bridge into drupal and use it for unit tests and simpletest to handle Deprecation.
Comment #4
Aki Tendo CreditAttribution: Aki Tendo commentedComment #5
Aki Tendo CreditAttribution: Aki Tendo commentedComment #6
Aki Tendo CreditAttribution: Aki Tendo commentedWhile I used deprecated for the example and agree they are related, deprecated functionality is only part of the scope. Consider the following line I'd like to be able to put in the Drupal\Core\Template\Attribute class
The new function referenced there, validAttributeName, checks the passed name parameter against a regular expression based on the W3C's published guidelines on attribute names. In the unlikely event a contrib module is tossing in an invalid attribute name - say my?attribute - this assertion would fire and the code would break in dev. Since it's an assertion it would continue to run in prod, but that just forestalls an immediate disaster since most dev houses won't be too happy about needing to turn assertions off just to get a contrib module through tests.
So this has a slightly wider scope than just deprecation.
Comment #7
cilefen CreditAttribution: cilefen commentedI know but they are similar notions.
Comment #8
xjmComment #14
apaderno