@@ -31,6 +31,9 @@ class Create {
3131 */
3232 public function writePage (): array {
3333 $ fields = ContentCore::getFields ();
34+ if ( Config::isDebug () ) {
35+ Debug::addToDebug ( 'Write page activated ' . time (), $ fields );
36+ }
3437
3538 $ this ->content = ContentCore::createContent ();
3639
@@ -207,25 +210,48 @@ private function setPageDataMultiple( string $page ) {
207210 public function writePages () : array {
208211 $ pageCount = 0 ;
209212 $ fields = ContentCore::getFields ();
213+ if ( Config::isDebug () ) {
214+ Debug::addToDebug ( 'Write several page activated ' . time (), $ fields );
215+ }
210216 foreach ( $ fields ['writepages ' ] as $ singlePage ) {
211217 $ pageCount ++;
212218 $ this ->setPageDataMultiple ( $ singlePage );
219+ if ( Config::isDebug () ) {
220+ Debug::addToDebug (
221+ 'Working on page ' . $ pageCount ,
222+ [ 'pageinfo ' => $ singlePage ,
223+ 'after setpageDataMultiple ' => $ this ->pageData ]
224+ );
225+ }
213226 // If we do not have a page title or a template, then skip!
214227 if ( $ this ->pageData ['template ' ] === false || $ this ->pageData ['title ' ] === false ) {
215228 continue ;
216229 }
217230 if ( !$ this ->pageData ['notemplate ' ] ) {
218231 $ this ->content = "{{ " . $ this ->pageData ['template ' ] . "\n" ;
219232 }
233+ if ( Config::isDebug () ) {
234+ Debug::addToDebug (
235+ 'Content original ' . $ pageCount ,
236+ $ this ->content
237+ );
238+ }
220239 $ this ->addPostFieldsToContent ();
240+ if ( Config::isDebug () ) {
241+ Debug::addToDebug (
242+ 'Content after adding form fields ' . $ pageCount ,
243+ $ this ->content
244+ );
245+ }
221246 if ( strpos (
222247 $ this ->pageData ['title ' ],
223248 '[ '
224249 ) !== false ) {
225250 $ this ->pageData ['title ' ] = ContentCore::parseTitle ( $ this ->pageData ['title ' ] );
226251 }
227252 if ( $ this ->pageData ['option ' ] == 'next_available ' && $ this ->pageData ['title ' ] !== false ) {
228- $ hnr = ContentCore::getNextAvailable ( $ this ->title );
253+
254+ $ hnr = ContentCore::getNextAvailable ( $ this ->pageData ['title ' ] );
229255 if ( Config::isDebug () ) {
230256 Debug::addToDebug (
231257 'next available ' ,
@@ -259,6 +285,7 @@ public function writePages() : array {
259285 if ( !ctype_digit ( $ rangeCheck [0 ] ) || !ctype_digit ( $ rangeCheck [1 ] ) ) {
260286 throw new FlexFormException ( wfMessage ( 'flexform-mwoption-bad-range ' ) );
261287 }
288+
262289 $ rangeResult = ContentCore::getFromRange (
263290 $ this ->pageData ['title ' ],
264291 $ range
@@ -299,14 +326,20 @@ public function writePages() : array {
299326 ];
300327 }
301328
329+
302330 if ( Config::isDebug () ) {
303331 Debug::addToDebug (
304332 '$pagesToSave ' ,
305333 $ pagesToSave
306334 );
307335 }
308-
336+ if ( Config::isDebug () ) {
337+ Debug::addToDebug ( 'Pages to save before addCreatToTile ' . time (), $ pagesToSave );
338+ }
309339 $ pagesToSave = $ this ->addCreateToTitle ( $ pagesToSave );
340+ if ( Config::isDebug () ) {
341+ Debug::addToDebug ( 'Pages to save after addCreatToTile ' . time (), $ pagesToSave );
342+ }
310343 $ finalPages = $ this ->createFinalPages ( $ pagesToSave );
311344 if ( Config::isDebug () ) {
312345 Debug::addToDebug (
0 commit comments