Jump to content

Fatal errors


MaryMatlow
 Share

Recommended Posts

I'm getting this repeated error. The first time it happened @kongondo suggested I clear the cache and it worked fine. But it happened again and even clearing the cache doesn't help. What could be the issue?

Compile Error: Cannot redeclare class BlogPublishDate (line 23 of /xx/xxxxxxxxx/html/site/modules/Blog/BlogPublishDate.module) 

 

The second error I get is on the gallery index page.

Fatal error: Call to undefined function wire() in /Applications/XAMPP/xamppfiles/htdocs/xxxxx/site/templates/_footer.php on line 14 

The same footer.php is being called on other templates also and it seems to work fine. See screenshot for the footer.php code:

If I remove line 14 the error shows up on line 21 and so on wherever the get() api is being used. Anyone knows what could be the problem here?

 

Screen Shot 2017-01-23 at 3.09.55 PM.png

Link to comment
Share on other sites

Your first error is a Compile error -> Check if there is a namespace in that file called processwire. If not then add this:

<?php namespace Processwire; ?>

For the 2nd error, I don't know at the moment... Are you 100% sure you have the right id's for your pages and everything in your wire folder of processwire is correct? Because for me the wire('pages')->get(pageid) works normal...

~ Harmen

  • Like 1
Link to comment
Share on other sites

18 minutes ago, Harmen said:

Your first error is a Compile error -> Check if there is a namespace in that file called processwire. If not then add this:


<?php namespace Processwire; ?>

 

Actually not a good idea to do that :). I made a decision not to namespace my modules (am the author of the Blog module) to instead let the compiler do its work. If @MaryMatlow did that, any changes will be overwritten by the next Blog update. There's something going on with this install which I'd like to get to the bottom of.

@MaryMatlow, could you please confirm the ProcessWire version that you are running? (down to the 3.x.x please). The only difference between that module (in the Blog suite of modules) and the others is that BlogPublishDate is an autoload module. I haven't received any other similar reports from other Blog users, which makes me even more curious.

  • Like 1
Link to comment
Share on other sites

1 minute ago, kongondo said:

Actually not a good idea to do that :). I made a decision not to namespace my modules (am the author of the Blog module) and let the compiler do its work. If @MaryMatlow did that, any changes will be overwritten by the next Blog update. There's something going on with this install which I'd like to get to the bottom of.

Didn't know that. I'm sorry :mellow:

  • Like 1
Link to comment
Share on other sites

19 minutes ago, Harmen said:

Didn't know that. I'm sorry :mellow:

No worries. You are just trying to help :).

2 minutes ago, adrian said:

There have been significant changes to the File Compiler since that version. I would recommend the latest dev version - 3.0.50

It may not be related to this issue, but it shouldn't hurt!

@MaryMatlow, what @adrian said. I've been testing against 3.0.42 and Blog seems to work fine. If upgrading doesn't fix the issue, we'll focus on autoload modules. 

  • Like 1
Link to comment
Share on other sites

The upgrade went well and seems to have sort out the problem. I just noticed that in the module folder I've Blog folder and MarkupBlog folder with identical files. I renamed MarkupBlog and everything seems to be fine. Is it right thing to do?

And, any clues about the error regarding the footer.php file?

Link to comment
Share on other sites

You should only have one set of files. That could have been the source of the problem. If you install (or upgrade) Blog via ProcessWire itself (i.e. as opposed to uploading the module yourself), the folder should be ProcessBlog (I think - not sure since being its developer, I don't install in that manner since I have the files locally). Whatever the case, you should only ever have one set of files, irrespective of whether they live in different folders. So, yes, delete one set and rename the Blog folder to what it should be (my guess is ProcessBlog; if not that, Blog, but definitely not MarkupBlog; I shouldn't think so). Hope this makes sense :).

Regarding _footer.php, is that a template file or a file you are including within some other template file?

Btw, looking at the code in footer.php, I notice you are getting a number of pages by their IDs. Whilst that is the most foolproof way to do it, down the line, especially if there's several such calls in different template files, you will start to get confused what page 1040 was :), especially if the code is not documented. In this regard, some people prefer to get by page: 

$pages->get('/path/to/page/');

Of course, if a page's path changed....you'll have a different problem to deal with. Just my 2p.

  • Like 1
Link to comment
Share on other sites

Changing "Blog" to "ProcessBlog" gives me this error

Error: Call to a member function renderPosts() on a non-object (line 24 of /nfs/c01/h05/mnt/xxxxxxxx/html/site/templates/blog-posts.php) 
                $content .= $blog->renderPosts("limit=5" . "", true, $options);

Above is line 24.

 

Link to comment
Share on other sites

Great, thanks.

In the footer.php I changed the get method to path but it didn't work on the gallery page but others pages worked as before on local machine. When uploaded the file to server it gives the error on all pages, reverted to paged IDs still the same error. So what worked before now broke down. Clearing the cache doesn't help either. It's so frustrating.

Error: Call to undefined function wire() (line 14 of /nfs/c01/h05/mnt/xxxxx/html/site/templates/_footer.php) 

 

Link to comment
Share on other sites

Using wire('pages') in a template file shouldn't cause an error (not sure why that's happening), but in template context you would normally access this API variable as $pages. In fact, in your screenshot you are doing that a few lines below on line 36.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...