Jump to content

saving ..sometimes, and nothing in errors.txt


joe_g
 Share

Recommended Posts

Hey there,

I run into a strange problem with a live site that's been running okay for quite some time. I installed sury so it runs the latest php always (this was before debian shipped with php 8). So the only thing that could have changed is the php version... I think. Its on php 8.3.13 and PW 3.0.229.

Anyway, if i create a page with some text field it saves ..sometimes. On average every second time. I press save and the page reloads, but then sometimes without the latest update. There is nothing in the PW error log, nothing in the apache error log, also no console errors.

To make things weirder, I have another test version of the same site running on the same server and that one is working great. So it might actually be that something is up with this particular install...

I'm totally stumped. If you got any ideas i'd love to hear them!

 

Link to comment
Share on other sites

I have no idea but in that case I would start by:

1. Activating debug mode.
2. If you have TracyDebugger go to ProcessWire info Pannel >  Clear Session, Cookies, & Modules Refresh. If you don't, install it 😉
3. Just for the sake of it Clear all your caches
4. Log what's happening when the page is saved:

Put this in your ready.php

$this->addHookBefore('Pages::save', function (HookEvent $event) {
    $page = $event->arguments(0);
    bd("Attempting to save: {$page->title}");
});

$this->addHookAfter('Pages::save', function (HookEvent $event) {
    $page = $event->arguments(0);
    bd("Saved: $page->title");
});

$this->addHookBefore('Pages::saved', function (HookEvent $event) {
    $page = $event->arguments(0);
    $changes = $event->arguments(1);
    bd($changes, "Changes on $page->title");
});

Check the Dumps:

931280166_Screenshot2024-10-3109_19_45.png.2f691189d88b8a67af07660a7c34ea14.png

 

 

 

  • Like 2
Link to comment
Share on other sites

aha thank you!

In the mean time the server crashed, pdo_mysql disappeared somehow. If i try to make a new PW install i get "PDO (pdo_mysql) is required (for MySQL database)". So I moved the site to a new server and to my surprise the sometimes-not-saving bug is still happening on the new server. It almost feels like i have two unrelated problems.

In any case, when saving it looks normal - changes are listed (below) it's just that it doesn't actually save anything. I'll try a site-export-import next, to see if i that can clear some database problems...

image.png.e05e26b7ec1758955740c4233ad52d6e.png

Link to comment
Share on other sites

aha, this code (in admin.php) seems to be the culprit: Leaving this code and saving many times (it will fail to save every 2-5 times) and then eventually the mysql install dies entirely. I think it's the first time I managed to truly crash a PW install.

You think I might be doing something verboten in the code below?

 

$pages->addHookAfter('saveReady', function($event) {

   //the following code borks the database!

   if($p->template->name == 'event') {


		$home = wire('pages')->get('/');

		if(!$p->onfrontpage) {
			$home->of(false);
			$home->home->remove($p);
			$home->save();
		}		

		if($p->enddate>time() && $p->onfrontpage) {

			if(!$home->home->has($p)) {
				$home->of(false);
				$home->home->add($p);
				wire('pages')->message('Added ' . $p->title . ' to the homepage');
				$home->of(false);
				$home->save();
			}
			
			$p->of(false);
			$p->onfrontpage = 0;
		}


   }
}

 

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...