Jump to content
Pete

Module: Maintenance Mode

Recommended Posts

The default header code for redirects in PW is a 302 redirect (page has temporarily moved) which is actually the default code for a redirect in PHP itself.

Just wanted to mention that the default for $session->redirect($url) in PW is a 301 (permanent) redirect. If you want a 302 redirect then give it a second param of false, i.e.

<?php
$this->session->redirect('http://processwire.com'); // 301 permanent redirect
$this->session->redirect('http://processwire.com', false); // 302 temporary redirect

http://processwire.com/api/variables/session/

Share this post


Link to post
Share on other sites

Cheers Ryan - i'll update the module tomorrow.

Share this post


Link to post
Share on other sites

Updated to v 1.0.4 to make redirects temporary (302) instead of permanent (301) - original post contains the updated file.

Thanks to ryan for pointing that out.

Share this post


Link to post
Share on other sites

Pete, thanks for your great work on this module!

Share this post


Link to post
Share on other sites

Pete,

Great module! Does 90% or more of what I needed right out of the box. I've added the ability to redirect to external URLs to your v1.0.4 code and pushed it to github as v1.0.5. I submitted a pull request should you find it worthy of inclusion in your module.

Thank you.

Edited by netcarver

Share this post


Link to post
Share on other sites

Cheers Steve

I'll merge that soon as it's very useful! There was a looping issue mentioned under very specific circumstances (something about a user who's not a superuser getting an infinite redirect) by someone recently too so I'll investigate that at some point next week and put any and all changes into a new version.

Share this post


Link to post
Share on other sites

I like the module a lot. Thank you for this!

One idea: I would find a 2 step maintenance extremely useful: 

a) EMERGENCY - Leave only the Superadmin in (as it is now) - good for updates and for working on the database.

b) NORMAL MAINTENANCE - apply a new Permission "bypass_maintenance" to a role which is given access to the backend next to the Superadmin. - good for developing.

Share this post


Link to post
Share on other sites

Updated this to v1.0.6.

You can now add optional roles that can bypass maintenance mode (superuser will always bypass regardless of whether it's selected or not!).

@ceberlin - this should help with your scenario :)

  • Like 2

Share this post


Link to post
Share on other sites

...using this module for my first processwire project: very useful indeed! Thanks Pete!

Share this post


Link to post
Share on other sites

Hi everybody,

quick update: I downloaded last version of the module and set the site in "Maintenance Mode" (with an exception for Superuser and guest): unfortunately the site was still visible to everybody...

did I miss anything?

If I remember well, last version worked like a charme...

Share this post


Link to post
Share on other sites

Superuser will always bypass see three posts above pete explains. The guest role is for public visitors.

Share this post


Link to post
Share on other sites

Hi Soma,

I know that superuser will always bypass but I wanted to add another user with "guest" role.

Doing this, (I tested it again) the site becomes visible to everybody.

How to show the site to a guest role without giving him full permissions?

Share this post


Link to post
Share on other sites

.....but I wanted to add another user with "guest" role.

Doing this, (I tested it again) the site becomes visible to everybody.

How to show the site to a guest role without giving him full permissions?

Am confused. Guest has view rights and that is everybody - the public. If you want the guest to view the site, it beats the logic of placing it in maintenance mode. Also, what are these full permissions for the guest? The full extent of the guest user's permissions is page-view. The only role they have is view pages. Are you talking of another user next to the superuser as requested in post #33?

Share this post


Link to post
Share on other sites

hi kongondo,

Are you talking of another user next to the superuser as requested in post #33?

short answer: yes.

As Pete said, I'd like to add an optional role that can bypass maintenance mode, but I don't want to give him the possibility to edit, delete or move pages. It's only a preview for a client before I teach him how to use PW.

How can it be done?
 

Share this post


Link to post
Share on other sites

Marco,

I haven't used this module, but from looking at the code, I think you will first need to create a role (e.g. "client"). Give that role the limited permissions you want. Create a user, e.g. "paul" and assign "paul" to the role "client". Then, in the module, add "client" as the role to bypass. 

Share this post


Link to post
Share on other sites

OK, I have now tested it and it doesn't seem to show any other roles in the drop down besides guest and supersuser. 

@Pete, is that a bug? Tested on PW 2.3

Share this post


Link to post
Share on other sites

HI Pete,

now I am using the DEV version. There is something funny:

I set the module to redirect to the login page (default behavior).

The "is in maintenance" info appears twice at the login screen. Maybe one time with the redirect and one time calculated new.

Because it is only one time after I refresh the login page.

Another idea: It would be great if the switch to put the maintenance mode on and off would be more accessible as a separate admin "setup" page and available to certain user roles - and not buried in the module's settings.

Share this post


Link to post
Share on other sites

One more observation: The green label "This site is in maintenance" destroys my page setup and makes design testings tricky.

If there was a css class with it, I could overwite the included hard coded styles more easily.

  • Like 1

Share this post


Link to post
Share on other sites

Agree. It should definitely have a class. And styling should be in an external css and not inline. @ceberlin, I think the best thing for you to do is to add the class on the module itself.

Share this post


Link to post
Share on other sites

Hi diego, sure I can edit modules like this one myself. Adding a class is not that difficult :-)

This would disconnect the module from the update path and this is against the idea of community delivered turn-key solutions?

Share this post


Link to post
Share on other sites

I'm not saying it's the ideal solution. The ideal would be Pete reading this and changing it on the module. We can also make a pull request to him, of course.

  • Like 1

Share this post


Link to post
Share on other sites

Great to know a module like this exists :)

Another alternative is to modify the .htaccess file and do a temporary redirect 302 to say a html file at the root called /maintenence.html and then when the site is out of it, edit the .htaccess file to no longer redirect everything to that page and then do a permanent redirect 301 back to the regular homepage / for anyone going to maintenence.html. The visitors won't know any difference

Now you might ask, how the admins would login, well if you know your IP address you can allow just that IP to not be redirected

Another alternative, is to only redirect everything but whats in your /admin/ directory (whatever you have it named, hopefully something else), granted noone would be able to preview the site

  • Like 2

Share this post


Link to post
Share on other sites

 Now you might ask, how the admins would login, well if you know your IP address you can allow just that IP to not be redirected

I don't have a static IP and I use a special string within the UserAgent, for example:

RewriteCond %{HTTP_USER_AGENT} !^.*(b346a0b6fe9d440d68e07c9619c0ba0a).*$

This way (with switching UserAgent of the browser) I am able to look to the site as admin and like the public from the same IP.

  • Like 3

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...