0

I have developed a website using CakePHP 2.4 and the server where i have uploaded website are using PHP 5.4. Everything is working correcctly, but as i have used AjaxHelper and JavascriptHelper in the website. It is generating warnings like:

Strict (2048): Declaration of JavascriptHelper::value() should be compatible with Helper::value($options = Array, $field = NULL, $key = 'value') [APP/View/Helper/JavascriptHelper.php, line 23]

Strict (2048): Declaration of JavascriptHelper::afterRender() should be compatible with Helper::afterRender($viewFile) [APP/View/Helper/JavascriptHelper.php, line 23]

Strict (2048): Declaration of AjaxHelper::afterRender() should be compatible with Helper::afterRender($viewFile) [APP/View/Helper/AjaxHelper.php, line 1398]

I am not clear as why is this happening? Is there any problem regarding versions?? Please help me.

Casey Rule
  • 2,085
  • 2
  • 18
  • 28
Divya Verma
  • 19
  • 1
  • 5
  • 3
    CakePHP 2.4 does not have an AjaxHelper. Regardless, the error message is pretty clear. Make sure the signatures of the methods are exactly same as that of the overridden parent class method. – ADmad Nov 18 '14 at 05:02
  • It comes with a compatibility problem with PHP5.4. By installing PHP5.3, it works. https://groups.google.com/forum/#!msg/cakephp-pt/t7A8T4w5Kzc/aOQmBlIS04sJ also here http://www.grafikart.fr/forum/topic/6638 – Zeeshan Nov 18 '14 at 05:17
  • Awesome idea @Zeeshan Let's downgrade to an outdated, not anymore maintained, EOL reached PHP version so that we are able to continue using our messed up code :) – ndm Nov 18 '14 at 05:29
  • But as server is using PHP 5.4, so how can i resolve this problem. I just need to make ajax calls in webpages(during pageload and on button click), if i can't use AjaxHelper, then what could be the alternate?? – Divya Verma Nov 18 '14 at 05:30
  • `AjaxHelper` and `JavaScriptHelper` are CakePHP 1.x relicts that were removed in CakePHP 2.x, you shouldn't be using them anymore at all! In 2.x there's only `JsHelper`, and it's alredy deprecated (but working). Simply use plain JavaScript, there's really no need for such helpers. That being said, as @ADmad already said, the general fix for such a problem is to make sure the method signatures are matching, a simple google search for the error message should get you a lot of helpful results, such as **http://stackoverflow.com/q/21092605/1392379** – ndm Nov 18 '14 at 05:36
  • 1
    @DivyaVerma Read the error message carefully and try to understand what it means. It already tells you how the problem can be fixed. – ADmad Nov 18 '14 at 05:40
  • @DivyaVerma use the search function and Google for these trivial kind of problems. Copy paste error message, click search, done. This has been asked a felt million times before. But I don't understand why there is a need to search for a solution the error message already explains the issue very well. – floriank Nov 18 '14 at 08:55
  • Thanx @ndm and everyone, my problem has been resolved. I am now using Plain Javascript without using any helper and everything is working perfectly. Thanks a lot again. – Divya Verma Nov 18 '14 at 09:17
  • @burzum i have searched for this problem many times on google, but was not getting solutions. Everything was working correctly on localhost, but on server, it was generating warnings etc. So at the end, i thought of discussing my issue here and "ndm" gave me satisfying solution. – Divya Verma Nov 18 '14 at 09:21

2 Answers2

0

as other already said, the message contains the proposal to change

afterRender

into

afterRender($viewFile)

within in the file mentioned in the error message. Not that hard to understand :)

l8erz

-d1g

-1

http://api.cakephp.org/2.5/source-class-JsHelper.html#23-436

Copy the jshelpercode and paste it into folder view/helper/JsHelper.php

Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89
pawan
  • 1