diff --git a/website/FORUM-NEWS-REVISIONS-372.md b/website/FORUM-NEWS-REVISIONS-372.md index 1ff841e5..96129426 100644 --- a/website/FORUM-NEWS-REVISIONS-372.md +++ b/website/FORUM-NEWS-REVISIONS-372.md @@ -19,3 +19,6 @@ Reproduce native checks by uploading tests/native-forum-news-shadow.php as /tmp/ For the actual MySQL worker test, upload node/forum-news.mjs as /tmp/forum-news372-candidate.mjs and tests/native-forum-news-mysql.mjs to /tmp, then execute with the deployed Node22 runtime. It uses the existing private connection file without printing credentials, shadows queue/source tables, and injects a send stub so no public announcement is made. This checkpoint is staged only. Merge/deployment, backup paths, live existing-topic reconciliation and a genuine fresh Discord delivery must be recorded in native task372 before closure. Do not fabricate a live test news article or enable paid/automatic X posting. + +Native subject compatibility follow-up: MyBB limits subjects to85characters while website titles allow120. Forum subjects are truncated with MyBB's Unicode-aware helper, the full long title is retained at the start of the post, and the Archived prefix also stays within85characters. The native temporary-table test now covers long-title editing, archive and republish without losing the full title. + diff --git a/website/integrations/forum-news.php b/website/integrations/forum-news.php index bf697813..2154faf0 100644 --- a/website/integrations/forum-news.php +++ b/website/integrations/forum-news.php @@ -37,10 +37,12 @@ try{ if($status==='published'){ $labels=['world'=>'World','news'=>'NEWS','maintenance'=>'Maintenance','changelogs'=>'Changelogs','events'=>'Events','community'=>'Community','unis_blog'=>"Uni’s Blog"];$label=$labels[$input['category']??'news']??'NEWS';$prefix=$db->fetch_array($db->simple_select('threadprefixes','pid',"prefix='".$db->escape_string($label)."' AND forums='14'")); if(!$prefix){$prefix=['pid'=>$db->insert_query('threadprefixes',['prefix'=>$label,'displaystyle'=>''.htmlspecialchars_uni($label).'','forums'=>'14','groups'=>'-1'])];$cache->update_threadprefixes();} - $subject=$input['title'];$prefix_id=(int)$prefix['pid']; + // MyBB's native validator limits subjects to85 characters; website titles allow120. + $subject=my_substr($input['title'],0,85);$prefix_id=(int)$prefix['pid']; $message='[b]'.$safe($label).'[/b]'."\n".'Written by '.$safe($input['author_name']??'DuneRealms')."\n".'Originally published '.gmdate('j F Y, H:i',(int)($input['published_at']/1000))." UTC\n\n".$safe($input['body'])."\n\n[url=".$url."]Read the original article[/url]\n\n[size=x-small]".$marker.'[/size]'; + if(my_strlen($input['title'])>85)$message='[b]'.$safe($input['title'])."[/b]\n\n".$message; }else{ - $subject=my_substr('[Archived] '.preg_replace('/^\[Archived\] /','',$thread['subject']),0,120);$prefix_id=(int)$thread['prefix']; + $subject=my_substr('[Archived] '.preg_replace('/^\[Archived\] /','',$thread['subject']),0,85);$prefix_id=(int)$thread['prefix']; $message="[b]Archived announcement[/b]\n\nThis article has been withdrawn from the DuneRealms website. Earlier replies are retained for context.\n\n[size=x-small]".$marker.'[/size]'; } require_once MYBB_ROOT.'inc/datahandlers/post.php'; diff --git a/website/tests/native-forum-news-qa.py b/website/tests/native-forum-news-qa.py index 222281ca..c80b846b 100644 --- a/website/tests/native-forum-news-qa.py +++ b/website/tests/native-forum-news-qa.py @@ -19,6 +19,8 @@ post.update(title='Corrected isolated announcement',body='Corrected article body edited,state=run(post,True);assert edited['thread_id']==tid and len(state['posts'])==2 and len(state['threads'])==1 assert state['posts'][0]['pid']==pid and state['posts'][0]['dateline']==date and 'Corrected article body' in state['posts'][0]['message'] reply=next(p for p in state['posts'] if str(p['pid'])=='100');reply_bytes=json.dumps(reply,sort_keys=True) +post['title']='A complete website announcement title longer than the native forum subject limit of eighty-five characters' +long_title,state=run(post);assert len(state['threads'][0]['subject'])==85 and post['title'] in state['posts'][0]['message'] archived,state=run({'id':id,'status':'archived'});assert archived['state']=='archived' and archived['thread_id']==tid and len(state['posts'])==2 assert state['threads'][0]['subject'].startswith('[Archived] ') and 'Archived announcement' in state['posts'][0]['message'] assert json.dumps(next(p for p in state['posts'] if str(p['pid'])=='100'),sort_keys=True)==reply_bytes @@ -35,4 +37,4 @@ for field,value in [('uid','7'),('fid','99'),('visible','0'),('firstpost','100') final=json.loads((qa/'state.json').read_text());assert final['posts']==changed['posts'],field denials.append(field) (qa/'state.json').write_text(json.dumps(baseline)) -print(json.dumps({'nativePostDataHandler':True,'temporaryTablesOnly':True,'createEditArchiveReplayRepublish':True,'topicIdentityPreserved':True,'replyByteForBytePreserved':True,'originalPostDatePreserved':True,'ownershipForumVisibilityFirstPostDenials':denials})) +print(json.dumps({'nativePostDataHandler':True,'temporaryTablesOnly':True,'createEditArchiveReplayRepublish':True,'topicIdentityPreserved':True,'replyByteForBytePreserved':True,'originalPostDatePreserved':True,'longTitlePreserved':True,'ownershipForumVisibilityFirstPostDenials':denials}))