Jump to content

PHP instance works locally but not on host


FrancisChung
 Share

Recommended Posts

Hi there,

I'm having a weird issue with the instanceof operator where it works locally and not on my server.

I'm using PW3 + PHP7.
I've posted the question on Stackoverflow but I was wondering if anyone here have seen it?

http://stackoverflow.com/questions/42552855/php-instanceof-works-locally-but-not-on-host-server

Thanks in advance.

Link to comment
Share on other sites

The problem turned out to be a bug in PW 2.6.1.

I didn't realise my local PW version was on 2.8.35 and not 2.6.1.


The bug was in        

 $ad = wire(pages)->get("/ads/")->children->getRandom();

It was not returning an object in PW 2.6.1 despite data being present.


Live and (hopefully) learn ....

  • Like 2
Link to comment
Share on other sites

6 hours ago, Christophe said:

Shouldn't it be with quotes around pages? Be it in blog/ or talk/, it seems to always be wire("pages") or wire('pages')wire("page") or wire('page').

I've used wire(pages) everywhere on my codebase. This was the first time I've had an issue with it.

I probably will leave it alone but I'll keep your post it mind. 
Thanks for the pointer, @Christophe. Much appreciated.

Link to comment
Share on other sites

I bet the server that is failing has strict error reporting on. The code you are using should return this error:

Error: Use of undefined constant pages - assumed 'pages'

So it will work with strict error reporting off, but it's not correct code.

  • Like 1
Link to comment
Share on other sites

Just now, adrian said:

I bet the server that is failing has strict error reporting on. The code you are using should return this error:


Error: Use of undefined constant pages - assumed 'pages'

So it will work with strict error reporting off, but it's not correct code.

 

@adrian, it was failing on this 1 particular call.  All the other calls were working fine.

In any case, I will change it to "pages" as it's the correct method.

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...