Issue
Prior this problem I had another issue related to the same subject. The problem has been sorted thanks ta @ndm.
Link the previous problem: Cakephp 3. Windows and Linux OS returning different result when querying the database
I have an article page and I am retrieving the associated data with articles. Article comments.
I have the following line of code
$this->Articles->find()->contain('ArticleComments');
This line of code on both local Windows 10 machine and production Debian server retrieves all articles including their comment. find a link to a screenshot of the returned result using Cakephp debugging function pr($object)
Screenshot of the returned result: http://s29.postimg.org/f76brygw6/cakephp.jpg
Now the only problem I have, which occurs only on the production Debian server is that despite the aforementioned line of code is returning articles and article comments I cannot use this object. For an instance if I try the following code:
$this->Articles->find()->contain('ArticleComments')->toArray();
Or
$this->set('articles', $this->Articles->find()->contain('ArticleComments'));
I get this error:
Cannot convert value to integer InvalidArgumentException
And the following error in tmp/error.log: http://s14.postimg.org/4e88qp6j4/cakephp_error.jpg
Again, this error occurs only on my Debian server and if I retrieve just articles by the following code it works fine.
$this->Articles->find()
What I have done to fix this issue:
- Triple checked (twice) table and classes names. 100% sure the issue is not file naming one.
- checked both machines PHP and Cakephp version. My Debian server runs PHP 5.6.15-1~dotdeb+zts+7.1 (cli) and My Windows 10 runs PHP 5.6.8 (cli). Cakephp versions are the same. Cakephp 3.1.4
Solution
Problem solved!
The issue was not coming from Linux nor CakePHP.
On my local machine which happens to be Windows OS I am running MySQL version 5.6.24 and on my live server, which runs Linux debian I have MySQL 5.5.46.
I had database columns "datetime" which is supported in 5.6 but was causing a problem in version 5.5.
I simply changed the column type to "timestamp" and the issue was resolved.
Both environments are running different OS's and an enormous amount of time was spent to ensure the issue is not Windows to Linux problem(i.e. filename case sensitivity). CakePHP misleading error messages has delay me to resolve the problem also.
I am glad after more than a month the problem is fixed :D
Answered By - Matthew Barbara
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.