3

What I did

  • Purposefully put $this->primaryKey('id') in my Table class
  • Call ->find('all')->all() on that Table inside Controller

What I expected

A deprecation notice at the top of my screen since primaryKey() is deprecated.

What actually happened

Everything worked with no errors shown

What have I checked

  • display_errors is On in phpinfo()
  • error_reporting is 32767 a.k.a. E_ALL in phpinfo()
  • $this->TESTprimaryKey('id') raises BadMethodCallException Unknown method "TESTprimaryKey", meaning it's the right Table
  • Error.errorLevel set to E_ALL in my app.php
  • php composer.phar upgrade and php composer.phar update just in case
  • VERSION.txt shows 3.6.10. All of this is also true for 4.2.4.
ᴍᴇʜᴏᴠ
  • 4,804
  • 4
  • 44
  • 57
  • Check that error reporting is enabled in php.ini file, Verify that `error_reporting = E_ALL` and `display_errors = On`. – pmarkoulidakis Aug 15 '18 at 13:47
  • @pmarkoulidakis Yes, I verified – ᴍᴇʜᴏᴠ Aug 15 '18 at 14:05
  • did you configure the errorLevel in your app.php ? – jbe Aug 15 '18 at 14:35
  • 1
    Are you using Debug Kit? If so, deprecation errors are intercepted and can be viewed in the **Deprecations** panel. – ndm Aug 15 '18 at 14:38
  • @ndm Honestly, your replies are the ones I'm actually waiting for each time I'm asking CakePHP-related questions. Can you please post this as an answer? – ᴍᴇʜᴏᴠ Aug 15 '18 at 15:16
  • @ndm your and ADmad's :) – ᴍᴇʜᴏᴠ Aug 15 '18 at 15:24
  • @ndm Reason why I haven't seen the panel is because this is a fresh install and first thing I did (after installing DebugKit) was implementing a JSON endpoint, which happened to be a content type hiding the DebugKit, including that panel. Not realising this, I expected the deprecation errors to show up at the top of the page. Do you think I should add this to [`cakephp/debug_kit`'s issues](https://github.com/cakephp/debug_kit/issues)? – ᴍᴇʜᴏᴠ Aug 15 '18 at 15:28
  • Well, I guess one could argue for as well as against having the deprecation warnings swallowed when debug kit isn't shown, but I guess the point is that they aren't actual problems that can cause things to fail, but just hints, and they can still be viewed via Debug Kits history, and they will show up in the test environment. – ndm Aug 15 '18 at 15:37

1 Answers1

6

This looks all good, E_ALL includes deprecations, and as long as debug is enabled in your app configuration, deprecation warnings will be shown (irrespectively of PHPs display_errors setting).

If you are using Debug Kit, deprecation warnings will be intercepted by it, and they can be found in the Deprecations panel.

ndm
  • 59,784
  • 9
  • 71
  • 110
  • Hi @ndm, if a page where a deprecation error is triggered redirects me away, I'm not seeing the Deprecations panel. And the logs aren't updated either. How do I then know there's a deprecation error? (If I disable the DebugKit altogether, the redirect gets aborted, and I do indeed see the deprecation warning.) – ᴍᴇʜᴏᴠ Apr 06 '21 at 18:11
  • @aexl I don't really have much to add to that since [**my last comment**](https://stackoverflow.com/questions/51859900/how-do-i-force-cakephp-3-and-cakephp-4-to-show-the-deprecation-warnings-notice/51861797?noredirect=1#comment90676014_51859900) from years ago ;) The errors will be available in debug kit's history, they will be shown in the test environment (make sure your application is properly covered by tests), and your production environment should swallow them (and possibly log them if configured accordingly). – ndm Apr 06 '21 at 18:43