Field.php - difference in path between local PC and hosted server for call_user_func(

Field.php - difference in path between local PC and hosted server for call_user_func(

tpaulsmetpaulsme Posts: 4Questions: 0Answers: 0
edited November 2012 in Editor
Downloaded DataTables v 1.9.4 & Editor to evaluate Editor for purchase.

Finally got Firebug to display something in Console. Needed to re-install it as either it was not working, or I could not get it to display the Console data, even though I enabled it, as shown in the Youtube demos. It did work as expected and display in Console after a re-install.

Using my local Windows PC for development which is running WAMP I went to:

/datatables/extras/Editor/examples/index.html

and selected 1 row and clicked Edit and then Update

I kept getting a POST Response:

Warning: call_user_func() expects parameter 1 to be a valid callback, class '\DataTables\Editor\Validate' not found in E:\Todd\git\tutti_systems\Tutti Systems\public_html\datatables\extras\Editor\examples\php\lib\Editor\Field.php on line 379


But, when I uploaded to my VPS at my hosting company, it worked fine.

So, on line 379, I changed from:

[code]return call_user_func( "\\DataTables\\Editor\\".$this->_validator, $val, $data, $this->_validatorOpts );[/code]

to this FIX:

[code]return call_user_func( "DataTables\\Editor\\".$this->_validator, $val, $data, $this->_validatorOpts );[/code]

and it works on both my local Windows PC using WAMP and on my VPS at my hosting company. It appears to me I've just made this a relative path. Correct?

I assume that the way it's working on my hosted server, but not my local WAMP on my PC, is a difference between either Apache on a Windows/Apache/WAMP versus a Linux server, or a difference in the two httpd.conf settings.

QUESTION: A) Is the FIX above that I implemented a change you'd make to the Field.php file in a future release [or via some other type of fix],

or B) should I try and figure out why my local Windows PC using WAMP does not handle that path the same as my hosted server?

If B) you have any idea what setting to look at?

Thanks!

Todd

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Todd,

    Thanks for your post and suggested fix. The `\DataTables...` is a reference to the root namespace (in which the `DataTables` lives) so that should work okay. As you say, it has made the namespace relative, so its an okay change to make since the `DataTables` namespace is available, however, it shouldn't be needed.

    My first thought is, what version of PHP are using using in your local WAMP environment and what on the remote server?

    Regards,
    Allan
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Follow up Allan's query re PHP versions.
    The behaviour of call_user_func() changed between one version and another. Sorry I can't remember exactly which versions.
  • tpaulsmetpaulsme Posts: 4Questions: 0Answers: 0
    Allan, Thanks for asking about the PHP version.

    Yes, it's a PHP version issue:

    PHP on server is 5.3.8.

    With PHP on local WAMP as 5.3.1 the following fails with the aforementioned error:
    [code]return call_user_func( "\\DataTables\\Editor\\".$this->_validator, $val, $data, $this->_validatorOpts );[\code]

    With PHP on local WAMP as 5.3.13 the above code works. Nice that WAMP makes it easy to switch PHP versions in just a 2 seconds. It's more effort than I want to put out to do a 'git' and build of PHP 5.3.8 to get it into WAMP. I was trying to run behind the server with 5.3.1. Oh, well. Guess I'll run local ahead of the server for now.

    So, I put the above line of code back the way it was, as you can see.

    Thank you!

    Now the Edit and Delete are working.

    Just need to get the Add to work. I'll poke at it more.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    That's interesting. Thanks for letting me know about this and confirming its a version issue. I'll dig thought the PHP release notes and update the Editor requirements.

    Allan
  • jwleighjwleigh Posts: 1Questions: 0Answers: 0
    I just had the same issue but I wasn't doing anything locally. My PHP 5.3.2 Ubuntu server was getting the error from the first post. Like tpaulsme I removed the leading \\ (thanks to his suggestion) and it now works on my server.

    Is there a "requirements" page for the Editor? I never saw any such thing prior to downloading and can't find one now. Had I not stumbled on this post I would have been asking the same thing. Never would have suspected my PHP version as I have tons of websites on this server and none are having issues.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It looks like it was this bug that is causing the problem: https://bugs.php.net/bug.php?id=50731 . It was fixed in PHP 5.3.3.

    The Editor PHP documentation notes that 5.3+ is required, but due to this unexpected issue in PHP, that requirement is actually 5.3.3+. I will be updating the documentation to reflect this issue.

    regards,
    Allan
This discussion has been closed.