Bharanikumar
Bharanikumar

Reputation: 25733

joomla 2.5.14 JRegistry::getValue() is deprecated

In my application logs folder, i am seeing the below error log multiple time, Why this log is occurring and i would like to know, in which situation this log will be occur.

WARNING deprecated  JRegistry::getValue() is deprecated. Use get instead

I understand, the function getValue() dperecated in 2.5.14.

i would like to know, in which situation this error log is occuring.

Upvotes: 2

Views: 1809

Answers (2)

MasterAM
MasterAM

Reputation: 16478

The Joomla log provides the warning, but not its origin (the "offending" function).

The error is produced by the JRegistry class, in:

libraries/joomla/registry/registry.php:583.

You can do one of several things, most are rather obvious:

  1. Search your entire project or suspicious parts of it for an "incriminating" expression, such as ‑>getValue(, possibly using a regexp. This is less than optimal, as other classes have getValue() methods as well.
  2. If you are able to cause the error to appear in log due to an action you performed, you can set a breakpoint in your code, start a debugging session and easily catch the function that uses this.

  3. Change the code that produces the error to include the calling function. This could help you identify the culprit, but it involves editing a core file, so use carefully and consider this a temporary fix. You can revert the file to its original state once the problem is identified. Do something like:

    $caller = array_shift(debug_backtrace());
    $data = $caller['file'].':'$caller['line'];
    JLog::add('JRegistry::getValue() is deprecated. Use get instead. At: '.$data, JLog::WARNING, 'deprecated');
    

I do wonder why Joomla does not seem to have the ability to configure adding the stack trace to the log.

Upvotes: 0

Dmitrijs Rekuns
Dmitrijs Rekuns

Reputation: 543

Well it is simple - this log entry is added when JRegistry::getValue() is used in the code. For example consider this part of code:

$registry = new JRegistry;  
$value = $registry->getValue('myVal');

Using $registry->getValue('myVal'); will add such log entry. The developer should use this instead:

$value = $registry->get('myVal');

Hope it's clear for you now.

Upvotes: 2

Related Questions