@@ -93,11 +93,19 @@ function ($stmt) {
9393 $ stmt ->execute ();
9494
9595 $ data = $ stmt ->fetch (PDO ::FETCH_OBJ );
96+ if ($ data === false ) {
97+ return false ;
98+ }
99+
96100 return $ data ->domain . $ data ->path ;
97101 },
98102 true ,
99103 );
100104
105+ if ($ res === false ) {
106+ throw new SiteNotFoundException ('site id not found ' );
107+ }
108+
101109 $ this ->log ->debug ('site url ' , ['siteurl ' => $ res ] + $ this ->log_values ());
102110
103111 return $ res ;
@@ -120,11 +128,14 @@ public function acquire_lock()
120128 $ nextrun = DateTime::createFromFormat ('Y-m-d H:i:s ' , $ this ->nextrun , new DateTimeZone ('UTC ' ));
121129 $ this ->execution_delay = $ started_at ->getTimestamp () - $ nextrun ->getTimestamp ();
122130
131+ $ this ->status = 'running ' ;
132+
123133 $ res = $ this ->db ->prepare_query (
124134 "UPDATE ` $ this ->table `
125- SET `status` = 'running' , `started_at` = :started_at
135+ SET `status` = :status , `started_at` = :started_at
126136 WHERE `status` = 'waiting' AND id = :id " ,
127137 function ($ stmt ) {
138+ $ stmt ->bindValue (':status ' , $ this ->status );
128139 $ stmt ->bindValue (':id ' , $ this ->id , PDO ::PARAM_INT );
129140 $ stmt ->bindValue (':started_at ' , $ this ->started_at );
130141 $ stmt ->execute ();
@@ -147,12 +158,17 @@ public function cancel_lock()
147158 {
148159 $ this ->log ->debug ('canceling lock ' , $ this ->log_values ());
149160
161+ $ this ->status = 'waiting ' ;
162+ $ this ->started_at = null ;
163+
150164 $ this ->db ->prepare_query (
151165 "UPDATE ` $ this ->table `
152- SET `status` = 'waiting' , `started_at` = NULL
166+ SET `status` = :status , `started_at` = :started_at
153167 WHERE id = :id " ,
154168 function ($ stmt ) {
169+ $ stmt ->bindValue (':status ' , $ this ->status );
155170 $ stmt ->bindValue (':id ' , $ this ->id , PDO ::PARAM_INT );
171+ $ stmt ->bindValue (':started_at ' , $ this ->started_at );
156172 $ stmt ->execute ();
157173 },
158174 true ,
@@ -172,11 +188,14 @@ public function mark_done()
172188 $ this ->reschedule ();
173189 $ this ->log ->debug ('rescheduled ' , $ this ->log_values ());
174190 } else {
191+ $ this ->status = 'done ' ;
192+
175193 $ this ->db ->prepare_query (
176194 "UPDATE ` $ this ->table `
177- SET `status` = 'done' , `finished_at` = :finished_at
195+ SET `status` = :status , `finished_at` = :finished_at
178196 WHERE `id` = :id " ,
179197 function ($ stmt ) {
198+ $ stmt ->bindValue (':status ' , $ this ->status );
180199 $ stmt ->bindValue (':id ' , $ this ->id , PDO ::PARAM_INT );
181200 $ stmt ->bindValue (':finished_at ' , $ this ->finished_at );
182201 $ stmt ->execute ();
0 commit comments