From a9cf558af7fc08539e15ceca1e889e087c815c8d Mon Sep 17 00:00:00 2001 From: Sajaki <sajaki9@gmail.com> Date: Sat, 28 Apr 2012 10:43:43 +0200 Subject: [PATCH 001/174] [ticket/10854] sql server drop default constraint when dropping column drops default columns with T-SQL before attempting drop column to avoids sql exception. This is a huge annoyance in UMIL scripts running under sql server. --- phpBB/includes/db/db_tools.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index c6dd23e6bd..f63ff18cbe 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -1819,6 +1819,22 @@ class phpbb_db_tools case 'mssql': case 'mssqlnative': + // remove default cosntraints first + // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx + $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) + SET @drop_default_name = + (SELECT so.name FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')) + IF @drop_default_name <> '' + BEGIN + SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' + EXEC(@cmd) + END"; $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; From 3e03f95cb73ad090e22514be856c9b0613e0448a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Sun, 11 Nov 2012 19:07:00 +0100 Subject: [PATCH 002/174] [ticket/10431] CSS3 buttons CSS3 replacements for big buttons PHPBB3-10431 --- phpBB/styles/prosilver/theme/buttons.css | 81 ++++++++++++------ phpBB/styles/prosilver/theme/colours.css | 8 -- .../styles/prosilver/theme/en/stylesheet.css | 16 ---- .../styles/prosilver/theme/images/buttons.png | Bin 0 -> 2563 bytes 4 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 phpBB/styles/prosilver/theme/images/buttons.png diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index e817380f8e..9a69956368 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -14,40 +14,71 @@ .buttons div { float: left; margin: 0 5px 0 0; - background-position: 0 100%; } /* Rolloff state */ .buttons div a { - display: block; - width: 100%; - height: 100%; - background-position: 0 0; - position: relative; - overflow: hidden; + display: inline-block; + line-height: 16px; + font-size: 13px; + white-space: nowrap; + border: 1px solid #c7c3bf; + border-radius: 4px; + background: #fff none 0 0 repeat-x; + background-image: -moz-linear-gradient(top, #fff, #e9e9e9); + background-image: -webkit-linear-gradient(top, #fff, #e9e9e9); + background-image: -o-linear-gradient(top, #fff, #e9e9e9); + background-image: linear-gradient(to bottom, #fff, #e9e9e9); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#e9e9e9')"; + box-shadow: 0 0 0 1px #fff inset; + -webkit-box-shadow: 0 0 0 1px #fff inset; + text-shadow: 1px 1px 0 #fff, -1px -1px 0 rgba(188, 42, 77, 0.25); + padding: 3px 22px 3px 8px; + color: #bc2a4d !important; + position: relative; + text-decoration: none !important; + outline-style: none !important; } -/* Hide <a> text and hide off-state image when rolling over (prevents flicker in IE) */ -/*.buttons div span { display: none; }*/ -/*.buttons div a:hover { background-image: none; }*/ -.buttons div span { position: absolute; width: 100%; height: 100%; cursor: pointer;} -.buttons div a:hover span { background-position: 0 100%; } +.buttons div span { display: none; } +.buttons div a:hover { + border-color: #0a8ed0; + background-image: -moz-linear-gradient(top, #e9e9e9, #fff); + background-image: -webkit-linear-gradient(top, #e9e9e9, #fff); + background-image: -o-linear-gradient(top, #e9e9e9, #fff); + background-image: linear-gradient(to bottom, #e9e9e9, #fff); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#e9e9e9', EndColorStr='#ffffff')"; + text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, -1px -1px 0 rgba(188, 42, 77, 0.2); +} + +.buttons div a:after { + content: ''; + display: block; + position: absolute; + top: 50%; + right: 6px; + width: 12px; + height: 12px; + margin-top: -6px; + background: url("images/buttons.png") 0px 0 no-repeat; +} + +.buttons div a:hover:after { + background-position: 0 -20px; +} /* Big button images */ -.reply-icon span { background: transparent none 0 0 no-repeat; } -.post-icon span { background: transparent none 0 0 no-repeat; } -.locked-icon span { background: transparent none 0 0 no-repeat; } -.pmreply-icon span { background: none 0 0 no-repeat; } -.newpm-icon span { background: none 0 0 no-repeat; } -.forwardpm-icon span { background: none 0 0 no-repeat; } +.buttons div.reply-icon a:after, .buttons div.pmreply-icon a:after { background-position: -20px 0; } +.buttons div.reply-icon a:hover:after, .buttons div.pmreply-icon a:hover:after { background-position: -20px -20px; } -/* Set big button dimensions */ -.buttons div.reply-icon { width: 96px; height: 25px; } -.buttons div.post-icon { width: 96px; height: 25px; } -.buttons div.locked-icon { width: 88px; height: 25px; } -.buttons div.pmreply-icon { width: 96px; height: 25px; } -.buttons div.newpm-icon { width: 84px; height: 25px; } -.buttons div.forwardpm-icon { width: 96px; height: 25px; } +.buttons div.post-icon a:after, .buttons div.newpm-icon a:after { background-position: 0 0; } +.buttons div.post-icon a:hover:after, .buttons div.newpm-icon a:hover:after { background-position: 0 -20px; } + +.buttons div.locked-icon a:after { background-position: -60px 0; } +.buttons div.locked-icon a:hover:after { background-position: -60px -20px; } + +.buttons div.forwardpm-icon a:after { background-position: -40px 0; } +.buttons div.forwardpm-icon a:hover:after { background-position: -40px -20px; } /* Sub-header (navigation bar) --------------------------------------------- */ diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index d7ce9a7622..0a8e011171 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -649,14 +649,6 @@ fieldset.polls dd div { Colours and backgrounds for buttons.css -------------------------------------------------------------- */ -/* Big button images */ -.reply-icon span { background-image: url("./en/button_topic_reply.gif"); } -.post-icon span { background-image: url("./en/button_topic_new.gif"); } -.locked-icon span { background-image: url("./en/button_topic_locked.gif"); } -.pmreply-icon span { background-image: url("./en/button_pm_reply.gif") ;} -.newpm-icon span { background-image: url("./en/button_pm_new.gif") ;} -.forwardpm-icon span { background-image: url("./en/button_pm_forward.gif") ;} - a.print { background-image: url("./images/icon_print.gif"); } diff --git a/phpBB/styles/prosilver/theme/en/stylesheet.css b/phpBB/styles/prosilver/theme/en/stylesheet.css index d17f9a5be4..1a3d0acb4b 100644 --- a/phpBB/styles/prosilver/theme/en/stylesheet.css +++ b/phpBB/styles/prosilver/theme/en/stylesheet.css @@ -1,11 +1,3 @@ -/* Set big button dimensions */ -.buttons div.reply-icon { width: 96px; height: 25px; } -.buttons div.post-icon { width: 96px; height: 25px; } -.buttons div.locked-icon { width: 88px; height: 25px; } -.buttons div.pmreply-icon { width: 96px; height: 25px; } -.buttons div.newpm-icon { width: 84px; height: 25px; } -.buttons div.forwardpm-icon { width: 96px; height: 25px; } - /* Set profile icon dimensions */ ul.profile-icons li.pm-icon { width: 28px; height: 20px; } ul.profile-icons li.quote-icon { width: 54px; height: 20px; } @@ -14,14 +6,6 @@ ul.profile-icons li.edit-icon { width: 42px; height: 20px; } /* Online image */ .online { background-image: url("./icon_user_online.gif"); } -/* Big button images */ -.reply-icon span { background-image: url("./button_topic_reply.gif"); } -.post-icon span { background-image: url("./button_topic_new.gif"); } -.locked-icon span { background-image: url("./button_topic_locked.gif"); } -.pmreply-icon span { background-image: url("./button_pm_reply.gif") ;} -.newpm-icon span { background-image: url("./button_pm_new.gif") ;} -.forwardpm-icon span { background-image: url("./button_pm_forward.gif") ;} - /* Icon images */ .pm-icon, .pm-icon a { background-image: url("./icon_contact_pm.gif"); } .quote-icon, .quote-icon a { background-image: url("./icon_post_quote.gif"); } diff --git a/phpBB/styles/prosilver/theme/images/buttons.png b/phpBB/styles/prosilver/theme/images/buttons.png new file mode 100644 index 0000000000000000000000000000000000000000..a19abdc2b8aeb3b344a1718d78314104082fa2ba GIT binary patch literal 2563 zcmbVOcT`hZ9?m9+fFlqA8?X~XuOXqN(Mdv)U<3rjfX3t@5mHD(LXkzHC|v?pnhdxK zQiQRhNOeIO2N+OMK*}Is1wkny>ONH5{lhbR&c6HJyXF19?^o`3&v_{{Z@0Bdo0T9C z$XX9~k`LI^z{f~I9(=QR$NvrNHi^iAB41vpNWu^R5N8%|4}kFCF!lmI0D~11c^9yQ zKwzP4zd%tS)r-L7aV!|iHWtwwK8S`u>>Q){3}!eWLhJ$dvbpxishbT*1e;}#46vbE zQu(ex7~4Ho0Qkmw`!Qp~nRph`(E(u>O#lfvfQW&J=0tFXglK!@7hVE5US38a5noJ1 z;r7U{K?PE22v?o}K-gGVnKLcXXoRh;1=`xi))sAsz*wR&C`<6RHAh<$Y-|Y_EaKaR z1icAZp#&ci<(n^XW{(ULiTDH*N+OY1NUSV)g1sm-9*<w<z+lWl3v*!%SHy@m=L&UK z7)XGSDPZ$OY#tY}%*fcoixSx*!AQTRz~NJ=--)@xZ-oL&hKgqJQD_TG6o<2%*B5J{ z$OrgO7(cWY`o-`8ln)@}MG2VTeuV0-fWg}RwWDQ2FdD*E0UO*DMg)n+jN$-Xkq5~h z34XC)u~`HPo`S_&xw@b+7*{d|jdsCNtjQQW-o_S3B9mRwD;z(<;wd-`4vnQ?T+w7S znv8M5TViln7ZMh0=>ihktYAI3LJ@<@1XldALBHRy<iErcTm=9_#1r`Oco8cKpoQ^7 zJYg7*k8t(1MHmIJxh$SUXuP~VU$Z3v0=5`nQ3N~=;!AxA>>v22xcslYzhYVcPt8zZ zFsNm5{Fhi(mOuqA55G$voP0k#02e$l0`O=QgdPckK;*4FNX~xIeXn*zx@!h({Old{ zqAT@}GNIyjHMc9pez2FKDsRn#^pC#%$1<)kG1k{#tL#kDNNP4SHgykpwC{XXj*cj= zxFEudeWjWZrIE8fHK^C5{E<J0xjwhz#o=r79XH=*57^9G>}13`E?l3lpPw0vZ<xO| z6?c+mO+Bb0M*eZ>wXt3=qkzF?r^JjueY${m#NpgWCQg{|WIZk>DVWs+nrUC(MyD@L z58jH?qzOZs2(=liT<NLI`-SSPemb3gXmK&Nb^88&zYs?UhYq{)^768-F4~T?zS|DE zk0*W}fY@qjYW^10@(3^S$Tv4NeHq5(4z>}-%VE%U?>jxIs{6M(@tqIG-;0Yn+Pl$U zn_j6NT$=Ly<xA5RY2PZOF#DDG1F^EQ^2jzK^<40-y|)x_@rxq217X>hPo6koV4~M3 z7bO-i!u9{DqMqmhgTa!NkCdp&aHq4f_$iwCd3jcWl@EP;dV26iXP+EV)?VCH<~Fu@ z18$t`1OQ_Wb9e6k>lk96bG2e>Bm7W_IV$1k5ZpkYh9wg7wAIvLn=@L6MTE67S-Ih6 zxTI@z`hb6VQgU+go3st6aSaWP$BLO4nBt7PU^r^Xdiatv>DlCD=*AoT5ov((?Rf6~ z&!0XX8$f2;T3InkZPuD(#^K+_+Tq?#GHi-qghrvX?iL7Uvb@^1ROjR$EGa2z$}-HA z$Hme0e!WT@+t_~Z-r4Z*@b}4TP_<NVZTd}dMz&^R387#TtM?Jh9Wa`F@uFS9ZP)<O zU5`EOWnTK8xbA4S_J*w05tF)=w~6}QkOsVGW~8TQ>eFcheDlV<NQ($IyDTUqL>asB zr^(8l*Su?=Os3b=ptsQJ1FYEC8*avl^p55Zld{~ccYcXgfcn7QrK;RS!>xr&s$)c0 zD#?juGd?yJKfN%`oNsUUj7~^M*j}Bc;ZHkZ_a_p0TwYyWztC)#&MJvaxh3FuVPWBg zg@uLM?(S|~_X&rDPy3B8++OcxL})#8scoSwB=&P!T1;@TcE&~1Y{j~>a+%shicB?G zmb}5r(ea`yxkU5I&%;H|F_Bp08>PFmfUfha?aC7^4RRl=cMFCndbA`dve-qR_O&H> z4)?Sgz_mXqHb^;V$TOc}g?%G@%g&05_<u-nH*Xz`fu&?-`tMgcTh^Otm9gcFmYi>> zkIue1lR(33@MfxNkE}088j-hV%^KCW<3Q_la4jJuVfN&v@%O|1P!kiAR3m7{tDe@Q zdU=q-k&I`L@vrqde0cfL#Wr1y3T8b4fslQ!P?sB0!|f}5&`b9kJU><S@c{pnzD)CE z9xUVP&Uv@$qPgTd`7>o7I_}PyGC8H3<Lutv9Vlq2%3*|)wMYM!JL@-O_o7Hy++t_Z zPcJ<bZo>ly-{olME^-f|@ec#JeH|)&=bm)EYq>Z+H^}G;D{icdTP?ofe|6TTtxln+ zlO=TXw&+kQ_P?&!KDcX#^ziCQ7x(ANAxA$1HC-Q2ur7H9P41F%jNxVlD%;|0P+G5Z z4~zTl8imh?(>tW%53sd`TkCd5f|^DYZizf=H8*Kw_-3}V_4LyDTQTw`4Sye9HJ>yp zNK1b3Jfwo%FnMS&#VuLyNUz-JRZGjgl!JKF&F?x7w@2lN=08QM63g@LrtR+ZjUr`N z%uPk>)+vPrKUTcnH}!ewQB}ZY%N{yRGD$!2@r-+=f!*bLJM3UYtWI4`uXs)V{h(Eg zrL?rW#KhbQr>2Yb4zji}hi=aSgiL<n_ia$GhYe9G>5a8-8mFfk@vou3&qY`oP+X>{ z8v^T3LrcWM3<rxno@h|c>$Hg37v3Mz3WBG<ZGp`%iBR=Rb;Vd&YRSYR-zIb>c(lL& zmuYkRuu`|-rMEoXn+F^PaZR&Q>K$Jnl3vdNX|bG6DXs2U`D~7=6#DDp*fV4X$uWkP zX#4P8*Eq_Mc9PptTT_`JeW<mms6RrbX3}0<rNu5flP(Y4S#PTeeFkkm_os4f|JD5- zO``&iBJos_Y*i=b6W^iyl6S`q{?LWSk+nK|E(#Vd{HgwKw&`j8tn#cQe0IX@xYKge iFiA8?{Or4=+X!jKNvM*nn-7+M%RI>5q$-!)(tiUMbvMEQ literal 0 HcmV?d00001 From 8b1920adb59d2cc6e8bed558c56fb33ab5c4b0f7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Mon, 12 Nov 2012 10:25:12 +0100 Subject: [PATCH 003/174] [ticket/10431] Different font for iOS Different font for buttons on iOS devices because Verdana looks incorrectly aligned in Safari/iOS. Also slightly changed text shadow. PHPBB3-10431 --- phpBB/styles/prosilver/theme/buttons.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 9a69956368..2ba17a7717 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -32,8 +32,9 @@ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#e9e9e9')"; box-shadow: 0 0 0 1px #fff inset; -webkit-box-shadow: 0 0 0 1px #fff inset; - text-shadow: 1px 1px 0 #fff, -1px -1px 0 rgba(188, 42, 77, 0.25); + text-shadow: 1px 1px 0 #fff, -1px -1px 1px rgba(188, 42, 77, 0.25); padding: 3px 22px 3px 8px; + font-family: "Futura-Medium", Verdana; color: #bc2a4d !important; position: relative; text-decoration: none !important; From 25124b361e8e23f338efb0f649abf46a37c66e3d Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Mon, 12 Nov 2012 10:42:11 +0100 Subject: [PATCH 004/174] [ticket/10431] Adjustments for IE7 Adjustments to buttons for IE7 PHPBB3-10431 --- phpBB/styles/prosilver/theme/buttons.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 2ba17a7717..544f4d3def 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -39,6 +39,7 @@ position: relative; text-decoration: none !important; outline-style: none !important; + *padding-right: 8px; } .buttons div span { display: none; } From 8e700f7e2bfecc514f8ed4ae8db43dd37703ca1e Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Mon, 12 Nov 2012 11:03:30 +0100 Subject: [PATCH 005/174] [ticket/10431] Changed fonts for Linux Added backup fonts for Linux systems that do not have Verdana font PHPBB3-10431 --- phpBB/styles/prosilver/theme/buttons.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 544f4d3def..02f973d0ff 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -34,7 +34,7 @@ -webkit-box-shadow: 0 0 0 1px #fff inset; text-shadow: 1px 1px 0 #fff, -1px -1px 1px rgba(188, 42, 77, 0.25); padding: 3px 22px 3px 8px; - font-family: "Futura-Medium", Verdana; + font-family: "Futura-Medium", Verdana, Arial, Helvetica; color: #bc2a4d !important; position: relative; text-decoration: none !important; From 9b018bd460376abce3f4fe9d8c11feef0c547b0d Mon Sep 17 00:00:00 2001 From: Bruno Ais <brunoaiss@gmail.com> Date: Sun, 2 Dec 2012 21:47:18 +0000 Subject: [PATCH 006/174] [ticket/11171] DB additions for these changes Made the required changes to develop/create_schema_files.php and this is what resulted of that. PHPBB3-11171 --- phpBB/develop/create_schema_files.php | 27 +++++++++++++---------- phpBB/install/schemas/firebird_schema.sql | 5 ++++- phpBB/install/schemas/mssql_schema.sql | 5 ++++- phpBB/install/schemas/mysql_40_schema.sql | 5 ++++- phpBB/install/schemas/mysql_41_schema.sql | 5 ++++- phpBB/install/schemas/oracle_schema.sql | 5 ++++- phpBB/install/schemas/postgres_schema.sql | 5 ++++- phpBB/install/schemas/sqlite_schema.sql | 5 ++++- 8 files changed, 43 insertions(+), 19 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3d3e478032..0ae75c2681 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1520,18 +1520,21 @@ function get_schema_struct() $schema_data['phpbb_reports'] = array( 'COLUMNS' => array( - 'report_id' => array('UINT', NULL, 'auto_increment'), - 'reason_id' => array('USINT', 0), - 'post_id' => array('UINT', 0), - 'pm_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'user_notify' => array('BOOL', 0), - 'report_closed' => array('BOOL', 0), - 'report_time' => array('TIMESTAMP', 0), - 'report_text' => array('MTEXT_UNI', ''), - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), + 'report_id' => array('UINT', NULL, 'auto_increment'), + 'reason_id' => array('USINT', 0), + 'post_id' => array('UINT', 0), + 'pm_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'user_notify' => array('BOOL', 0), + 'report_closed' => array('BOOL', 0), + 'report_time' => array('TIMESTAMP', 0), + 'report_text' => array('MTEXT_UNI', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_magic_url' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_bbcode' => array('BOOL', 1) ), 'PRIMARY_KEY' => 'report_id', 'KEYS' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 767ce68b4a..bd97fefb36 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -912,8 +912,11 @@ CREATE TABLE phpbb_reports ( report_time INTEGER DEFAULT 0 NOT NULL, report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, reported_post_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL + reported_post_enable_magic_url INTEGER DEFAULT 1 NOT NULL, + reported_post_enable_smilies INTEGER DEFAULT 1 NOT NULL, + reported_post_enable_bbcode INTEGER DEFAULT 1 NOT NULL );; ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 84c975942f..bb0890e439 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1111,8 +1111,11 @@ CREATE TABLE [phpbb_reports] ( [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , [reported_post_text] [text] DEFAULT ('') NOT NULL , + [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL , [reported_post_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL + [reported_post_enable_magic_url] [int] DEFAULT (1) NOT NULL , + [reported_post_enable_smilies] [int] DEFAULT (1) NOT NULL , + [reported_post_enable_bbcode] [int] DEFAULT (1) NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8aab949103..bf3d7fecfa 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -649,8 +649,11 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumblob NOT NULL, reported_post_text mediumblob NOT NULL, - reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, reported_post_uid varbinary(8) DEFAULT '' NOT NULL, + reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, + reported_post_enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 04aef2844a..372b63d83c 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -649,8 +649,11 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumtext NOT NULL, reported_post_text mediumtext NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, + reported_post_enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 91f906bc8b..671347ebe1 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1216,8 +1216,11 @@ CREATE TABLE phpbb_reports ( report_time number(11) DEFAULT '0' NOT NULL, report_text clob DEFAULT '' , reported_post_text clob DEFAULT '' , - reported_post_bitfield varchar2(255) DEFAULT '' , reported_post_uid varchar2(8) DEFAULT '' , + reported_post_bitfield varchar2(255) DEFAULT '' , + reported_post_enable_magic_url number(1) DEFAULT '1' NOT NULL, + reported_post_enable_smilies number(1) DEFAULT '1' NOT NULL, + reported_post_enable_bbcode number(1) DEFAULT '1' NOT NULL, CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 619985e0d6..4c13bf0ba9 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -855,8 +855,11 @@ CREATE TABLE phpbb_reports ( report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), report_text TEXT DEFAULT '' NOT NULL, reported_post_text TEXT DEFAULT '' NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, + reported_post_enable_magic_url INT2 DEFAULT '1' NOT NULL CHECK (reported_post_enable_magic_url >= 0), + reported_post_enable_smilies INT2 DEFAULT '1' NOT NULL CHECK (reported_post_enable_smilies >= 0), + reported_post_enable_bbcode INT2 DEFAULT '1' NOT NULL CHECK (reported_post_enable_bbcode >= 0), PRIMARY KEY (report_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 1690a7dcab..46a96a1edd 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -630,8 +630,11 @@ CREATE TABLE phpbb_reports ( report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', report_text mediumtext(16777215) NOT NULL DEFAULT '', reported_post_text mediumtext(16777215) NOT NULL DEFAULT '', + reported_post_uid varchar(8) NOT NULL DEFAULT '', reported_post_bitfield varchar(255) NOT NULL DEFAULT '', - reported_post_uid varchar(8) NOT NULL DEFAULT '' + reported_post_enable_magic_url INTEGER UNSIGNED NOT NULL DEFAULT '1', + reported_post_enable_smilies INTEGER UNSIGNED NOT NULL DEFAULT '1', + reported_post_enable_bbcode INTEGER UNSIGNED NOT NULL DEFAULT '1' ); CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); From 25780c17a4e9c1e96e8f1648bd9bd16ff06afb7f Mon Sep 17 00:00:00 2001 From: Bruno Ais <brunoaiss@gmail.com> Date: Sun, 2 Dec 2012 22:59:11 +0000 Subject: [PATCH 007/174] [ticket/11171] DB changes for the update These are the changes to database_update.php required for this ticket. PHPBB3-11171 --- phpBB/install/database_update.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e966756337..060d749b92 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2792,6 +2792,23 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + // PHPBB3-11171: Copy bbcode fields, etc. for reported posts. Add 5 columns to the reports table + + // Add the columns used by these changes + $changes['add_columns'] = array( + REPORTS_TABLE => array( + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1) + ) + ); + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + break; } } From 83a71a2e777dcc9d1c717b6bf438b9aaf41dffba Mon Sep 17 00:00:00 2001 From: Bruno Ais <brunoaiss@gmail.com> Date: Sun, 2 Dec 2012 23:01:29 +0000 Subject: [PATCH 008/174] [ticket/11171] Use the options stored to decide how to show it Added what's needed so that the post in the report is parsed the same way as it was being parsed when the post was reported PHPBB3-11171 --- phpBB/includes/mcp/mcp_reports.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 3426d62cdb..ca730f7728 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -71,7 +71,7 @@ class mcp_reports // closed reports are accessed by report id $report_id = request_var('r', 0); - $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour + $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id @@ -94,6 +94,10 @@ class mcp_reports $post_id = $report['post_id']; $report_id = $report['report_id']; + + $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0; + $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0; + $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0; $post_info = get_post_data(array($post_id), 'm_report', true); @@ -227,7 +231,7 @@ class mcp_reports 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), - 'POST_PREVIEW' => generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], OPTION_FLAG_BBCODE | OPTION_FLAG_SMILIES, false), + 'POST_PREVIEW' => generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false), 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], From 91246c20fa8b9218fe0ddc8b52236d4b878346dd Mon Sep 17 00:00:00 2001 From: Bruno Ais <brunoaiss@gmail.com> Date: Sun, 2 Dec 2012 23:07:40 +0000 Subject: [PATCH 009/174] [ticket/11171] Adapted the code in report.php Added the variable aliases needed (to look and feel the same as it was before) Added the variables into the table insert. PHPBB3-11171 --- phpBB/report.php | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/phpBB/report.php b/phpBB/report.php index d792b8df6a..be38bad2f3 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -71,11 +71,14 @@ if ($post_id) trigger_error('POST_NOT_EXIST'); } - $forum_id = (int) $report_data['forum_id']; - $topic_id = (int) $report_data['topic_id']; - $reported_post_text = $report_data['post_text']; - $reported_post_bitfield = $report_data['bbcode_bitfield']; - $reported_post_uid = $report_data['bbcode_uid']; + $forum_id = (int) $report_data['forum_id']; + $topic_id = (int) $report_data['topic_id']; + $reported_post_text = $report_data['post_text']; + $reported_post_bitfield = $report_data['bbcode_bitfield']; + $reported_post_uid = $report_data['bbcode_uid']; + $reported_post_enable_bbcode = $report_data['enable_bbcode']; + $reported_post_enable_smilies = $report_data['enable_smilies']; + $reported_post_enable_magic_url = $report_data['enable_magic_url']; $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' @@ -134,9 +137,11 @@ else trigger_error($message); } - $reported_post_text = $report_data['message_text']; - $reported_post_bitfield = $report_data['bbcode_bitfield']; - $reported_post_uid = $report_data['bbcode_uid']; + $reported_post_text = $report_data['message_text']; + $reported_post_bitfield = $report_data['bbcode_bitfield']; + $reported_post_enable_bbcode = $report_data['reported_post_enable_bbcode']; + $reported_post_enable_smilies = $report_data['reported_post_enable_smilies']; + $reported_post_enable_magic_url = $report_data['reported_post_enable_magic_url']; } // Submit report? @@ -155,17 +160,20 @@ if ($submit && $reason_id) } $sql_ary = array( - 'reason_id' => (int) $reason_id, - 'post_id' => $post_id, - 'pm_id' => $pm_id, - 'user_id' => (int) $user->data['user_id'], - 'user_notify' => (int) $user_notify, - 'report_closed' => 0, - 'report_time' => (int) time(), - 'report_text' => (string) $report_text, - 'reported_post_text' => $reported_post_text, - 'reported_post_uid' => $reported_post_uid, - 'reported_post_bitfield'=> $reported_post_bitfield, + 'reason_id' => (int) $reason_id, + 'post_id' => $post_id, + 'pm_id' => $pm_id, + 'user_id' => (int) $user->data['user_id'], + 'user_notify' => (int) $user_notify, + 'report_closed' => 0, + 'report_time' => (int) time(), + 'report_text' => (string) $report_text, + 'reported_post_text' => $reported_post_text, + 'reported_post_uid' => $reported_post_uid, + 'reported_post_bitfield' => $reported_post_bitfield, + 'reported_post_enable_bbcode' => $reported_post_enable_bbcode, + 'reported_post_enable_smilies' => $reported_post_enable_smilies, + 'reported_post_enable_magic_url' => $reported_post_enable_magic_url, ); $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); From 73971ef0fa2a53b056847a524bb84f8b2d3e5a4b Mon Sep 17 00:00:00 2001 From: Bruno Ais <brunoaiss@gmail.com> Date: Sun, 2 Dec 2012 23:19:59 +0000 Subject: [PATCH 010/174] [ticket/11171] Cleanup of leftovers I didn't notice that there were actually leftovers from the other PR. Anyway, this will remove all the leftovers I noticed from the other PR. PHPBB3-11171 --- phpBB/includes/mcp/mcp_reports.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index ca730f7728..8da303f6e3 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -140,18 +140,7 @@ class mcp_reports $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; - // Process message, leave it uncensored - $message = $post_info['post_text']; - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) @@ -172,7 +161,7 @@ class mcp_reports if (sizeof($attachments)) { $update_count = array(); - parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); + parse_attachments($post_info['forum_id'], $report['reported_post_text'], $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) From 9eecaa21e3fe23c0c1afc7f8d057754fca68e9a6 Mon Sep 17 00:00:00 2001 From: Bruno Ais <brunoaiss@gmail.com> Date: Thu, 6 Dec 2012 11:22:56 +0000 Subject: [PATCH 011/174] [ticket/11171] Moved the DB schema changes to its place Moved the db changes schema to the place where all the other schema changes are. PHPBB3-11171 --- phpBB/install/database_update.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 060d749b92..91365d4a72 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1123,9 +1123,12 @@ function database_update_info() 'style_parent_tree' => array('TEXT', ''), ), REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1), ), ), 'change_columns' => array( @@ -2791,23 +2794,7 @@ function change_database_data(&$no_updates, $version) _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); - - // PHPBB3-11171: Copy bbcode fields, etc. for reported posts. Add 5 columns to the reports table - // Add the columns used by these changes - $changes['add_columns'] = array( - REPORTS_TABLE => array( - 'reported_post_enable_bbcode' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_magic_url' => array('BOOL', 1) - ) - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } break; } From 02a1777fcbc550b4d91aaa585cffa9c052e4c525 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev <oleg@bsdpower.com> Date: Wed, 26 Dec 2012 00:30:20 -0500 Subject: [PATCH 012/174] [ticket/11295] Drop tables rather than database for postgres in test suite. Doing so allows: 1. User running the tests no longer needs create database privilege. 2. Test database may be located in a non-default tablespace and generally have site-specific options applied to it. PHPBB3-11295 --- ...phpbb_database_test_connection_manager.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index d7c2804aa7..3b8c2e99ae 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -186,6 +186,16 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; + case 'postgres': + $this->connect(); + // Drop all of the tables + foreach ($this->get_tables() as $table) + { + $this->pdo->exec('DROP TABLE ' . $table . ' CASCADE'); + } + $this->purge_extras(); + break; + default: $this->connect(false); @@ -293,7 +303,7 @@ class phpbb_database_test_connection_manager protected function load_schema_from_file($directory) { $schema = $this->dbms['SCHEMA']; - + if ($this->config['dbms'] == 'mysql') { $sth = $this->pdo->query('SELECT VERSION() AS version'); @@ -313,7 +323,7 @@ class phpbb_database_test_connection_manager $queries = file_get_contents($filename); $sql = phpbb_remove_comments($queries); - + $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) @@ -419,6 +429,19 @@ class phpbb_database_test_connection_manager $queries[] = 'DROP SEQUENCE ' . current($row); } break; + + case 'postgres': + $sql = 'SELECT sequence_name + FROM information_schema.sequences'; + $result = $this->pdo->query($sql); + + while ($row = $result->fetch(PDO::FETCH_NUM)) + { + $queries[] = 'DROP SEQUENCE ' . current($row); + } + + $queries[] = 'DROP TYPE IF EXISTS varchar_ci CASCADE'; + break; } foreach ($queries as $query) From f817e20f287a21e2dddfba9721f5e02dce162d29 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Fri, 15 Jul 2011 11:57:53 -0400 Subject: [PATCH 013/174] [feature/migrations] Basic migrations with schema and data changes The migrator takes care of applying migrations as necessary. RFC: http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=41337 PHPBB3-9737 --- phpBB/develop/create_schema_files.php | 14 ++ phpBB/includes/constants.php | 1 + phpBB/includes/db/migration.php | 79 ++++++++ phpBB/includes/db/migrator.php | 227 ++++++++++++++++++++++ phpBB/install/schemas/firebird_schema.sql | 12 ++ phpBB/install/schemas/mssql_schema.sql | 17 ++ phpBB/install/schemas/mysql_40_schema.sql | 12 ++ phpBB/install/schemas/mysql_41_schema.sql | 12 ++ phpBB/install/schemas/oracle_schema.sql | 15 ++ phpBB/install/schemas/postgres_schema.sql | 14 ++ phpBB/install/schemas/sqlite_schema.sql | 12 ++ tests/dbal/fixtures/migrator.xml | 27 +++ tests/dbal/migration/dummy.php | 26 +++ tests/dbal/migration/unfulfillable.php | 26 +++ tests/dbal/migrator_test.php | 80 ++++++++ 15 files changed, 574 insertions(+) create mode 100644 phpBB/includes/db/migration.php create mode 100644 phpBB/includes/db/migrator.php create mode 100644 tests/dbal/fixtures/migrator.xml create mode 100644 tests/dbal/migration/dummy.php create mode 100644 tests/dbal/migration/unfulfillable.php create mode 100644 tests/dbal/migrator_test.php diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3d3e478032..82fbb183c1 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1258,6 +1258,20 @@ function get_schema_struct() ), ); + $schema_data['phpbb_migrations'] = array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'KEYS' => array( + 'migration_name' => array('UNIQUE', 'migration_name'), + ), + ); + $schema_data['phpbb_moderator_cache'] = array( 'COLUMNS' => array( 'forum_id' => array('UINT', 0), diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 68af41ab20..68c96a2759 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -237,6 +237,7 @@ define('ICONS_TABLE', $table_prefix . 'icons'); define('LANG_TABLE', $table_prefix . 'lang'); define('LOG_TABLE', $table_prefix . 'log'); define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); +define('MIGRATIONS_TABLE', $table_prefix . 'migrations'); define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache'); define('MODULES_TABLE', $table_prefix . 'modules'); define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options'); diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php new file mode 100644 index 0000000000..f96fcb9568 --- /dev/null +++ b/phpBB/includes/db/migration.php @@ -0,0 +1,79 @@ +<?php +/** +* +* @package db +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Abstract base class for database migrations +* +* Each migration consists of a set of schema and data changes to be implemented +* in a subclass. This class provides various utility methods to simplify editing +* a phpBB. +* +* @package db +*/ +class phpbb_db_migration +{ + var $db; + var $db_tools; + + /** + * Migration constructor + * + * @param dbal $db Connected database abstraction instance + * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools + */ + function phpbb_db_migration(&$db, &$db_tools) + { + $this->db = &$db; + $this->db_tools = &$db_tools; + } + + /** + * Defines other migrationsto be applied first (abstract method) + * + * @return array An array of migration class names + */ + function depends_on() + { + return array(); + } + + /** + * Updates the database schema + * + * @return null + */ + function update_schema() + { + } + + /** + * Updates data + * + * @return null + */ + function update_data() + { + } + + /** + * Adds a column to a database table + */ + function db_column_add($table_name, $column_name, $column_data) + { + $this->db_tools->sql_column_add($table_name, $column_name, $column_data); + } +} diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php new file mode 100644 index 0000000000..d5d938ca28 --- /dev/null +++ b/phpBB/includes/db/migrator.php @@ -0,0 +1,227 @@ +<?php +/** +* +* @package db +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* The migrator is responsible for applying new migrations in the correct order. +* +* @package db +*/ +class phpbb_db_migrator +{ + var $db; + var $db_tools; + + var $migrations_table; + var $migration_state; + + var $migrations; + + /** + * Constructor of the database migrator + * + * @param dbal $db Connected database abstraction instance + * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools + * @param string $migrations_table The name of the db table storing + * information on applied migrations + */ + function phpbb_db_migrator(&$db, &$db_tools, $migrations_table) + { + $this->db = &$db; + $this->db_tools = &$db_tools; + $this->migrations_table = $migrations_table; + $this->migrations = array(); + + $this->load_migration_state(); + } + + /** + * Loads all migrations and their application state from the database. + * + * @return null + */ + function load_migration_state() + { + $sql = "SELECT * + FROM " . $this->migrations_table; + $result = $this->db->sql_query($sql); + + $this->migration_state = array(); + while ($migration = $this->db->sql_fetchrow($result)) + { + $this->migration_state[$migration['migration_name']] = $migration; + } + + $this->db->sql_freeresult($result); + } + + /** + * Sets the list of available migration class names to the given array. + * + * @param array $class_names An array of migration class names + * @return null + */ + function set_migrations($class_names) + { + $this->migrations = $class_names; + } + + /** + * Runs a single update step from the next migration to be applied. + * + * The update step can either be a schema or a (partial) data update. To + * check if update() needs to be called again use the finished() method. + * + * @return null + */ + function update() + { + foreach ($this->migrations as $name) + { + if (!isset($this->migration_state[$name]) || + !$this->migration_state[$name]['migration_schema_done'] || + !$this->migration_state[$name]['migration_data_done']) + { + if (!$this->try_apply($name)) + { + continue; + } + else + { + return; + } + } + } + } + + /** + * Attempts to apply a step of the given migration or one of its dependencies + * + * @param string The class name of the migration + * @return bool Whether any update step was successfully run + */ + function try_apply($name) + { + if (!class_exists($name)) + { + return false; + } + + $migration =& new $name($this->db, $this->db_tools); + $state = (isset($this->migration_state[$name])) ? + $this->migration_state[$name] : + array( + 'migration_schema_done' => false, + 'migration_data_done' => false, + 'migration_data_state' => '', + ); + + $depends = $migration->depends_on(); + + foreach ($depends as $depend) + { + if (!isset($this->migration_state[$depend]) || + !$this->migration_state[$depend]['migration_schema_done'] || + !$this->migration_state[$depend]['migration_data_done']) + { + return $this->try_apply($depend); + } + } + + if (!$state['migration_schema_done']) + { + $migration->update_schema(); + $state['migration_schema_done'] = true; + } + else + { + $migration->update_data(); + $state['migration_data_done'] = true; + } + + $sql = 'UPDATE ' . $this->migrations_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $state) . " + WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; + $this->db->sql_query($sql); + + $this->migration_state[$name] = $state; + + return true; + } + + /** + * Checks if a migration's dependencies can even theoretically be satisfied. + * + * @param string $name The class name of the migration + * @return bool Whether the migration cannot be fulfilled + */ + function unfulfillable($name) + { + if (isset($this->migration_state[$name])) + { + return false; + } + + if (!class_exists($name)) + { + return true; + } + + $migration =& new $name($this->db, $this->db_tools); + $depends = $migration->depends_on(); + + foreach ($depends as $depend) + { + if ($this->unfulfillable($depend)) + { + return true; + } + } + + return false; + } + + /** + * Checks whether all available, fulfillable migrations have been applied. + * + * @return bool Whether the migrations have been applied + */ + function finished() + { + foreach ($this->migrations as $name) + { + if (!isset($this->migration_state[$name])) + { + // skip unfulfillable migrations, but fulfillables mean we + // are not finished yet + if ($this->unfulfillable($name)) + { + continue; + } + return false; + } + + $migration = $this->migration_state[$name]; + + if (!$migration['migration_schema_done'] || !$migration['migration_data_done']) + { + return false; + } + } + + return true; + } +} diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 767ce68b4a..43099fc33b 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -573,6 +573,18 @@ CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts(attempt_forwar CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts(attempt_time);; CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts(user_id);; +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + migration_schema_done INTEGER DEFAULT 0 NOT NULL, + migration_data_done INTEGER DEFAULT 0 NOT NULL, + migration_data_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, + migration_start_time INTEGER DEFAULT 0 NOT NULL, + migration_end_time INTEGER DEFAULT 0 NOT NULL +);; + +CREATE UNIQUE INDEX phpbb_migrations_migration_name ON phpbb_migrations(migration_name);; + # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id INTEGER DEFAULT 0 NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 84c975942f..1174cdfa3d 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -696,6 +696,23 @@ CREATE INDEX [user_id] ON [phpbb_login_attempts]([user_id]) ON [PRIMARY] GO +/* + Table: 'phpbb_migrations' +*/ +CREATE TABLE [phpbb_migrations] ( + [migration_name] [varchar] (255) DEFAULT ('') NOT NULL , + [migration_schema_done] [int] DEFAULT (0) NOT NULL , + [migration_data_done] [int] DEFAULT (0) NOT NULL , + [migration_data_state] [varchar] (8000) DEFAULT ('') NOT NULL , + [migration_start_time] [int] DEFAULT (0) NOT NULL , + [migration_end_time] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [migration_name] ON [phpbb_migrations]([migration_name]) ON [PRIMARY] +GO + + /* Table: 'phpbb_moderator_cache' */ diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8aab949103..d645c3384d 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -397,6 +397,18 @@ CREATE TABLE phpbb_login_attempts ( ); +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name varbinary(255) DEFAULT '' NOT NULL, + migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_state blob NOT NULL, + migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + UNIQUE migration_name (migration_name) +); + + # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 04aef2844a..d10f2dc55a 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -397,6 +397,18 @@ CREATE TABLE phpbb_login_attempts ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name varchar(255) DEFAULT '' NOT NULL, + migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_state text NOT NULL, + migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + UNIQUE migration_name (migration_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 91f906bc8b..9993caeb7a 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -780,6 +780,21 @@ CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id) / +/* + Table: 'phpbb_migrations' +*/ +CREATE TABLE phpbb_migrations ( + migration_name varchar2(255) DEFAULT '' , + migration_schema_done number(1) DEFAULT '0' NOT NULL, + migration_data_done number(1) DEFAULT '0' NOT NULL, + migration_data_state clob DEFAULT '' , + migration_start_time number(11) DEFAULT '0' NOT NULL, + migration_end_time number(11) DEFAULT '0' NOT NULL, + CONSTRAINT u_phpbb_migration_name UNIQUE (migration_name) +) +/ + + /* Table: 'phpbb_moderator_cache' */ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 619985e0d6..ef138dac0f 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -557,6 +557,20 @@ CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwa CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); +/* + Table: 'phpbb_migrations' +*/ +CREATE TABLE phpbb_migrations ( + migration_name varchar(255) DEFAULT '' NOT NULL, + migration_schema_done INT2 DEFAULT '0' NOT NULL CHECK (migration_schema_done >= 0), + migration_data_done INT2 DEFAULT '0' NOT NULL CHECK (migration_data_done >= 0), + migration_data_state varchar(8000) DEFAULT '' NOT NULL, + migration_start_time INT4 DEFAULT '0' NOT NULL CHECK (migration_start_time >= 0), + migration_end_time INT4 DEFAULT '0' NOT NULL CHECK (migration_end_time >= 0) +); + +CREATE UNIQUE INDEX phpbb_migrations_migration_name ON phpbb_migrations (migration_name); + /* Table: 'phpbb_moderator_cache' */ diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 1690a7dcab..309297779e 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -385,6 +385,18 @@ CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwa CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name varchar(255) NOT NULL DEFAULT '', + migration_schema_done INTEGER UNSIGNED NOT NULL DEFAULT '0', + migration_data_done INTEGER UNSIGNED NOT NULL DEFAULT '0', + migration_data_state text(65535) NOT NULL DEFAULT '', + migration_start_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + migration_end_time INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE UNIQUE INDEX phpbb_migrations_migration_name ON phpbb_migrations (migration_name); + # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', diff --git a/tests/dbal/fixtures/migrator.xml b/tests/dbal/fixtures/migrator.xml new file mode 100644 index 0000000000..1f9079c811 --- /dev/null +++ b/tests/dbal/fixtures/migrator.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_migrations"> + <column>migration_name</column> + <column>migration_schema_done</column> + <column>migration_data_done</column> + <column>migration_data_state</column> + <column>migration_start_time</column> + <column>migration_end_time</column> + <row> + <value>installed_migration</value> + <value>1</value> + <value>1</value> + <value></value> + <value>1234</value> + <value>5678</value> + </row> + </table> + <table name="phpbb_config"> + <column>config_name</column> + <column>config_value</column> + <row> + <value>foo</value> + <value>bar</value> + </row> + </table> +</dataset> diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php new file mode 100644 index 0000000000..b286d44f77 --- /dev/null +++ b/tests/dbal/migration/dummy.php @@ -0,0 +1,26 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_dummy extends phpbb_db_migration +{ + function depends_on() + { + return array('installed_migration'); + } + + function update_schema() + { + $this->db_column_add('phpbb_config', 'extra_column', array('UINT', 0)); + } + + function update_data() + { + $this->db->sql_query('UPDATE phpbb_config SET extra_column = 1'); + } +} diff --git a/tests/dbal/migration/unfulfillable.php b/tests/dbal/migration/unfulfillable.php new file mode 100644 index 0000000000..84136ffe6d --- /dev/null +++ b/tests/dbal/migration/unfulfillable.php @@ -0,0 +1,26 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_unfulfillable extends phpbb_db_migration +{ + function depends_on() + { + return array('installed_migration', 'phpbb_dbal_migration_dummy', 'non_existant_migration'); + } + + function update_schema() + { + trigger_error('Schema update of migration with unfulfillable dependency was run!'); + } + + function update_data() + { + trigger_error('Data update of migration with unfulfillable dependency was run!'); + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php new file mode 100644 index 0000000000..1e7d1343fc --- /dev/null +++ b/tests/dbal/migrator_test.php @@ -0,0 +1,80 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migrator.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; + +require_once dirname(__FILE__) . '/migration/dummy.php'; +require_once dirname(__FILE__) . '/migration/unfulfillable.php'; + +class phpbb_dbal_migrator_test extends phpbb_database_test_case +{ + protected $db; + protected $db_tools; + protected $migrator; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml'); + } + + public function setup() + { + parent::setup(); + + $this->db = $this->new_dbal(); + $this->db_tools = new phpbb_db_tools($this->db); + $this->migrator = new phpbb_db_migrator($this->db, $this->db_tools, MIGRATIONS_TABLE); + } + + public function test_update() + { + $this->migrator->set_migrations(array('phpbb_dbal_migration_dummy')); + + // schema + $this->migrator->update(); + $this->assertFalse($this->migrator->finished()); + + // data + $this->migrator->update(); + $this->assertTrue($this->migrator->finished()); + + $this->assertSqlResultEquals( + array(array('extra_column' => '1')), + "SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'", + 'Dummy migration created extra_column with value 1 in all rows.' + ); + + // cleanup + $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); + } + + public function test_unfulfillable() + { + $this->migrator->set_migrations(array('phpbb_dbal_migration_unfulfillable', 'phpbb_dbal_migration_dummy')); + + while (!$this->migrator->finished()) + { + $this->migrator->update(); + } + + $this->assertTrue($this->migrator->finished()); + + $this->assertSqlResultEquals( + array(array('extra_column' => '1')), + "SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'", + 'Dummy migration was run, even though an unfulfillable migration was found.' + ); + + // cleanup + $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); + } +} From d304b6449db6e7c6f3c9058062aca0c641f023a4 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Sun, 7 Aug 2011 19:10:38 -0400 Subject: [PATCH 014/174] [feature/migrations] Store start and end time of migrations PHPBB3-9737 --- phpBB/includes/db/migrator.php | 21 +++++++++++++++++++++ tests/dbal/migrator_test.php | 33 +++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index d5d938ca28..f4613e3aec 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -127,6 +127,8 @@ class phpbb_db_migrator 'migration_schema_done' => false, 'migration_data_done' => false, 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, ); $depends = $migration->depends_on(); @@ -141,6 +143,12 @@ class phpbb_db_migrator } } + if (!isset($this->migration_state[$name])) + { + $state['migration_start_time'] = time(); + $this->insert_migration($name, $state); + } + if (!$state['migration_schema_done']) { $migration->update_schema(); @@ -150,6 +158,7 @@ class phpbb_db_migrator { $migration->update_data(); $state['migration_data_done'] = true; + $state['migration_end_time'] = time(); } $sql = 'UPDATE ' . $this->migrations_table . ' @@ -162,6 +171,18 @@ class phpbb_db_migrator return true; } + function insert_migration($name, $state) + { + $migration_row = $state; + $migration_row['migration_name'] = $name; + + $sql = 'INSERT INTO ' . $this->migrations_table . ' + ' . $this->db->sql_build_array('INSERT', $migration_row); + $this->db->sql_query($sql); + + $this->migration_state[$name] = $state; + } + /** * Checks if a migration's dependencies can even theoretically be satisfied. * diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 1e7d1343fc..dd194d7c05 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -26,7 +26,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml'); } - public function setup() + public function setUp() { parent::setup(); @@ -35,6 +35,12 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->migrator = new phpbb_db_migrator($this->db, $this->db_tools, MIGRATIONS_TABLE); } + public function tearDown() + { + // cleanup + $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); + } + public function test_update() { $this->migrator->set_migrations(array('phpbb_dbal_migration_dummy')); @@ -43,6 +49,16 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->migrator->update(); $this->assertFalse($this->migrator->finished()); + $this->assertSqlResultEquals( + array(array('success' => '1')), + "SELECT 1 as success + FROM phpbb_migrations + WHERE migration_name = 'phpbb_dbal_migration_dummy' + AND migration_start_time >= " . (time() - 1) . " + AND migration_start_time <= " . (time() + 1), + 'Start time set correctly' + ); + // data $this->migrator->update(); $this->assertTrue($this->migrator->finished()); @@ -53,8 +69,16 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case 'Dummy migration created extra_column with value 1 in all rows.' ); - // cleanup - $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); + $this->assertSqlResultEquals( + array(array('success' => '1')), + "SELECT 1 as success + FROM phpbb_migrations + WHERE migration_name = 'phpbb_dbal_migration_dummy' + AND migration_start_time <= migration_end_time + AND migration_end_time >= " . (time() - 1) . " + AND migration_end_time <= " . (time() + 1), + 'End time set correctly' + ); } public function test_unfulfillable() @@ -73,8 +97,5 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case "SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'", 'Dummy migration was run, even though an unfulfillable migration was found.' ); - - // cleanup - $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); } } From 8645321f40d0b13de6201688c69f9f05bc649dcf Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Thu, 25 Oct 2012 12:26:44 -0700 Subject: [PATCH 015/174] [feature/migrations] Return schema changes in database update style array Returning the set of schema changes allows potentially aggregating to generate the overall install schema automatically from a set of migrations PHPBB3-9737 --- phpBB/includes/db/migration.php | 5 +++-- phpBB/includes/db/migrator.php | 7 ++++++- tests/dbal/migration/dummy.php | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index f96fcb9568..ee916aedc0 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -52,12 +52,13 @@ class phpbb_db_migration } /** - * Updates the database schema + * Updates the database schema by providing a set of change instructions * - * @return null + * @return array */ function update_schema() { + return array(); } /** diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index f4613e3aec..4a178af468 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -151,7 +151,7 @@ class phpbb_db_migrator if (!$state['migration_schema_done']) { - $migration->update_schema(); + $this->apply_schema_changes($migration->update_schema()); $state['migration_schema_done'] = true; } else @@ -245,4 +245,9 @@ class phpbb_db_migrator return true; } + + function apply_schema_changes($schema_changes) + { + $this->db_tools->perform_schema_changes($schema_changes); + } } diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php index b286d44f77..0567b50740 100644 --- a/tests/dbal/migration/dummy.php +++ b/tests/dbal/migration/dummy.php @@ -16,7 +16,13 @@ class phpbb_dbal_migration_dummy extends phpbb_db_migration function update_schema() { - $this->db_column_add('phpbb_config', 'extra_column', array('UINT', 0)); + return array( + 'add_columns' => array( + 'phpbb_config' => array( + 'extra_column' => array('UINT', 0), + ), + ), + ); } function update_data() From c802f2a66c577781036b7bfd6d6689159028c3a6 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Thu, 25 Oct 2012 13:02:56 -0700 Subject: [PATCH 016/174] [feature/migrations] Standard vars for migrations and run sql with feedback PHPBB3-9737 --- phpBB/includes/db/migration.php | 52 ++++++++++++++++++++++++++++++--- phpBB/includes/db/migrator.php | 17 +++++++++-- tests/dbal/migrator_test.php | 2 +- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index ee916aedc0..09d4e31344 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -28,17 +28,32 @@ class phpbb_db_migration { var $db; var $db_tools; + var $table_prefix; + + var $phpbb_root_path; + var $php_ext; + + var $errors; /** * Migration constructor * * @param dbal $db Connected database abstraction instance * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools + * @param string $table_prefix The prefix for all table names + * @param string $phpbb_root_path + * @param string $php_ext */ - function phpbb_db_migration(&$db, &$db_tools) + function phpbb_db_migration(&$db, &$db_tools, $table_prefix, $phpbb_root_path, $php_ext) { $this->db = &$db; $this->db_tools = &$db_tools; + $this->table_prefix = $table_prefix; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->errors = array(); } /** @@ -71,10 +86,39 @@ class phpbb_db_migration } /** - * Adds a column to a database table + * Wrapper for running queries to generate user feedback on updates */ - function db_column_add($table_name, $column_name, $column_data) + function sql_query($sql) { - $this->db_tools->sql_column_add($table_name, $column_name, $column_data); + if (defined('DEBUG_EXTRA')) + { + echo "<br />\n{$sql}\n<br />"; + } + + $db->sql_return_on_error(true); + + if ($sql === 'begin') + { + $result = $db->sql_transaction('begin'); + } + else if ($sql === 'commit') + { + $result = $db->sql_transaction('commit'); + } + else + { + $result = $db->sql_query($sql); + if ($db->sql_error_triggered) + { + $this->errors[] = array( + 'sql' => $db->sql_error_sql, + 'code' => $db->sql_error_returned, + ); + } + } + + $db->sql_return_on_error(false); + + return $result; } } diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 4a178af468..4ce54a4b92 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -24,6 +24,10 @@ class phpbb_db_migrator { var $db; var $db_tools; + var $table_prefix; + + var $phpbb_root_path; + var $php_ext; var $migrations_table; var $migration_state; @@ -35,16 +39,23 @@ class phpbb_db_migrator * * @param dbal $db Connected database abstraction instance * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools + * @param string $table_prefix The prefix for all table names * @param string $migrations_table The name of the db table storing * information on applied migrations + * @param string $phpbb_root_path + * @param string $php_ext */ - function phpbb_db_migrator(&$db, &$db_tools, $migrations_table) + function phpbb_db_migrator(&$db, &$db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext) { $this->db = &$db; $this->db_tools = &$db_tools; + $this->table_prefix = $table_prefix; $this->migrations_table = $migrations_table; $this->migrations = array(); + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->load_migration_state(); } @@ -120,7 +131,7 @@ class phpbb_db_migrator return false; } - $migration =& new $name($this->db, $this->db_tools); + $migration =& new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); $state = (isset($this->migration_state[$name])) ? $this->migration_state[$name] : array( @@ -201,7 +212,7 @@ class phpbb_db_migrator return true; } - $migration =& new $name($this->db, $this->db_tools); + $migration =& new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); $depends = $migration->depends_on(); foreach ($depends as $depend) diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index dd194d7c05..898a197dfd 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -32,7 +32,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->db = $this->new_dbal(); $this->db_tools = new phpbb_db_tools($this->db); - $this->migrator = new phpbb_db_migrator($this->db, $this->db_tools, MIGRATIONS_TABLE); + $this->migrator = new phpbb_db_migrator($this->db, $this->db_tools, 'phpbb_', MIGRATIONS_TABLE, 'phpBB/', '.php'); } public function tearDown() From b1f9ca2f6541924c75a30c68dd8a4bc8db62205d Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Fri, 9 Nov 2012 17:10:48 +0100 Subject: [PATCH 017/174] [feature/migrations] Moved database_update info to individual migration classes --- phpBB/develop/create_schema_files.php | 14 - phpBB/includes/db/migration.php | 2 +- phpBB/includes/db/migration/v301.php | 25 + phpBB/includes/db/migration/v3010.php | 25 + phpBB/includes/db/migration/v3010rc1.php | 29 + phpBB/includes/db/migration/v3010rc2.php | 25 + phpBB/includes/db/migration/v3010rc3.php | 25 + phpBB/includes/db/migration/v3011.php | 25 + phpBB/includes/db/migration/v3011rc1.php | 83 ++ phpBB/includes/db/migration/v3011rc2.php | 31 + phpBB/includes/db/migration/v3012rc1.php | 26 + phpBB/includes/db/migration/v301rc1.php | 77 ++ phpBB/includes/db/migration/v302.php | 25 + phpBB/includes/db/migration/v302rc1.php | 30 + phpBB/includes/db/migration/v302rc2.php | 52 + phpBB/includes/db/migration/v303.php | 25 + phpBB/includes/db/migration/v303rc1.php | 135 ++ phpBB/includes/db/migration/v304.php | 40 + phpBB/includes/db/migration/v304rc1.php | 96 ++ phpBB/includes/db/migration/v305.php | 25 + phpBB/includes/db/migration/v305rc1.php | 146 +++ phpBB/includes/db/migration/v306.php | 25 + phpBB/includes/db/migration/v306rc1.php | 350 ++++++ phpBB/includes/db/migration/v306rc2.php | 25 + phpBB/includes/db/migration/v306rc3.php | 31 + phpBB/includes/db/migration/v306rc4.php | 25 + phpBB/includes/db/migration/v307.php | 25 + phpBB/includes/db/migration/v307pl1.php | 25 + phpBB/includes/db/migration/v307rc1.php | 46 + phpBB/includes/db/migration/v307rc2.php | 53 + phpBB/includes/db/migration/v308.php | 25 + phpBB/includes/db/migration/v308rc1.php | 222 ++++ phpBB/includes/db/migration/v309.php | 25 + phpBB/includes/db/migration/v309rc1.php | 100 ++ phpBB/includes/db/migration/v309rc2.php | 25 + phpBB/includes/db/migration/v309rc3.php | 25 + phpBB/includes/db/migration/v309rc4.php | 25 + phpBB/install/database_update.php | 1457 ---------------------- 38 files changed, 1998 insertions(+), 1472 deletions(-) create mode 100644 phpBB/includes/db/migration/v301.php create mode 100644 phpBB/includes/db/migration/v3010.php create mode 100644 phpBB/includes/db/migration/v3010rc1.php create mode 100644 phpBB/includes/db/migration/v3010rc2.php create mode 100644 phpBB/includes/db/migration/v3010rc3.php create mode 100644 phpBB/includes/db/migration/v3011.php create mode 100644 phpBB/includes/db/migration/v3011rc1.php create mode 100644 phpBB/includes/db/migration/v3011rc2.php create mode 100644 phpBB/includes/db/migration/v3012rc1.php create mode 100644 phpBB/includes/db/migration/v301rc1.php create mode 100644 phpBB/includes/db/migration/v302.php create mode 100644 phpBB/includes/db/migration/v302rc1.php create mode 100644 phpBB/includes/db/migration/v302rc2.php create mode 100644 phpBB/includes/db/migration/v303.php create mode 100644 phpBB/includes/db/migration/v303rc1.php create mode 100644 phpBB/includes/db/migration/v304.php create mode 100644 phpBB/includes/db/migration/v304rc1.php create mode 100644 phpBB/includes/db/migration/v305.php create mode 100644 phpBB/includes/db/migration/v305rc1.php create mode 100644 phpBB/includes/db/migration/v306.php create mode 100644 phpBB/includes/db/migration/v306rc1.php create mode 100644 phpBB/includes/db/migration/v306rc2.php create mode 100644 phpBB/includes/db/migration/v306rc3.php create mode 100644 phpBB/includes/db/migration/v306rc4.php create mode 100644 phpBB/includes/db/migration/v307.php create mode 100644 phpBB/includes/db/migration/v307pl1.php create mode 100644 phpBB/includes/db/migration/v307rc1.php create mode 100644 phpBB/includes/db/migration/v307rc2.php create mode 100644 phpBB/includes/db/migration/v308.php create mode 100644 phpBB/includes/db/migration/v308rc1.php create mode 100644 phpBB/includes/db/migration/v309.php create mode 100644 phpBB/includes/db/migration/v309rc1.php create mode 100644 phpBB/includes/db/migration/v309rc2.php create mode 100644 phpBB/includes/db/migration/v309rc3.php create mode 100644 phpBB/includes/db/migration/v309rc4.php diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 82fbb183c1..3d3e478032 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1258,20 +1258,6 @@ function get_schema_struct() ), ); - $schema_data['phpbb_migrations'] = array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'KEYS' => array( - 'migration_name' => array('UNIQUE', 'migration_name'), - ), - ); - $schema_data['phpbb_moderator_cache'] = array( 'COLUMNS' => array( 'forum_id' => array('UINT', 0), diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index 09d4e31344..aca9d264bb 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -3,7 +3,7 @@ * * @package db * @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 * */ diff --git a/phpBB/includes/db/migration/v301.php b/phpBB/includes/db/migration/v301.php new file mode 100644 index 0000000000..8a2a265a3c --- /dev/null +++ b/phpBB/includes/db/migration/v301.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v301 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v301rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3010.php b/phpBB/includes/db/migration/v3010.php new file mode 100644 index 0000000000..7490ba1005 --- /dev/null +++ b/phpBB/includes/db/migration/v3010.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3010 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3010rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3010rc1.php b/phpBB/includes/db/migration/v3010rc1.php new file mode 100644 index 0000000000..9a43b4c81d --- /dev/null +++ b/phpBB/includes/db/migration/v3010rc1.php @@ -0,0 +1,29 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3010rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v309'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + if (!isset($config['email_max_chunk_size'])) + { + set_config('email_max_chunk_size', '50'); + } + } +} diff --git a/phpBB/includes/db/migration/v3010rc2.php b/phpBB/includes/db/migration/v3010rc2.php new file mode 100644 index 0000000000..8c1809227c --- /dev/null +++ b/phpBB/includes/db/migration/v3010rc2.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3010rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3010rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3010rc3.php b/phpBB/includes/db/migration/v3010rc3.php new file mode 100644 index 0000000000..917cabd8fe --- /dev/null +++ b/phpBB/includes/db/migration/v3010rc3.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3010rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3010rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3011.php b/phpBB/includes/db/migration/v3011.php new file mode 100644 index 0000000000..7d506308b1 --- /dev/null +++ b/phpBB/includes/db/migration/v3011.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3011 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3011rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3011rc1.php b/phpBB/includes/db/migration/v3011rc1.php new file mode 100644 index 0000000000..04f86b47ae --- /dev/null +++ b/phpBB/includes/db/migration/v3011rc1.php @@ -0,0 +1,83 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3011rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3010'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + // Updates users having current style a deactivated one + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_active = 0'; + $result = $db->sql_query($sql); + + $deactivated_style_ids = array(); + while ($style_id = $db->sql_fetchfield('style_id', false, $result)) + { + $deactivated_style_ids[] = (int) $style_id; + } + $db->sql_freeresult($result); + + if (!empty($deactivated_style_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $config['default_style'] .' + WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); + _sql($sql, $errored, $error_ary); + } + + // Delete orphan private messages + $batch_size = 500; + + $sql_array = array( + 'SELECT' => 'p.msg_id', + 'FROM' => array( + PRIVMSGS_TABLE => 'p', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), + 'ON' => 'p.msg_id = t.msg_id', + ), + ), + 'WHERE' => 't.user_id IS NULL', + ); + $sql = $db->sql_build_query('SELECT', $sql_array); + + do + { + $result = $db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $db->sql_fetchrow($result)) + { + $delete_pms[] = (int) $row['msg_id']; + } + $db->sql_freeresult($result); + + if (!empty($delete_pms)) + { + $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' + WHERE ' . $db->sql_in_set('msg_id', $delete_pms); + _sql($sql, $errored, $error_ary); + } + } + while (sizeof($delete_pms) == $batch_size); + } +} diff --git a/phpBB/includes/db/migration/v3011rc2.php b/phpBB/includes/db/migration/v3011rc2.php new file mode 100644 index 0000000000..0f66eff156 --- /dev/null +++ b/phpBB/includes/db/migration/v3011rc2.php @@ -0,0 +1,31 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3011rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3011rc1'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue' => array('BOOL', 0), + ), + ), + ); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3012rc1.php b/phpBB/includes/db/migration/v3012rc1.php new file mode 100644 index 0000000000..67f7a29b02 --- /dev/null +++ b/phpBB/includes/db/migration/v3012rc1.php @@ -0,0 +1,26 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v3012rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v3011'); + } + + function update_schema() + { + /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v301rc1.php b/phpBB/includes/db/migration/v301rc1.php new file mode 100644 index 0000000000..aee50e3039 --- /dev/null +++ b/phpBB/includes/db/migration/v301rc1.php @@ -0,0 +1,77 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v301rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array(); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list' => array('BOOL', 1), + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'groups' => array('group_legend'), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('session_forum_id'), + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + ); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'fix_unset_last_view_time'))), + array('custom', array(array(&$this, 'reset_smiley_size'))), + ); + } + + function fix_unset_last_view_time() + { + $sql = 'UPDATE ' . $this->table_prefix . "topics + SET topic_last_view_time = topic_last_post_time + WHERE topic_last_view_time = 0"; + $this->sql_query($sql); + } + + function reset_smiley_size() + { + // Update smiley sizes + $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); + + foreach ($smileys as $smiley) + { + if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley)) + { + list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET smiley_width = ' . $width . ', smiley_height = ' . $height . " + WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'"; + + $this->sql_query($sql); + } + } + } +} diff --git a/phpBB/includes/db/migration/v302.php b/phpBB/includes/db/migration/v302.php new file mode 100644 index 0000000000..942a0ac58c --- /dev/null +++ b/phpBB/includes/db/migration/v302.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v302 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v302rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v302rc1.php b/phpBB/includes/db/migration/v302rc1.php new file mode 100644 index 0000000000..ced4d9fbfc --- /dev/null +++ b/phpBB/includes/db/migration/v302rc1.php @@ -0,0 +1,30 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v301rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v301'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.add', array('referer_validation', '1')), + array('config.add', array('check_attachment_content', '1')), + array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), + ); + } +} diff --git a/phpBB/includes/db/migration/v302rc2.php b/phpBB/includes/db/migration/v302rc2.php new file mode 100644 index 0000000000..21aa5ca728 --- /dev/null +++ b/phpBB/includes/db/migration/v302rc2.php @@ -0,0 +1,52 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v302rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v302rc1'); + } + + function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'drafts' => array( + 'draft_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'forums' => array( + 'forum_last_post_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'posts' => array( + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'topics' => array( + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array('session_forum_id'), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid' => array('session_forum_id'), + ), + ), + ); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v303.php b/phpBB/includes/db/migration/v303.php new file mode 100644 index 0000000000..409c396baf --- /dev/null +++ b/phpBB/includes/db/migration/v303.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v303 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v302rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v303rc1.php b/phpBB/includes/db/migration/v303rc1.php new file mode 100644 index 0000000000..b8ec5668fd --- /dev/null +++ b/phpBB/includes/db/migration/v303rc1.php @@ -0,0 +1,135 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v303rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v302'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('enable_queue_trigger', '0')), + array('config.add', array('queue_trigger_posts', '3')), + array('config.add', array('pm_max_recipients', '0')), + array('custom', array('set_group_default_max_recipients')) + + // Not prefilling yet + set_config('dbms_version', ''); + + // Add new permission u_masspm_group and duplicate settings from u_masspm + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + + // Only add the new permission if it does not already exist + if (empty($auth_admin->acl_options['id']['u_masspm_group'])) + { + $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['u_masspm']; + $new_id = $auth_admin->acl_options['id']['u_masspm_group']; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + // Remove any old permission entries + $auth_admin->acl_clear_prefetch(); + } + + /** + * Do not resync post counts here. An admin may do this later from the ACP + $start = 0; + $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; + _sql($sql, $errored, $error_ary); + + do + { + $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id + FROM ' . POSTS_TABLE . ' + WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' + AND post_postcount = 1 AND post_approved = 1 + GROUP BY poster_id'; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; + _sql($sql, $errored, $error_ary); + } + while ($row = $db->sql_fetchrow($result)); + + $start += $step; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + */ + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_a_email && cfg_email_enable\' + WHERE module_class = \'acp\' + AND module_basename = \'email\''; + _sql($sql, $errored, $error_ary); + } + + function set_group_default_max_recipients() + { + // Set maximum number of recipients for the registered users, bots, guests group + $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 + WHERE ' . $this->db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); + $this->sql_query($sql); + } + +} diff --git a/phpBB/includes/db/migration/v304.php b/phpBB/includes/db/migration/v304.php new file mode 100644 index 0000000000..2895caaa6d --- /dev/null +++ b/phpBB/includes/db/migration/v304.php @@ -0,0 +1,40 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v304 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v304rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + if ($db->sql_layer == 'oracle') + { + // log_operation is CLOB - but we can change this later + $sql = 'UPDATE ' . LOG_TABLE . " + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; + _sql($sql, $errored, $error_ary); + } + else + { + $sql = 'UPDATE ' . LOG_TABLE . " + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation = 'LOG_TOPIC_DELETED'"; + _sql($sql, $errored, $error_ary); + } + } +} diff --git a/phpBB/includes/db/migration/v304rc1.php b/phpBB/includes/db/migration/v304rc1.php new file mode 100644 index 0000000000..a7098ce62f --- /dev/null +++ b/phpBB/includes/db/migration/v304rc1.php @@ -0,0 +1,96 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v304rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v303'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile' => array('BOOL', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'styles' => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_imageset' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_theme' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template_data' => array( + 'template_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_style' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide + FROM ' . PROFILE_FIELDS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + $sql_ary = array( + 'field_required' => 0, + 'field_show_on_reg' => 0, + 'field_hide' => 0, + 'field_show_profile'=> 0, + ); + + if ($row['field_required']) + { + $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_show_on_reg']) + { + $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_hide']) + { + // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module + $sql_ary['field_hide'] = 1; + } + else + { + // equivelant to "none", which is the "Display in user control panel" option + $sql_ary['field_show_profile'] = 1; + } + + _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); + } + } +} diff --git a/phpBB/includes/db/migration/v305.php b/phpBB/includes/db/migration/v305.php new file mode 100644 index 0000000000..b4d676d72a --- /dev/null +++ b/phpBB/includes/db/migration/v305.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v305 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v305rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v305rc1.php b/phpBB/includes/db/migration/v305rc1.php new file mode 100644 index 0000000000..8d9c4d2456 --- /dev/null +++ b/phpBB/includes/db/migration/v305rc1.php @@ -0,0 +1,146 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v305rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v304'); + } + + function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + // Captcha config variables + set_config('captcha_gd_wave', 0); + set_config('captcha_gd_3d_noise', 1); + set_config('captcha_gd_fonts', 1); + set_config('confirm_refresh', 1); + + // Maximum number of keywords + set_config('max_num_search_keywords', 10); + + // Remove static config var and put it back as dynamic variable + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET is_dynamic = 1 + WHERE config_name = 'search_indexing_state'"; + _sql($sql, $errored, $error_ary); + + // Hash old MD5 passwords + $sql = 'SELECT user_id, user_password + FROM ' . USERS_TABLE . ' + WHERE user_pass_convert = 1'; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + if (strlen($row['user_password']) == 32) + { + $sql_ary = array( + 'user_password' => phpbb_hash($row['user_password']), + ); + + _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); + } + } + $db->sql_freeresult($result); + + // Adjust bot entry + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + _sql($sql, $errored, $error_ary); + + + // Before we are able to add a unique key to auth_option, we need to remove duplicate entries + + // We get duplicate entries first + $sql = 'SELECT auth_option + FROM ' . ACL_OPTIONS_TABLE . ' + GROUP BY auth_option + HAVING COUNT(*) >= 2'; + $result = $db->sql_query($sql); + + $auth_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $auth_options[] = $row['auth_option']; + } + $db->sql_freeresult($result); + + // Remove specific auth options + if (!empty($auth_options)) + { + foreach ($auth_options as $option) + { + // Select auth_option_ids... the largest id will be preserved + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $db->sql_escape($option) . "' + ORDER BY auth_option_id DESC"; + // sql_query_limit not possible here, due to bug in postgresql layer + $result = $db->sql_query($sql); + + // Skip first row, this is our original auth option we want to preserve + $row = $db->sql_fetchrow($result); + + while ($row = $db->sql_fetchrow($result)) + { + // Ok, remove this auth option... + _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + } + $db->sql_freeresult($result); + } + } + + // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. + $changes = array( + 'drop_keys' => array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + ); + + global $db_tools; + + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + + $changes = array( + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + } +} diff --git a/phpBB/includes/db/migration/v306.php b/phpBB/includes/db/migration/v306.php new file mode 100644 index 0000000000..eec2f7c752 --- /dev/null +++ b/phpBB/includes/db/migration/v306.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v306 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v306rc4'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v306rc1.php b/phpBB/includes/db/migration/v306rc1.php new file mode 100644 index 0000000000..63d1c66c2d --- /dev/null +++ b/phpBB/includes/db/migration/v306rc1.php @@ -0,0 +1,350 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v306rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v305'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'confirm' => array( + 'attempts' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time' => array('TIMESTAMP', 0), + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported' => array('BOOL', 0), + ), + $this->table_prefix . 'reports' => array( + 'pm_id' => array('UINT', 0), + ), + $this->table_prefix . 'fields' => array( + 'field_show_on_vt' => array('BOOL', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_options' => array('UINT:20', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_options' => array('UINT:11', 230271), + ), + ), + 'add_index' => array( + $this->table_prefix . 'reports' => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), + $this->table_prefix . 'posts' => array( + 'post_username' => array('post_username:255'), + ), + ), + ); + } + + function update_data() + { + // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... + if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) + { + set_config('captcha_plugin', 'phpbb_captcha_gd'); + } + else if (!isset($config['captcha_plugin'])) + { + set_config('captcha_plugin', 'phpbb_captcha_nogd'); + } + + // Entries for the Feed Feature + set_config('feed_enable', '0'); + set_config('feed_limit', '10'); + + set_config('feed_overall_forums', '1'); + set_config('feed_overall_forums_limit', '15'); + + set_config('feed_overall_topics', '0'); + set_config('feed_overall_topics_limit', '15'); + + set_config('feed_forum', '1'); + set_config('feed_topic', '1'); + set_config('feed_item_statistics', '1'); + + // Entries for smiley pagination + set_config('smilies_per_page', '50'); + + // Entry for reporting PMs + set_config('allow_pm_report', '1'); + + // Install modules + $modules_to_install = array( + 'feed' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_FEED_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_BOARD_CONFIGURATION', + 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') + ), + 'warnings' => array( + 'base' => 'users', + 'class' => 'acp', + 'title' => 'ACP_USER_WARNINGS', + 'auth' => 'acl_a_user', + 'display' => 0, + 'cat' => 'ACP_CAT_USERS', + 'after' => array('feedback', 'ACP_USER_FEEDBACK') + ), + 'send_statistics' => array( + 'base' => 'send_statistics', + 'class' => 'acp', + 'title' => 'ACP_SEND_STATISTICS', + 'auth' => 'acl_a_server', + 'cat' => 'ACP_SERVER_CONFIGURATION' + ), + 'setting_forum_copy' => array( + 'base' => 'permissions', + 'class' => 'acp', + 'title' => 'ACP_FORUM_PERMISSIONS_COPY', + 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', + 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', + 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') + ), + 'pm_reports' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_OPEN', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + 'pm_reports_closed' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_CLOSED', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + 'pm_report_details' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORT_DETAILS', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + ); + + _add_modules($modules_to_install); + + // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED'"; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + if (!$group_id) + { + $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; + _sql($sql, $errored, $error_ary); + + $group_id = $db->sql_nextid(); + } + + // Insert new user role... at the end of the chain + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_USER_NEW_MEMBER' + AND role_type = 'u_'"; + $result = $db->sql_query($sql); + $u_role = (int) $db->sql_fetchfield('role_id'); + $db->sql_freeresult($result); + + if (!$u_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'u_'"; + $result = $db->sql_query($sql); + $next_order_id = (int) $db->sql_fetchfield('max_order_id'); + $db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; + _sql($sql, $errored, $error_ary); + $u_role = $db->sql_nextid(); + + if (!$errored) + { + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + _sql($sql, $errored, $error_ary); + + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + _sql($sql, $errored, $error_ary); + } + } + + // Insert new forum role + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' + AND role_type = 'f_'"; + $result = $db->sql_query($sql); + $f_role = (int) $db->sql_fetchfield('role_id'); + $db->sql_freeresult($result); + + if (!$f_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'f_'"; + $result = $db->sql_query($sql); + $next_order_id = (int) $db->sql_fetchfield('max_order_id'); + $db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; + _sql($sql, $errored, $error_ary); + $f_role = $db->sql_nextid(); + + if (!$errored) + { + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + _sql($sql, $errored, $error_ary); + } + } + + // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) + $sql = 'SELECT 1 + FROM ' . USERS_TABLE . ' + WHERE user_new = 0'; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; + _sql($sql, $errored, $error_ary); + } + + // Newly registered users limit + if (!isset($config['new_member_post_limit'])) + { + set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); + } + + if (!isset($config['new_member_group_default'])) + { + set_config('new_member_group_default', 0); + } + + // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... + // Check if the role is already assigned... + $sql = 'SELECT forum_id + FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id = ' . $f_role; + $result = $db->sql_query($sql); + $is_options = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + + // Not assigned at all... :/ + if (!$is_options) + { + // Get postable forums + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type != ' . FORUM_LINK; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); + } + $db->sql_freeresult($result); + } + + // Clear permissions... + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + $auth_admin->acl_clear_prefetch(); + + if (!isset($config['allow_avatar'])) + { + if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) + { + set_config('allow_avatar', '1'); + } + else + { + set_config('allow_avatar', '0'); + } + } + + if (!isset($config['allow_avatar_remote_upload'])) + { + if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) + { + set_config('allow_avatar_remote_upload', '1'); + } + else + { + set_config('allow_avatar_remote_upload', '0'); + } + } + + // Minimum number of characters + if (!isset($config['min_post_chars'])) + { + set_config('min_post_chars', '1'); + } + + if (!isset($config['allow_quick_reply'])) + { + set_config('allow_quick_reply', '1'); + } + + // Set every members user_options column to enable + // bbcode, smilies and URLs for signatures by default + $sql = 'SELECT user_options + FROM ' . USERS_TABLE . ' + WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + $result = $db->sql_query_limit($sql, 1); + $user_option = (int) $db->sql_fetchfield('user_options'); + $db->sql_freeresult($result); + + // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option + if (!($user_option & 1 << 15)) + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + _sql($sql, $errored, $error_ary); + } + + if (!isset($config['delete_time'])) + { + set_config('delete_time', $config['edit_time']); + } + } +} diff --git a/phpBB/includes/db/migration/v306rc2.php b/phpBB/includes/db/migration/v306rc2.php new file mode 100644 index 0000000000..0a6c388da6 --- /dev/null +++ b/phpBB/includes/db/migration/v306rc2.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v306rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v306rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v306rc3.php b/phpBB/includes/db/migration/v306rc3.php new file mode 100644 index 0000000000..b3bd49eafa --- /dev/null +++ b/phpBB/includes/db/migration/v306rc3.php @@ -0,0 +1,31 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v306rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v306rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' + SET field_show_on_vt = 1 + WHERE field_hide = 0 + AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; + _sql($sql, $errored, $error_ary); + } +} diff --git a/phpBB/includes/db/migration/v306rc4.php b/phpBB/includes/db/migration/v306rc4.php new file mode 100644 index 0000000000..92c1979311 --- /dev/null +++ b/phpBB/includes/db/migration/v306rc4.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v306rc4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v306rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v307.php b/phpBB/includes/db/migration/v307.php new file mode 100644 index 0000000000..a693a16676 --- /dev/null +++ b/phpBB/includes/db/migration/v307.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v307 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v307rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v307pl1.php b/phpBB/includes/db/migration/v307pl1.php new file mode 100644 index 0000000000..3c1ed2be94 --- /dev/null +++ b/phpBB/includes/db/migration/v307pl1.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v307pl1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v307'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v307rc1.php b/phpBB/includes/db/migration/v307rc1.php new file mode 100644 index 0000000000..f1c8b3384a --- /dev/null +++ b/phpBB/includes/db/migration/v307rc1.php @@ -0,0 +1,46 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v307rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v306'); + } + + function update_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'log' => array('log_time'), + ), + 'add_index' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id' => array('topic_id'), + ), + ), + ); + } + + function update_data() + { + // ATOM Feeds + set_config('feed_overall', '1'); + set_config('feed_http_auth', '0'); + set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15)); + set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10)); + set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0')); + set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0')); + + // Delete all text-templates from the template_data + $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' + WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt'); + _sql($sql, $errored, $error_ary); + } +} diff --git a/phpBB/includes/db/migration/v307rc2.php b/phpBB/includes/db/migration/v307rc2.php new file mode 100644 index 0000000000..f9492f3d1c --- /dev/null +++ b/phpBB/includes/db/migration/v307rc2.php @@ -0,0 +1,53 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v307rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v307rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + $sql = 'SELECT user_id, user_email, user_email_hash + FROM ' . USERS_TABLE . ' + WHERE user_type <> ' . USER_IGNORE . " + AND user_email <> ''"; + $result = $db->sql_query($sql); + + $i = 0; + while ($row = $db->sql_fetchrow($result)) + { + // Snapshot of the phpbb_email_hash() function + // We cannot call it directly because the auto updater updates the DB first. :/ + $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); + + if ($user_email_hash != $row['user_email_hash']) + { + $sql_ary = array( + 'user_email_hash' => $user_email_hash, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (int) $row['user_id']; + _sql($sql, $errored, $error_ary, ($i % 100 == 0)); + + ++$i; + } + } + $db->sql_freeresult($result); + } +} diff --git a/phpBB/includes/db/migration/v308.php b/phpBB/includes/db/migration/v308.php new file mode 100644 index 0000000000..8a0d96b2e7 --- /dev/null +++ b/phpBB/includes/db/migration/v308.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v308 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v308rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v308rc1.php b/phpBB/includes/db/migration/v308rc1.php new file mode 100644 index 0000000000..13d0e98b1c --- /dev/null +++ b/phpBB/includes/db/migration/v308rc1.php @@ -0,0 +1,222 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v308rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v307pl1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + + // The language strings we need are either in language/.../acp/attachments.php + // in the update package if we're updating to 3.0.8-RC1 or later, + // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. + // On an already updated board, they can also already be in language/.../acp/attachments.php + // in the board root. + $lang_files = array( + "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", + "{$phpbb_root_path}language/$lang_dir/install.$phpEx", + "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", + ); + + foreach ($lang_files as $lang_file) + { + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; + _sql($sql, $errored, $error_ary); + + $extension_groups_updated[$lang_key] = true; + } + } + } + $db->sql_freeresult($result); + + // Install modules + $modules_to_install = array( + 'post' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_POST_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_MESSAGES', + 'after' => array('message', 'ACP_MESSAGE_SETTINGS') + ), + ); + + _add_modules($modules_to_install); + + // update + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'avatar\''; + _sql($sql, $errored, $error_ary); + + // add Bing Bot + $bot_name = 'Bing [Bot]'; + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; + $result = $db->sql_query($sql); + $bing_already_added = (bool) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); + + if (!$bing_already_added) + { + $bot_agent = 'bingbot/'; + $bot_ip = ''; + $sql = 'SELECT group_id, group_colour + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $db->sql_query($sql); + $group_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$group_row) + { + // default fallback, should never get here + $group_row['group_id'] = 6; + $group_row['group_colour'] = '9E8DA7'; + } + + if (!function_exists('user_add')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_row['group_id'], + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => $config['default_lang'], + 'user_style' => $config['default_style'], + 'user_timezone' => 0, + 'user_dateformat' => $config['default_dateformat'], + 'user_allow_massemail' => 0, + ); + + $user_id = user_add($user_row); + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )); + + _sql($sql, $errored, $error_ary); + } + // end Bing Bot addition + + // Delete shadow topics pointing to not existing topics + $batch_size = 500; + + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + do + { + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', + ), + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + } + } + while (sizeof($topic_ids) == $batch_size); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + // Unread posts search load switch + set_config('load_unreads_search', '1'); + + // Reduce queue interval to 60 seconds, email package size to 20 + if ($config['queue_interval'] == 600) + { + set_config('queue_interval', '60'); + } + + if ($config['email_package_size'] == 50) + { + set_config('email_package_size', '20'); + } + } +} diff --git a/phpBB/includes/db/migration/v309.php b/phpBB/includes/db/migration/v309.php new file mode 100644 index 0000000000..ebb246da3a --- /dev/null +++ b/phpBB/includes/db/migration/v309.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v309 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v309rc4'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v309rc1.php b/phpBB/includes/db/migration/v309rc1.php new file mode 100644 index 0000000000..ca56a4e7d9 --- /dev/null +++ b/phpBB/includes/db/migration/v309rc1.php @@ -0,0 +1,100 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v309rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v308'); + } + + function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'login_attempts' => array( + 'COLUMNS' => array( + // this column was removed from the database updater + // after 3.0.9-RC3 was released. It might still exist + // in 3.0.9-RCX installations and has to be dropped in + // 3.0.12 after the db_tools class is capable of properly + // removing a primary key. + // 'attempt_id' => array('UINT', NULL, 'auto_increment'), + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + //'PRIMARY_KEY' => 'attempt_id', + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'bbcode' => array( + 'bbcode_id' => array('USINT', 0), + ), + ), + ); + } + + function update_data() + { + set_config('ip_login_limit_max', '50'); + set_config('ip_login_limit_time', '21600'); + set_config('ip_login_limit_use_forwarded', '0'); + + // Update file extension group names to use language strings, again. + $sql = 'SELECT group_id, group_name + FROM ' . EXTENSION_GROUPS_TABLE . ' + WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $sql_ary = array( + 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE group_id = ' . $row['group_id']; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + global $db_tools, $table_prefix; + + // Recover from potentially broken Q&A CAPTCHA table on firebird + // Q&A CAPTCHA was uninstallable, so it's safe to remove these + // without data loss + if ($db_tools->sql_layer == 'firebird') + { + $tables = array( + $table_prefix . 'captcha_questions', + $table_prefix . 'captcha_answers', + $table_prefix . 'qa_confirm', + ); + foreach ($tables as $table) + { + if ($db_tools->sql_table_exists($table)) + { + $db_tools->sql_table_drop($table); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/v309rc2.php b/phpBB/includes/db/migration/v309rc2.php new file mode 100644 index 0000000000..d552b95e7a --- /dev/null +++ b/phpBB/includes/db/migration/v309rc2.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v309rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v309rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v309rc3.php b/phpBB/includes/db/migration/v309rc3.php new file mode 100644 index 0000000000..4c215c09f7 --- /dev/null +++ b/phpBB/includes/db/migration/v309rc3.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v309rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v309rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v309rc4.php b/phpBB/includes/db/migration/v309rc4.php new file mode 100644 index 0000000000..92f3d81947 --- /dev/null +++ b/phpBB/includes/db/migration/v309rc4.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v309rc4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v309rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8950d677ae..1f89035b43 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -881,277 +881,6 @@ function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permissio function database_update_info() { return array( - // Changes from 3.0.0 to the next version - '3.0.0' => array( - // Add the following columns - 'add_columns' => array( - FORUMS_TABLE => array( - 'display_subforum_list' => array('BOOL', 1), - ), - SESSIONS_TABLE => array( - 'session_forum_id' => array('UINT', 0), - ), - ), - 'drop_keys' => array( - GROUPS_TABLE => array('group_legend'), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_forum_id' => array('session_forum_id'), - ), - GROUPS_TABLE => array( - 'group_legend_name' => array('group_legend', 'group_name'), - ), - ), - ), - // No changes from 3.0.1-RC1 to 3.0.1 - '3.0.1-RC1' => array(), - // No changes from 3.0.1 to 3.0.2-RC1 - '3.0.1' => array(), - // Changes from 3.0.2-RC1 to 3.0.2-RC2 - '3.0.2-RC1' => array( - 'change_columns' => array( - DRAFTS_TABLE => array( - 'draft_subject' => array('STEXT_UNI', ''), - ), - FORUMS_TABLE => array( - 'forum_last_post_subject' => array('STEXT_UNI', ''), - ), - POSTS_TABLE => array( - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - ), - PRIVMSGS_TABLE => array( - 'message_subject' => array('STEXT_UNI', ''), - ), - TOPICS_TABLE => array( - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - ), - ), - 'drop_keys' => array( - SESSIONS_TABLE => array('session_forum_id'), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_fid' => array('session_forum_id'), - ), - ), - ), - // No changes from 3.0.2-RC2 to 3.0.2 - '3.0.2-RC2' => array(), - - // Changes from 3.0.2 to 3.0.3-RC1 - '3.0.2' => array( - // Add the following columns - 'add_columns' => array( - STYLES_TEMPLATE_TABLE => array( - 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', ''), - ), - GROUPS_TABLE => array( - 'group_max_recipients' => array('UINT', 0), - ), - ), - ), - - // No changes from 3.0.3-RC1 to 3.0.3 - '3.0.3-RC1' => array(), - - // Changes from 3.0.3 to 3.0.4-RC1 - '3.0.3' => array( - 'add_columns' => array( - PROFILE_FIELDS_TABLE => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - STYLES_TABLE => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - STYLES_IMAGESET_TABLE => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_IMAGESET_DATA_TABLE => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - STYLES_THEME_TABLE => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_TABLE => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_DATA_TABLE => array( - 'template_id' => array('UINT', 0), - ), - FORUMS_TABLE => array( - 'forum_style' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_style' => array('UINT', 0), - ), - ), - ), - - // Changes from 3.0.4-RC1 to 3.0.4 - '3.0.4-RC1' => array(), - - // Changes from 3.0.4 to 3.0.5-RC1 - '3.0.4' => array( - 'change_columns' => array( - FORUMS_TABLE => array( - 'forum_style' => array('UINT', 0), - ), - ), - ), - - // No changes from 3.0.5-RC1 to 3.0.5 - '3.0.5-RC1' => array(), - - // Changes from 3.0.5 to 3.0.6-RC1 - '3.0.5' => array( - 'add_columns' => array( - CONFIRM_TABLE => array( - 'attempts' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time'=> array('TIMESTAMP', 0), - ), - GROUPS_TABLE => array( - 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), - ), - PRIVMSGS_TABLE => array( - 'message_reported' => array('BOOL', 0), - ), - REPORTS_TABLE => array( - 'pm_id' => array('UINT', 0), - ), - PROFILE_FIELDS_TABLE => array( - 'field_show_on_vt' => array('BOOL', 0), - ), - FORUMS_TABLE => array( - 'forum_options' => array('UINT:20', 0), - ), - ), - 'change_columns' => array( - USERS_TABLE => array( - 'user_options' => array('UINT:11', 230271), - ), - ), - 'add_index' => array( - REPORTS_TABLE => array( - 'post_id' => array('post_id'), - 'pm_id' => array('pm_id'), - ), - POSTS_TABLE => array( - 'post_username' => array('post_username:255'), - ), - ), - ), - - // No changes from 3.0.6-RC1 to 3.0.6-RC2 - '3.0.6-RC1' => array(), - // No changes from 3.0.6-RC2 to 3.0.6-RC3 - '3.0.6-RC2' => array(), - // No changes from 3.0.6-RC3 to 3.0.6-RC4 - '3.0.6-RC3' => array(), - // No changes from 3.0.6-RC4 to 3.0.6 - '3.0.6-RC4' => array(), - - // Changes from 3.0.6 to 3.0.7-RC1 - '3.0.6' => array( - 'drop_keys' => array( - LOG_TABLE => array('log_time'), - ), - 'add_index' => array( - TOPICS_TRACK_TABLE => array( - 'topic_id' => array('topic_id'), - ), - ), - ), - - // No changes from 3.0.7-RC1 to 3.0.7-RC2 - '3.0.7-RC1' => array(), - // No changes from 3.0.7-RC2 to 3.0.7 - '3.0.7-RC2' => array(), - // No changes from 3.0.7 to 3.0.7-PL1 - '3.0.7' => array(), - // No changes from 3.0.7-PL1 to 3.0.8-RC1 - '3.0.7-PL1' => array(), - // No changes from 3.0.8-RC1 to 3.0.8 - '3.0.8-RC1' => array(), - // Changes from 3.0.8 to 3.0.9-RC1 - '3.0.8' => array( - 'add_tables' => array( - LOGIN_ATTEMPT_TABLE => array( - 'COLUMNS' => array( - // this column was removed from the database updater - // after 3.0.9-RC3 was released. It might still exist - // in 3.0.9-RCX installations and has to be dropped in - // 3.0.12 after the db_tools class is capable of properly - // removing a primary key. - // 'attempt_id' => array('UINT', NULL, 'auto_increment'), - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - //'PRIMARY_KEY' => 'attempt_id', - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ), - ), - 'change_columns' => array( - BBCODES_TABLE => array( - 'bbcode_id' => array('USINT', 0), - ), - ), - ), - // No changes from 3.0.9-RC1 to 3.0.9-RC2 - '3.0.9-RC1' => array(), - // No changes from 3.0.9-RC2 to 3.0.9-RC3 - '3.0.9-RC2' => array(), - // No changes from 3.0.9-RC3 to 3.0.9-RC4 - '3.0.9-RC3' => array(), - // No changes from 3.0.9-RC4 to 3.0.9 - '3.0.9-RC4' => array(), - // No changes from 3.0.9 to 3.0.10-RC1 - '3.0.9' => array(), - // No changes from 3.0.10-RC1 to 3.0.10-RC2 - '3.0.10-RC1' => array(), - // No changes from 3.0.10-RC2 to 3.0.10-RC3 - '3.0.10-RC2' => array(), - // No changes from 3.0.10-RC3 to 3.0.10 - '3.0.10-RC3' => array(), - // No changes from 3.0.10 to 3.0.11-RC1 - '3.0.10' => array(), - // Changes from 3.0.11-RC1 to 3.0.11-RC2 - '3.0.11-RC1' => array( - 'add_columns' => array( - PROFILE_FIELDS_TABLE => array( - 'field_show_novalue' => array('BOOL', 0), - ), - ), - ), - // No changes from 3.0.11-RC2 to 3.0.11 - '3.0.11-RC2' => array(), - // No changes from 3.0.11 to 3.0.12-RC1 - '3.0.11' => array(), - - /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ - // Changes from 3.1.0-dev to 3.1.0-A1 '3.1.0-dev' => array( 'add_tables' => array( @@ -1210,1192 +939,6 @@ function change_database_data(&$no_updates, $version) switch ($version) { - case '3.0.0': - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_view_time = topic_last_post_time - WHERE topic_last_view_time = 0"; - _sql($sql, $errored, $error_ary); - - // Update smiley sizes - $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); - - foreach ($smileys as $smiley) - { - if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) - { - list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley); - - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET smiley_width = ' . $width . ', smiley_height = ' . $height . " - WHERE smiley_url = '" . $db->sql_escape($smiley) . "'"; - - _sql($sql, $errored, $error_ary); - } - } - - $no_updates = false; - break; - - // No changes from 3.0.1-RC1 to 3.0.1 - case '3.0.1-RC1': - break; - - // changes from 3.0.1 to 3.0.2-RC1 - case '3.0.1': - - set_config('referer_validation', '1'); - set_config('check_attachment_content', '1'); - set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); - - $no_updates = false; - break; - - // No changes from 3.0.2-RC1 to 3.0.2-RC2 - case '3.0.2-RC1': - break; - - // No changes from 3.0.2-RC2 to 3.0.2 - case '3.0.2-RC2': - break; - - // Changes from 3.0.2 to 3.0.3-RC1 - case '3.0.2': - set_config('enable_queue_trigger', '0'); - set_config('queue_trigger_posts', '3'); - - set_config('pm_max_recipients', '0'); - - // Set maximum number of recipients for the registered users, bots, guests group - $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 - WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); - _sql($sql, $errored, $error_ary); - - // Not prefilling yet - set_config('dbms_version', ''); - - // Add new permission u_masspm_group and duplicate settings from u_masspm - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_masspm_group'])) - { - $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_masspm']; - $new_id = $auth_admin->acl_options['id']['u_masspm_group']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } - - /** - * Do not resync post counts here. An admin may do this later from the ACP - $start = 0; - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; - _sql($sql, $errored, $error_ary); - - do - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_approved = 1 - GROUP BY poster_id'; - $result = _sql($sql, $errored, $error_ary); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - _sql($sql, $errored, $error_ary); - } - while ($row = $db->sql_fetchrow($result)); - - $start += $step; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - */ - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_a_email && cfg_email_enable\' - WHERE module_class = \'acp\' - AND module_basename = \'email\''; - _sql($sql, $errored, $error_ary); - - $no_updates = false; - break; - - // Changes from 3.0.3-RC1 to 3.0.3 - case '3.0.3-RC1': - if ($db->sql_layer == 'oracle') - { - // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); - } - else - { - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation = 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - break; - - // Changes from 3.0.3 to 3.0.4-RC1 - case '3.0.3': - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide - FROM ' . PROFILE_FIELDS_TABLE; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivelant to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); - } - $no_updates = false; - - break; - - // Changes from 3.0.4-RC1 to 3.0.4 - case '3.0.4-RC1': - break; - - // Changes from 3.0.4 to 3.0.5-RC1 - case '3.0.4': - - // Captcha config variables - set_config('captcha_gd_wave', 0); - set_config('captcha_gd_3d_noise', 1); - set_config('captcha_gd_fonts', 1); - set_config('confirm_refresh', 1); - - // Maximum number of keywords - set_config('max_num_search_keywords', 10); - - // Remove static config var and put it back as dynamic variable - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET is_dynamic = 1 - WHERE config_name = 'search_indexing_state'"; - _sql($sql, $errored, $error_ary); - - // Hash old MD5 passwords - $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' - WHERE user_pass_convert = 1'; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - if (strlen($row['user_password']) == 32) - { - $sql_ary = array( - 'user_password' => phpbb_hash($row['user_password']), - ); - - _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); - } - } - $db->sql_freeresult($result); - - // Adjust bot entry - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = 'ichiro/' - WHERE bot_agent = 'ichiro/2'"; - _sql($sql, $errored, $error_ary); - - - // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - - // We get duplicate entries first - $sql = 'SELECT auth_option - FROM ' . ACL_OPTIONS_TABLE . ' - GROUP BY auth_option - HAVING COUNT(*) >= 2'; - $result = $db->sql_query($sql); - - $auth_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $auth_options[] = $row['auth_option']; - } - $db->sql_freeresult($result); - - // Remove specific auth options - if (!empty($auth_options)) - { - foreach ($auth_options as $option) - { - // Select auth_option_ids... the largest id will be preserved - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = '" . $db->sql_escape($option) . "' - ORDER BY auth_option_id DESC"; - // sql_query_limit not possible here, due to bug in postgresql layer - $result = $db->sql_query($sql); - - // Skip first row, this is our original auth option we want to preserve - $row = $db->sql_fetchrow($result); - - while ($row = $db->sql_fetchrow($result)) - { - // Ok, remove this auth option... - _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - } - $db->sql_freeresult($result); - } - } - - // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. - $changes = array( - 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $changes = array( - 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - - break; - - // No changes from 3.0.5-RC1 to 3.0.5 - case '3.0.5-RC1': - break; - - // Changes from 3.0.5 to 3.0.6-RC1 - case '3.0.5': - // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... - if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_gd'); - } - else if (!isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_nogd'); - } - - // Entries for the Feed Feature - set_config('feed_enable', '0'); - set_config('feed_limit', '10'); - - set_config('feed_overall_forums', '1'); - set_config('feed_overall_forums_limit', '15'); - - set_config('feed_overall_topics', '0'); - set_config('feed_overall_topics_limit', '15'); - - set_config('feed_forum', '1'); - set_config('feed_topic', '1'); - set_config('feed_item_statistics', '1'); - - // Entries for smiley pagination - set_config('smilies_per_page', '50'); - - // Entry for reporting PMs - set_config('allow_pm_report', '1'); - - // Install modules - $modules_to_install = array( - 'feed' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_FEED_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_BOARD_CONFIGURATION', - 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') - ), - 'warnings' => array( - 'base' => 'users', - 'class' => 'acp', - 'title' => 'ACP_USER_WARNINGS', - 'auth' => 'acl_a_user', - 'display' => 0, - 'cat' => 'ACP_CAT_USERS', - 'after' => array('feedback', 'ACP_USER_FEEDBACK') - ), - 'send_statistics' => array( - 'base' => 'send_statistics', - 'class' => 'acp', - 'title' => 'ACP_SEND_STATISTICS', - 'auth' => 'acl_a_server', - 'cat' => 'ACP_SERVER_CONFIGURATION' - ), - 'setting_forum_copy' => array( - 'base' => 'permissions', - 'class' => 'acp', - 'title' => 'ACP_FORUM_PERMISSIONS_COPY', - 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', - 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', - 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') - ), - 'pm_reports' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_OPEN', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_reports_closed' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_CLOSED', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_report_details' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORT_DETAILS', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - ); - - _add_modules($modules_to_install); - - // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; - _sql($sql, $errored, $error_ary); - - $group_id = $db->sql_nextid(); - } - - // Insert new user role... at the end of the chain - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_USER_NEW_MEMBER' - AND role_type = 'u_'"; - $result = $db->sql_query($sql); - $u_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); - - if (!$u_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'u_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $u_role = $db->sql_nextid(); - - if (!$errored) - { - // Now add the correct data to the roles... - // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - _sql($sql, $errored, $error_ary); - - // Add user role to group - $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - _sql($sql, $errored, $error_ary); - } - } - - // Insert new forum role - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' - AND role_type = 'f_'"; - $result = $db->sql_query($sql); - $f_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); - - if (!$f_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'f_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $f_role = $db->sql_nextid(); - - if (!$errored) - { - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - _sql($sql, $errored, $error_ary); - } - } - - // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) - $sql = 'SELECT 1 - FROM ' . USERS_TABLE . ' - WHERE user_new = 0'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - _sql($sql, $errored, $error_ary); - } - - // Newly registered users limit - if (!isset($config['new_member_post_limit'])) - { - set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); - } - - if (!isset($config['new_member_group_default'])) - { - set_config('new_member_group_default', 0); - } - - // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... - // Check if the role is already assigned... - $sql = 'SELECT forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id = ' . $f_role; - $result = $db->sql_query($sql); - $is_options = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - // Not assigned at all... :/ - if (!$is_options) - { - // Get postable forums - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type != ' . FORUM_LINK; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); - } - $db->sql_freeresult($result); - } - - // Clear permissions... - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - $auth_admin->acl_clear_prefetch(); - - if (!isset($config['allow_avatar'])) - { - if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) - { - set_config('allow_avatar', '1'); - } - else - { - set_config('allow_avatar', '0'); - } - } - - if (!isset($config['allow_avatar_remote_upload'])) - { - if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) - { - set_config('allow_avatar_remote_upload', '1'); - } - else - { - set_config('allow_avatar_remote_upload', '0'); - } - } - - // Minimum number of characters - if (!isset($config['min_post_chars'])) - { - set_config('min_post_chars', '1'); - } - - if (!isset($config['allow_quick_reply'])) - { - set_config('allow_quick_reply', '1'); - } - - // Set every members user_options column to enable - // bbcode, smilies and URLs for signatures by default - $sql = 'SELECT user_options - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query_limit($sql, 1); - $user_option = (int) $db->sql_fetchfield('user_options'); - $db->sql_freeresult($result); - - // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option - if (!($user_option & 1 << 15)) - { - // 229376 is the added value to enable all three signature options - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; - _sql($sql, $errored, $error_ary); - } - - if (!isset($config['delete_time'])) - { - set_config('delete_time', $config['edit_time']); - } - - $no_updates = false; - break; - - // No changes from 3.0.6-RC1 to 3.0.6-RC2 - case '3.0.6-RC1': - break; - - // Changes from 3.0.6-RC2 to 3.0.6-RC3 - case '3.0.6-RC2': - - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' - SET field_show_on_vt = 1 - WHERE field_hide = 0 - AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; - _sql($sql, $errored, $error_ary); - $no_updates = false; - - break; - - // No changes from 3.0.6-RC3 to 3.0.6-RC4 - case '3.0.6-RC3': - break; - - // No changes from 3.0.6-RC4 to 3.0.6 - case '3.0.6-RC4': - break; - - // Changes from 3.0.6 to 3.0.7-RC1 - case '3.0.6': - - // ATOM Feeds - set_config('feed_overall', '1'); - set_config('feed_http_auth', '0'); - set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15)); - set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10)); - set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0')); - set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0')); - - // Delete all text-templates from the template_data - $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' - WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt'); - _sql($sql, $errored, $error_ary); - - $no_updates = false; - break; - - // Changes from 3.0.7-RC1 to 3.0.7-RC2 - case '3.0.7-RC1': - - $sql = 'SELECT user_id, user_email, user_email_hash - FROM ' . USERS_TABLE . ' - WHERE user_type <> ' . USER_IGNORE . " - AND user_email <> ''"; - $result = $db->sql_query($sql); - - $i = 0; - while ($row = $db->sql_fetchrow($result)) - { - // Snapshot of the phpbb_email_hash() function - // We cannot call it directly because the auto updater updates the DB first. :/ - $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); - - if ($user_email_hash != $row['user_email_hash']) - { - $sql_ary = array( - 'user_email_hash' => $user_email_hash, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $row['user_id']; - _sql($sql, $errored, $error_ary, ($i % 100 == 0)); - - ++$i; - } - } - $db->sql_freeresult($result); - - $no_updates = false; - - break; - - // No changes from 3.0.7-RC2 to 3.0.7 - case '3.0.7-RC2': - break; - - // No changes from 3.0.7 to 3.0.7-PL1 - case '3.0.7': - break; - - // Changes from 3.0.7-PL1 to 3.0.8-RC1 - case '3.0.7-PL1': - // Update file extension group names to use language strings. - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $extension_groups_updated = array(); - while ($lang_dir = $db->sql_fetchfield('lang_dir')) - { - $lang_dir = basename($lang_dir); - - // The language strings we need are either in language/.../acp/attachments.php - // in the update package if we're updating to 3.0.8-RC1 or later, - // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. - // On an already updated board, they can also already be in language/.../acp/attachments.php - // in the board root. - $lang_files = array( - "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", - "{$phpbb_root_path}language/$lang_dir/install.$phpEx", - "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", - ); - - foreach ($lang_files as $lang_file) - { - if (!file_exists($lang_file)) - { - continue; - } - - $lang = array(); - include($lang_file); - - foreach($lang as $lang_key => $lang_val) - { - if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) - { - continue; - } - - $sql_ary = array( - 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; - _sql($sql, $errored, $error_ary); - - $extension_groups_updated[$lang_key] = true; - } - } - } - $db->sql_freeresult($result); - - // Install modules - $modules_to_install = array( - 'post' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_POST_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_MESSAGES', - 'after' => array('message', 'ACP_MESSAGE_SETTINGS') - ), - ); - - _add_modules($modules_to_install); - - // update - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'avatar\''; - _sql($sql, $errored, $error_ary); - - // add Bing Bot - $bot_name = 'Bing [Bot]'; - $bot_name_clean = utf8_clean_string($bot_name); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; - $result = $db->sql_query($sql); - $bing_already_added = (bool) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if (!$bing_already_added) - { - $bot_agent = 'bingbot/'; - $bot_ip = ''; - $sql = 'SELECT group_id, group_colour - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - // default fallback, should never get here - $group_row['group_id'] = 6; - $group_row['group_colour'] = '9E8DA7'; - } - - if (!function_exists('user_add')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_row['group_id'], - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => $group_row['group_colour'], - 'user_email' => '', - 'user_lang' => $config['default_lang'], - 'user_style' => $config['default_style'], - 'user_timezone' => 'UTC', - 'user_dateformat' => $config['default_dateformat'], - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => (string) $bot_name, - 'user_id' => (int) $user_id, - 'bot_agent' => (string) $bot_agent, - 'bot_ip' => (string) $bot_ip, - )); - - _sql($sql, $errored, $error_ary); - } - // end Bing Bot addition - - // Delete shadow topics pointing to not existing topics - $batch_size = 500; - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - do - { - $sql_array = array( - 'SELECT' => 't1.topic_id, t1.forum_id', - 'FROM' => array( - TOPICS_TABLE => 't1', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't2'), - 'ON' => 't1.topic_moved_id = t2.topic_id', - ), - ), - 'WHERE' => 't1.topic_moved_id <> 0 - AND t2.topic_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - } - while (sizeof($topic_ids) == $batch_size); - - // Sync the forums we have deleted shadow topics from. - sync('forum', 'forum_id', $sync_forum_ids, true, true); - - // Unread posts search load switch - set_config('load_unreads_search', '1'); - - // Reduce queue interval to 60 seconds, email package size to 20 - if ($config['queue_interval'] == 600) - { - set_config('queue_interval', '60'); - } - - if ($config['email_package_size'] == 50) - { - set_config('email_package_size', '20'); - } - - $no_updates = false; - break; - - // No changes from 3.0.8-RC1 to 3.0.8 - case '3.0.8-RC1': - break; - - // Changes from 3.0.8 to 3.0.9-RC1 - case '3.0.8': - set_config('ip_login_limit_max', '50'); - set_config('ip_login_limit_time', '21600'); - set_config('ip_login_limit_use_forwarded', '0'); - - // Update file extension group names to use language strings, again. - $sql = 'SELECT group_id, group_name - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE group_id = ' . $row['group_id']; - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - /* - * Due to a bug, vanilla phpbb could not create captcha tables - * in 3.0.8 on firebird. It was possible for board administrators - * to adjust the code to work. If code was manually adjusted by - * board administrators, index names would not be the same as - * what 3.0.9 and newer expect. This code fragment drops captcha - * tables, destroying all entered Q&A captcha configuration, such - * that when Q&A is configured next the respective tables will be - * created with correct index names. - * - * If you wish to preserve your Q&A captcha configuration, you can - * manually rename indexes to the currently expected name: - * phpbb_captcha_questions_lang_iso => phpbb_captcha_questions_lang - * phpbb_captcha_answers_question_id => phpbb_captcha_answers_qid - * - * Again, this needs to be done only if a board was manually modified - * to fix broken captcha code. - * - if ($db_tools->sql_layer == 'firebird') - { - $changes = array( - 'drop_tables' => array( - $table_prefix . 'captcha_questions', - $table_prefix . 'captcha_answers', - $table_prefix . 'qa_confirm', - ), - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } - */ - - $no_updates = false; - break; - - // No changes from 3.0.9-RC1 to 3.0.9-RC2 - case '3.0.9-RC1': - break; - - // No changes from 3.0.9-RC2 to 3.0.9-RC3 - case '3.0.9-RC2': - break; - - // No changes from 3.0.9-RC3 to 3.0.9-RC4 - case '3.0.9-RC3': - break; - - // No changes from 3.0.9-RC4 to 3.0.9 - case '3.0.9-RC4': - break; - - // Changes from 3.0.9 to 3.0.10-RC1 - case '3.0.9': - if (!isset($config['email_max_chunk_size'])) - { - set_config('email_max_chunk_size', '50'); - } - - $no_updates = false; - break; - - // No changes from 3.0.10-RC1 to 3.0.10-RC2 - case '3.0.10-RC1': - break; - - // No changes from 3.0.10-RC2 to 3.0.10-RC3 - case '3.0.10-RC2': - break; - - // No changes from 3.0.10-RC3 to 3.0.10 - case '3.0.10-RC3': - break; - - // Changes from 3.0.10 to 3.0.11-RC1 - case '3.0.10': - // Updates users having current style a deactivated one - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_active = 0'; - $result = $db->sql_query($sql); - - $deactivated_style_ids = array(); - while ($style_id = $db->sql_fetchfield('style_id', false, $result)) - { - $deactivated_style_ids[] = (int) $style_id; - } - $db->sql_freeresult($result); - - if (!empty($deactivated_style_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $config['default_style'] .' - WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); - _sql($sql, $errored, $error_ary); - } - - // Delete orphan private messages - $batch_size = 500; - - $sql_array = array( - 'SELECT' => 'p.msg_id', - 'FROM' => array( - PRIVMSGS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), - 'ON' => 'p.msg_id = t.msg_id', - ), - ), - 'WHERE' => 't.user_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - - do - { - $result = $db->sql_query_limit($sql, $batch_size); - - $delete_pms = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_pms[] = (int) $row['msg_id']; - } - $db->sql_freeresult($result); - - if (!empty($delete_pms)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_pms); - _sql($sql, $errored, $error_ary); - } - } - while (sizeof($delete_pms) == $batch_size); - - $no_updates = false; - break; - - // No changes from 3.0.11-RC1 to 3.0.11-RC2 - case '3.0.11-RC1': - break; - - // No changes from 3.0.11-RC2 to 3.0.11 - case '3.0.11-RC2': - break; - - // Changes from 3.0.11 to 3.0.12-RC1 - case '3.0.11': - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_u_sig\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'signature\''; - _sql($sql, $errored, $error_ary); - - // Update bots - if (!function_exists('user_delete')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $bots_updates = array( - // Bot Deletions - 'NG-Search [Bot]' => false, - 'Nutch/CVS [Bot]' => false, - 'OmniExplorer [Bot]' => false, - 'Seekport [Bot]' => false, - 'Synoo [Bot]' => false, - 'WiseNut [Bot]' => false, - - // Bot Updates - // Bot name to bot user agent map - 'Baidu [Spider]' => 'Baiduspider', - 'Exabot [Bot]' => 'Exabot', - 'Voyager [Bot]' => 'voyager/', - 'W3C [Validator]' => 'W3C_Validator', - ); - - foreach ($bots_updates as $bot_name => $bot_agent) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_IGNORE . " - AND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'"; - $result = $db->sql_query($sql); - $bot_user_id = (int) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if ($bot_user_id) - { - if ($bot_agent === false) - { - $sql = 'DELETE FROM ' . BOTS_TABLE . " - WHERE user_id = $bot_user_id"; - _sql($sql, $errored, $error_ary); - - user_delete('remove', $bot_user_id); - } - else - { - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $db->sql_escape($bot_agent) . "' - WHERE user_id = $bot_user_id"; - _sql($sql, $errored, $error_ary); - } - } - } - - // Disable receiving pms for bots - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $db->sql_query($sql); - - $bot_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $bot_user_ids[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - if (!empty($bot_user_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE ' . $db->sql_in_set('user_id', $bot_user_ids); - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - break; - // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': From b999a75528156b2cf229cc2ceac04b5a8bac859d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Fri, 9 Nov 2012 10:54:33 -0600 Subject: [PATCH 018/174] [feature/migrations] Some migrations data PHPBB3-9737 --- phpBB/includes/db/migration/v3010rc1.php | 7 ++- phpBB/includes/db/migration/v3011rc1.php | 61 ++++++++++++++---------- phpBB/includes/db/migration/v309rc1.php | 42 +++++++++------- 3 files changed, 65 insertions(+), 45 deletions(-) diff --git a/phpBB/includes/db/migration/v3010rc1.php b/phpBB/includes/db/migration/v3010rc1.php index 9a43b4c81d..847fe7c250 100644 --- a/phpBB/includes/db/migration/v3010rc1.php +++ b/phpBB/includes/db/migration/v3010rc1.php @@ -21,9 +21,8 @@ class phpbb_db_migration_v3010rc1 extends phpbb_db_migration function update_data() { - if (!isset($config['email_max_chunk_size'])) - { - set_config('email_max_chunk_size', '50'); - } + return array( + array('config.add', array('email_max_chunk_size', 50)), + ); } } diff --git a/phpBB/includes/db/migration/v3011rc1.php b/phpBB/includes/db/migration/v3011rc1.php index 04f86b47ae..aad80ba59f 100644 --- a/phpBB/includes/db/migration/v3011rc1.php +++ b/phpBB/includes/db/migration/v3011rc1.php @@ -20,28 +20,39 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration } function update_data() + { + return array( + array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), + array('custom', array(array(&$this, 'delete_orphan_private_messages'))), + ); + } + + function cleanup_deactivated_styles() { // Updates users having current style a deactivated one $sql = 'SELECT style_id FROM ' . STYLES_TABLE . ' WHERE style_active = 0'; - $result = $db->sql_query($sql); + $result = $this->sql_query($sql); $deactivated_style_ids = array(); - while ($style_id = $db->sql_fetchfield('style_id', false, $result)) + while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) { $deactivated_style_ids[] = (int) $style_id; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (!empty($deactivated_style_ids)) { $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $config['default_style'] .' - WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); - _sql($sql, $errored, $error_ary); + SET user_style = ' . (int) $this->config['default_style'] .' + WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); + $this->sql_query($sql, $errored, $error_ary); } + } + function delete_orphan_private_messages() + { // Delete orphan private messages $batch_size = 500; @@ -58,26 +69,28 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration ), 'WHERE' => 't.user_id IS NULL', ); - $sql = $db->sql_build_query('SELECT', $sql_array); + $sql = $this->db->sql_build_query('SELECT', $sql_array); - do + $result = $this->db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $this->db->sql_fetchrow($result)) { - $result = $db->sql_query_limit($sql, $batch_size); - - $delete_pms = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_pms[] = (int) $row['msg_id']; - } - $db->sql_freeresult($result); - - if (!empty($delete_pms)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_pms); - _sql($sql, $errored, $error_ary); - } + $delete_pms[] = (int) $row['msg_id']; + } + $db->sql_freeresult($result); + + if (!empty($delete_pms)) + { + $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' + WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); + $this->sql_query($sql, $errored, $error_ary); + + return true; + } + else + { + return false; } - while (sizeof($delete_pms) == $batch_size); } } diff --git a/phpBB/includes/db/migration/v309rc1.php b/phpBB/includes/db/migration/v309rc1.php index ca56a4e7d9..ce51e54642 100644 --- a/phpBB/includes/db/migration/v309rc1.php +++ b/phpBB/includes/db/migration/v309rc1.php @@ -53,46 +53,54 @@ class phpbb_db_migration_v309rc1 extends phpbb_db_migration function update_data() { - set_config('ip_login_limit_max', '50'); - set_config('ip_login_limit_time', '21600'); - set_config('ip_login_limit_use_forwarded', '0'); + return array( + array('config.add', array('ip_login_limit_max', 50)), + array('config.add', array('ip_login_limit_time', 21600)), + array('config.add', array('ip_login_limit_use_forwarded', 0)), + array('custom', array(array(&$this, 'update_file_extension_group_names'))), + array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))), + ); + } + function update_file_extension_group_names() + { // Update file extension group names to use language strings, again. $sql = 'SELECT group_id, group_name FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); - $result = $db->sql_query($sql); + WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); + $result = $this->db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $sql_ary = array( 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' ); $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE group_id = ' . $row['group_id']; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql, $errored, $error_ary); } - $db->sql_freeresult($result); - - global $db_tools, $table_prefix; + $this->db->sql_freeresult($result); + } + function fix_firebird_qa_captcha() + { // Recover from potentially broken Q&A CAPTCHA table on firebird // Q&A CAPTCHA was uninstallable, so it's safe to remove these // without data loss - if ($db_tools->sql_layer == 'firebird') + if ($this->db_tools->sql_layer == 'firebird') { $tables = array( - $table_prefix . 'captcha_questions', - $table_prefix . 'captcha_answers', - $table_prefix . 'qa_confirm', + $this->table_prefix . 'captcha_questions', + $this->table_prefix . 'captcha_answers', + $this->table_prefix . 'qa_confirm', ); foreach ($tables as $table) { - if ($db_tools->sql_table_exists($table)) + if ($this->db_tools->sql_table_exists($table)) { - $db_tools->sql_table_drop($table); + $this->db_tools->sql_table_drop($table); } } } From e7389e4c32f031fc6025880adf22b40d7d195f27 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 10 Nov 2012 04:00:38 -0600 Subject: [PATCH 019/174] [feature/migrations] 3.0.8-rc1 migration, fix some calls PHPBB3-9737 --- phpBB/includes/db/migration/v3011rc1.php | 4 +- phpBB/includes/db/migration/v308rc1.php | 177 ++++++++++++----------- phpBB/includes/db/migration/v309rc1.php | 2 +- 3 files changed, 93 insertions(+), 90 deletions(-) diff --git a/phpBB/includes/db/migration/v3011rc1.php b/phpBB/includes/db/migration/v3011rc1.php index aad80ba59f..3bae7a4a2d 100644 --- a/phpBB/includes/db/migration/v3011rc1.php +++ b/phpBB/includes/db/migration/v3011rc1.php @@ -47,7 +47,7 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = ' . (int) $this->config['default_style'] .' WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); - $this->sql_query($sql, $errored, $error_ary); + $this->sql_query($sql); } } @@ -84,7 +84,7 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration { $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); - $this->sql_query($sql, $errored, $error_ary); + $this->sql_query($sql); return true; } diff --git a/phpBB/includes/db/migration/v308rc1.php b/phpBB/includes/db/migration/v308rc1.php index 13d0e98b1c..cbfedb1b53 100644 --- a/phpBB/includes/db/migration/v308rc1.php +++ b/phpBB/includes/db/migration/v308rc1.php @@ -20,14 +20,37 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration } function update_data() + { + return array( + array('custom', array(array(&$this, 'update_file_extension_group_names'))), + array('custom', array(array(&$this, 'update_module_auth'))), + array('custom', array(array(&$this, 'update_bots'))), + array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))), + array('module.add', array( + 'post' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_POST_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_MESSAGES', + 'after' => array('message', 'ACP_MESSAGE_SETTINGS') + ), + )), + array('config.add', array('load_unreads_search', 1)), + array('config.update_if', array(600, 'queue_interval', 60)), + array('config.update_if', array(50, 'email_package_size', 20)), + ); + } + + function update_file_extension_group_names() { // Update file extension group names to use language strings. $sql = 'SELECT lang_dir FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $extension_groups_updated = array(); - while ($lang_dir = $db->sql_fetchfield('lang_dir')) + while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) { $lang_dir = basename($lang_dir); @@ -37,9 +60,9 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration // On an already updated board, they can also already be in language/.../acp/attachments.php // in the board root. $lang_files = array( - "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", - "{$phpbb_root_path}language/$lang_dir/install.$phpEx", - "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", + "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$this->phpEx", + "{$this->phpbb_root_path}language/$lang_dir/install.$this->phpEx", + "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.$this->phpEx", ); foreach ($lang_files as $lang_file) @@ -64,48 +87,38 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration ); $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; - _sql($sql, $errored, $error_ary); + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'"; + $this->sql_query($sql); $extension_groups_updated[$lang_key] = true; } } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); + } - // Install modules - $modules_to_install = array( - 'post' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_POST_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_MESSAGES', - 'after' => array('message', 'ACP_MESSAGE_SETTINGS') - ), - ); - - _add_modules($modules_to_install); - - // update + function update_module_auth() + { $sql = 'UPDATE ' . MODULES_TABLE . ' SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' WHERE module_class = \'ucp\' AND module_basename = \'profile\' AND module_mode = \'avatar\''; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); + } - // add Bing Bot + function update_bots() + { $bot_name = 'Bing [Bot]'; $bot_name_clean = utf8_clean_string($bot_name); $sql = 'SELECT user_id FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; - $result = $db->sql_query($sql); - $bing_already_added = (bool) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); + WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; + $result = $this->db->sql_query($sql); + $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); if (!$bing_already_added) { @@ -114,9 +127,9 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration $sql = 'SELECT group_id, group_colour FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $group_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if (!$group_row) { @@ -127,7 +140,7 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration if (!function_exists('user_add')) { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); } $user_row = array( @@ -138,16 +151,16 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration 'user_password' => '', 'user_colour' => $group_row['group_colour'], 'user_email' => '', - 'user_lang' => $config['default_lang'], - 'user_style' => $config['default_style'], + 'user_lang' => $this->config['default_lang'], + 'user_style' => $this->config['default_style'], 'user_timezone' => 0, - 'user_dateformat' => $config['default_dateformat'], + 'user_dateformat' => $this->config['default_dateformat'], 'user_allow_massemail' => 0, ); $user_id = user_add($user_row); - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( 'bot_active' => 1, 'bot_name' => (string) $bot_name, 'user_id' => (int) $user_id, @@ -155,68 +168,58 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration 'bot_ip' => (string) $bot_ip, )); - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } - // end Bing Bot addition + } + function delete_orphan_shadow_topics() + { // Delete shadow topics pointing to not existing topics $batch_size = 500; // Set of affected forums we have to resync $sync_forum_ids = array(); - do - { - $sql_array = array( - 'SELECT' => 't1.topic_id, t1.forum_id', - 'FROM' => array( - TOPICS_TABLE => 't1', + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't2'), - 'ON' => 't1.topic_moved_id = t2.topic_id', - ), - ), - 'WHERE' => 't1.topic_moved_id <> 0 - AND t2.topic_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $batch_size); + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query_limit($sql, $batch_size); - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - } - while (sizeof($topic_ids) == $batch_size); - - // Sync the forums we have deleted shadow topics from. - sync('forum', 'forum_id', $sync_forum_ids, true, true); - - // Unread posts search load switch - set_config('load_unreads_search', '1'); - - // Reduce queue interval to 60 seconds, email package size to 20 - if ($config['queue_interval'] == 600) + $topic_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) { - set_config('queue_interval', '60'); - } + $topic_ids[] = (int) $row['topic_id']; - if ($config['email_package_size'] == 50) + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($topic_ids)) { - set_config('email_package_size', '20'); + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); + $this->db->sql_query($sql); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + return true; + } + else + { + return false; } } } diff --git a/phpBB/includes/db/migration/v309rc1.php b/phpBB/includes/db/migration/v309rc1.php index ce51e54642..e8db93c78d 100644 --- a/phpBB/includes/db/migration/v309rc1.php +++ b/phpBB/includes/db/migration/v309rc1.php @@ -79,7 +79,7 @@ class phpbb_db_migration_v309rc1 extends phpbb_db_migration $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE group_id = ' . $row['group_id']; - $this->sql_query($sql, $errored, $error_ary); + $this->sql_query($sql); } $this->db->sql_freeresult($result); } From 2a7985c26fcf558c30fa316262344307ffc99e9e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 10 Nov 2012 05:59:01 -0600 Subject: [PATCH 020/174] [feature/migrations] Migrations back through 3.0.6 PHPBB3-9737 --- phpBB/includes/db/migration/v306rc1.php | 336 +++++++++++------------- phpBB/includes/db/migration/v306rc3.php | 9 +- phpBB/includes/db/migration/v307rc1.php | 23 +- phpBB/includes/db/migration/v307rc2.php | 29 +- phpBB/includes/db/migration/v308rc1.php | 4 +- 5 files changed, 197 insertions(+), 204 deletions(-) diff --git a/phpBB/includes/db/migration/v306rc1.php b/phpBB/includes/db/migration/v306rc1.php index 63d1c66c2d..45b597d56b 100644 --- a/phpBB/includes/db/migration/v306rc1.php +++ b/phpBB/includes/db/migration/v306rc1.php @@ -61,109 +61,141 @@ class phpbb_db_migration_v306rc1 extends phpbb_db_migration function update_data() { - // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... - if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_gd'); - } - else if (!isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_nogd'); - } + return array( + //array('custom', array(array(&$this, ''))) + array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), + array('config.update_if', array( + ($this->config['captcha_gd']), + 'captcha_plugin', + 'phpbb_captcha_gd', + )), - // Entries for the Feed Feature - set_config('feed_enable', '0'); - set_config('feed_limit', '10'); + array('config.add', array('feed_enable', 0)), + array('config.add', array('feed_limit', 10)), + array('config.add', array('feed_overall_forums', 1)), + array('config.add', array('feed_overall_forums_limit', 15)), + array('config.add', array('feed_overall_topics', 0)), + array('config.add', array('feed_overall_topics_limit', 15)), + array('config.add', array('feed_forum', 1)), + array('config.add', array('feed_topic', 1)), + array('config.add', array('feed_item_statistics', 1)), - set_config('feed_overall_forums', '1'); - set_config('feed_overall_forums_limit', '15'); + array('config.add', array('smilies_per_page', 50)), + array('config.add', array('allow_pm_report', 1)), + array('config.add', array('min_post_chars', 1)), + array('config.add', array('allow_quick_reply', 1)), + array('config.add', array('new_member_post_limit', 0)), + array('config.add', array('new_member_group_default', 0)), + array('config.add', array('delete_time', $this->config['edit_time'])), - set_config('feed_overall_topics', '0'); - set_config('feed_overall_topics_limit', '15'); + array('config.add', array('allow_avatar', 0)), + array('config.add_if', array( + ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), + 'allow_avatar', + 1, + )), + array('config.add', array('allow_avatar_remote_upload', 0)), + array('config.add_if', array( + ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), + 'allow_avatar_remote_upload', + 1, + )), - set_config('feed_forum', '1'); - set_config('feed_topic', '1'); - set_config('feed_item_statistics', '1'); - - // Entries for smiley pagination - set_config('smilies_per_page', '50'); - - // Entry for reporting PMs - set_config('allow_pm_report', '1'); - - // Install modules - $modules_to_install = array( - 'feed' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_FEED_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_BOARD_CONFIGURATION', - 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') - ), - 'warnings' => array( - 'base' => 'users', - 'class' => 'acp', - 'title' => 'ACP_USER_WARNINGS', - 'auth' => 'acl_a_user', - 'display' => 0, - 'cat' => 'ACP_CAT_USERS', - 'after' => array('feedback', 'ACP_USER_FEEDBACK') - ), - 'send_statistics' => array( - 'base' => 'send_statistics', - 'class' => 'acp', - 'title' => 'ACP_SEND_STATISTICS', - 'auth' => 'acl_a_server', - 'cat' => 'ACP_SERVER_CONFIGURATION' - ), - 'setting_forum_copy' => array( - 'base' => 'permissions', - 'class' => 'acp', - 'title' => 'ACP_FORUM_PERMISSIONS_COPY', - 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', - 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', - 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') - ), - 'pm_reports' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_OPEN', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_reports_closed' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_CLOSED', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_report_details' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORT_DETAILS', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), + array('module.add', array( + 'feed' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_FEED_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_BOARD_CONFIGURATION', + 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') + ), + )), + array('module.add', array( + 'warnings' => array( + 'base' => 'users', + 'class' => 'acp', + 'title' => 'ACP_USER_WARNINGS', + 'auth' => 'acl_a_user', + 'display' => 0, + 'cat' => 'ACP_CAT_USERS', + 'after' => array('feedback', 'ACP_USER_FEEDBACK') + ), + )), + array('module.add', array( + 'send_statistics' => array( + 'base' => 'send_statistics', + 'class' => 'acp', + 'title' => 'ACP_SEND_STATISTICS', + 'auth' => 'acl_a_server', + 'cat' => 'ACP_SERVER_CONFIGURATION' + ), + )), + array('module.add', array( + 'setting_forum_copy' => array( + 'base' => 'permissions', + 'class' => 'acp', + 'title' => 'ACP_FORUM_PERMISSIONS_COPY', + 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', + 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', + 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') + ), + )), + array('module.add', array( + 'pm_reports' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_OPEN', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + )), + array('module.add', array( + 'pm_reports_closed' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_CLOSED', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + )), + array('module.add', array( + 'pm_report_details' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORT_DETAILS', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + )), + array('custom', array(array(&$this, 'add_newly_registered_group'))), + array('custom', array(array(&$this, 'set_user_options_default'))), ); + } - _add_modules($modules_to_install); + function set_user_options_default() + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + $this->sql_query($sql); + } + function add_newly_registered_group() + { // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'NEWLY_REGISTERED'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $group_id = (int) $this->db->sql_fetchfield('group_id'); + $this->db->sql_freeresult($result); if (!$group_id) { $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); - $group_id = $db->sql_nextid(); + $group_id = $this->db->sql_nextid(); } // Insert new user role... at the end of the chain @@ -171,35 +203,35 @@ class phpbb_db_migration_v306rc1 extends phpbb_db_migration FROM ' . ACL_ROLES_TABLE . " WHERE role_name = 'ROLE_USER_NEW_MEMBER' AND role_type = 'u_'"; - $result = $db->sql_query($sql); - $u_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $u_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); if (!$u_role) { $sql = 'SELECT MAX(role_order) as max_order_id FROM ' . ACL_ROLES_TABLE . " WHERE role_type = 'u_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); $next_order_id++; $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $u_role = $db->sql_nextid(); + $this->sql_query($sql); + $u_role = $this->db->sql_nextid(); if (!$errored) { // Now add the correct data to the roles... // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); // Add user role to group $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } } @@ -208,29 +240,29 @@ class phpbb_db_migration_v306rc1 extends phpbb_db_migration FROM ' . ACL_ROLES_TABLE . " WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' AND role_type = 'f_'"; - $result = $db->sql_query($sql); - $f_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $f_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); if (!$f_role) { $sql = 'SELECT MAX(role_order) as max_order_id FROM ' . ACL_ROLES_TABLE . " WHERE role_type = 'f_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); $next_order_id++; $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $f_role = $db->sql_nextid(); + $this->sql_query($sql); + $f_role = $this->db->sql_nextid(); if (!$errored) { $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } } @@ -238,25 +270,14 @@ class phpbb_db_migration_v306rc1 extends phpbb_db_migration $sql = 'SELECT 1 FROM ' . USERS_TABLE . ' WHERE user_new = 0'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if (!$row) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - _sql($sql, $errored, $error_ary); - } - - // Newly registered users limit - if (!isset($config['new_member_post_limit'])) - { - set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); - } - - if (!isset($config['new_member_group_default'])) - { - set_config('new_member_group_default', 0); + $this->sql_query($sql); } // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... @@ -265,9 +286,9 @@ class phpbb_db_migration_v306rc1 extends phpbb_db_migration FROM ' . ACL_GROUPS_TABLE . ' WHERE group_id = ' . $group_id . ' AND auth_role_id = ' . $f_role; - $result = $db->sql_query($sql); - $is_options = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $is_options = (int) $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); // Not assigned at all... :/ if (!$is_options) @@ -276,75 +297,18 @@ class phpbb_db_migration_v306rc1 extends phpbb_db_migration $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type != ' . FORUM_LINK; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { - _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); + $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); } // Clear permissions... - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->phpEx); $auth_admin = new auth_admin(); $auth_admin->acl_clear_prefetch(); - - if (!isset($config['allow_avatar'])) - { - if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) - { - set_config('allow_avatar', '1'); - } - else - { - set_config('allow_avatar', '0'); - } - } - - if (!isset($config['allow_avatar_remote_upload'])) - { - if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) - { - set_config('allow_avatar_remote_upload', '1'); - } - else - { - set_config('allow_avatar_remote_upload', '0'); - } - } - - // Minimum number of characters - if (!isset($config['min_post_chars'])) - { - set_config('min_post_chars', '1'); - } - - if (!isset($config['allow_quick_reply'])) - { - set_config('allow_quick_reply', '1'); - } - - // Set every members user_options column to enable - // bbcode, smilies and URLs for signatures by default - $sql = 'SELECT user_options - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query_limit($sql, 1); - $user_option = (int) $db->sql_fetchfield('user_options'); - $db->sql_freeresult($result); - - // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option - if (!($user_option & 1 << 15)) - { - // 229376 is the added value to enable all three signature options - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; - _sql($sql, $errored, $error_ary); - } - - if (!isset($config['delete_time'])) - { - set_config('delete_time', $config['edit_time']); - } } } diff --git a/phpBB/includes/db/migration/v306rc3.php b/phpBB/includes/db/migration/v306rc3.php index b3bd49eafa..e2c4e66ada 100644 --- a/phpBB/includes/db/migration/v306rc3.php +++ b/phpBB/includes/db/migration/v306rc3.php @@ -20,12 +20,19 @@ class phpbb_db_migration_v306rc3 extends phpbb_db_migration } function update_data() + { + return array( + array('custom', array(array(&$this, 'update_cp_fields'))), + ); + } + + function update_cp_fields() { // Update the Custom Profile Fields based on previous settings to the new format $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' SET field_show_on_vt = 1 WHERE field_hide = 0 AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } } diff --git a/phpBB/includes/db/migration/v307rc1.php b/phpBB/includes/db/migration/v307rc1.php index f1c8b3384a..9b55cb2757 100644 --- a/phpBB/includes/db/migration/v307rc1.php +++ b/phpBB/includes/db/migration/v307rc1.php @@ -30,17 +30,22 @@ class phpbb_db_migration_v307rc1 extends phpbb_db_migration function update_data() { - // ATOM Feeds - set_config('feed_overall', '1'); - set_config('feed_http_auth', '0'); - set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15)); - set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10)); - set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0')); - set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0')); + return array( + array('config.add', array('feed_overall', 1)), + array('config.add', array('feed_http_auth', 0)), + array('config.add', array('feed_limit_post', $this->config['feed_limit'])), + array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])), + array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), + array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), + array('custom', array(array(&$this, 'delete_text_templates'))), + ); + } + function delete_text_templates() + { // Delete all text-templates from the template_data $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' - WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt'); - _sql($sql, $errored, $error_ary); + WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); + $this->sql_query($sql); } } diff --git a/phpBB/includes/db/migration/v307rc2.php b/phpBB/includes/db/migration/v307rc2.php index f9492f3d1c..438ebfb8c2 100644 --- a/phpBB/includes/db/migration/v307rc2.php +++ b/phpBB/includes/db/migration/v307rc2.php @@ -21,15 +21,26 @@ class phpbb_db_migration_v307rc2 extends phpbb_db_migration function update_data() { + return array( + array('custom', array(array(&$this, 'update_email_hash'))), + ); + } + + function update_email_hash($start = 0) + { + $limit = 1000; + $sql = 'SELECT user_id, user_email, user_email_hash FROM ' . USERS_TABLE . ' WHERE user_type <> ' . USER_IGNORE . " AND user_email <> ''"; - $result = $db->sql_query($sql); + $result = $this->db->sql_query_limit($sql, $limit, $start); $i = 0; - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { + $i++; + // Snapshot of the phpbb_email_hash() function // We cannot call it directly because the auto updater updates the DB first. :/ $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); @@ -41,13 +52,19 @@ class phpbb_db_migration_v307rc2 extends phpbb_db_migration ); $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . (int) $row['user_id']; - _sql($sql, $errored, $error_ary, ($i % 100 == 0)); - - ++$i; + $this->sql_query($sql); } } $db->sql_freeresult($result); + + if ($i < $limit) + { + // Completed + return false; + } + + return $start + $limit; } } diff --git a/phpBB/includes/db/migration/v308rc1.php b/phpBB/includes/db/migration/v308rc1.php index cbfedb1b53..f365695058 100644 --- a/phpBB/includes/db/migration/v308rc1.php +++ b/phpBB/includes/db/migration/v308rc1.php @@ -37,8 +37,8 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration ), )), array('config.add', array('load_unreads_search', 1)), - array('config.update_if', array(600, 'queue_interval', 60)), - array('config.update_if', array(50, 'email_package_size', 20)), + array('config.update_if_equals', array(600, 'queue_interval', 60)), + array('config.update_if_equals', array(50, 'email_package_size', 20)), ); } From ae8edf7b0e74c54b5b02b66a8b2a436a4172c63e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 10 Nov 2012 06:26:38 -0600 Subject: [PATCH 021/174] [feature/migrations] Use $this->db PHPBB3-9737 --- phpBB/includes/db/migration.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index aca9d264bb..de9f6d07e3 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -95,29 +95,29 @@ class phpbb_db_migration echo "<br />\n{$sql}\n<br />"; } - $db->sql_return_on_error(true); + $this->db->sql_return_on_error(true); if ($sql === 'begin') { - $result = $db->sql_transaction('begin'); + $result = $this->db->sql_transaction('begin'); } else if ($sql === 'commit') { - $result = $db->sql_transaction('commit'); + $result = $this->db->sql_transaction('commit'); } else { - $result = $db->sql_query($sql); - if ($db->sql_error_triggered) + $result = $this->db->sql_query($sql); + if ($this->db->sql_error_triggered) { $this->errors[] = array( - 'sql' => $db->sql_error_sql, - 'code' => $db->sql_error_returned, + 'sql' => $this->db->sql_error_sql, + 'code' => $this->db->sql_error_returned, ); } } - $db->sql_return_on_error(false); + $this->db->sql_return_on_error(false); return $result; } From 167faed1630d01e3d592a6696f58316c1d832ff9 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 10 Nov 2012 06:32:02 -0600 Subject: [PATCH 022/174] [feature/migrations] Depend on part2 PHPBB3-9737 --- phpBB/includes/db/migration/v305.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migration/v305.php b/phpBB/includes/db/migration/v305.php index b4d676d72a..71e28c6b7b 100644 --- a/phpBB/includes/db/migration/v305.php +++ b/phpBB/includes/db/migration/v305.php @@ -11,7 +11,7 @@ class phpbb_db_migration_v305 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v305rc1'); + return array('phpbb_db_migration_v305rc1part2'); } function update_schema() From b52a0f50ab980ca941267ddb4f509f104b07db77 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Sat, 10 Nov 2012 13:32:44 +0100 Subject: [PATCH 023/174] [feature/migrations] Update 3.0.3-3.0.5 migrations to work --- phpBB/includes/db/migration/305rc1part2.php | 34 +++++++ phpBB/includes/db/migration/v303rc1.php | 100 +++---------------- phpBB/includes/db/migration/v304.php | 15 ++- phpBB/includes/db/migration/v304rc1.php | 13 ++- phpBB/includes/db/migration/v305rc1.php | 105 ++++++++------------ 5 files changed, 107 insertions(+), 160 deletions(-) create mode 100644 phpBB/includes/db/migration/305rc1part2.php diff --git a/phpBB/includes/db/migration/305rc1part2.php b/phpBB/includes/db/migration/305rc1part2.php new file mode 100644 index 0000000000..238e533b06 --- /dev/null +++ b/phpBB/includes/db/migration/305rc1part2.php @@ -0,0 +1,34 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_v305rc1part2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_v305rc1'); + } + + function update_schema() + { + return array( + 'drop_keys' => array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v303rc1.php b/phpBB/includes/db/migration/v303rc1.php index b8ec5668fd..7518a6ed54 100644 --- a/phpBB/includes/db/migration/v303rc1.php +++ b/phpBB/includes/db/migration/v303rc1.php @@ -35,93 +35,20 @@ class phpbb_db_migration_v303rc1 extends phpbb_db_migration array('config.add', array('enable_queue_trigger', '0')), array('config.add', array('queue_trigger_posts', '3')), array('config.add', array('pm_max_recipients', '0')), - array('custom', array('set_group_default_max_recipients')) + array('custom', array(array(&$this, 'set_group_default_max_recipients'))), + array('config.add', array('dbms_version', '')), + array('permission.add', array('u_masspm_group', phpbb_auth::IS_GLOBAL), + array('custom', array(array(&$this, 'correct_acp_email_permissions'))), + )); + } - // Not prefilling yet - set_config('dbms_version', ''); - - // Add new permission u_masspm_group and duplicate settings from u_masspm - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_masspm_group'])) - { - $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_masspm']; - $new_id = $auth_admin->acl_options['id']['u_masspm_group']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } - - /** - * Do not resync post counts here. An admin may do this later from the ACP - $start = 0; - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; - _sql($sql, $errored, $error_ary); - - do - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_approved = 1 - GROUP BY poster_id'; - $result = _sql($sql, $errored, $error_ary); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - _sql($sql, $errored, $error_ary); - } - while ($row = $db->sql_fetchrow($result)); - - $start += $step; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - */ - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_a_email && cfg_email_enable\' - WHERE module_class = \'acp\' - AND module_basename = \'email\''; - _sql($sql, $errored, $error_ary); + function correct_acp_email_permissions() + { + $sql = 'UPDATE ' . $this->table_prefix . 'modules + SET module_auth = \'acl_a_email && cfg_email_enable\' + WHERE module_class = \'acp\' + AND module_basename = \'email\''; + $this->sql_query($sql); } function set_group_default_max_recipients() @@ -131,5 +58,4 @@ class phpbb_db_migration_v303rc1 extends phpbb_db_migration WHERE ' . $this->db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); $this->sql_query($sql); } - } diff --git a/phpBB/includes/db/migration/v304.php b/phpBB/includes/db/migration/v304.php index 2895caaa6d..5358bcc20f 100644 --- a/phpBB/includes/db/migration/v304.php +++ b/phpBB/includes/db/migration/v304.php @@ -20,21 +20,28 @@ class phpbb_db_migration_v304 extends phpbb_db_migration } function update_data() + { + return array( + array('custom', array(array(&$this, 'rename_log_delete_topic'))), + ); + } + + function rename_log_delete_topic() { if ($db->sql_layer == 'oracle') { // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . LOG_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "log SET log_operation = 'LOG_DELETE_TOPIC' WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } else { - $sql = 'UPDATE ' . LOG_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "log SET log_operation = 'LOG_DELETE_TOPIC' WHERE log_operation = 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); + $this->sql_query($sql); } } } diff --git a/phpBB/includes/db/migration/v304rc1.php b/phpBB/includes/db/migration/v304rc1.php index a7098ce62f..2daad4e826 100644 --- a/phpBB/includes/db/migration/v304rc1.php +++ b/phpBB/includes/db/migration/v304rc1.php @@ -56,13 +56,20 @@ class phpbb_db_migration_v304rc1 extends phpbb_db_migration } function update_data() + { + return array( + array('custom', array(array(&$this, 'update_custom_profile_fields'))), + ); + } + + function update_custom_profile_fields() { // Update the Custom Profile Fields based on previous settings to the new format $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide FROM ' . PROFILE_FIELDS_TABLE; - $result = _sql($sql, $errored, $error_ary); + $result = $this->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $sql_ary = array( 'field_required' => 0, @@ -90,7 +97,7 @@ class phpbb_db_migration_v304rc1 extends phpbb_db_migration $sql_ary['field_show_profile'] = 1; } - _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); + $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); } } } diff --git a/phpBB/includes/db/migration/v305rc1.php b/phpBB/includes/db/migration/v305rc1.php index 8d9c4d2456..4f20796608 100644 --- a/phpBB/includes/db/migration/v305rc1.php +++ b/phpBB/includes/db/migration/v305rc1.php @@ -27,28 +27,29 @@ class phpbb_db_migration_v305rc1 extends phpbb_db_migration function update_data() { - // Captcha config variables - set_config('captcha_gd_wave', 0); - set_config('captcha_gd_3d_noise', 1); - set_config('captcha_gd_fonts', 1); - set_config('confirm_refresh', 1); + $search_indexing_state = $this->config['search_indexing_state']; - // Maximum number of keywords - set_config('max_num_search_keywords', 10); + return array( + array('config.add', array('captcha_gd_wave', 0)), + array('config.add', array('captcha_gd_3d_noise', 1)), + array('config.add', array('captcha_gd_refresh', 1)), + array('config.add', array('confirm_refresh', 1)), + array('config.add', array('max_num_search_keywords', 10)), + array('config.remove', array('search_indexing_state')), + array('config.add', array('search_indexing_state', $search_indexing_state, true)), + array('custom', array(array(&$this, 'hash_old_passwords'))), + array('custom', array(array(&$this, 'update_ichiro_bot'))), + ); + } - // Remove static config var and put it back as dynamic variable - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET is_dynamic = 1 - WHERE config_name = 'search_indexing_state'"; - _sql($sql, $errored, $error_ary); - - // Hash old MD5 passwords + function hash_old_passwords() + { $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' + FROM ' . $this->table_prefix . 'users WHERE user_pass_convert = 1'; - $result = _sql($sql, $errored, $error_ary); + $result = $this->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { if (strlen($row['user_password']) == 32) { @@ -56,33 +57,36 @@ class phpbb_db_migration_v305rc1 extends phpbb_db_migration 'user_password' => phpbb_hash($row['user_password']), ); - _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); + $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); } } $db->sql_freeresult($result); + } + function update_ichiro_bot() + { // Adjust bot entry - $sql = 'UPDATE ' . BOTS_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "bots SET bot_agent = 'ichiro/' WHERE bot_agent = 'ichiro/2'"; - _sql($sql, $errored, $error_ary); - + $this->sql_query($sql); + } + function remove_duplicate_auth_options() + { // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - - // We get duplicate entries first $sql = 'SELECT auth_option - FROM ' . ACL_OPTIONS_TABLE . ' + FROM ' . $this->table_prefix . 'acl_options GROUP BY auth_option HAVING COUNT(*) >= 2'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $auth_options = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $auth_options[] = $row['auth_option']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); // Remove specific auth options if (!empty($auth_options)) @@ -95,52 +99,21 @@ class phpbb_db_migration_v305rc1 extends phpbb_db_migration WHERE auth_option = '" . $db->sql_escape($option) . "' ORDER BY auth_option_id DESC"; // sql_query_limit not possible here, due to bug in postgresql layer - $result = $db->sql_query($sql); + $result = $this->sql_query($sql); // Skip first row, this is our original auth option we want to preserve - $row = $db->sql_fetchrow($result); + $row = $this->db->sql_fetchrow($result); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { // Ok, remove this auth option... - _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + $this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); } } - - // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. - $changes = array( - 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), - ), - ); - - global $db_tools; - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $changes = array( - 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } } } From ce021710fbe4d594e4f66c3338da8bb2610a0c75 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 8 Jan 2013 22:07:01 -0600 Subject: [PATCH 024/174] [feature/migrations] Rename classes, depends on PHPBB3-9737 --- .../db/migration/{v3011.php => 3_0_1.php} | 4 +- .../db/migration/{v3010rc2.php => 3_0_10.php} | 4 +- .../{v3010rc1.php => 3_0_10_rc1.php} | 4 +- phpBB/includes/db/migration/3_0_10_rc2.php | 25 + phpBB/includes/db/migration/3_0_10_rc3.php | 25 + .../db/migration/{v3010rc3.php => 3_0_11.php} | 4 +- .../{v3011rc1.php => 3_0_11_rc1.php} | 4 +- .../db/migration/{v3011rc2.php => 3_0_11_rc2} | 4 +- .../{v3012rc1.php => 3_0_12_rc1.php} | 4 +- .../migration/{v301rc1.php => 3_0_1_rc1.php} | 2 +- .../db/migration/{v301.php => 3_0_2.php} | 4 +- .../migration/{v302rc1.php => 3_0_2_rc1.php} | 4 +- .../migration/{v302rc2.php => 3_0_2_rc2.php} | 4 +- .../db/migration/{v3010.php => 3_0_3.php} | 4 +- .../migration/{v303rc1.php => 3_0_3_rc1.php} | 4 +- .../db/migration/{v304.php => 3_0_4.php} | 4 +- .../migration/{v304rc1.php => 3_0_4_rc1.php} | 4 +- phpBB/includes/db/migration/3_0_5.php | 25 + .../migration/{v305rc1.php => 3_0_5_rc1.php} | 4 +- .../{305rc1part2.php => 3_0_5_rc1part2.php} | 4 +- .../db/migration/{v302.php => 3_0_6.php} | 4 +- .../migration/{v306rc1.php => 3_0_6_rc1.php} | 4 +- phpBB/includes/db/migration/3_0_6_rc2.php | 25 + .../migration/{v306rc3.php => 3_0_6_rc3.php} | 4 +- phpBB/includes/db/migration/3_0_6_rc4.php | 25 + phpBB/includes/db/migration/3_0_7.php | 25 + phpBB/includes/db/migration/3_0_7_pl1.php | 25 + .../migration/{v307rc1.php => 3_0_7_rc1.php} | 4 +- .../migration/{v307rc2.php => 3_0_7_rc2.php} | 4 +- phpBB/includes/db/migration/3_0_8.php | 25 + .../migration/{v308rc1.php => 3_0_8_rc1.php} | 4 +- phpBB/includes/db/migration/3_0_9.php | 25 + .../migration/{v309rc1.php => 3_0_9_rc1.php} | 4 +- phpBB/includes/db/migration/3_0_9_rc2.php | 25 + phpBB/includes/db/migration/3_0_9_rc3.php | 25 + phpBB/includes/db/migration/3_0_9_rc4.php | 25 + phpBB/includes/db/migration/v303.php | 25 - phpBB/includes/db/migration/v305.php | 25 - phpBB/includes/db/migration/v306.php | 25 - phpBB/includes/db/migration/v306rc2.php | 25 - phpBB/includes/db/migration/v306rc4.php | 25 - phpBB/includes/db/migration/v307.php | 25 - phpBB/includes/db/migration/v307pl1.php | 25 - phpBB/includes/db/migration/v308.php | 25 - phpBB/includes/db/migration/v309.php | 25 - phpBB/includes/db/migration/v309rc2.php | 25 - phpBB/includes/db/migration/v309rc3.php | 25 - phpBB/includes/db/migration/v309rc4.php | 25 - phpBB/includes/db/migrationtools/base.php | 15 + phpBB/includes/db/migrationtools/config.php | 121 + phpBB/includes/db/migrationtools/umil.php | 3037 +++++++++++++++++ 51 files changed, 3520 insertions(+), 347 deletions(-) rename phpBB/includes/db/migration/{v3011.php => 3_0_1.php} (71%) rename phpBB/includes/db/migration/{v3010rc2.php => 3_0_10.php} (71%) rename phpBB/includes/db/migration/{v3010rc1.php => 3_0_10_rc1.php} (76%) create mode 100644 phpBB/includes/db/migration/3_0_10_rc2.php create mode 100644 phpBB/includes/db/migration/3_0_10_rc3.php rename phpBB/includes/db/migration/{v3010rc3.php => 3_0_11.php} (71%) rename phpBB/includes/db/migration/{v3011rc1.php => 3_0_11_rc1.php} (94%) rename phpBB/includes/db/migration/{v3011rc2.php => 3_0_11_rc2} (78%) rename phpBB/includes/db/migration/{v3012rc1.php => 3_0_12_rc1.php} (75%) rename phpBB/includes/db/migration/{v301rc1.php => 3_0_1_rc1.php} (97%) rename phpBB/includes/db/migration/{v301.php => 3_0_2.php} (71%) rename phpBB/includes/db/migration/{v302rc1.php => 3_0_2_rc1.php} (83%) rename phpBB/includes/db/migration/{v302rc2.php => 3_0_2_rc2.php} (91%) rename phpBB/includes/db/migration/{v3010.php => 3_0_3.php} (71%) rename phpBB/includes/db/migration/{v303rc1.php => 3_0_3_rc1.php} (93%) rename phpBB/includes/db/migration/{v304.php => 3_0_4.php} (88%) rename phpBB/includes/db/migration/{v304rc1.php => 3_0_4_rc1.php} (96%) create mode 100644 phpBB/includes/db/migration/3_0_5.php rename phpBB/includes/db/migration/{v305rc1.php => 3_0_5_rc1.php} (97%) rename phpBB/includes/db/migration/{305rc1part2.php => 3_0_5_rc1part2.php} (80%) rename phpBB/includes/db/migration/{v302.php => 3_0_6.php} (71%) rename phpBB/includes/db/migration/{v306rc1.php => 3_0_6_rc1.php} (98%) create mode 100644 phpBB/includes/db/migration/3_0_6_rc2.php rename phpBB/includes/db/migration/{v306rc3.php => 3_0_6_rc3.php} (86%) create mode 100644 phpBB/includes/db/migration/3_0_6_rc4.php create mode 100644 phpBB/includes/db/migration/3_0_7.php create mode 100644 phpBB/includes/db/migration/3_0_7_pl1.php rename phpBB/includes/db/migration/{v307rc1.php => 3_0_7_rc1.php} (92%) rename phpBB/includes/db/migration/{v307rc2.php => 3_0_7_rc2.php} (92%) create mode 100644 phpBB/includes/db/migration/3_0_8.php rename phpBB/includes/db/migration/{v308rc1.php => 3_0_8_rc1.php} (98%) create mode 100644 phpBB/includes/db/migration/3_0_9.php rename phpBB/includes/db/migration/{v309rc1.php => 3_0_9_rc1.php} (96%) create mode 100644 phpBB/includes/db/migration/3_0_9_rc2.php create mode 100644 phpBB/includes/db/migration/3_0_9_rc3.php create mode 100644 phpBB/includes/db/migration/3_0_9_rc4.php delete mode 100644 phpBB/includes/db/migration/v303.php delete mode 100644 phpBB/includes/db/migration/v305.php delete mode 100644 phpBB/includes/db/migration/v306.php delete mode 100644 phpBB/includes/db/migration/v306rc2.php delete mode 100644 phpBB/includes/db/migration/v306rc4.php delete mode 100644 phpBB/includes/db/migration/v307.php delete mode 100644 phpBB/includes/db/migration/v307pl1.php delete mode 100644 phpBB/includes/db/migration/v308.php delete mode 100644 phpBB/includes/db/migration/v309.php delete mode 100644 phpBB/includes/db/migration/v309rc2.php delete mode 100644 phpBB/includes/db/migration/v309rc3.php delete mode 100644 phpBB/includes/db/migration/v309rc4.php create mode 100644 phpBB/includes/db/migrationtools/base.php create mode 100644 phpBB/includes/db/migrationtools/config.php create mode 100644 phpBB/includes/db/migrationtools/umil.php diff --git a/phpBB/includes/db/migration/v3011.php b/phpBB/includes/db/migration/3_0_1.php similarity index 71% rename from phpBB/includes/db/migration/v3011.php rename to phpBB/includes/db/migration/3_0_1.php index 7d506308b1..1cb069a2b1 100644 --- a/phpBB/includes/db/migration/v3011.php +++ b/phpBB/includes/db/migration/3_0_1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3011 extends phpbb_db_migration +class phpbb_db_migration_3_0_1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3011rc2'); + return array('phpbb_db_migration_3_0_1_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/v3010rc2.php b/phpBB/includes/db/migration/3_0_10.php similarity index 71% rename from phpBB/includes/db/migration/v3010rc2.php rename to phpBB/includes/db/migration/3_0_10.php index 8c1809227c..aae27a08c7 100644 --- a/phpBB/includes/db/migration/v3010rc2.php +++ b/phpBB/includes/db/migration/3_0_10.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3010rc2 extends phpbb_db_migration +class phpbb_db_migration_3_0_10 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3010rc1'); + return array('phpbb_db_migration_3_0_10_rc3'); } function update_schema() diff --git a/phpBB/includes/db/migration/v3010rc1.php b/phpBB/includes/db/migration/3_0_10_rc1.php similarity index 76% rename from phpBB/includes/db/migration/v3010rc1.php rename to phpBB/includes/db/migration/3_0_10_rc1.php index 847fe7c250..5d65ae15da 100644 --- a/phpBB/includes/db/migration/v3010rc1.php +++ b/phpBB/includes/db/migration/3_0_10_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3010rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_10_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v309'); + return array('phpbb_db_migration_3_0_9'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_10_rc2.php b/phpBB/includes/db/migration/3_0_10_rc2.php new file mode 100644 index 0000000000..d5dc4caec9 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_10_rc2.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_10_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_10_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/3_0_10_rc3.php b/phpBB/includes/db/migration/3_0_10_rc3.php new file mode 100644 index 0000000000..dc962b73c8 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_10_rc3.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_10_rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_10_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v3010rc3.php b/phpBB/includes/db/migration/3_0_11.php similarity index 71% rename from phpBB/includes/db/migration/v3010rc3.php rename to phpBB/includes/db/migration/3_0_11.php index 917cabd8fe..89ffe310f4 100644 --- a/phpBB/includes/db/migration/v3010rc3.php +++ b/phpBB/includes/db/migration/3_0_11.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3010rc3 extends phpbb_db_migration +class phpbb_db_migration_3_0_11 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3010rc2'); + return array('phpbb_db_migration_3_0_11_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/v3011rc1.php b/phpBB/includes/db/migration/3_0_11_rc1.php similarity index 94% rename from phpBB/includes/db/migration/v3011rc1.php rename to phpBB/includes/db/migration/3_0_11_rc1.php index 3bae7a4a2d..1b74aa9a4c 100644 --- a/phpBB/includes/db/migration/v3011rc1.php +++ b/phpBB/includes/db/migration/3_0_11_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3011rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_11_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3010'); + return array('phpbb_db_migration_3_0_10'); } function update_schema() diff --git a/phpBB/includes/db/migration/v3011rc2.php b/phpBB/includes/db/migration/3_0_11_rc2 similarity index 78% rename from phpBB/includes/db/migration/v3011rc2.php rename to phpBB/includes/db/migration/3_0_11_rc2 index 0f66eff156..f4e64871ed 100644 --- a/phpBB/includes/db/migration/v3011rc2.php +++ b/phpBB/includes/db/migration/3_0_11_rc2 @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3011rc2 extends phpbb_db_migration +class phpbb_db_migration_3_0_11_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3011rc1'); + return array('phpbb_db_migration_3_0_11_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/v3012rc1.php b/phpBB/includes/db/migration/3_0_12_rc1.php similarity index 75% rename from phpBB/includes/db/migration/v3012rc1.php rename to phpBB/includes/db/migration/3_0_12_rc1.php index 67f7a29b02..58e112a43a 100644 --- a/phpBB/includes/db/migration/v3012rc1.php +++ b/phpBB/includes/db/migration/3_0_12_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3012rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_12_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3011'); + return array('phpbb_db_migration_3_0_11'); } function update_schema() diff --git a/phpBB/includes/db/migration/v301rc1.php b/phpBB/includes/db/migration/3_0_1_rc1.php similarity index 97% rename from phpBB/includes/db/migration/v301rc1.php rename to phpBB/includes/db/migration/3_0_1_rc1.php index aee50e3039..e3be8b36d4 100644 --- a/phpBB/includes/db/migration/v301rc1.php +++ b/phpBB/includes/db/migration/3_0_1_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_v301rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_1_rc1 extends phpbb_db_migration { function depends_on() { diff --git a/phpBB/includes/db/migration/v301.php b/phpBB/includes/db/migration/3_0_2.php similarity index 71% rename from phpBB/includes/db/migration/v301.php rename to phpBB/includes/db/migration/3_0_2.php index 8a2a265a3c..36e8d52e6b 100644 --- a/phpBB/includes/db/migration/v301.php +++ b/phpBB/includes/db/migration/3_0_2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v301 extends phpbb_db_migration +class phpbb_db_migration_3_0_2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v301rc1'); + return array('phpbb_db_migration_3_0_2_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/v302rc1.php b/phpBB/includes/db/migration/3_0_2_rc1.php similarity index 83% rename from phpBB/includes/db/migration/v302rc1.php rename to phpBB/includes/db/migration/3_0_2_rc1.php index ced4d9fbfc..cd21b7f64f 100644 --- a/phpBB/includes/db/migration/v302rc1.php +++ b/phpBB/includes/db/migration/3_0_2_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v301rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_1_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v301'); + return array('phpbb_db_migration_3_0_1'); } function update_schema() diff --git a/phpBB/includes/db/migration/v302rc2.php b/phpBB/includes/db/migration/3_0_2_rc2.php similarity index 91% rename from phpBB/includes/db/migration/v302rc2.php rename to phpBB/includes/db/migration/3_0_2_rc2.php index 21aa5ca728..a1fab753e2 100644 --- a/phpBB/includes/db/migration/v302rc2.php +++ b/phpBB/includes/db/migration/3_0_2_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v302rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_2_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v302rc1'); + return array('phpbb_db_migration_3_0_2_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/v3010.php b/phpBB/includes/db/migration/3_0_3.php similarity index 71% rename from phpBB/includes/db/migration/v3010.php rename to phpBB/includes/db/migration/3_0_3.php index 7490ba1005..c9ca33ee88 100644 --- a/phpBB/includes/db/migration/v3010.php +++ b/phpBB/includes/db/migration/3_0_3.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v3010 extends phpbb_db_migration +class phpbb_db_migration_3_0_3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v3010rc3'); + return array('phpbb_db_migration_3_0_2_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/v303rc1.php b/phpBB/includes/db/migration/3_0_3_rc1.php similarity index 93% rename from phpBB/includes/db/migration/v303rc1.php rename to phpBB/includes/db/migration/3_0_3_rc1.php index 7518a6ed54..0cd99457ee 100644 --- a/phpBB/includes/db/migration/v303rc1.php +++ b/phpBB/includes/db/migration/3_0_3_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v303rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_3_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v302'); + return array('phpbb_db_migration_3_0_2'); } function update_schema() diff --git a/phpBB/includes/db/migration/v304.php b/phpBB/includes/db/migration/3_0_4.php similarity index 88% rename from phpBB/includes/db/migration/v304.php rename to phpBB/includes/db/migration/3_0_4.php index 5358bcc20f..bbaaea54c9 100644 --- a/phpBB/includes/db/migration/v304.php +++ b/phpBB/includes/db/migration/3_0_4.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v304 extends phpbb_db_migration +class phpbb_db_migration_3_0_4 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v304rc1'); + return array('phpbb_db_migration_3_0_4_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/v304rc1.php b/phpBB/includes/db/migration/3_0_4_rc1.php similarity index 96% rename from phpBB/includes/db/migration/v304rc1.php rename to phpBB/includes/db/migration/3_0_4_rc1.php index 2daad4e826..b783e58e24 100644 --- a/phpBB/includes/db/migration/v304rc1.php +++ b/phpBB/includes/db/migration/3_0_4_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v304rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_4_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v303'); + return array('phpbb_db_migration_3_0_3'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_5.php b/phpBB/includes/db/migration/3_0_5.php new file mode 100644 index 0000000000..272779f083 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_5.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_5 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_5_rc1part2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v305rc1.php b/phpBB/includes/db/migration/3_0_5_rc1.php similarity index 97% rename from phpBB/includes/db/migration/v305rc1.php rename to phpBB/includes/db/migration/3_0_5_rc1.php index 4f20796608..8975728cca 100644 --- a/phpBB/includes/db/migration/v305rc1.php +++ b/phpBB/includes/db/migration/3_0_5_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v305rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_5_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v304'); + return array('phpbb_db_migration_3_0_4'); } function update_schema() diff --git a/phpBB/includes/db/migration/305rc1part2.php b/phpBB/includes/db/migration/3_0_5_rc1part2.php similarity index 80% rename from phpBB/includes/db/migration/305rc1part2.php rename to phpBB/includes/db/migration/3_0_5_rc1part2.php index 238e533b06..710c8dce91 100644 --- a/phpBB/includes/db/migration/305rc1part2.php +++ b/phpBB/includes/db/migration/3_0_5_rc1part2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v305rc1part2 extends phpbb_db_migration +class phpbb_db_migration_3_0_5_rc1part2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v305rc1'); + return array('phpbb_db_migration_3_0_5_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/v302.php b/phpBB/includes/db/migration/3_0_6.php similarity index 71% rename from phpBB/includes/db/migration/v302.php rename to phpBB/includes/db/migration/3_0_6.php index 942a0ac58c..9582038b36 100644 --- a/phpBB/includes/db/migration/v302.php +++ b/phpBB/includes/db/migration/3_0_6.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v302 extends phpbb_db_migration +class phpbb_db_migration_3_0_6 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v302rc2'); + return array('phpbb_db_migration_3_0_6_rc4'); } function update_schema() diff --git a/phpBB/includes/db/migration/v306rc1.php b/phpBB/includes/db/migration/3_0_6_rc1.php similarity index 98% rename from phpBB/includes/db/migration/v306rc1.php rename to phpBB/includes/db/migration/3_0_6_rc1.php index 45b597d56b..0aa5746164 100644 --- a/phpBB/includes/db/migration/v306rc1.php +++ b/phpBB/includes/db/migration/3_0_6_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v306rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_6_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v305'); + return array('phpbb_db_migration_3_0_5'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_6_rc2.php b/phpBB/includes/db/migration/3_0_6_rc2.php new file mode 100644 index 0000000000..1552485d0a --- /dev/null +++ b/phpBB/includes/db/migration/3_0_6_rc2.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_6_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_6_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v306rc3.php b/phpBB/includes/db/migration/3_0_6_rc3.php similarity index 86% rename from phpBB/includes/db/migration/v306rc3.php rename to phpBB/includes/db/migration/3_0_6_rc3.php index e2c4e66ada..6a7ad1c56d 100644 --- a/phpBB/includes/db/migration/v306rc3.php +++ b/phpBB/includes/db/migration/3_0_6_rc3.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v306rc3 extends phpbb_db_migration +class phpbb_db_migration_3_0_6_rc3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v306rc2'); + return array('phpbb_db_migration_3_0_6_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_6_rc4.php b/phpBB/includes/db/migration/3_0_6_rc4.php new file mode 100644 index 0000000000..00161456b6 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_6_rc4.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_6_rc4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_6_rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/3_0_7.php b/phpBB/includes/db/migration/3_0_7.php new file mode 100644 index 0000000000..2b5ec15fa9 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_7.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_7 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_7_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/3_0_7_pl1.php b/phpBB/includes/db/migration/3_0_7_pl1.php new file mode 100644 index 0000000000..22c04f1daf --- /dev/null +++ b/phpBB/includes/db/migration/3_0_7_pl1.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_7_pl1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_7'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v307rc1.php b/phpBB/includes/db/migration/3_0_7_rc1.php similarity index 92% rename from phpBB/includes/db/migration/v307rc1.php rename to phpBB/includes/db/migration/3_0_7_rc1.php index 9b55cb2757..d08a468941 100644 --- a/phpBB/includes/db/migration/v307rc1.php +++ b/phpBB/includes/db/migration/3_0_7_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v307rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_7_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v306'); + return array('phpbb_db_migration_3_0_6'); } function update_schema() diff --git a/phpBB/includes/db/migration/v307rc2.php b/phpBB/includes/db/migration/3_0_7_rc2.php similarity index 92% rename from phpBB/includes/db/migration/v307rc2.php rename to phpBB/includes/db/migration/3_0_7_rc2.php index 438ebfb8c2..4ab4e906d7 100644 --- a/phpBB/includes/db/migration/v307rc2.php +++ b/phpBB/includes/db/migration/3_0_7_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v307rc2 extends phpbb_db_migration +class phpbb_db_migration_3_0_7_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v307rc1'); + return array('phpbb_db_migration_3_0_7_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_8.php b/phpBB/includes/db/migration/3_0_8.php new file mode 100644 index 0000000000..3e7f843a65 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_8.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_8 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_8_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v308rc1.php b/phpBB/includes/db/migration/3_0_8_rc1.php similarity index 98% rename from phpBB/includes/db/migration/v308rc1.php rename to phpBB/includes/db/migration/3_0_8_rc1.php index f365695058..0d93efedce 100644 --- a/phpBB/includes/db/migration/v308rc1.php +++ b/phpBB/includes/db/migration/3_0_8_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v308rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_8_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v307pl1'); + return array('phpbb_db_migration_3_0_7_pl1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_9.php b/phpBB/includes/db/migration/3_0_9.php new file mode 100644 index 0000000000..2e1eab26e7 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_9.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_9 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_9_rc4'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v309rc1.php b/phpBB/includes/db/migration/3_0_9_rc1.php similarity index 96% rename from phpBB/includes/db/migration/v309rc1.php rename to phpBB/includes/db/migration/3_0_9_rc1.php index e8db93c78d..4ee18349ce 100644 --- a/phpBB/includes/db/migration/v309rc1.php +++ b/phpBB/includes/db/migration/3_0_9_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_v309rc1 extends phpbb_db_migration +class phpbb_db_migration_3_0_9_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_v308'); + return array('phpbb_db_migration_3_0_8'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_9_rc2.php b/phpBB/includes/db/migration/3_0_9_rc2.php new file mode 100644 index 0000000000..96782b2b01 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_9_rc2.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_9_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_9_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/3_0_9_rc3.php b/phpBB/includes/db/migration/3_0_9_rc3.php new file mode 100644 index 0000000000..ac0f3cb972 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_9_rc3.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_9_rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_9_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/3_0_9_rc4.php b/phpBB/includes/db/migration/3_0_9_rc4.php new file mode 100644 index 0000000000..7880e1b864 --- /dev/null +++ b/phpBB/includes/db/migration/3_0_9_rc4.php @@ -0,0 +1,25 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_3_0_9_rc4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_3_0_9_rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + } +} diff --git a/phpBB/includes/db/migration/v303.php b/phpBB/includes/db/migration/v303.php deleted file mode 100644 index 409c396baf..0000000000 --- a/phpBB/includes/db/migration/v303.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v303 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v302rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v305.php b/phpBB/includes/db/migration/v305.php deleted file mode 100644 index 71e28c6b7b..0000000000 --- a/phpBB/includes/db/migration/v305.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v305 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v305rc1part2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v306.php b/phpBB/includes/db/migration/v306.php deleted file mode 100644 index eec2f7c752..0000000000 --- a/phpBB/includes/db/migration/v306.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v306 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v306rc4'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v306rc2.php b/phpBB/includes/db/migration/v306rc2.php deleted file mode 100644 index 0a6c388da6..0000000000 --- a/phpBB/includes/db/migration/v306rc2.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v306rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v306rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v306rc4.php b/phpBB/includes/db/migration/v306rc4.php deleted file mode 100644 index 92c1979311..0000000000 --- a/phpBB/includes/db/migration/v306rc4.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v306rc4 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v306rc3'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v307.php b/phpBB/includes/db/migration/v307.php deleted file mode 100644 index a693a16676..0000000000 --- a/phpBB/includes/db/migration/v307.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v307 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v307rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v307pl1.php b/phpBB/includes/db/migration/v307pl1.php deleted file mode 100644 index 3c1ed2be94..0000000000 --- a/phpBB/includes/db/migration/v307pl1.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v307pl1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v307'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v308.php b/phpBB/includes/db/migration/v308.php deleted file mode 100644 index 8a0d96b2e7..0000000000 --- a/phpBB/includes/db/migration/v308.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v308 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v308rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v309.php b/phpBB/includes/db/migration/v309.php deleted file mode 100644 index ebb246da3a..0000000000 --- a/phpBB/includes/db/migration/v309.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v309 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v309rc4'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v309rc2.php b/phpBB/includes/db/migration/v309rc2.php deleted file mode 100644 index d552b95e7a..0000000000 --- a/phpBB/includes/db/migration/v309rc2.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v309rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v309rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v309rc3.php b/phpBB/includes/db/migration/v309rc3.php deleted file mode 100644 index 4c215c09f7..0000000000 --- a/phpBB/includes/db/migration/v309rc3.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v309rc3 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v309rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migration/v309rc4.php b/phpBB/includes/db/migration/v309rc4.php deleted file mode 100644 index 92f3d81947..0000000000 --- a/phpBB/includes/db/migration/v309rc4.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_v309rc4 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_v309rc3'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - } -} diff --git a/phpBB/includes/db/migrationtools/base.php b/phpBB/includes/db/migrationtools/base.php new file mode 100644 index 0000000000..7fc6057e3a --- /dev/null +++ b/phpBB/includes/db/migrationtools/base.php @@ -0,0 +1,15 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migrationtools_base +{ + var $cache; + var $config; + var $db; +} \ No newline at end of file diff --git a/phpBB/includes/db/migrationtools/config.php b/phpBB/includes/db/migrationtools/config.php new file mode 100644 index 0000000000..5a40e39943 --- /dev/null +++ b/phpBB/includes/db/migrationtools/config.php @@ -0,0 +1,121 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migrationtools_config extends phpbb_db_migration +{ + /** + * Config Exists + * + * This function is to check to see if a config variable exists or if it does not. + * + * @param string $config_name The name of the config setting you wish to check for. + * @param bool $return_result - return the config value/default if true : default false. + * + * @return bool true/false if config exists + */ + function config_exists($config_name, $return_result = false) + { + $sql = 'SELECT * + FROM ' . CONFIG_TABLE . " + WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + if (!isset($this->config[$config_name])) + { + $this->config[$config_name] = $row['config_value']; + + if (!$row['is_dynamic']) + { + $this->cache->destroy('config'); + } + } + + return ($return_result) ? $row : true; + } + + // this should never happen, but if it does, we need to remove the config from the array + if (isset($this->config[$config_name])) + { + unset($this->config[$config_name]); + $this->cache->destroy('config'); + } + + return false; + } + + /** + * Config Add + * + * This function allows you to add a config setting. + * + * @param string $config_name The name of the config setting you would like to add + * @param mixed $config_value The value of the config setting + * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + * + * @return result + */ + function config_add($config_name, $config_value = '', $is_dynamic = false) + { + if ($this->config_exists($config_name)) + { + return $this->umil_end('CONFIG_ALREADY_EXISTS', $config_name); + } + + set_config($config_name, $config_value, $is_dynamic); + } + + /** + * Config Update + * + * This function allows you to update an existing config setting. + * + * @param string $config_name The name of the config setting you would like to update + * @param mixed $config_value The value of the config setting + * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + * + * @return result + */ + function config_update($config_name, $config_value = '') + { + if (!$this->config_exists($config_name)) + { + return $this->umil_end('CONFIG_NOT_EXIST', $config_name); + } + + set_config($config_name, $config_value); + } + + /** + * Config Remove + * + * This function allows you to remove an existing config setting. + * + * @param string $config_name The name of the config setting you would like to remove + * + * @return result + */ + function config_remove($config_name) + { + if (!$this->config_exists($config_name)) + { + return $this->umil_end('CONFIG_NOT_EXIST', $config_name); + } + + $sql = 'DELETE FROM ' . CONFIG_TABLE . " + WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; + $this->db->sql_query($sql); + + unset($this->config[$config_name]); + $this->cache->destroy('config'); + } +} \ No newline at end of file diff --git a/phpBB/includes/db/migrationtools/umil.php b/phpBB/includes/db/migrationtools/umil.php new file mode 100644 index 0000000000..ce7b8ff3be --- /dev/null +++ b/phpBB/includes/db/migrationtools/umil.php @@ -0,0 +1,3037 @@ +<?php +/** + * + * @author Nathan Guse (EXreaction) http://lithiumstudios.org + * @author David Lewis (Highway of Life) highwayoflife@gmail.com + * @package umil + * @version $Id$ + * @copyright (c) 2008 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License + * + */ + +/** + * @ignore + */ +if (!defined('IN_PHPBB')) +{ + exit; +} + +define('UMIL_VERSION', '1.0.4'); + +/** +* Multicall instructions +* +* With the "multicall" (as I am calling it) you can make a single function call and have it repeat the actions multiple times on information sent from an array. +* +* To do this (it does not work on the _exists functions), all you must do is send the first variable in the function call as an array and for each item, send an array for each of the variables in order. +* +* Example: +* $umil->config_add(array( +* array('config_name', 'config_value'), +* array('config_name1', 'config_value1'), +* array('config_name2', 'config_value2', true), +* array('config_name3', 'config_value3', true), +* ); +*/ + +/** +* UMIL - Unified MOD Installation Library class +* +* Cache Functions +* cache_purge($type = '', $style_id = 0) +* +* Config Functions: +* config_exists($config_name, $return_result = false) +* config_add($config_name, $config_value = '', $is_dynamic = false) +* config_update($config_name, $config_value, $is_dynamic = false) +* config_remove($config_name) +* +* Module Functions +* module_exists($class, $parent, $module) +* module_add($class, $parent = 0, $data = array()) +* module_remove($class, $parent = 0, $module = '') +* +* Permissions/Auth Functions +* permission_exists($auth_option, $global = true) +* permission_add($auth_option, $global = true) +* permission_remove($auth_option, $global = true) +* permission_set($name, $auth_option = array(), $type = 'role', $global = true, $has_permission = true) +* permission_unset($name, $auth_option = array(), $type = 'role', $global = true) +* +* Table Functions +* table_exists($table_name) +* table_add($table_name, $table_data = array()) +* table_remove($table_name) +* +* Table Column Functions +* table_column_exists($table_name, $column_name) +* table_column_add($table_name, $column_name = '', $column_data = array()) +* table_column_update($table_name, $column_name = '', $column_data = array()) +* table_column_remove($table_name, $column_name = '') +* +* Table Key/Index Functions +* table_index_exists($table_name, $index_name) +* table_index_add($table_name, $index_name = '', $column = array()) +* table_index_remove($table_name, $index_name = '') +* +* Table Row Functions (note that these actions are not reversed automatically during uninstallation) +* table_row_insert($table_name, $data = array()) +* table_row_remove($table_name, $data = array()) +* table_row_update($table_name, $data = array(), $new_data = array()) +* +* Version Check Function +* version_check($url, $path, $file) +*/ +class umil +{ + /** + * This will hold the text output for the inputted command (if the mod author would like to display the command that was ran) + * + * @var string + */ + var $command = ''; + + /** + * This will hold the text output for the result of the command. $user->lang['SUCCESS'] if everything worked. + * + * @var string + */ + var $result = ''; + + /** + * Auto run $this->display_results after running a command + */ + var $auto_display_results = false; + + /** + * Stand Alone option (this makes it possible to just use the single umil file and not worry about any language stuff + */ + var $stand_alone = false; + + /** + * Were any new permissions added (used in umil_frontend)? + */ + var $permissions_added = false; + + /** + * Database Object + */ + var $db = false; + + /** + * Database Tools Object + */ + var $db_tools = false; + + /** + * Do we want a custom prefix besides the phpBB table prefix? You *probably* should not change this... + */ + var $table_prefix = false; + + /** + * Constructor + */ + function umil($stand_alone = false, $db = false) + { + // Setup $this->db + if ($db !== false) + { + if (!is_object($db) || !method_exists($db, 'sql_query')) + { + trigger_error('Invalid $db Object'); + } + + $this->db = $db; + } + else + { + global $db; + $this->db = $db; + } + + // Setup $this->db_tools + if (!class_exists('phpbb_db_tools')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); + } + $this->db_tools = new phpbb_db_tools($this->db); + + $this->stand_alone = $stand_alone; + + if (!$stand_alone) + { + global $config, $user, $phpbb_root_path, $phpEx; + + /* Does not have the fall back option to use en/ if the user's language file does not exist, so we will not use it...unless that is changed. + if (method_exists('user', 'set_custom_lang_path')) + { + $user->set_custom_lang_path($phpbb_root_path . 'umil/language/'); + $user->add_lang('umil'); + $user->set_custom_lang_path($phpbb_root_path . 'language/'); + } + else + {*/ + // Include the umil language file. First we check if the language file for the user's language is available, if not we check if the board's default language is available, if not we use the english file. + if (isset($user->data['user_lang']) && file_exists("{$phpbb_root_path}umil/language/{$user->data['user_lang']}/umil.$phpEx")) + { + $path = $user->data['user_lang']; + } + else if (file_exists("{$phpbb_root_path}umil/language/" . basename($config['default_lang']) . "/umil.$phpEx")) + { + $path = basename($config['default_lang']); + } + else if (file_exists("{$phpbb_root_path}umil/language/en/umil.$phpEx")) + { + $path = 'en'; + } + else + { + trigger_error('Language Files Missing.<br /><br />Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR); + } + + $user->add_lang('./../../umil/language/' . $path . '/umil'); + //} + + $user->add_lang(array('acp/common', 'acp/permissions')); + + // Check to see if a newer version is available. + $info = $this->version_check('version.phpbb.com', '/umil', ((defined('PHPBB_QA')) ? 'umil_qa.txt' : 'umil.txt')); + if (is_array($info) && isset($info[0]) && isset($info[1])) + { + if (version_compare(UMIL_VERSION, $info[0], '<')) + { + global $template; + + // Make sure user->setup() has been called + if (empty($user->lang)) + { + $user->setup(); + } + + page_header('', false); + + $user->lang['UPDATE_UMIL'] = (isset($user->lang['UPDATE_UMIL'])) ? $user->lang['UPDATE_UMIL'] : 'This version of UMIL is outdated.<br /><br />Please download the latest UMIL (Unified MOD Install Library) from: <a href="%1$s">%1$s</a>'; + $template->assign_vars(array( + 'S_BOARD_DISABLED' => true, + 'L_BOARD_DISABLED' => sprintf($user->lang['UPDATE_UMIL'], $info[1]), + )); + } + } + } + } + + /** + * umil_start + * + * A function which runs (almost) every time a function here is ran + */ + function umil_start() + { + global $user; + + // Set up the command. This will get the arguments sent to the function. + $args = func_get_args(); + $this->command = call_user_func_array(array($this, 'get_output_text'), $args); + + $this->result = (isset($user->lang['SUCCESS'])) ? $user->lang['SUCCESS'] : 'SUCCESS'; + $this->db->sql_return_on_error(true); + + //$this->db->sql_transaction('begin'); + } + + /** + * umil_end + * + * A function which runs (almost) every time a function here is ran + */ + function umil_end() + { + global $user; + + // Set up the result. This will get the arguments sent to the function. + $args = func_get_args(); + $result = call_user_func_array(array($this, 'get_output_text'), $args); + $this->result = ($result) ? $result : $this->result; + + if ($this->db->sql_error_triggered) + { + if ($this->result == ((isset($user->lang['SUCCESS'])) ? $user->lang['SUCCESS'] : 'SUCCESS')) + { + $this->result = 'SQL ERROR ' . $this->db->sql_error_returned['message']; + } + else + { + $this->result .= '<br /><br />SQL ERROR ' . $this->db->sql_error_returned['message']; + } + + //$this->db->sql_transaction('rollback'); + } + else + { + //$this->db->sql_transaction('commit'); + } + + $this->db->sql_return_on_error(false); + + // Auto output if requested. + if ($this->auto_display_results && method_exists($this, 'display_results')) + { + $this->display_results(); + } + + return '<strong>' . $this->command . '</strong><br />' . $this->result; + } + + /** + * Get text for output + * + * Takes the given arguments and prepares them for the UI + * + * First argument sent is used as the language key + * Further arguments (if send) are used on the language key through vsprintf() + * + * @return string Returns the prepared string for output + */ + function get_output_text() + { + global $user; + + // Set up the command. This will get the arguments sent to the function. + $args = func_get_args(); + if (sizeof($args)) + { + $lang_key = array_shift($args); + + if (sizeof($args)) + { + $lang_args = array(); + foreach ($args as $arg) + { + $lang_args[] = (isset($user->lang[$arg])) ? $user->lang[$arg] : $arg; + } + + return @vsprintf(((isset($user->lang[$lang_key])) ? $user->lang[$lang_key] : $lang_key), $lang_args); + } + else + { + return ((isset($user->lang[$lang_key])) ? $user->lang[$lang_key] : $lang_key); + } + } + + return ''; + } + + /** + * Run Actions + * + * Do-It-All function that can do everything required for installing/updating/uninstalling a mod based on an array of actions and the versions. + * + * @param string $action The action. install|update|uninstall + * @param array $versions The array of versions and the actions for each + * @param string $version_config_name The name of the config setting which holds/will hold the currently installed version + * @param string $version_select Added for the UMIL Auto system to allow you to select the version you want to install/update/uninstall to. + */ + function run_actions($action, $versions, $version_config_name, $version_select = '') + { + // We will sort the actions to prevent issues from mod authors incorrectly listing the version numbers + uksort($versions, 'version_compare'); + + // Find the current version to install + $current_version = '0.0.0'; + foreach ($versions as $version => $actions) + { + $current_version = $version; + } + + $db_version = ''; + if ($this->config_exists($version_config_name)) + { + global $config; + $db_version = $config[$version_config_name]; + } + + // Set the action to install from update if nothing is currently installed + if ($action == 'update' && !$db_version) + { + $action = 'install'; + } + + if ($action == 'install' || $action == 'update') + { + $version_installed = $db_version; + foreach ($versions as $version => $version_actions) + { + // If we are updating + if ($db_version && version_compare($version, $db_version, '<=')) + { + continue; + } + + if ($version_select && version_compare($version, $version_select, '>')) + { + break; + } + + foreach ($version_actions as $method => $params) + { + if ($method == 'custom') + { + $this->_call_custom_function($params, $action, $version); + } + else + { + if (method_exists($this, $method)) + { + call_user_func(array($this, $method), $params); + } + } + } + + $version_installed = $version; + } + + // update the version number or add it + if ($this->config_exists($version_config_name)) + { + $this->config_update($version_config_name, $version_installed); + } + else + { + $this->config_add($version_config_name, $version_installed); + } + } + else if ($action == 'uninstall' && $db_version) + { + // reverse version list + $versions = array_reverse($versions); + + foreach ($versions as $version => $version_actions) + { + // Uninstalling and this listed version is newer than installed + if (version_compare($version, $db_version, '>')) + { + continue; + } + + // Version selection stuff + if ($version_select && version_compare($version, $version_select, '<=')) + { + // update the version number + $this->config_update($version_config_name, $version); + break; + } + + $cache_purge = false; + $version_actions = array_reverse($version_actions); + foreach ($version_actions as $method => $params) + { + if ($method == 'custom') + { + $this->_call_custom_function($params, $action, $version); + } + else + { + // This way we always run the cache purge at the end of the version (done for the uninstall because the instructions are reversed, which would cause the cache purge to be run at the beginning if it was meant to run at the end). + if ($method == 'cache_purge') + { + $cache_purge = $params; + continue; + } + + // A few things are not possible for uninstallations update actions and table_row actions + if (strpos($method, 'update') !== false || strpos($method, 'table_insert') !== false || strpos($method, 'table_row_') !== false) + { + continue; + } + + // reverse function call + $method = str_replace(array('add', 'remove', 'temp'), array('temp', 'add', 'remove'), $method); + $method = str_replace(array('set', 'unset', 'temp'), array('temp', 'set', 'unset'), $method); + + if (method_exists($this, $method)) + { + call_user_func(array($this, $method), ((is_array($params) ? array_reverse($params) : $params))); + } + } + } + + if ($cache_purge !== false) + { + $this->cache_purge($cache_purge); + } + } + + if (!$version_select) + { + // Unset the version number + $this->config_remove($version_config_name); + } + } + } + + /** + * Call custom function helper + */ + function _call_custom_function($functions, $action, $version) + { + if (!is_array($functions)) + { + $functions = array($functions); + } + + $return = ''; + + foreach ($functions as $function) + { + if (function_exists($function)) + { + // Must reset before calling the function + $this->umil_start(); + + $returned = call_user_func($function, $action, $version); + if (is_string($returned)) + { + $this->command = $this->get_output_text($returned); + } + else if (is_array($returned) && isset($returned['command'])) + { + if (is_array($returned['command'])) + { + $this->command = call_user_func_array(array($this, 'get_output_text'), $returned['command']); + } + else + { + $this->command = $this->get_output_text($returned['command']); + } + + if (isset($returned['result'])) + { + $this->result = $this->get_output_text($returned['result']); + } + } + else + { + $this->command = $this->get_output_text('UNKNOWN'); + } + + $return .= $this->umil_end() . '<br />'; + } + } + + return $return; + } + + /** + * Multicall Helper + * + * @param mixed $function Function name to call + * @param mixed $params The parameters array + * + * @return bool True if we have done a multicall ($params is an array), false if not ($params is not an array) + */ + function multicall($function, $params) + { + if (is_array($params) && !empty($params)) + { + foreach ($params as $param) + { + if (!is_array($param)) + { + call_user_func(array($this, $function), $param); + } + else + { + call_user_func_array(array($this, $function), $param); + } + } + return true; + } + + return false; + } + + /** + * Cache Purge + * + * This function is for purging either phpBB3’s data cache, authorization cache, or the styles cache. + * + * @param string $type The type of cache you want purged. Available types: auth, imageset, template, theme. Anything else sent will purge the forum's cache. + * @param int $style_id The id of the item you want purged (if the type selected is imageset/template/theme, 0 for all items in that section) + */ + function cache_purge($type = '', $style_id = 0) + { + global $auth, $cache, $user, $phpbb_root_path, $phpEx; + + // Multicall + if ($this->multicall(__FUNCTION__, $type)) + { + return; + } + + $style_id = (int) $style_id; + $type = (string) $type; // Prevent PHP bug. + + switch ($type) + { + case 'auth' : + $this->umil_start('AUTH_CACHE_PURGE'); + $cache->destroy('_acl_options'); + $auth->acl_clear_prefetch(); + + return $this->umil_end(); + break; + + case 'imageset' : + if ($style_id == 0) + { + $return = array(); + $sql = 'SELECT imageset_id + FROM ' . STYLES_IMAGESET_TABLE; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $return[] = $this->cache_purge('imageset', $row['imageset_id']); + } + $this->db->sql_freeresult($result); + + return implode('<br /><br />', $return); + } + else + { + $sql = 'SELECT * + FROM ' . STYLES_IMAGESET_TABLE . " + WHERE imageset_id = $style_id"; + $result = $this->db->sql_query($sql); + $imageset_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$imageset_row) + { + $this->umil_start('IMAGESET_CACHE_PURGE', 'UNKNOWN'); + return $this->umil_end('FAIL'); + } + + $this->umil_start('IMAGESET_CACHE_PURGE', $imageset_row['imageset_name']); + + // The following is from includes/acp/acp_styles.php (edited) + $sql_ary = array(); + + $cfg_data_imageset = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/imageset.cfg"); + + $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . ' + WHERE imageset_id = ' . $style_id; + $result = $this->db->sql_query($sql); + + foreach ($cfg_data_imageset as $image_name => $value) + { + if (strpos($value, '*') !== false) + { + if (substr($value, -1, 1) === '*') + { + list($image_filename, $image_height) = explode('*', $value); + $image_width = 0; + } + else + { + list($image_filename, $image_height, $image_width) = explode('*', $value); + } + } + else + { + $image_filename = $value; + $image_height = $image_width = 0; + } + + if (strpos($image_name, 'img_') === 0 && $image_filename) + { + $image_name = substr($image_name, 4); + + $sql_ary[] = array( + 'image_name' => (string) $image_name, + 'image_filename' => (string) $image_filename, + 'image_height' => (int) $image_height, + 'image_width' => (int) $image_width, + 'imageset_id' => (int) $style_id, + 'image_lang' => '', + ); + } + } + + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg")) + { + $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg"); + foreach ($cfg_data_imageset_data as $image_name => $value) + { + if (strpos($value, '*') !== false) + { + if (substr($value, -1, 1) === '*') + { + list($image_filename, $image_height) = explode('*', $value); + $image_width = 0; + } + else + { + list($image_filename, $image_height, $image_width) = explode('*', $value); + } + } + else + { + $image_filename = $value; + $image_height = $image_width = 0; + } + + if (strpos($image_name, 'img_') === 0 && $image_filename) + { + $image_name = substr($image_name, 4); + $sql_ary[] = array( + 'image_name' => (string) $image_name, + 'image_filename' => (string) $image_filename, + 'image_height' => (int) $image_height, + 'image_width' => (int) $image_width, + 'imageset_id' => (int) $style_id, + 'image_lang' => (string) $row['lang_dir'], + ); + } + } + } + } + $this->db->sql_freeresult($result); + + $this->db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); + + $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); + + return $this->umil_end(); + } + break; + //case 'imageset' : + + case 'template' : + if ($style_id == 0) + { + $return = array(); + $sql = 'SELECT template_id + FROM ' . STYLES_TEMPLATE_TABLE; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $return[] = $this->cache_purge('template', $row['template_id']); + } + $this->db->sql_freeresult($result); + + return implode('<br /><br />', $return); + } + else + { + $sql = 'SELECT * + FROM ' . STYLES_TEMPLATE_TABLE . " + WHERE template_id = $style_id"; + $result = $this->db->sql_query($sql); + $template_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$template_row) + { + $this->umil_start('TEMPLATE_CACHE_PURGE', 'UNKNOWN'); + return $this->umil_end('FAIL'); + } + + $this->umil_start('TEMPLATE_CACHE_PURGE', $template_row['template_name']); + + // The following is from includes/acp/acp_styles.php + if ($template_row['template_storedb'] && file_exists("{$phpbb_root_path}styles/{$template_row['template_path']}/template/")) + { + $filelist = array('' => array()); + + $sql = 'SELECT template_filename, template_mtime + FROM ' . STYLES_TEMPLATE_DATA_TABLE . " + WHERE template_id = $style_id"; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { +// if (@filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/" . $row['template_filename']) > $row['template_mtime']) +// { + // get folder info from the filename + if (($slash_pos = strrpos($row['template_filename'], '/')) === false) + { + $filelist[''][] = $row['template_filename']; + } + else + { + $filelist[substr($row['template_filename'], 0, $slash_pos + 1)][] = substr($row['template_filename'], $slash_pos + 1, strlen($row['template_filename']) - $slash_pos - 1); + } +// } + } + $this->db->sql_freeresult($result); + + $includes = array(); + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + if (!($fp = @fopen("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file", 'r'))) + { + return $this->umil_end('FILE_COULD_NOT_READ', "{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file"); + } + $template_data = fread($fp, filesize("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file")); + fclose($fp); + + if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches)) + { + foreach ($matches[1] as $match) + { + $includes[trim($match)][] = $file; + } + } + } + } + + foreach ($filelist as $pathfile => $file_ary) + { + foreach ($file_ary as $file) + { + // Skip index. + if (strpos($file, 'index.') === 0) + { + continue; + } + + // We could do this using extended inserts ... but that could be one + // heck of a lot of data ... + $sql_ary = array( + 'template_id' => (int) $style_id, + 'template_filename' => "$pathfile$file", + 'template_included' => (isset($includes[$file])) ? implode(':', $includes[$file]) . ':' : '', + 'template_mtime' => (int) filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file"), + 'template_data' => (string) file_get_contents("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file"), + ); + + $sql = 'UPDATE ' . STYLES_TEMPLATE_DATA_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE template_id = $style_id + AND template_filename = '" . $this->db->sql_escape("$pathfile$file") . "'"; + $this->db->sql_query($sql); + } + } + unset($filelist); + } + + // Purge the forum's cache as well. + $cache->purge(); + + return $this->umil_end(); + } + break; + //case 'template' : + + case 'theme' : + if ($style_id == 0) + { + $return = array(); + $sql = 'SELECT theme_id + FROM ' . STYLES_THEME_TABLE; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $return[] = $this->cache_purge('theme', $row['theme_id']); + } + $this->db->sql_freeresult($result); + + return implode('<br /><br />', $return); + } + else + { + $sql = 'SELECT * + FROM ' . STYLES_THEME_TABLE . " + WHERE theme_id = $style_id"; + $result = $this->db->sql_query($sql); + $theme_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$theme_row) + { + $this->umil_start('THEME_CACHE_PURGE', 'UNKNOWN'); + return $this->umil_end('FAIL'); + } + + $this->umil_start('THEME_CACHE_PURGE', $theme_row['theme_name']); + + // The following is from includes/acp/acp_styles.php + if ($theme_row['theme_storedb'] && file_exists("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css")) + { + $stylesheet = file_get_contents($phpbb_root_path . 'styles/' . $theme_row['theme_path'] . '/theme/stylesheet.css'); + + // Match CSS imports + $matches = array(); + preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches); + + if (sizeof($matches)) + { + foreach ($matches[0] as $idx => $match) + { + if (!file_exists("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/{$matches[1][$idx]}")) + { + continue; + } + + $content = trim(file_get_contents("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/{$matches[1][$idx]}")); + $stylesheet = str_replace($match, $content, $stylesheet); + } + } + + // adjust paths + $db_theme_data = str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet); + + // Save CSS contents + $sql_ary = array( + 'theme_mtime' => (int) filemtime("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css"), + 'theme_data' => $db_theme_data, + ); + + $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE theme_id = $style_id"; + $this->db->sql_query($sql); + + $cache->destroy('sql', STYLES_THEME_TABLE); + } + + return $this->umil_end(); + } + break; + //case 'theme' : + + default: + $this->umil_start('CACHE_PURGE'); + $cache->purge(); + + return $this->umil_end(); + break; + } + } + + /** + * Config Exists + * + * This function is to check to see if a config variable exists or if it does not. + * + * @param string $config_name The name of the config setting you wish to check for. + * @param bool $return_result - return the config value/default if true : default false. + * + * @return bool true/false if config exists + */ + function config_exists($config_name, $return_result = false) + { + global $config, $cache; + + $sql = 'SELECT * + FROM ' . CONFIG_TABLE . " + WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + if (!isset($config[$config_name])) + { + $config[$config_name] = $row['config_value']; + + if (!$row['is_dynamic']) + { + $cache->destroy('config'); + } + } + + return ($return_result) ? $row : true; + } + + // this should never happen, but if it does, we need to remove the config from the array + if (isset($config[$config_name])) + { + unset($config[$config_name]); + $cache->destroy('config'); + } + + return false; + } + + /** + * Config Add + * + * This function allows you to add a config setting. + * + * @param string $config_name The name of the config setting you would like to add + * @param mixed $config_value The value of the config setting + * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + * + * @return result + */ + function config_add($config_name, $config_value = '', $is_dynamic = false) + { + // Multicall + if ($this->multicall(__FUNCTION__, $config_name)) + { + return; + } + + $this->umil_start('CONFIG_ADD', $config_name); + + if ($this->config_exists($config_name)) + { + return $this->umil_end('CONFIG_ALREADY_EXISTS', $config_name); + } + + set_config($config_name, $config_value, $is_dynamic); + + return $this->umil_end(); + } + + /** + * Config Update + * + * This function allows you to update an existing config setting. + * + * @param string $config_name The name of the config setting you would like to update + * @param mixed $config_value The value of the config setting + * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + * + * @return result + */ + function config_update($config_name, $config_value = '', $is_dynamic = false) + { + // Multicall + if ($this->multicall(__FUNCTION__, $config_name)) + { + return; + } + + $this->umil_start('CONFIG_UPDATE', $config_name); + + if (!$this->config_exists($config_name)) + { + return $this->umil_end('CONFIG_NOT_EXIST', $config_name); + } + + set_config($config_name, $config_value, $is_dynamic); + + return $this->umil_end(); + } + + /** + * Config Remove + * + * This function allows you to remove an existing config setting. + * + * @param string $config_name The name of the config setting you would like to remove + * + * @return result + */ + function config_remove($config_name) + { + global $cache, $config; + + // Multicall + if ($this->multicall(__FUNCTION__, $config_name)) + { + return; + } + + $this->umil_start('CONFIG_REMOVE', $config_name); + + if (!$this->config_exists($config_name)) + { + return $this->umil_end('CONFIG_NOT_EXIST', $config_name); + } + + $sql = 'DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; + $this->db->sql_query($sql); + + unset($config[$config_name]); + $cache->destroy('config'); + + return $this->umil_end(); + } + + /** + * Module Exists + * + * Check if a module exists + * + * @param string $class The module class(acp|mcp|ucp) + * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. + * @param int|string $module The module_id|module_langname you would like to check for to see if it exists + */ + function module_exists($class, $parent, $module) + { + // the main root directory should return true + if (!$module) + { + return true; + } + + $class = $this->db->sql_escape($class); + $module = $this->db->sql_escape($module); + + $parent_sql = ''; + if ($parent !== false) + { + // Allows '' to be sent as 0 + $parent = (!$parent) ? 0 : $parent; + + if (!is_numeric($parent)) + { + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($parent) . "' + AND module_class = '$class'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + return false; + } + + $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; + } + else + { + $parent_sql = 'AND parent_id = ' . (int) $parent; + } + } + + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_class = '$class' + $parent_sql + AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '$module'"); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + return true; + } + + return false; + } + + /** + * Module Add + * + * Add a new module + * + * @param string $class The module class(acp|mcp|ucp) + * @param int|string $parent The parent module_id|module_langname (0 for no parent) + * @param array $data an array of the data on the new module. This can be setup in two different ways. + * 1. The "manual" way. For inserting a category or one at a time. It will be merged with the base array shown a bit below, + * but at the least requires 'module_langname' to be sent, and, if you want to create a module (instead of just a category) you must send module_basename and module_mode. + * array( + * 'module_enabled' => 1, + * 'module_display' => 1, + * 'module_basename' => '', + * 'module_class' => $class, + * 'parent_id' => (int) $parent, + * 'module_langname' => '', + * 'module_mode' => '', + * 'module_auth' => '', + * ) + * 2. The "automatic" way. For inserting multiple at a time based on the specs in the info file for the module(s). For this to work the modules must be correctly setup in the info file. + * An example follows (this would insert the settings, log, and flag modes from the includes/acp/info/acp_asacp.php file): + * array( + * 'module_basename' => 'asacp', + * 'modes' => array('settings', 'log', 'flag'), + * ) + * Optionally you may not send 'modes' and it will insert all of the modules in that info file. + * @param string|bool $include_path If you would like to use a custom include path, specify that here + */ + function module_add($class, $parent = 0, $data = array(), $include_path = false) + { + global $cache, $user, $phpbb_root_path, $phpEx; + + // Multicall + if ($this->multicall(__FUNCTION__, $class)) + { + return; + } + + // Prevent stupid things like trying to add a module with no name or any data on it + if (empty($data)) + { + $this->umil_start('MODULE_ADD', $class, 'UNKNOWN'); + return $this->umil_end('FAIL'); + } + + // Allows '' to be sent as 0 + $parent = (!$parent) ? 0 : $parent; + + // allow sending the name as a string in $data to create a category + if (!is_array($data)) + { + $data = array('module_langname' => $data); + } + + if (!isset($data['module_langname'])) + { + // The "automatic" way + $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; + $basename = str_replace(array('/', '\\'), '', $basename); + $class = str_replace(array('/', '\\'), '', $class); + $info_file = "$class/info/{$class}_$basename.$phpEx"; + + // The manual and automatic ways both failed... + if (!file_exists((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file)) + { + $this->umil_start('MODULE_ADD', $class, $info_file); + return $this->umil_end('FAIL'); + } + + $classname = "{$class}_{$basename}_info"; + + if (!class_exists($classname)) + { + include((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file); + } + + $info = new $classname; + $module = $info->module(); + unset($info); + + $result = ''; + foreach ($module['modes'] as $mode => $module_info) + { + if (!isset($data['modes']) || in_array($mode, $data['modes'])) + { + $new_module = array( + 'module_basename' => $basename, + 'module_langname' => $module_info['title'], + 'module_mode' => $mode, + 'module_auth' => $module_info['auth'], + 'module_display' => (isset($module_info['display'])) ? $module_info['display'] : true, + 'before' => (isset($module_info['before'])) ? $module_info['before'] : false, + 'after' => (isset($module_info['after'])) ? $module_info['after'] : false, + ); + + // Run the "manual" way with the data we've collected. + $result .= ((isset($data['spacer'])) ? $data['spacer'] : '<br />') . $this->module_add($class, $parent, $new_module); + } + } + + return $result; + } + + // The "manual" way + $this->umil_start('MODULE_ADD', $class, ((isset($user->lang[$data['module_langname']])) ? $user->lang[$data['module_langname']] : $data['module_langname'])); + add_log('admin', 'LOG_MODULE_ADD', ((isset($user->lang[$data['module_langname']])) ? $user->lang[$data['module_langname']] : $data['module_langname'])); + + $class = $this->db->sql_escape($class); + + if (!is_numeric($parent)) + { + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($parent) . "' + AND module_class = '$class'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + return $this->umil_end('PARENT_NOT_EXIST'); + } + + $parent = $data['parent_id'] = $row['module_id']; + } + else if (!$this->module_exists($class, false, $parent)) + { + return $this->umil_end('PARENT_NOT_EXIST'); + } + + if ($this->module_exists($class, $parent, $data['module_langname'])) + { + return $this->umil_end('MODULE_ALREADY_EXIST'); + } + + if (!class_exists('acp_modules')) + { + include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); + $user->add_lang('acp/modules'); + } + $acp_modules = new acp_modules(); + + $module_data = array( + 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, + 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, + 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', + 'module_class' => $class, + 'parent_id' => (int) $parent, + 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', + 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', + 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', + ); + $result = $acp_modules->update_module_data($module_data, true); + + // update_module_data can either return a string or an empty array... + if (is_string($result)) + { + // Error + $this->result = $this->get_output_text($result); + } + else + { + // Success + + // Move the module if requested above/below an existing one + if (isset($data['before']) && $data['before']) + { + $sql = 'SELECT left_id FROM ' . MODULES_TABLE . ' + WHERE module_class = \'' . $class . '\' + AND parent_id = ' . (int) $parent . ' + AND module_langname = \'' . $this->db->sql_escape($data['before']) . '\''; + $this->db->sql_query($sql); + $to_left = $this->db->sql_fetchfield('left_id'); + + $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 + WHERE module_class = '$class' + AND left_id >= $to_left + AND left_id < {$module_data['left_id']}"; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = $to_left, right_id = " . ($to_left + 1) . " + WHERE module_class = '$class' + AND module_id = {$module_data['module_id']}"; + $this->db->sql_query($sql); + } + else if (isset($data['after']) && $data['after']) + { + $sql = 'SELECT right_id FROM ' . MODULES_TABLE . ' + WHERE module_class = \'' . $class . '\' + AND parent_id = ' . (int) $parent . ' + AND module_langname = \'' . $this->db->sql_escape($data['after']) . '\''; + $this->db->sql_query($sql); + $to_right = $this->db->sql_fetchfield('right_id'); + + $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 + WHERE module_class = '$class' + AND left_id >= $to_right + AND left_id < {$module_data['left_id']}"; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " + WHERE module_class = '$class' + AND module_id = {$module_data['module_id']}"; + $this->db->sql_query($sql); + } + } + + // Clear the Modules Cache + $cache->destroy("_modules_$class"); + + return $this->umil_end(); + } + + /** + * Module Remove + * + * Remove a module + * + * @param string $class The module class(acp|mcp|ucp) + * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. + * @param int|string $module The module id|module_langname + * @param string|bool $include_path If you would like to use a custom include path, specify that here + */ + function module_remove($class, $parent = 0, $module = '', $include_path = false) + { + global $cache, $user, $phpbb_root_path, $phpEx; + + // Multicall + if ($this->multicall(__FUNCTION__, $class)) + { + return; + } + + // Imitation of module_add's "automatic" and "manual" method so the uninstaller works from the same set of instructions for umil_auto + if (is_array($module)) + { + if (isset($module['module_langname'])) + { + // Manual Method + return $this->module_remove($class, $parent, $module['module_langname'], $include_path); + } + + // Failed. + if (!isset($module['module_basename'])) + { + $this->umil_start('MODULE_REMOVE', $class, 'UNKNOWN'); + return $this->umil_end('FAIL'); + } + + // Automatic method + $basename = str_replace(array('/', '\\'), '', $module['module_basename']); + $class = str_replace(array('/', '\\'), '', $class); + $info_file = "$class/info/{$class}_$basename.$phpEx"; + + if (!file_exists((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file)) + { + $this->umil_start('MODULE_REMOVE', $class, $info_file); + return $this->umil_end('FAIL'); + } + + $classname = "{$class}_{$basename}_info"; + + if (!class_exists($classname)) + { + include((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file); + } + + $info = new $classname; + $module_info = $info->module(); + unset($info); + + $result = ''; + foreach ($module_info['modes'] as $mode => $info) + { + if (!isset($module['modes']) || in_array($mode, $module['modes'])) + { + $result .= $this->module_remove($class, $parent, $info['title']) . '<br />'; + } + } + return $result; + } + else + { + $class = $this->db->sql_escape($class); + + if (!$this->module_exists($class, $parent, $module)) + { + $this->umil_start('MODULE_REMOVE', $class, ((isset($user->lang[$module])) ? $user->lang[$module] : $module)); + return $this->umil_end('MODULE_NOT_EXIST'); + } + + $parent_sql = ''; + if ($parent !== false) + { + // Allows '' to be sent as 0 + $parent = (!$parent) ? 0 : $parent; + + if (!is_numeric($parent)) + { + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($parent) . "' + AND module_class = '$class'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // we know it exists from the module_exists check + $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; + } + else + { + $parent_sql = 'AND parent_id = ' . (int) $parent; + } + } + + $module_ids = array(); + if (!is_numeric($module)) + { + $module = $this->db->sql_escape($module); + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '$module' + AND module_class = '$class' + $parent_sql"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $module_ids[] = (int) $row['module_id']; + } + $this->db->sql_freeresult($result); + + $module_name = $module; + } + else + { + $module = (int) $module; + $sql = 'SELECT module_langname FROM ' . MODULES_TABLE . " + WHERE module_id = $module + AND module_class = '$class' + $parent_sql"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $module_name = $row['module_langname']; + $module_ids[] = $module; + } + + $this->umil_start('MODULE_REMOVE', $class, ((isset($user->lang[$module_name])) ? $user->lang[$module_name] : $module_name)); + add_log('admin', 'LOG_MODULE_REMOVED', ((isset($user->lang[$module_name])) ? $user->lang[$module_name] : $module_name)); + + if (!class_exists('acp_modules')) + { + include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); + $user->add_lang('acp/modules'); + } + $acp_modules = new acp_modules(); + $acp_modules->module_class = $class; + + foreach ($module_ids as $module_id) + { + $result = $acp_modules->delete_module($module_id); + if (!empty($result)) + { + if ($this->result == ((isset($user->lang['SUCCESS'])) ? $user->lang['SUCCESS'] : 'SUCCESS')) + { + $this->result = implode('<br />', $result); + } + else + { + $this->result .= '<br />' . implode('<br />', $result); + } + } + } + + $cache->destroy("_modules_$class"); + + return $this->umil_end(); + } + } + + /** + * Permission Exists + * + * Check if a permission (auth) setting exists + * + * @param string $auth_option The name of the permission (auth) option + * @param bool $global True for checking a global permission setting, False for a local permission setting + * + * @return bool true if it exists, false if not + */ + function permission_exists($auth_option, $global = true) + { + if ($global) + { + $type_sql = ' AND is_global = 1'; + } + else + { + $type_sql = ' AND is_local = 1'; + } + + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" + . $type_sql; + $result = $this->db->sql_query($sql); + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + return true; + } + + return false; + } + + /** + * Permission Add + * + * Add a permission (auth) option + * + * @param string $auth_option The name of the permission (auth) option + * @param bool $global True for checking a global permission setting, False for a local permission setting + * + * @return result + */ + function permission_add($auth_option, $global = true) + { + // Multicall + if ($this->multicall(__FUNCTION__, $auth_option)) + { + return; + } + + $this->umil_start('PERMISSION_ADD', $auth_option); + + if ($this->permission_exists($auth_option, $global)) + { + return $this->umil_end('PERMISSION_ALREADY_EXISTS', $auth_option); + } + + // We've added permissions, so set to true to notify the user. + $this->permissions_added = true; + + if (!class_exists('auth_admin')) + { + global $phpbb_root_path, $phpEx; + + include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + } + $auth_admin = new auth_admin(); + + // We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists. If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here. + if ($this->permission_exists($auth_option, !$global)) + { + $sql_ary = array( + 'is_global' => 1, + 'is_local' => 1, + ); + $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE auth_option = \'' . $this->db->sql_escape($auth_option) . "'"; + $this->db->sql_query($sql); + } + else + { + if ($global) + { + $auth_admin->acl_add_option(array('global' => array($auth_option))); + } + else + { + $auth_admin->acl_add_option(array('local' => array($auth_option))); + } + } + + return $this->umil_end(); + } + + /** + * Permission Remove + * + * Remove a permission (auth) option + * + * @param string $auth_option The name of the permission (auth) option + * @param bool $global True for checking a global permission setting, False for a local permission setting + * + * @return result + */ + function permission_remove($auth_option, $global = true) + { + global $auth, $cache; + + // Multicall + if ($this->multicall(__FUNCTION__, $auth_option)) + { + return; + } + + $this->umil_start('PERMISSION_REMOVE', $auth_option); + + if (!$this->permission_exists($auth_option, $global)) + { + return $this->umil_end('PERMISSION_NOT_EXIST', $auth_option); + } + + if ($global) + { + $type_sql = ' AND is_global = 1'; + } + else + { + $type_sql = ' AND is_local = 1'; + } + $sql = 'SELECT auth_option_id, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" . + $type_sql; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $id = $row['auth_option_id']; + + // If it is a local and global permission, do not remove the row! :P + if ($row['is_global'] && $row['is_local']) + { + $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' + SET ' . (($global) ? 'is_global = 0' : 'is_local = 0') . ' + WHERE auth_option_id = ' . $id; + $this->db->sql_query($sql); + } + else + { + // Delete time + $this->db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $id); + $this->db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $id); + $this->db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $id); + $this->db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $id); + } + + // Purge the auth cache + $cache->destroy('_acl_options'); + $auth->acl_clear_prefetch(); + + return $this->umil_end(); + } + + /** + * Add a new permission role + * + * @param string $role_name The new role name + * @param sting $role_type The type (u_, m_, a_) + */ + function permission_role_add($role_name, $role_type = '', $role_description = '') + { + // Multicall + if ($this->multicall(__FUNCTION__, $role_name)) + { + return; + } + + $this->umil_start('PERMISSION_ROLE_ADD', $role_name); + + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if ($role_id) + { + return $this->umil_end('ROLE_ALREADY_EXISTS', $old_role_name); + } + + $sql = 'SELECT MAX(role_order) AS max FROM ' . ACL_ROLES_TABLE . ' + WHERE role_type = \'' . $this->db->sql_escape($role_type) . '\''; + $this->db->sql_query($sql); + $role_order = $this->db->sql_fetchfield('max'); + $role_order = (!$role_order) ? 1 : $role_order + 1; + + $sql_ary = array( + 'role_name' => $role_name, + 'role_description' => $role_description, + 'role_type' => $role_type, + 'role_order' => $role_order, + ); + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->db->sql_query($sql); + + return $this->umil_end(); + } + + /** + * Update the name on a permission role + * + * @param string $old_role_name The old role name + * @param string $new_role_name The new role name + */ + function permission_role_update($old_role_name, $new_role_name = '') + { + // Multicall + if ($this->multicall(__FUNCTION__, $role_name)) + { + return; + } + + $this->umil_start('PERMISSION_ROLE_UPDATE', $old_role_name); + + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + return $this->umil_end('ROLE_NOT_EXIST', $old_role_name); + } + + $sql = 'UPDATE ' . ACL_ROLES_TABLE . ' + SET role_name = \'' . $this->db->sql_escape($new_role_name) . '\' + WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; + $this->db->sql_query($sql); + + return $this->umil_end(); + } + + /** + * Remove a permission role + * + * @param string $role_name The role name to remove + */ + function permission_role_remove($role_name) + { + global $auth; + + // Multicall + if ($this->multicall(__FUNCTION__, $role_name)) + { + return; + } + + $this->umil_start('PERMISSION_ROLE_REMOVE', $role_name); + + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + return $this->umil_end('ROLE_NOT_EXIST', $role_name); + } + + $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_ROLES_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + + $auth->acl_clear_prefetch(); + + return $this->umil_end(); + } + + /** + * Permission Set + * + * Allows you to set permissions for a certain group/role + * + * @param string $name The name of the role/group + * @param string|array $auth_option The auth_option or array of auth_options you would like to set + * @param string $type The type (role|group) + * @param bool $has_permission True if you want to give them permission, false if you want to deny them permission + */ + function permission_set($name, $auth_option = array(), $type = 'role', $has_permission = true) + { + global $auth; + + // Multicall + if ($this->multicall(__FUNCTION__, $name)) + { + return; + } + + if (!is_array($auth_option)) + { + $auth_option = array($auth_option); + } + + $new_auth = array(); + $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $new_auth[] = $row['auth_option_id']; + } + $this->db->sql_freeresult($result); + + if (!sizeof($new_auth)) + { + return false; + } + + $current_auth = array(); + + $type = (string) $type; // Prevent PHP bug. + + switch ($type) + { + case 'role' : + $this->umil_start('PERMISSION_SET_ROLE', $name); + + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + return $this->umil_end('ROLE_NOT_EXIST'); + } + + $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' + WHERE role_id = ' . $role_id; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $current_auth[$row['auth_option_id']] = $row['auth_setting']; + } + $this->db->sql_freeresult($result); + break; + + case 'group' : + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $group_id = $this->db->sql_fetchfield('group_id'); + + if (!$group_id) + { + $this->umil_start('PERMISSION_SET_GROUP', $name); + return $this->umil_end('GROUP_NOT_EXIST'); + } + + // If the group has a role set for them we will add the requested permissions to that role. + $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id <> 0 + AND forum_id = 0'; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('auth_role_id'); + if ($role_id) + { + $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + $role_name = $this->db->sql_fetchfield('role_name'); + + return $this->permission_set($role_name, $auth_option, 'role', $has_permission); + } + + $this->umil_start('PERMISSION_SET_GROUP', $name); + + $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $current_auth[$row['auth_option_id']] = $row['auth_setting']; + } + $this->db->sql_freeresult($result); + break; + } + + $sql_ary = array(); + switch ($type) + { + case 'role' : + foreach ($new_auth as $auth_option_id) + { + if (!isset($current_auth[$auth_option_id])) + { + $sql_ary[] = array( + 'role_id' => $role_id, + 'auth_option_id' => $auth_option_id, + 'auth_setting' => $has_permission, + ); + } + } + + $this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); + break; + + case 'group' : + foreach ($new_auth as $auth_option_id) + { + if (!isset($current_auth[$auth_option_id])) + { + $sql_ary[] = array( + 'group_id' => $group_id, + 'auth_option_id' => $auth_option_id, + 'auth_setting' => $has_permission, + ); + } + } + + $this->db->sql_multi_insert(ACL_GROUPS_TABLE, $sql_ary); + break; + } + + $auth->acl_clear_prefetch(); + + return $this->umil_end(); + } + + /** + * Permission Unset + * + * Allows you to unset (remove) permissions for a certain group/role + * + * @param string $name The name of the role/group + * @param string|array $auth_option The auth_option or array of auth_options you would like to set + * @param string $type The type (role|group) + */ + function permission_unset($name, $auth_option = array(), $type = 'role') + { + global $auth; + + // Multicall + if ($this->multicall(__FUNCTION__, $name)) + { + return; + } + + if (!is_array($auth_option)) + { + $auth_option = array($auth_option); + } + + $to_remove = array(); + $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $to_remove[] = $row['auth_option_id']; + } + $this->db->sql_freeresult($result); + + if (!sizeof($to_remove)) + { + return false; + } + + $type = (string) $type; // Prevent PHP bug. + + switch ($type) + { + case 'role' : + $this->umil_start('PERMISSION_UNSET_ROLE', $name); + + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + return $this->umil_end('ROLE_NOT_EXIST'); + } + + $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove); + $this->db->sql_query($sql); + break; + + case 'group' : + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $group_id = $this->db->sql_fetchfield('group_id'); + + if (!$group_id) + { + $this->umil_start('PERMISSION_UNSET_GROUP', $name); + return $this->umil_end('GROUP_NOT_EXIST'); + } + + // If the group has a role set for them we will remove the requested permissions from that role. + $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id <> 0'; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('auth_role_id'); + if ($role_id) + { + $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + $role_name = $this->db->sql_fetchfield('role_name'); + + return $this->permission_unset($role_name, $auth_option, 'role'); + } + + $this->umil_start('PERMISSION_UNSET_GROUP', $name); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove); + $this->db->sql_query($sql); + break; + } + + $auth->acl_clear_prefetch(); + + return $this->umil_end(); + } + + /** + * Table Exists + * + * Check if a table exists in the DB or not + * + * @param string $table_name The table name to check for + * + * @return bool true if the table exists, false if not + */ + function table_exists($table_name) + { + $this->get_table_name($table_name); + + // Use sql_table_exists if available + if (method_exists($this->db_tools, 'sql_table_exists')) + { + $roe = $this->db->return_on_error; + $result = $this->db_tools->sql_table_exists($table_name); + + // db_tools::sql_table_exists resets the return_on_error to false always after completing, so we must make sure we set it to true again if it was before + if ($roe) + { + $this->db->sql_return_on_error(true); + } + + return $result; + } + + if (!function_exists('get_tables')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/functions_install.' . $phpEx); + } + + $tables = get_tables($this->db); + + if (in_array($table_name, $tables)) + { + return true; + } + else + { + return false; + } + } + + /** + * Table Add + * + * This only supports input from the array format of db_tools or create_schema_files. + */ + function table_add($table_name, $table_data = array()) + { + global $dbms, $user; + + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + /** + * $table_data can be empty when uninstalling a mod and table_remove was used, but no 2rd argument was given. + * In that case we'll assume that it was a column previously added by the mod (if not the author should specify a 2rd argument) and skip this to prevent an error + */ + if (empty($table_data)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_ADD', $table_name); + + if ($this->table_exists($table_name)) + { + return $this->umil_end('TABLE_ALREADY_EXISTS', $table_name); + } + + if (!is_array($table_data)) + { + return $this->umil_end('NO_TABLE_DATA'); + } + + if (!function_exists('get_available_dbms')) + { + global $phpbb_root_path, $phpEx; + include("{$phpbb_root_path}includes/functions_install.$phpEx"); + } + + /* + * This function has had numerous problems and is currently broken, so until phpBB uses it I will not be anymore + if (method_exists($this->db_tools, 'sql_create_table')) + { + // Added in 3.0.5 + $this->db_tools->sql_create_table($table_name, $table_data); + } + else + {*/ + $available_dbms = get_available_dbms($dbms); + + $sql_query = $this->create_table_sql($table_name, $table_data); + $sql_query = split_sql_file($sql_query, $available_dbms[$dbms]['DELIM']); + + foreach ($sql_query as $sql) + { + $this->db->sql_query($sql); + } + //} + + return $this->umil_end(); + } + + /** + * Table Remove + * + * Delete/Drop a DB table + */ + function table_remove($table_name) + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_REMOVE', $table_name); + + if (!$this->table_exists($table_name)) + { + return $this->umil_end('TABLE_NOT_EXIST', $table_name); + } + + if (method_exists($this->db_tools, 'sql_table_drop')) + { + // Added in 3.0.5 + $this->db_tools->sql_table_drop($table_name); + } + else + { + $this->db->sql_query('DROP TABLE ' . $table_name); + } + + return $this->umil_end(); + } + + /** + * Table Column Exists + * + * Check to see if a column exists in a table + */ + function table_column_exists($table_name, $column_name) + { + $this->get_table_name($table_name); + + return $this->db_tools->sql_column_exists($table_name, $column_name); + } + + /** + * Table Column Add + * + * Add a new column to a table. + */ + function table_column_add($table_name, $column_name = '', $column_data = array()) + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + /** + * $column_data can be empty when uninstalling a mod and table_column_remove was used, but no 3rd argument was given. + * In that case we'll assume that it was a column previously added by the mod (if not the author should specify a 3rd argument) and skip this to prevent an error + */ + if (empty($column_data)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_COLUMN_ADD', $table_name, $column_name); + + if ($this->table_column_exists($table_name, $column_name)) + { + return $this->umil_end('TABLE_COLUMN_ALREADY_EXISTS', $table_name, $column_name); + } + + $this->db_tools->sql_column_add($table_name, $column_name, $column_data); + + return $this->umil_end(); + } + + /** + * Table Column Update + * + * Alter/Update a column in a table. You can not change a column name with this. + */ + function table_column_update($table_name, $column_name = '', $column_data = array()) + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_COLUMN_UPDATE', $table_name, $column_name); + + if (!$this->table_column_exists($table_name, $column_name)) + { + return $this->umil_end('TABLE_COLUMN_NOT_EXIST', $table_name, $column_name); + } + + $this->db_tools->sql_column_change($table_name, $column_name, $column_data); + + return $this->umil_end(); + } + + /** + * Table Column Remove + * + * Remove a column from a table + */ + function table_column_remove($table_name, $column_name = '') + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_COLUMN_REMOVE', $table_name, $column_name); + + if (!$this->table_column_exists($table_name, $column_name)) + { + return $this->umil_end('TABLE_COLUMN_NOT_EXIST', $table_name, $column_name); + } + + $this->db_tools->sql_column_remove($table_name, $column_name); + + return $this->umil_end(); + } + + /** + * Table Index Exists + * + * Check if a table key/index exists on a table (can not check primary or unique) + */ + function table_index_exists($table_name, $index_name) + { + $this->get_table_name($table_name); + + $indexes = $this->db_tools->sql_list_index($table_name); + + if (in_array($index_name, $indexes)) + { + return true; + } + + return false; + } + + /** + * Table Index Add + * + * Add a new key/index to a table + */ + function table_index_add($table_name, $index_name = '', $column = array()) + { + global $config; + + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + // Let them skip the column field and just use the index name in that case as the column as well + if (empty($column)) + { + $column = array($index_name); + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_KEY_ADD', $table_name, $index_name); + + if ($this->table_index_exists($table_name, $index_name)) + { + return $this->umil_end('TABLE_KEY_ALREADY_EXIST', $table_name, $index_name); + } + + if (!is_array($column)) + { + $column = array($column); + } + + // remove index length if we are before 3.0.8 + // the feature (required for some types when using MySQL4) + // was added in that release (ticket PHPBB3-8944) + if (version_compare($config['version'], '3.0.7-pl1', '<=')) + { + $column = preg_replace('#:.*$#', '', $column); + } + + $this->db_tools->sql_create_index($table_name, $index_name, $column); + + return $this->umil_end(); + } + + /** + * Table Index Remove + * + * Remove a key/index from a table + */ + function table_index_remove($table_name, $index_name = '') + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_KEY_REMOVE', $table_name, $index_name); + + if (!$this->table_index_exists($table_name, $index_name)) + { + return $this->umil_end('TABLE_KEY_NOT_EXIST', $table_name, $index_name); + } + + $this->db_tools->sql_index_drop($table_name, $index_name); + + return $this->umil_end(); + } + + // Ignore, function was renamed to table_row_insert and keeping for backwards compatibility + function table_insert($table_name, $data = array()) { $this->table_row_insert($table_name, $data); } + + /** + * Table Insert + * + * Insert data into a table + */ + function table_row_insert($table_name, $data = array()) + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_ROW_INSERT_DATA', $table_name); + + if (!$this->table_exists($table_name)) + { + return $this->umil_end('TABLE_NOT_EXIST', $table_name); + } + + $this->db->sql_multi_insert($table_name, $data); + + return $this->umil_end(); + } + + /** + * Table Row Update + * + * Update a row in a table + * + * $data should be an array with the column names as keys and values as the items to check for each column. Example: + * array('user_id' => 123, 'user_name' => 'test user') would become: + * WHERE user_id = 123 AND user_name = 'test user' + * + * $new_data is the new data it will be updated to (same format as you'd enter into $db->sql_build_array('UPDATE' ). + */ + function table_row_update($table_name, $data = array(), $new_data = array()) + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + if (!sizeof($data)) + { + return $this->umil_end('FAIL'); + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_ROW_UPDATE_DATA', $table_name); + + if (!$this->table_exists($table_name)) + { + return $this->umil_end('TABLE_NOT_EXIST', $table_name); + } + + $sql = 'UPDATE ' . $table_name . ' + SET ' . $this->db->sql_build_array('UPDATE', $new_data) . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $this->db->sql_query($sql); + + return $this->umil_end(); + } + + /** + * Table Row Remove + * + * Remove a row from a table + * + * $data should be an array with the column names as keys and values as the items to check for each column. Example: + * array('user_id' => 123, 'user_name' => 'test user') would become: + * WHERE user_id = 123 AND user_name = 'test user' + */ + function table_row_remove($table_name, $data = array()) + { + // Multicall + if ($this->multicall(__FUNCTION__, $table_name)) + { + return; + } + + if (!sizeof($data)) + { + return $this->umil_end('FAIL'); + } + + $this->get_table_name($table_name); + + $this->umil_start('TABLE_ROW_REMOVE_DATA', $table_name); + + if (!$this->table_exists($table_name)) + { + return $this->umil_end('TABLE_NOT_EXIST', $table_name); + } + + $sql = 'DELETE FROM ' . $table_name . ' WHERE ' . $this->db->sql_build_array('SELECT', $data); + $this->db->sql_query($sql); + + return $this->umil_end(); + } + + /** + * Version Checker + * + * Format the file like the following: + * http://www.phpbb.com/updatecheck/30x.txt + * + * @param string $url The url to access (ex: www.phpbb.com) + * @param string $path The path to access (ex: /updatecheck) + * @param string $file The name of the file to access (ex: 30x.txt) + * + * @return array|string Error Message if there was any error, or an array (each line in the file as a value) + */ + function version_check($url, $path, $file, $timeout = 10, $port = 80) + { + if (!function_exists('get_remote_file')) + { + global $phpbb_root_path, $phpEx; + + include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + } + + $errstr = $errno = ''; + + $info = get_remote_file($url, $path, $file, $errstr, $errno, $port, $timeout); + + if ($info === false) + { + return $errstr . ' [ ' . $errno . ' ]'; + } + + $info = str_replace("\r\n", "\n", $info); + $info = explode("\n", $info); + + return $info; + } + + /** + * Create table SQL + * + * Create the SQL query for the specified DBMS on the fly from a create_schema_files type of table array + * + * @param string $table_name The name of the table + * @param array $table_data The table data (formatted in the array format used by create_schema_files) + * @param string $dbms The dbms this will be built for (for testing only, leave blank to use the current DBMS) + * + * @return The sql query to run for the submitted dbms to insert the table + */ + function create_table_sql($table_name, $table_data, $dbms = '') + { + // To allow testing + $dbms = ($dbms) ? $dbms : $this->db_tools->sql_layer; + + // A list of types being unsigned for better reference in some db's + $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); + $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); + + $sql = ''; + + // Create Table statement + $generator = $textimage = false; + + switch ($dbms) + { + case 'mysql_40': + case 'mysql_41': + case 'firebird': + case 'oracle': + case 'sqlite': + case 'postgres': + $sql .= "CREATE TABLE {$table_name} (\n"; + break; + + case 'mssql': + $sql .= "CREATE TABLE [{$table_name}] (\n"; + break; + } + + // Table specific so we don't get overlap + $modded_array = array(); + + // Write columns one by one... + foreach ($table_data['COLUMNS'] as $column_name => $column_data) + { + // Get type + if (strpos($column_data[0], ':') !== false) + { + list($orig_column_type, $column_length) = explode(':', $column_data[0]); + if (!is_array($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'])) + { + $column_type = sprintf($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'], $column_length); + } + else + { + if (isset($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['rule'])) + { + switch ($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['rule'][0]) + { + case 'div': + $column_length /= $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['rule'][1]; + $column_length = ceil($column_length); + $column_type = sprintf($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length); + break; + } + } + + if (isset($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'])) + { + switch ($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][0]) + { + case 'mult': + $column_length *= $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][1]; + if ($column_length > $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][2]) + { + $column_type = $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][3]; + $modded_array[$column_name] = $column_type; + } + else + { + $column_type = sprintf($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length); + } + break; + } + } + } + $orig_column_type .= ':'; + } + else + { + $orig_column_type = $column_data[0]; + $column_type = $this->db_tools->dbms_type_map[$dbms][$column_data[0]]; + if ($column_type == 'text' || $column_type == 'blob') + { + $modded_array[$column_name] = $column_type; + } + } + + // Adjust default value if db-dependant specified + if (is_array($column_data[1])) + { + $column_data[1] = (isset($column_data[1][$dbms])) ? $column_data[1][$dbms] : $column_data[1]['default']; + } + + switch ($dbms) + { + case 'mysql_40': + case 'mysql_41': + $sql .= "\t{$column_name} {$column_type} "; + + // For hexadecimal values do not use single quotes + if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob') + { + $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; + } + $sql .= 'NOT NULL'; + + if (isset($column_data[2])) + { + if ($column_data[2] == 'auto_increment') + { + $sql .= ' auto_increment'; + } + else if ($dbms === 'mysql_41' && $column_data[2] == 'true_sort') + { + $sql .= ' COLLATE utf8_unicode_ci'; + } + } + + $sql .= ",\n"; + break; + + case 'sqlite': + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $sql .= "\t{$column_name} INTEGER PRIMARY KEY "; + $generator = $column_name; + } + else + { + $sql .= "\t{$column_name} {$column_type} "; + } + + $sql .= 'NOT NULL '; + $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : ''; + $sql .= ",\n"; + break; + + case 'firebird': + $sql .= "\t{$column_name} {$column_type} "; + + if (!is_null($column_data[1])) + { + $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; + } + + $sql .= 'NOT NULL'; + + // This is a UNICODE column and thus should be given it's fair share + if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0])) + { + $sql .= ' COLLATE UNICODE'; + } + + $sql .= ",\n"; + + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $generator = $column_name; + } + break; + + case 'mssql': + if ($column_type == '[text]') + { + $textimage = true; + } + + $sql .= "\t[{$column_name}] {$column_type} "; + + if (!is_null($column_data[1])) + { + // For hexadecimal values do not use single quotes + if (strpos($column_data[1], '0x') === 0) + { + $sql .= 'DEFAULT (' . $column_data[1] . ') '; + } + else + { + $sql .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; + } + } + + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $sql .= 'IDENTITY (1, 1) '; + } + + $sql .= 'NOT NULL'; + $sql .= " ,\n"; + break; + + case 'oracle': + $sql .= "\t{$column_name} {$column_type} "; + $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; + + // In Oracle empty strings ('') are treated as NULL. + // Therefore in oracle we allow NULL's for all DEFAULT '' entries + $sql .= ($column_data[1] === '') ? ",\n" : "NOT NULL,\n"; + + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $generator = $column_name; + } + break; + + case 'postgres': + $sql .= "\t{$column_name} {$column_type} "; + + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $sql .= "DEFAULT nextval('{$table_name}_seq'),\n"; + + // Make sure the sequence will be created before creating the table + $sql = "CREATE SEQUENCE {$table_name}_seq;\n\n" . $sql; + } + else + { + $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; + $sql .= "NOT NULL"; + + // Unsigned? Then add a CHECK contraint + if (in_array($orig_column_type, $unsigned_types)) + { + $sql .= " CHECK ({$column_name} >= 0)"; + } + + $sql .= ",\n"; + } + break; + } + } + + switch ($dbms) + { + case 'firebird': + // Remove last line delimiter... + $sql = substr($sql, 0, -2); + $sql .= "\n);;\n\n"; + break; + + case 'mssql': + $sql = substr($sql, 0, -2); + $sql .= "\n) ON [PRIMARY]" . (($textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : '') . "\n"; + $sql .= "GO\n\n"; + break; + } + + // Write primary key + if (isset($table_data['PRIMARY_KEY'])) + { + if (!is_array($table_data['PRIMARY_KEY'])) + { + $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); + } + + switch ($dbms) + { + case 'mysql_40': + case 'mysql_41': + case 'postgres': + $sql .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n"; + break; + + case 'firebird': + $sql .= "ALTER TABLE {$table_name} ADD PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ");;\n\n"; + break; + + case 'sqlite': + if ($generator === false || !in_array($generator, $table_data['PRIMARY_KEY'])) + { + $sql .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n"; + } + break; + + case 'mssql': + $sql .= "ALTER TABLE [{$table_name}] WITH NOCHECK ADD \n"; + $sql .= "\tCONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED \n"; + $sql .= "\t(\n"; + $sql .= "\t\t[" . implode("],\n\t\t[", $table_data['PRIMARY_KEY']) . "]\n"; + $sql .= "\t) ON [PRIMARY] \n"; + $sql .= "GO\n\n"; + break; + + case 'oracle': + $sql .= "\tCONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n"; + break; + } + } + + switch ($dbms) + { + case 'oracle': + // UNIQUE contrains to be added? + if (isset($table_data['KEYS'])) + { + foreach ($table_data['KEYS'] as $key_name => $key_data) + { + if (!is_array($key_data[1])) + { + $key_data[1] = array($key_data[1]); + } + + if ($key_data[0] == 'UNIQUE') + { + $sql .= "\tCONSTRAINT u_phpbb_{$key_name} UNIQUE (" . implode(', ', $key_data[1]) . "),\n"; + } + } + } + + // Remove last line delimiter... + $sql = substr($sql, 0, -2); + $sql .= "\n)\n/\n\n"; + break; + + case 'postgres': + // Remove last line delimiter... + $sql = substr($sql, 0, -2); + $sql .= "\n);\n\n"; + break; + + case 'sqlite': + // Remove last line delimiter... + $sql = substr($sql, 0, -2); + $sql .= "\n);\n\n"; + break; + } + + // Write Keys + if (isset($table_data['KEYS'])) + { + foreach ($table_data['KEYS'] as $key_name => $key_data) + { + if (!is_array($key_data[1])) + { + $key_data[1] = array($key_data[1]); + } + + switch ($dbms) + { + case 'mysql_40': + case 'mysql_41': + $sql .= ($key_data[0] == 'INDEX') ? "\tKEY" : ''; + $sql .= ($key_data[0] == 'UNIQUE') ? "\tUNIQUE" : ''; + foreach ($key_data[1] as $key => $col_name) + { + if (isset($modded_array[$col_name])) + { + switch ($modded_array[$col_name]) + { + case 'text': + case 'blob': + $key_data[1][$key] = $col_name . '(255)'; + break; + } + } + } + $sql .= ' ' . $key_name . ' (' . implode(', ', $key_data[1]) . "),\n"; + break; + + case 'firebird': + $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; + $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; + + $sql .= ' ' . $table_name . '_' . $key_name . ' ON ' . $table_name . '(' . implode(', ', $key_data[1]) . ");;\n"; + break; + + case 'mssql': + $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; + $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; + $sql .= " [{$key_name}] ON [{$table_name}]([" . implode('], [', $key_data[1]) . "]) ON [PRIMARY]\n"; + $sql .= "GO\n\n"; + break; + + case 'oracle': + if ($key_data[0] == 'UNIQUE') + { + continue; + } + + $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; + + $sql .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ")\n"; + $sql .= "/\n"; + break; + + case 'sqlite': + $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; + $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; + + $sql .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n"; + break; + + case 'postgres': + $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; + $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; + + $sql .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n"; + break; + } + } + } + + switch ($dbms) + { + case 'mysql_40': + // Remove last line delimiter... + $sql = substr($sql, 0, -2); + $sql .= "\n);\n\n"; + break; + + case 'mysql_41': + // Remove last line delimiter... + $sql = substr($sql, 0, -2); + $sql .= "\n) CHARACTER SET utf8 COLLATE utf8_bin;\n\n"; + break; + + // Create Generator + case 'firebird': + if ($generator !== false) + { + $sql .= "\nCREATE GENERATOR {$table_name}_gen;;\n"; + $sql .= 'SET GENERATOR ' . $table_name . "_gen TO 0;;\n\n"; + + $sql .= 'CREATE TRIGGER t_' . $table_name . ' FOR ' . $table_name . "\n"; + $sql .= "BEFORE INSERT\nAS\nBEGIN\n"; + $sql .= "\tNEW.{$generator} = GEN_ID({$table_name}_gen, 1);\nEND;;\n\n"; + } + break; + + case 'oracle': + if ($generator !== false) + { + $sql .= "\nCREATE SEQUENCE {$table_name}_seq\n/\n\n"; + + $sql .= "CREATE OR REPLACE TRIGGER t_{$table_name}\n"; + $sql .= "BEFORE INSERT ON {$table_name}\n"; + $sql .= "FOR EACH ROW WHEN (\n"; + $sql .= "\tnew.{$generator} IS NULL OR new.{$generator} = 0\n"; + $sql .= ")\nBEGIN\n"; + $sql .= "\tSELECT {$table_name}_seq.nextval\n"; + $sql .= "\tINTO :new.{$generator}\n"; + $sql .= "\tFROM dual;\nEND;\n/\n\n"; + } + break; + } + + return $sql; + } + + /** + * Get the real table name + * By A_Jelly_Doughnut + * + * @param string $table_name The table name to get the real table name from + */ + function get_table_name(&$table_name) + { + // Use the global table prefix if a custom one is not specified + if ($this->table_prefix === false) + { + global $table_prefix; + } + else + { + $table_prefix = $this->table_prefix; + } + + static $constants = NULL; + + if (is_null($constants)) + { + $constants = get_defined_constants(); + } + + /** + * only do the replace if the table prefix is not already present + * this is required since UMIL supports specifying a table via phpbb_foo + * (where a replace would be needed) + * or by FOO_TABLE (where a replace is already done at constant-define time) + */ + if (!preg_match('#^' . preg_quote($table_prefix, '#') . '#', $table_name) || !in_array($table_name, $constants, true)) + { + $table_name = preg_replace('#^phpbb_#i', $table_prefix, $table_name); + } + } +} + +?> \ No newline at end of file From 91a921a96bf26607879de850fca105be78eadf1d Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Sun, 11 Nov 2012 09:43:07 +0100 Subject: [PATCH 025/174] [feature/migrations] Change migration data processing to run step by step --- phpBB/includes/db/migrator.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 4ce54a4b92..912a7b34ba 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -167,7 +167,7 @@ class phpbb_db_migrator } else { - $migration->update_data(); + $this->process_data_step($migration); $state['migration_data_done'] = true; $state['migration_end_time'] = time(); } @@ -182,6 +182,28 @@ class phpbb_db_migrator return true; } + function process_data_step(&$migration) + { + $continue = false; + $steps = $migration->update_data(); + + foreach ($steps as $step) + { + $continue = $this->run_step($step); + if (!$continue) + { + return false; + } + } + + return $continue; + } + + function run_step(&$step) + { + + } + function insert_migration($name, $state) { $migration_row = $state; From 82efb3e446efbb8ef05c6a777e3866901abfd07a Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 8 Jan 2013 22:07:12 -0600 Subject: [PATCH 026/174] [feature/migrations] Remove references as it is now 3.1 code PHPBB3-9737 --- phpBB/includes/db/migration.php | 6 +- .../db/migration/{ => data}/3_0_1.php | 4 +- .../db/migration/{ => data}/3_0_10.php | 4 +- .../db/migration/{ => data}/3_0_10_rc1.php | 4 +- .../db/migration/{ => data}/3_0_10_rc2.php | 4 +- .../db/migration/{ => data}/3_0_10_rc3.php | 4 +- .../db/migration/{ => data}/3_0_11.php | 4 +- .../db/migration/{ => data}/3_0_11_rc1.php | 4 +- .../db/migration/{ => data}/3_0_11_rc2 | 4 +- .../db/migration/{ => data}/3_0_12_rc1.php | 4 +- .../db/migration/{ => data}/3_0_1_rc1.php | 2 +- .../db/migration/{ => data}/3_0_2.php | 4 +- .../db/migration/{ => data}/3_0_2_rc1.php | 4 +- .../db/migration/{ => data}/3_0_2_rc2.php | 4 +- .../db/migration/{ => data}/3_0_3.php | 4 +- .../db/migration/{ => data}/3_0_3_rc1.php | 4 +- .../db/migration/{ => data}/3_0_4.php | 4 +- .../db/migration/{ => data}/3_0_4_rc1.php | 4 +- .../db/migration/{ => data}/3_0_5.php | 4 +- .../db/migration/{ => data}/3_0_5_rc1.php | 4 +- .../migration/{ => data}/3_0_5_rc1part2.php | 4 +- .../db/migration/{ => data}/3_0_6.php | 4 +- .../db/migration/{ => data}/3_0_6_rc1.php | 101 ++-- .../db/migration/{ => data}/3_0_6_rc2.php | 4 +- .../db/migration/{ => data}/3_0_6_rc3.php | 4 +- .../db/migration/{ => data}/3_0_6_rc4.php | 4 +- .../db/migration/{ => data}/3_0_7.php | 4 +- .../db/migration/{ => data}/3_0_7_pl1.php | 4 +- .../db/migration/{ => data}/3_0_7_rc1.php | 4 +- .../db/migration/{ => data}/3_0_7_rc2.php | 4 +- .../db/migration/{ => data}/3_0_8.php | 4 +- .../db/migration/{ => data}/3_0_8_rc1.php | 16 +- .../db/migration/{ => data}/3_0_9.php | 4 +- .../db/migration/{ => data}/3_0_9_rc1.php | 4 +- .../db/migration/{ => data}/3_0_9_rc2.php | 4 +- .../db/migration/{ => data}/3_0_9_rc3.php | 4 +- .../db/migration/{ => data}/3_0_9_rc4.php | 4 +- phpBB/includes/db/migration/tools/base.php | 47 ++ phpBB/includes/db/migration/tools/config.php | 106 ++++ phpBB/includes/db/migration/tools/module.php | 419 +++++++++++++++ .../db/migration/tools/permission.php | 480 ++++++++++++++++++ .../tools}/umil.php | 0 phpBB/includes/db/migrationtools/base.php | 15 - phpBB/includes/db/migrationtools/config.php | 121 ----- phpBB/includes/db/migrator.php | 14 +- 45 files changed, 1179 insertions(+), 280 deletions(-) rename phpBB/includes/db/migration/{ => data}/3_0_1.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_10.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_10_rc1.php (74%) rename phpBB/includes/db/migration/{ => data}/3_0_10_rc2.php (68%) rename phpBB/includes/db/migration/{ => data}/3_0_10_rc3.php (68%) rename phpBB/includes/db/migration/{ => data}/3_0_11.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_11_rc1.php (94%) rename phpBB/includes/db/migration/{ => data}/3_0_11_rc2 (77%) rename phpBB/includes/db/migration/{ => data}/3_0_12_rc1.php (73%) rename phpBB/includes/db/migration/{ => data}/3_0_1_rc1.php (96%) rename phpBB/includes/db/migration/{ => data}/3_0_2.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_2_rc1.php (81%) rename phpBB/includes/db/migration/{ => data}/3_0_2_rc2.php (90%) rename phpBB/includes/db/migration/{ => data}/3_0_3.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_3_rc1.php (93%) rename phpBB/includes/db/migration/{ => data}/3_0_4.php (88%) rename phpBB/includes/db/migration/{ => data}/3_0_4_rc1.php (96%) rename phpBB/includes/db/migration/{ => data}/3_0_5.php (68%) rename phpBB/includes/db/migration/{ => data}/3_0_5_rc1.php (96%) rename phpBB/includes/db/migration/{ => data}/3_0_5_rc1part2.php (79%) rename phpBB/includes/db/migration/{ => data}/3_0_6.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_6_rc1.php (81%) rename phpBB/includes/db/migration/{ => data}/3_0_6_rc2.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_6_rc3.php (84%) rename phpBB/includes/db/migration/{ => data}/3_0_6_rc4.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_7.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_7_pl1.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_7_rc1.php (91%) rename phpBB/includes/db/migration/{ => data}/3_0_7_rc2.php (92%) rename phpBB/includes/db/migration/{ => data}/3_0_8.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_8_rc1.php (94%) rename phpBB/includes/db/migration/{ => data}/3_0_9.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_9_rc1.php (96%) rename phpBB/includes/db/migration/{ => data}/3_0_9_rc2.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_9_rc3.php (69%) rename phpBB/includes/db/migration/{ => data}/3_0_9_rc4.php (69%) create mode 100644 phpBB/includes/db/migration/tools/base.php create mode 100644 phpBB/includes/db/migration/tools/config.php create mode 100644 phpBB/includes/db/migration/tools/module.php create mode 100644 phpBB/includes/db/migration/tools/permission.php rename phpBB/includes/db/{migrationtools => migration/tools}/umil.php (100%) delete mode 100644 phpBB/includes/db/migrationtools/base.php delete mode 100644 phpBB/includes/db/migrationtools/config.php diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index de9f6d07e3..c98ac8728a 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -44,10 +44,10 @@ class phpbb_db_migration * @param string $phpbb_root_path * @param string $php_ext */ - function phpbb_db_migration(&$db, &$db_tools, $table_prefix, $phpbb_root_path, $php_ext) + function phpbb_db_migration($db, $db_tools, $table_prefix, $phpbb_root_path, $php_ext) { - $this->db = &$db; - $this->db_tools = &$db_tools; + $this->db = $db; + $this->db_tools = $db_tools; $this->table_prefix = $table_prefix; $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/db/migration/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php similarity index 69% rename from phpBB/includes/db/migration/3_0_1.php rename to phpBB/includes/db/migration/data/3_0_1.php index 1cb069a2b1..294db3d946 100644 --- a/phpBB/includes/db/migration/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_1_rc1'); + return array('phpbb_db_migration_data_3_0_1_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php similarity index 69% rename from phpBB/includes/db/migration/3_0_10.php rename to phpBB/includes/db/migration/data/3_0_10.php index aae27a08c7..6d39969d48 100644 --- a/phpBB/includes/db/migration/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_10 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_10_rc3'); + return array('phpbb_db_migration_data_3_0_10_rc3'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php similarity index 74% rename from phpBB/includes/db/migration/3_0_10_rc1.php rename to phpBB/includes/db/migration/data/3_0_10_rc1.php index 5d65ae15da..06105c5b0d 100644 --- a/phpBB/includes/db/migration/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_10_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_9'); + return array('phpbb_db_migration_data_3_0_9'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php similarity index 68% rename from phpBB/includes/db/migration/3_0_10_rc2.php rename to phpBB/includes/db/migration/data/3_0_10_rc2.php index d5dc4caec9..04161caf28 100644 --- a/phpBB/includes/db/migration/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_10_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_10_rc1'); + return array('phpbb_db_migration_data_3_0_10_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php similarity index 68% rename from phpBB/includes/db/migration/3_0_10_rc3.php rename to phpBB/includes/db/migration/data/3_0_10_rc3.php index dc962b73c8..539f0b8fec 100644 --- a/phpBB/includes/db/migration/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_10_rc3 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_10_rc2'); + return array('phpbb_db_migration_data_3_0_10_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php similarity index 69% rename from phpBB/includes/db/migration/3_0_11.php rename to phpBB/includes/db/migration/data/3_0_11.php index 89ffe310f4..3404272ef9 100644 --- a/phpBB/includes/db/migration/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_11 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_11_rc2'); + return array('phpbb_db_migration_data_3_0_11_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php similarity index 94% rename from phpBB/includes/db/migration/3_0_11_rc1.php rename to phpBB/includes/db/migration/data/3_0_11_rc1.php index 1b74aa9a4c..f44226df02 100644 --- a/phpBB/includes/db/migration/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_11_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_10'); + return array('phpbb_db_migration_data_3_0_10'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_11_rc2 b/phpBB/includes/db/migration/data/3_0_11_rc2 similarity index 77% rename from phpBB/includes/db/migration/3_0_11_rc2 rename to phpBB/includes/db/migration/data/3_0_11_rc2 index f4e64871ed..6add980c73 100644 --- a/phpBB/includes/db/migration/3_0_11_rc2 +++ b/phpBB/includes/db/migration/data/3_0_11_rc2 @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_11_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_11_rc1'); + return array('phpbb_db_migration_data_3_0_11_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php similarity index 73% rename from phpBB/includes/db/migration/3_0_12_rc1.php rename to phpBB/includes/db/migration/data/3_0_12_rc1.php index 58e112a43a..734a57ecee 100644 --- a/phpBB/includes/db/migration/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_12_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_11'); + return array('phpbb_db_migration_data_3_0_11'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php similarity index 96% rename from phpBB/includes/db/migration/3_0_1_rc1.php rename to phpBB/includes/db/migration/data/3_0_1_rc1.php index e3be8b36d4..1a696e0003 100644 --- a/phpBB/includes/db/migration/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_3_0_1_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration { function depends_on() { diff --git a/phpBB/includes/db/migration/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php similarity index 69% rename from phpBB/includes/db/migration/3_0_2.php rename to phpBB/includes/db/migration/data/3_0_2.php index 36e8d52e6b..a5f94e644b 100644 --- a/phpBB/includes/db/migration/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_2_rc2'); + return array('phpbb_db_migration_data_3_0_2_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php similarity index 81% rename from phpBB/includes/db/migration/3_0_2_rc1.php rename to phpBB/includes/db/migration/data/3_0_2_rc1.php index cd21b7f64f..1b4d3bc2b8 100644 --- a/phpBB/includes/db/migration/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_1_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_1'); + return array('phpbb_db_migration_data_3_0_1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php similarity index 90% rename from phpBB/includes/db/migration/3_0_2_rc2.php rename to phpBB/includes/db/migration/data/3_0_2_rc2.php index a1fab753e2..9ddeb60a14 100644 --- a/phpBB/includes/db/migration/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_2_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_2_rc1'); + return array('phpbb_db_migration_data_3_0_2_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php similarity index 69% rename from phpBB/includes/db/migration/3_0_3.php rename to phpBB/includes/db/migration/data/3_0_3.php index c9ca33ee88..f989eea025 100644 --- a/phpBB/includes/db/migration/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_3 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_2_rc2'); + return array('phpbb_db_migration_data_3_0_2_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php similarity index 93% rename from phpBB/includes/db/migration/3_0_3_rc1.php rename to phpBB/includes/db/migration/data/3_0_3_rc1.php index 0cd99457ee..737eab4bd3 100644 --- a/phpBB/includes/db/migration/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_3_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_2'); + return array('phpbb_db_migration_data_3_0_2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php similarity index 88% rename from phpBB/includes/db/migration/3_0_4.php rename to phpBB/includes/db/migration/data/3_0_4.php index bbaaea54c9..cd34fda9ab 100644 --- a/phpBB/includes/db/migration/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_4 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_4_rc1'); + return array('phpbb_db_migration_data_3_0_4_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php similarity index 96% rename from phpBB/includes/db/migration/3_0_4_rc1.php rename to phpBB/includes/db/migration/data/3_0_4_rc1.php index b783e58e24..342f1fa910 100644 --- a/phpBB/includes/db/migration/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_4_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_3'); + return array('phpbb_db_migration_data_3_0_3'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php similarity index 68% rename from phpBB/includes/db/migration/3_0_5.php rename to phpBB/includes/db/migration/data/3_0_5.php index 272779f083..5671832a82 100644 --- a/phpBB/includes/db/migration/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_5 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_5_rc1part2'); + return array('phpbb_db_migration_data_3_0_5_rc1part2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php similarity index 96% rename from phpBB/includes/db/migration/3_0_5_rc1.php rename to phpBB/includes/db/migration/data/3_0_5_rc1.php index 8975728cca..9205f0d5f8 100644 --- a/phpBB/includes/db/migration/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_5_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_4'); + return array('phpbb_db_migration_data_3_0_4'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php similarity index 79% rename from phpBB/includes/db/migration/3_0_5_rc1part2.php rename to phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 710c8dce91..6be8ea9845 100644 --- a/phpBB/includes/db/migration/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_5_rc1part2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_5_rc1'); + return array('phpbb_db_migration_data_3_0_5_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php similarity index 69% rename from phpBB/includes/db/migration/3_0_6.php rename to phpBB/includes/db/migration/data/3_0_6.php index 9582038b36..c2cb59e62a 100644 --- a/phpBB/includes/db/migration/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_6 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_6_rc4'); + return array('phpbb_db_migration_data_3_0_6_rc4'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php similarity index 81% rename from phpBB/includes/db/migration/3_0_6_rc1.php rename to phpBB/includes/db/migration/data/3_0_6_rc1.php index 0aa5746164..eefdc1692d 100644 --- a/phpBB/includes/db/migration/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_6_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_5'); + return array('phpbb_db_migration_data_3_0_5'); } function update_schema() @@ -62,12 +62,10 @@ class phpbb_db_migration_3_0_6_rc1 extends phpbb_db_migration function update_data() { return array( - //array('custom', array(array(&$this, ''))) array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), - array('config.update_if', array( + array('if', array( ($this->config['captcha_gd']), - 'captcha_plugin', - 'phpbb_captcha_gd', + array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), )), array('config.add', array('feed_enable', 0)), @@ -89,83 +87,70 @@ class phpbb_db_migration_3_0_6_rc1 extends phpbb_db_migration array('config.add', array('delete_time', $this->config['edit_time'])), array('config.add', array('allow_avatar', 0)), - array('config.add_if', array( + array('if', array( ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), - 'allow_avatar', - 1, + array('config.add', array('allow_avatar', 1)), )), array('config.add', array('allow_avatar_remote_upload', 0)), - array('config.add_if', array( + array('if', array( ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), - 'allow_avatar_remote_upload', - 1, + array('config.add', array('allow_avatar_remote_upload', 1)), )), array('module.add', array( - 'feed' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_FEED_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_BOARD_CONFIGURATION', - 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') + 'acp', + 'ACP_BOARD_CONFIGURATION', + array( + 'module_basename' => 'board', + 'modes' => array('feed'), ), )), array('module.add', array( - 'warnings' => array( - 'base' => 'users', - 'class' => 'acp', - 'title' => 'ACP_USER_WARNINGS', - 'auth' => 'acl_a_user', - 'display' => 0, - 'cat' => 'ACP_CAT_USERS', - 'after' => array('feedback', 'ACP_USER_FEEDBACK') + 'acp', + 'ACP_CAT_USERS', + array( + 'module_basename' => 'users', + 'modes' => array('warnings'), ), )), array('module.add', array( - 'send_statistics' => array( - 'base' => 'send_statistics', - 'class' => 'acp', - 'title' => 'ACP_SEND_STATISTICS', - 'auth' => 'acl_a_server', - 'cat' => 'ACP_SERVER_CONFIGURATION' + 'acp', + 'ACP_SERVER_CONFIGURATION', + array( + 'module_basename' => 'send_statistics', + 'modes' => array('send_statistics'), ), )), array('module.add', array( - 'setting_forum_copy' => array( - 'base' => 'permissions', - 'class' => 'acp', - 'title' => 'ACP_FORUM_PERMISSIONS_COPY', - 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', - 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', - 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') + 'acp', + 'ACP_FORUM_BASED_PERMISSIONS', + array( + 'module_basename' => 'permissions', + 'modes' => array('setting_forum_copy'), ), )), array('module.add', array( - 'pm_reports' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_OPEN', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'pm_reports', + 'modes' => array('pm_reports'), ), )), array('module.add', array( - 'pm_reports_closed' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_CLOSED', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'pm_reports', + 'modes' => array('pm_reports_closed'), ), )), array('module.add', array( - 'pm_report_details' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORT_DETAILS', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'pm_reports', + 'modes' => array('pm_report_details'), ), )), array('custom', array(array(&$this, 'add_newly_registered_group'))), diff --git a/phpBB/includes/db/migration/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php similarity index 69% rename from phpBB/includes/db/migration/3_0_6_rc2.php rename to phpBB/includes/db/migration/data/3_0_6_rc2.php index 1552485d0a..07b31a53b9 100644 --- a/phpBB/includes/db/migration/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_6_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_6_rc1'); + return array('phpbb_db_migration_data_3_0_6_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php similarity index 84% rename from phpBB/includes/db/migration/3_0_6_rc3.php rename to phpBB/includes/db/migration/data/3_0_6_rc3.php index 6a7ad1c56d..c19a792bad 100644 --- a/phpBB/includes/db/migration/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_6_rc3 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_6_rc2'); + return array('phpbb_db_migration_data_3_0_6_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php similarity index 69% rename from phpBB/includes/db/migration/3_0_6_rc4.php rename to phpBB/includes/db/migration/data/3_0_6_rc4.php index 00161456b6..c48b1ca394 100644 --- a/phpBB/includes/db/migration/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_6_rc4 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_6_rc3'); + return array('phpbb_db_migration_data_3_0_6_rc3'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php similarity index 69% rename from phpBB/includes/db/migration/3_0_7.php rename to phpBB/includes/db/migration/data/3_0_7.php index 2b5ec15fa9..05781b7b49 100644 --- a/phpBB/includes/db/migration/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_7 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_7_rc2'); + return array('phpbb_db_migration_data_3_0_7_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php similarity index 69% rename from phpBB/includes/db/migration/3_0_7_pl1.php rename to phpBB/includes/db/migration/data/3_0_7_pl1.php index 22c04f1daf..cee7a91a2e 100644 --- a/phpBB/includes/db/migration/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_7_pl1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_7'); + return array('phpbb_db_migration_data_3_0_7'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php similarity index 91% rename from phpBB/includes/db/migration/3_0_7_rc1.php rename to phpBB/includes/db/migration/data/3_0_7_rc1.php index d08a468941..b2d49cce63 100644 --- a/phpBB/includes/db/migration/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_7_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_6'); + return array('phpbb_db_migration_data_3_0_6'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php similarity index 92% rename from phpBB/includes/db/migration/3_0_7_rc2.php rename to phpBB/includes/db/migration/data/3_0_7_rc2.php index 4ab4e906d7..8a751328bf 100644 --- a/phpBB/includes/db/migration/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_7_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_7_rc1'); + return array('phpbb_db_migration_data_3_0_7_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php similarity index 69% rename from phpBB/includes/db/migration/3_0_8.php rename to phpBB/includes/db/migration/data/3_0_8.php index 3e7f843a65..a714a3d2f6 100644 --- a/phpBB/includes/db/migration/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_8 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_8_rc1'); + return array('phpbb_db_migration_data_3_0_8_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php similarity index 94% rename from phpBB/includes/db/migration/3_0_8_rc1.php rename to phpBB/includes/db/migration/data/3_0_8_rc1.php index 0d93efedce..73838d9d29 100644 --- a/phpBB/includes/db/migration/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_8_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_7_pl1'); + return array('phpbb_db_migration_data_3_0_7_pl1'); } function update_schema() @@ -27,13 +27,11 @@ class phpbb_db_migration_3_0_8_rc1 extends phpbb_db_migration array('custom', array(array(&$this, 'update_bots'))), array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))), array('module.add', array( - 'post' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_POST_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_MESSAGES', - 'after' => array('message', 'ACP_MESSAGE_SETTINGS') + 'acp', + 'ACP_MESSAGES', + array( + 'module_basename' => 'board', + 'modes' => array('post'), ), )), array('config.add', array('load_unreads_search', 1)), diff --git a/phpBB/includes/db/migration/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php similarity index 69% rename from phpBB/includes/db/migration/3_0_9.php rename to phpBB/includes/db/migration/data/3_0_9.php index 2e1eab26e7..4b2c08a256 100644 --- a/phpBB/includes/db/migration/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_9 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_9_rc4'); + return array('phpbb_db_migration_data_3_0_9_rc4'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php similarity index 96% rename from phpBB/includes/db/migration/3_0_9_rc1.php rename to phpBB/includes/db/migration/data/3_0_9_rc1.php index 4ee18349ce..98d3a26481 100644 --- a/phpBB/includes/db/migration/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_9_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_8'); + return array('phpbb_db_migration_data_3_0_8'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php similarity index 69% rename from phpBB/includes/db/migration/3_0_9_rc2.php rename to phpBB/includes/db/migration/data/3_0_9_rc2.php index 96782b2b01..589047670a 100644 --- a/phpBB/includes/db/migration/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_9_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_9_rc1'); + return array('phpbb_db_migration_data_3_0_9_rc1'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php similarity index 69% rename from phpBB/includes/db/migration/3_0_9_rc3.php rename to phpBB/includes/db/migration/data/3_0_9_rc3.php index ac0f3cb972..06061cbcb6 100644 --- a/phpBB/includes/db/migration/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_9_rc3 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_9_rc2'); + return array('phpbb_db_migration_data_3_0_9_rc2'); } function update_schema() diff --git a/phpBB/includes/db/migration/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php similarity index 69% rename from phpBB/includes/db/migration/3_0_9_rc4.php rename to phpBB/includes/db/migration/data/3_0_9_rc4.php index 7880e1b864..04b3ae4b39 100644 --- a/phpBB/includes/db/migration/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -7,11 +7,11 @@ * */ -class phpbb_db_migration_3_0_9_rc4 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_3_0_9_rc3'); + return array('phpbb_db_migration_data_3_0_9_rc3'); } function update_schema() diff --git a/phpBB/includes/db/migration/tools/base.php b/phpBB/includes/db/migration/tools/base.php new file mode 100644 index 0000000000..61116d8b55 --- /dev/null +++ b/phpBB/includes/db/migration/tools/base.php @@ -0,0 +1,47 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_tools_base +{ + /** @var phpbb_auth */ + protected $auth = null; + + /** @var phpbb_cache_service */ + protected $cache = null; + + /** @var phpbb_config */ + protected $config = null; + + /** @var dbal */ + protected $db = null; + + /** @var phpbb_template */ + protected $template = null; + + /** @var phpbb_user */ + protected $user = null; + + /** @var string */ + protected $phpbb_root_path = null; + + /** @var string */ + protected $php_ext = null; + + public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) + { + $this->db = $db; + $this->cache = $cache; + $this->template = $template; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } +} \ No newline at end of file diff --git a/phpBB/includes/db/migration/tools/config.php b/phpBB/includes/db/migration/tools/config.php new file mode 100644 index 0000000000..965ba1d136 --- /dev/null +++ b/phpBB/includes/db/migration/tools/config.php @@ -0,0 +1,106 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base +{ + /** + * Config Exists + * + * This function is to check to see if a config variable exists or if it does not. + * + * @param string $config_name The name of the config setting you wish to check for. + * + * @return bool true/false if config exists + */ + public function exists($config_name) + { + return (bool) $this->config->offsetExists($config_name); + } + + /** + * Config Add + * + * This function allows you to add a config setting. + * + * @param string $config_name The name of the config setting you would like to add + * @param mixed $config_value The value of the config setting + * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + */ + public function add($config_name, $config_value = '', $is_dynamic = false) + { + if ($this->config_exists($config_name)) + { + throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name); + } + + $this->config->set($config_name, $config_value, $is_dynamic); + + return false; + } + + /** + * Config Update + * + * This function allows you to update an existing config setting. + * + * @param string $config_name The name of the config setting you would like to update + * @param mixed $config_value The value of the config setting + */ + public function update($config_name, $config_value = '') + { + if (!$this->config_exists($config_name)) + { + throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); + } + + $this->config->set($config_name, $config_value); + + return false; + } + + /** + * Config Update If Equals + * + * This function allows you to update a config setting if the first argument equal to the current config value + * + * @param bool $compare If equal to the current config value, will be updated to the new config value, otherwise not + * @param string $config_name The name of the config setting you would like to update + * @param mixed $config_value The value of the config setting + */ + public function update_if_equals($compare, $config_name, $config_value = '') + { + if (!$this->config_exists($config_name)) + { + throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); + } + + $this->config->set_atomic($config_name, $compare, $config_value); + + return false; + } + + /** + * Config Remove + * + * This function allows you to remove an existing config setting. + * + * @param string $config_name The name of the config setting you would like to remove + */ + public function remove($config_name) + { + if (!$this->config_exists($config_name)) + { + throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); + } + + $this->config->delete($config_name); + + return false; + } +} \ No newline at end of file diff --git a/phpBB/includes/db/migration/tools/module.php b/phpBB/includes/db/migration/tools/module.php new file mode 100644 index 0000000000..df1912a022 --- /dev/null +++ b/phpBB/includes/db/migration/tools/module.php @@ -0,0 +1,419 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base +{ + /** + * Module Exists + * + * Check if a module exists + * + * @param string $class The module class(acp|mcp|ucp) + * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. + * @param int|string $module The module_id|module_langname you would like to check for to see if it exists + * + * @return bool true/false if module exists + */ + public function exists($class, $parent, $module) + { + // the main root directory should return true + if (!$module) + { + return true; + } + + $class = $this->db->sql_escape($class); + $module = $this->db->sql_escape($module); + + $parent_sql = ''; + if ($parent !== false) + { + // Allows '' to be sent as 0 + $parent = (!$parent) ? 0 : $parent; + + if (!is_numeric($parent)) + { + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($parent) . "' + AND module_class = '$class'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + return false; + } + + $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; + } + else + { + $parent_sql = 'AND parent_id = ' . (int) $parent; + } + } + + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_class = '$class' + $parent_sql + AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '$module'"); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + return true; + } + + return false; + } + + /** + * Module Add + * + * Add a new module + * + * @param string $class The module class(acp|mcp|ucp) + * @param int|string $parent The parent module_id|module_langname (0 for no parent) + * @param array $data an array of the data on the new module. This can be setup in two different ways. + * 1. The "manual" way. For inserting a category or one at a time. It will be merged with the base array shown a bit below, + * but at the least requires 'module_langname' to be sent, and, if you want to create a module (instead of just a category) you must send module_basename and module_mode. + * array( + * 'module_enabled' => 1, + * 'module_display' => 1, + * 'module_basename' => '', + * 'module_class' => $class, + * 'parent_id' => (int) $parent, + * 'module_langname' => '', + * 'module_mode' => '', + * 'module_auth' => '', + * ) + * 2. The "automatic" way. For inserting multiple at a time based on the specs in the info file for the module(s). For this to work the modules must be correctly setup in the info file. + * An example follows (this would insert the settings, log, and flag modes from the includes/acp/info/acp_asacp.php file): + * array( + * 'module_basename' => 'asacp', + * 'modes' => array('settings', 'log', 'flag'), + * ) + * Optionally you may not send 'modes' and it will insert all of the modules in that info file. + * @param string|bool $include_path If you would like to use a custom include path, specify that here + */ + public function add($class, $parent = 0, $data = array(), $include_path = false) + { + // Allows '' to be sent as 0 + $parent = (!$parent) ? 0 : $parent; + + // allow sending the name as a string in $data to create a category + if (!is_array($data)) + { + $data = array('module_langname' => $data); + } + + if (!isset($data['module_langname'])) + { + // The "automatic" way + $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; + $basename = str_replace(array('/', '\\'), '', $basename); + $class = str_replace(array('/', '\\'), '', $class); + $info_file = "$class/info/{$class}_$basename.$this->phpEx"; + + // The manual and automatic ways both failed... + if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) + { + throw new phpbb_db_migration_exception('MODULE_ADD', $class, $info_file); + } + + $classname = "{$class}_{$basename}_info"; + + if (!class_exists($classname)) + { + include((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file); + } + + $info = new $classname; + $module = $info->module(); + unset($info); + + $result = ''; + foreach ($module['modes'] as $mode => $module_info) + { + if (!isset($data['modes']) || in_array($mode, $data['modes'])) + { + $new_module = array( + 'module_basename' => $basename, + 'module_langname' => $module_info['title'], + 'module_mode' => $mode, + 'module_auth' => $module_info['auth'], + 'module_display' => (isset($module_info['display'])) ? $module_info['display'] : true, + 'before' => (isset($module_info['before'])) ? $module_info['before'] : false, + 'after' => (isset($module_info['after'])) ? $module_info['after'] : false, + ); + + // Run the "manual" way with the data we've collected. + $result .= ((isset($data['spacer'])) ? $data['spacer'] : '<br />') . $this->add($class, $parent, $new_module); + } + } + + return $result; + } + + // The "manual" way + add_log('admin', 'LOG_MODULE_ADD', ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname'])); + + $class = $this->db->sql_escape($class); + + if (!is_numeric($parent)) + { + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($parent) . "' + AND module_class = '$class'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); + } + + $parent = $data['parent_id'] = $row['module_id']; + } + else if (!$this->exists($class, false, $parent)) + { + throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); + } + + if ($this->exists($class, $parent, $data['module_langname'])) + { + throw new phpbb_db_migration_exception('MODULE_ALREADY_EXIST', $data['module_langname']); + } + + if (!class_exists('acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->phpEx); + $this->user->add_lang('acp/modules'); + } + $acp_modules = new acp_modules(); + + $module_data = array( + 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, + 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, + 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', + 'module_class' => $class, + 'parent_id' => (int) $parent, + 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', + 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', + 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', + ); + $result = $acp_modules->update_module_data($module_data, true); + + // update_module_data can either return a string or an empty array... + if (is_string($result)) + { + // Error + throw new phpbb_db_migration_exception('MODULE_ERROR', $result); + } + else + { + // Success + + // Move the module if requested above/below an existing one + if (isset($data['before']) && $data['before']) + { + $sql = 'SELECT left_id FROM ' . MODULES_TABLE . ' + WHERE module_class = \'' . $class . '\' + AND parent_id = ' . (int) $parent . ' + AND module_langname = \'' . $this->db->sql_escape($data['before']) . '\''; + $this->db->sql_query($sql); + $to_left = $this->db->sql_fetchfield('left_id'); + + $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 + WHERE module_class = '$class' + AND left_id >= $to_left + AND left_id < {$module_data['left_id']}"; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = $to_left, right_id = " . ($to_left + 1) . " + WHERE module_class = '$class' + AND module_id = {$module_data['module_id']}"; + $this->db->sql_query($sql); + } + else if (isset($data['after']) && $data['after']) + { + $sql = 'SELECT right_id FROM ' . MODULES_TABLE . ' + WHERE module_class = \'' . $class . '\' + AND parent_id = ' . (int) $parent . ' + AND module_langname = \'' . $this->db->sql_escape($data['after']) . '\''; + $this->db->sql_query($sql); + $to_right = $this->db->sql_fetchfield('right_id'); + + $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 + WHERE module_class = '$class' + AND left_id >= $to_right + AND left_id < {$module_data['left_id']}"; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " + WHERE module_class = '$class' + AND module_id = {$module_data['module_id']}"; + $this->db->sql_query($sql); + } + } + + // Clear the Modules Cache + $this->cache->destroy("_modules_$class"); + + return false; + } + + /** + * Module Remove + * + * Remove a module + * + * @param string $class The module class(acp|mcp|ucp) + * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. + * @param int|string $module The module id|module_langname + * @param string|bool $include_path If you would like to use a custom include path, specify that here + */ + public function remove($class, $parent = 0, $module = '', $include_path = false) + { + // Imitation of module_add's "automatic" and "manual" method so the uninstaller works from the same set of instructions for umil_auto + if (is_array($module)) + { + if (isset($module['module_langname'])) + { + // Manual Method + return $this->remove($class, $parent, $module['module_langname'], $include_path); + } + + // Failed. + if (!isset($module['module_basename'])) + { + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST'); + } + + // Automatic method + $basename = str_replace(array('/', '\\'), '', $module['module_basename']); + $class = str_replace(array('/', '\\'), '', $class); + $info_file = "$class/info/{$class}_$basename.$this->phpEx"; + + if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) + { + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $info_file); + } + + $classname = "{$class}_{$basename}_info"; + + if (!class_exists($classname)) + { + include((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file); + } + + $info = new $classname; + $module_info = $info->module(); + unset($info); + + foreach ($module_info['modes'] as $mode => $info) + { + if (!isset($module['modes']) || in_array($mode, $module['modes'])) + { + $this->remove($class, $parent, $info['title']) . '<br />'; + } + } + return false; + } + else + { + $class = $this->db->sql_escape($class); + + if (!$this->exists($class, $parent, $module)) + { + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', ((isset($this->user->lang[$module])) ? $this->user->lang[$module] : $module)); + } + + $parent_sql = ''; + if ($parent !== false) + { + // Allows '' to be sent as 0 + $parent = (!$parent) ? 0 : $parent; + + if (!is_numeric($parent)) + { + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '" . $this->db->sql_escape($parent) . "' + AND module_class = '$class'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // we know it exists from the module_exists check + $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; + } + else + { + $parent_sql = 'AND parent_id = ' . (int) $parent; + } + } + + $module_ids = array(); + if (!is_numeric($module)) + { + $module = $this->db->sql_escape($module); + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = '$module' + AND module_class = '$class' + $parent_sql"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $module_ids[] = (int) $row['module_id']; + } + $this->db->sql_freeresult($result); + + $module_name = $module; + } + else + { + $module = (int) $module; + $sql = 'SELECT module_langname FROM ' . MODULES_TABLE . " + WHERE module_id = $module + AND module_class = '$class' + $parent_sql"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $module_name = $row['module_langname']; + $module_ids[] = $module; + } + + if (!class_exists('acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->phpEx); + $this->user->add_lang('acp/modules'); + } + $acp_modules = new acp_modules(); + $acp_modules->module_class = $class; + + foreach ($module_ids as $module_id) + { + $result = $acp_modules->delete_module($module_id); + if (!empty($result)) + { + throw new phpbb_db_migration_exception('CANNOT_REMOVE_MODULE', $module_id); + } + } + + $cache->destroy("_modules_$class"); + + return false; + } + } +} \ No newline at end of file diff --git a/phpBB/includes/db/migration/tools/permission.php b/phpBB/includes/db/migration/tools/permission.php new file mode 100644 index 0000000000..3fbe7c649c --- /dev/null +++ b/phpBB/includes/db/migration/tools/permission.php @@ -0,0 +1,480 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base +{ + /** + * Permission Exists + * + * Check if a permission (auth) setting exists + * + * @param string $auth_option The name of the permission (auth) option + * @param bool $global True for checking a global permission setting, False for a local permission setting + * + * @return bool true if it exists, false if not + */ + public function exists($auth_option, $global = true) + { + if ($global) + { + $type_sql = ' AND is_global = 1'; + } + else + { + $type_sql = ' AND is_local = 1'; + } + + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" + . $type_sql; + $result = $this->db->sql_query($sql); + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + return true; + } + + return false; + } + + /** + * Permission Add + * + * Add a permission (auth) option + * + * @param string $auth_option The name of the permission (auth) option + * @param bool $global True for checking a global permission setting, False for a local permission setting + * + * @return result + */ + public function add($auth_option, $global = true) + { + if ($this->exists($auth_option, $global)) + { + throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXISTS', $auth_option); + } + + // We've added permissions, so set to true to notify the user. + $this->permissions_added = true; + + if (!class_exists('auth_admin')) + { + include($this->phpbb_root_path . 'includes/acp/auth.' . $this->phpEx); + } + $auth_admin = new auth_admin(); + + // We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists. If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here. + if ($this->exists($auth_option, !$global)) + { + $sql_ary = array( + 'is_global' => 1, + 'is_local' => 1, + ); + $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE auth_option = \'' . $this->db->sql_escape($auth_option) . "'"; + $this->db->sql_query($sql); + } + else + { + if ($global) + { + $auth_admin->acl_add_option(array('global' => array($auth_option))); + } + else + { + $auth_admin->acl_add_option(array('local' => array($auth_option))); + } + } + + return false; + } + + /** + * Permission Remove + * + * Remove a permission (auth) option + * + * @param string $auth_option The name of the permission (auth) option + * @param bool $global True for checking a global permission setting, False for a local permission setting + * + * @return result + */ + public function remove($auth_option, $global = true) + { + if (!$this->exists($auth_option, $global)) + { + throw new phpbb_db_migration_exception('PERMISSION_NOT_EXIST', $auth_option); + } + + if ($global) + { + $type_sql = ' AND is_global = 1'; + } + else + { + $type_sql = ' AND is_local = 1'; + } + $sql = 'SELECT auth_option_id, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" . + $type_sql; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $id = $row['auth_option_id']; + + // If it is a local and global permission, do not remove the row! :P + if ($row['is_global'] && $row['is_local']) + { + $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' + SET ' . (($global) ? 'is_global = 0' : 'is_local = 0') . ' + WHERE auth_option_id = ' . $id; + $this->db->sql_query($sql); + } + else + { + // Delete time + $this->db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $id); + $this->db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $id); + $this->db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $id); + $this->db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $id); + } + + // Purge the auth cache + $this->cache->destroy('_acl_options'); + $this->auth->acl_clear_prefetch(); + + return false; + } + + /** + * Add a new permission role + * + * @param string $role_name The new role name + * @param sting $role_type The type (u_, m_, a_) + */ + public function role_add($role_name, $role_type = '', $role_description = '') + { + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if ($role_id) + { + throw new phpbb_db_migration_exception('ROLE_ALREADY_EXISTS', $old_role_name); + } + + $sql = 'SELECT MAX(role_order) AS max FROM ' . ACL_ROLES_TABLE . ' + WHERE role_type = \'' . $this->db->sql_escape($role_type) . '\''; + $this->db->sql_query($sql); + $role_order = $this->db->sql_fetchfield('max'); + $role_order = (!$role_order) ? 1 : $role_order + 1; + + $sql_ary = array( + 'role_name' => $role_name, + 'role_description' => $role_description, + 'role_type' => $role_type, + 'role_order' => $role_order, + ); + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->db->sql_query($sql); + + return false; + } + + /** + * Update the name on a permission role + * + * @param string $old_role_name The old role name + * @param string $new_role_name The new role name + */ + public function role_update($old_role_name, $new_role_name = '') + { + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + throw new phpbb_db_migration_exception('ROLE_NOT_EXISTS', $old_role_name); + } + + $sql = 'UPDATE ' . ACL_ROLES_TABLE . ' + SET role_name = \'' . $this->db->sql_escape($new_role_name) . '\' + WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; + $this->db->sql_query($sql); + + return false; + } + + /** + * Remove a permission role + * + * @param string $role_name The role name to remove + */ + public function role_remove($role_name) + { + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $role_name); + } + + $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_ROLES_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + + $this->auth->acl_clear_prefetch(); + + return false; + } + + /** + * Permission Set + * + * Allows you to set permissions for a certain group/role + * + * @param string $name The name of the role/group + * @param string|array $auth_option The auth_option or array of auth_options you would like to set + * @param string $type The type (role|group) + * @param bool $has_permission True if you want to give them permission, false if you want to deny them permission + */ + public function permission_set($name, $auth_option = array(), $type = 'role', $has_permission = true) + { + if (!is_array($auth_option)) + { + $auth_option = array($auth_option); + } + + $new_auth = array(); + $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $new_auth[] = $row['auth_option_id']; + } + $this->db->sql_freeresult($result); + + if (!sizeof($new_auth)) + { + return false; + } + + $current_auth = array(); + + $type = (string) $type; // Prevent PHP bug. + + switch ($type) + { + case 'role' : + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name); + } + + $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' + WHERE role_id = ' . $role_id; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $current_auth[$row['auth_option_id']] = $row['auth_setting']; + } + $this->db->sql_freeresult($result); + break; + + case 'group' : + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $group_id = $this->db->sql_fetchfield('group_id'); + + if (!$group_id) + { + throw new phpbb_db_migration_exception('GROUP_NOT_EXIST', $name); + } + + // If the group has a role set for them we will add the requested permissions to that role. + $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id <> 0 + AND forum_id = 0'; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('auth_role_id'); + if ($role_id) + { + $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + $role_name = $this->db->sql_fetchfield('role_name'); + + return $this->set($role_name, $auth_option, 'role', $has_permission); + } + + $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $current_auth[$row['auth_option_id']] = $row['auth_setting']; + } + $this->db->sql_freeresult($result); + break; + } + + $sql_ary = array(); + switch ($type) + { + case 'role' : + foreach ($new_auth as $auth_option_id) + { + if (!isset($current_auth[$auth_option_id])) + { + $sql_ary[] = array( + 'role_id' => $role_id, + 'auth_option_id' => $auth_option_id, + 'auth_setting' => $has_permission, + ); + } + } + + $this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); + break; + + case 'group' : + foreach ($new_auth as $auth_option_id) + { + if (!isset($current_auth[$auth_option_id])) + { + $sql_ary[] = array( + 'group_id' => $group_id, + 'auth_option_id' => $auth_option_id, + 'auth_setting' => $has_permission, + ); + } + } + + $this->db->sql_multi_insert(ACL_GROUPS_TABLE, $sql_ary); + break; + } + + $this->auth->acl_clear_prefetch(); + + return false; + } + + /** + * Permission Unset + * + * Allows you to unset (remove) permissions for a certain group/role + * + * @param string $name The name of the role/group + * @param string|array $auth_option The auth_option or array of auth_options you would like to set + * @param string $type The type (role|group) + */ + public function permission_unset($name, $auth_option = array(), $type = 'role') + { + if (!is_array($auth_option)) + { + $auth_option = array($auth_option); + } + + $to_remove = array(); + $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $to_remove[] = $row['auth_option_id']; + } + $this->db->sql_freeresult($result); + + if (!sizeof($to_remove)) + { + return false; + } + + $type = (string) $type; // Prevent PHP bug. + + switch ($type) + { + case 'role' : + $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('role_id'); + + if (!$role_id) + { + throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name); + } + + $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove); + $this->db->sql_query($sql); + break; + + case 'group' : + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' + WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; + $this->db->sql_query($sql); + $group_id = $this->db->sql_fetchfield('group_id'); + + if (!$group_id) + { + throw new phpbb_db_migration_exception('GROUP_NOT_EXIST', $name); + } + + // If the group has a role set for them we will remove the requested permissions from that role. + $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id <> 0'; + $this->db->sql_query($sql); + $role_id = $this->db->sql_fetchfield('auth_role_id'); + if ($role_id) + { + $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' + WHERE role_id = ' . $role_id; + $this->db->sql_query($sql); + $role_name = $this->db->sql_fetchfield('role_name'); + + return $this->permission_unset($role_name, $auth_option, 'role'); + } + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove); + $this->db->sql_query($sql); + break; + } + + $this->auth->acl_clear_prefetch(); + + return false; + } +} \ No newline at end of file diff --git a/phpBB/includes/db/migrationtools/umil.php b/phpBB/includes/db/migration/tools/umil.php similarity index 100% rename from phpBB/includes/db/migrationtools/umil.php rename to phpBB/includes/db/migration/tools/umil.php diff --git a/phpBB/includes/db/migrationtools/base.php b/phpBB/includes/db/migrationtools/base.php deleted file mode 100644 index 7fc6057e3a..0000000000 --- a/phpBB/includes/db/migrationtools/base.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migrationtools_base -{ - var $cache; - var $config; - var $db; -} \ No newline at end of file diff --git a/phpBB/includes/db/migrationtools/config.php b/phpBB/includes/db/migrationtools/config.php deleted file mode 100644 index 5a40e39943..0000000000 --- a/phpBB/includes/db/migrationtools/config.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migrationtools_config extends phpbb_db_migration -{ - /** - * Config Exists - * - * This function is to check to see if a config variable exists or if it does not. - * - * @param string $config_name The name of the config setting you wish to check for. - * @param bool $return_result - return the config value/default if true : default false. - * - * @return bool true/false if config exists - */ - function config_exists($config_name, $return_result = false) - { - $sql = 'SELECT * - FROM ' . CONFIG_TABLE . " - WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - if (!isset($this->config[$config_name])) - { - $this->config[$config_name] = $row['config_value']; - - if (!$row['is_dynamic']) - { - $this->cache->destroy('config'); - } - } - - return ($return_result) ? $row : true; - } - - // this should never happen, but if it does, we need to remove the config from the array - if (isset($this->config[$config_name])) - { - unset($this->config[$config_name]); - $this->cache->destroy('config'); - } - - return false; - } - - /** - * Config Add - * - * This function allows you to add a config setting. - * - * @param string $config_name The name of the config setting you would like to add - * @param mixed $config_value The value of the config setting - * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. - * - * @return result - */ - function config_add($config_name, $config_value = '', $is_dynamic = false) - { - if ($this->config_exists($config_name)) - { - return $this->umil_end('CONFIG_ALREADY_EXISTS', $config_name); - } - - set_config($config_name, $config_value, $is_dynamic); - } - - /** - * Config Update - * - * This function allows you to update an existing config setting. - * - * @param string $config_name The name of the config setting you would like to update - * @param mixed $config_value The value of the config setting - * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. - * - * @return result - */ - function config_update($config_name, $config_value = '') - { - if (!$this->config_exists($config_name)) - { - return $this->umil_end('CONFIG_NOT_EXIST', $config_name); - } - - set_config($config_name, $config_value); - } - - /** - * Config Remove - * - * This function allows you to remove an existing config setting. - * - * @param string $config_name The name of the config setting you would like to remove - * - * @return result - */ - function config_remove($config_name) - { - if (!$this->config_exists($config_name)) - { - return $this->umil_end('CONFIG_NOT_EXIST', $config_name); - } - - $sql = 'DELETE FROM ' . CONFIG_TABLE . " - WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; - $this->db->sql_query($sql); - - unset($this->config[$config_name]); - $this->cache->destroy('config'); - } -} \ No newline at end of file diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 912a7b34ba..9f94273c63 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -45,10 +45,10 @@ class phpbb_db_migrator * @param string $phpbb_root_path * @param string $php_ext */ - function phpbb_db_migrator(&$db, &$db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext) + function phpbb_db_migrator($db, $db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext) { - $this->db = &$db; - $this->db_tools = &$db_tools; + $this->db = $db; + $this->db_tools = $db_tools; $this->table_prefix = $table_prefix; $this->migrations_table = $migrations_table; $this->migrations = array(); @@ -131,7 +131,7 @@ class phpbb_db_migrator return false; } - $migration =& new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); + $migration = new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); $state = (isset($this->migration_state[$name])) ? $this->migration_state[$name] : array( @@ -182,7 +182,7 @@ class phpbb_db_migrator return true; } - function process_data_step(&$migration) + function process_data_step($migration) { $continue = false; $steps = $migration->update_data(); @@ -199,7 +199,7 @@ class phpbb_db_migrator return $continue; } - function run_step(&$step) + function run_step($step) { } @@ -234,7 +234,7 @@ class phpbb_db_migrator return true; } - $migration =& new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); + $migration = new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); $depends = $migration->depends_on(); foreach ($depends as $depend) From 41de95bc11c0b64eafa294f03432f619d3d712d5 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Sun, 11 Nov 2012 12:12:05 +0100 Subject: [PATCH 027/174] [feature/migrations] Process migration steps and move to PHP5 code --- phpBB/includes/db/migration.php | 26 +++---- phpBB/includes/db/migrator.php | 126 +++++++++++++++++++++++++++----- tests/dbal/migration/dummy.php | 9 ++- 3 files changed, 128 insertions(+), 33 deletions(-) diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index c98ac8728a..4e83d2570c 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -26,14 +26,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migration { - var $db; - var $db_tools; - var $table_prefix; + protected $db; + protected $db_tools; + protected $table_prefix; - var $phpbb_root_path; - var $php_ext; + protected $phpbb_root_path; + protected $php_ext; - var $errors; + protected $errors; /** * Migration constructor @@ -44,7 +44,7 @@ class phpbb_db_migration * @param string $phpbb_root_path * @param string $php_ext */ - function phpbb_db_migration($db, $db_tools, $table_prefix, $phpbb_root_path, $php_ext) + public function phpbb_db_migration($db, $db_tools, $table_prefix, $phpbb_root_path, $php_ext) { $this->db = $db; $this->db_tools = $db_tools; @@ -61,7 +61,7 @@ class phpbb_db_migration * * @return array An array of migration class names */ - function depends_on() + public function depends_on() { return array(); } @@ -71,24 +71,24 @@ class phpbb_db_migration * * @return array */ - function update_schema() + public function update_schema() { return array(); } /** - * Updates data + * Updates data by returning a list of instructions to be executed * - * @return null + * @return array */ - function update_data() + public function update_data() { } /** * Wrapper for running queries to generate user feedback on updates */ - function sql_query($sql) + protected function sql_query($sql) { if (defined('DEBUG_EXTRA')) { diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 9f94273c63..9187e09869 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -22,17 +22,17 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migrator { - var $db; - var $db_tools; - var $table_prefix; + protected $db; + protected $db_tools; + protected $table_prefix; - var $phpbb_root_path; - var $php_ext; + protected $phpbb_root_path; + protected $php_ext; - var $migrations_table; - var $migration_state; + protected $migrations_table; + protected $migration_state; - var $migrations; + protected $migrations; /** * Constructor of the database migrator @@ -45,7 +45,7 @@ class phpbb_db_migrator * @param string $phpbb_root_path * @param string $php_ext */ - function phpbb_db_migrator($db, $db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext) + public function phpbb_db_migrator($db, $db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext) { $this->db = $db; $this->db_tools = $db_tools; @@ -64,7 +64,7 @@ class phpbb_db_migrator * * @return null */ - function load_migration_state() + public function load_migration_state() { $sql = "SELECT * FROM " . $this->migrations_table; @@ -85,7 +85,7 @@ class phpbb_db_migrator * @param array $class_names An array of migration class names * @return null */ - function set_migrations($class_names) + public function set_migrations($class_names) { $this->migrations = $class_names; } @@ -98,7 +98,7 @@ class phpbb_db_migrator * * @return null */ - function update() + public function update() { foreach ($this->migrations as $name) { @@ -124,7 +124,7 @@ class phpbb_db_migrator * @param string The class name of the migration * @return bool Whether any update step was successfully run */ - function try_apply($name) + protected function try_apply($name) { if (!class_exists($name)) { @@ -182,7 +182,7 @@ class phpbb_db_migrator return true; } - function process_data_step($migration) + protected function process_data_step($migration) { $continue = false; $steps = $migration->update_data(); @@ -190,6 +190,7 @@ class phpbb_db_migrator foreach ($steps as $step) { $continue = $this->run_step($step); + if (!$continue) { return false; @@ -199,12 +200,99 @@ class phpbb_db_migrator return $continue; } - function run_step($step) + protected function run_step($step) { + try + { + $callable_and_parameters = $this->get_callable_from_step($step); + $callable = $callable_and_parameters[0]; + $parameters = $callable_and_parameters[1]; + call_user_func_array($callable, $parameters); + + return false; + } + catch (phpbb_db_migration_exception $e) + { + echo $e;die(); + } } - function insert_migration($name, $state) + public function get_callable_from_step($step) + { + $type = $step[0]; + $parameters = $step[1]; + + $parts = explode('.', $type); + + $class = $parts[0]; + $method = false; + + if (isset($parts[1])) + { + $method = $parts[1]; + } + + switch ($class) + { + case 'if': + if (!isset($parameters[0])) + { + throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step); + } + + if (!isset($parameters[1])) + { + throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step); + } + + $condition = $parameters[0]; + $step = $parameters[1]; + + $callable_and_parameters = $this->get_callable_from_step($step); + $callable = $callable_and_parameters[0]; + $sub_parameters = $callable_and_parameters[1]; + return array( + function ($condition) use ($callable, $sub_parameters) { + return call_user_func_array($callable, $sub_parameters); + }, + array($condition) + ); + break; + case 'custom': + if (!is_callable($parameters[0])) + { + throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step); + } + + return array($parameters[0], array()); + break; + + default: + if (!$method) + { + throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step); + } + + if (!isset($this->tools[$class])) + { + throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step); + } + + if (!method_exists(get_class($this->tools[$class]), $method)) + { + throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step); + } + + return array( + array($this->tools[$class], $method), + $parameters + ); + break; + } + } + + protected function insert_migration($name, $state) { $migration_row = $state; $migration_row['migration_name'] = $name; @@ -222,7 +310,7 @@ class phpbb_db_migrator * @param string $name The class name of the migration * @return bool Whether the migration cannot be fulfilled */ - function unfulfillable($name) + public function unfulfillable($name) { if (isset($this->migration_state[$name])) { @@ -253,7 +341,7 @@ class phpbb_db_migrator * * @return bool Whether the migrations have been applied */ - function finished() + public function finished() { foreach ($this->migrations as $name) { @@ -279,7 +367,7 @@ class phpbb_db_migrator return true; } - function apply_schema_changes($schema_changes) + protected function apply_schema_changes($schema_changes) { $this->db_tools->perform_schema_changes($schema_changes); } diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php index 0567b50740..942c499bb5 100644 --- a/tests/dbal/migration/dummy.php +++ b/tests/dbal/migration/dummy.php @@ -27,6 +27,13 @@ class phpbb_dbal_migration_dummy extends phpbb_db_migration function update_data() { - $this->db->sql_query('UPDATE phpbb_config SET extra_column = 1'); + return array( + array('if', array(true, array('custom', array(array($this, 'set_extra_column'))))), + ); + } + + public function set_extra_column() + { + $this->sql_query('UPDATE phpbb_config SET extra_column = 1'); } } From 6c44dadecbf50d6550f98dd1e1694519f39be680 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 8 Jan 2013 22:07:26 -0600 Subject: [PATCH 028/174] [feature/migrations] Move migrator to service container Version numbers 3.1 updates Restore database_update.php file to what it was in develop Get first forum to place global announcements in PHPBB3-9737 --- phpBB/config/services.yml | 45 + phpBB/config/tables.yml | 1 + phpBB/develop/create_schema_files.php | 14 +- phpBB/includes/db/db_tools.php | 10 + phpBB/includes/db/migration.php | 20 +- phpBB/includes/db/migration/data/3_0_1.php | 3 + phpBB/includes/db/migration/data/3_0_10.php | 3 + .../includes/db/migration/data/3_0_10_rc1.php | 2 + .../includes/db/migration/data/3_0_10_rc2.php | 3 + .../includes/db/migration/data/3_0_10_rc3.php | 3 + phpBB/includes/db/migration/data/3_0_11.php | 3 + .../includes/db/migration/data/3_0_11_rc1.php | 2 + .../data/{3_0_11_rc2 => 3_0_11_rc2.php} | 3 + .../includes/db/migration/data/3_0_12_rc1.php | 8 +- .../includes/db/migration/data/3_0_1_rc1.php | 2 + phpBB/includes/db/migration/data/3_0_2.php | 3 + .../includes/db/migration/data/3_0_2_rc1.php | 4 +- .../includes/db/migration/data/3_0_2_rc2.php | 3 + phpBB/includes/db/migration/data/3_0_3.php | 5 +- .../includes/db/migration/data/3_0_3_rc1.php | 2 + phpBB/includes/db/migration/data/3_0_4.php | 2 + .../includes/db/migration/data/3_0_4_rc1.php | 2 + phpBB/includes/db/migration/data/3_0_5.php | 3 + .../db/migration/data/3_0_5_rc1part2.php | 3 + phpBB/includes/db/migration/data/3_0_6.php | 3 + .../includes/db/migration/data/3_0_6_rc1.php | 2 + .../includes/db/migration/data/3_0_6_rc2.php | 3 + .../includes/db/migration/data/3_0_6_rc3.php | 2 + .../includes/db/migration/data/3_0_6_rc4.php | 3 + phpBB/includes/db/migration/data/3_0_7.php | 3 + .../includes/db/migration/data/3_0_7_pl1.php | 3 + .../includes/db/migration/data/3_0_7_rc1.php | 2 + .../includes/db/migration/data/3_0_7_rc2.php | 2 + phpBB/includes/db/migration/data/3_0_8.php | 3 + .../includes/db/migration/data/3_0_8_rc1.php | 2 + phpBB/includes/db/migration/data/3_0_9.php | 3 + .../includes/db/migration/data/3_0_9_rc1.php | 2 + .../includes/db/migration/data/3_0_9_rc2.php | 3 + .../includes/db/migration/data/3_0_9_rc3.php | 3 + .../includes/db/migration/data/3_0_9_rc4.php | 3 + .../includes/db/migration/data/3_1_0_dev.php | 283 ++++ .../includes/db/migration/data/extensions.php | 48 + .../db/migration/data/style_update_p1.php | 99 ++ .../db/migration/data/style_update_p2.php | 83 + .../migration/data/timezone.php} | 60 +- phpBB/includes/db/migration/tools/base.php | 47 - phpBB/includes/db/migration/tools/config.php | 26 +- phpBB/includes/db/migration/tools/module.php | 38 +- .../db/migration/tools/permission.php | 26 +- phpBB/includes/db/migrator.php | 33 +- phpBB/install/database_update.php | 1424 +++++++++++++++++ 51 files changed, 2252 insertions(+), 106 deletions(-) rename phpBB/includes/db/migration/data/{3_0_11_rc2 => 3_0_11_rc2.php} (86%) create mode 100644 phpBB/includes/db/migration/data/3_1_0_dev.php create mode 100644 phpBB/includes/db/migration/data/extensions.php create mode 100644 phpBB/includes/db/migration/data/style_update_p1.php create mode 100644 phpBB/includes/db/migration/data/style_update_p2.php rename phpBB/includes/{update_helpers.php => db/migration/data/timezone.php} (74%) delete mode 100644 phpBB/includes/db/migration/tools/base.php diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 5c450a5cf6..4125491dd0 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -94,6 +94,12 @@ services: calls: - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] + dbal.tools: + file: %core.root_path%includes/db/db_tools.%core.php_ext% + class: phpbb_db_tools + arguments: + - @dbal.conn + event.subscriber_loader: class: phpbb_event_extension_subscriber_loader arguments: @@ -156,6 +162,45 @@ services: tags: - { name: kernel.event_subscriber } + migrator: + class: phpbb_db_migrator + arguments: + - @service_container + + migrator.tools_collection + class: phpbb_di_service_collection + arguments: + - @service_container + + migrator.tools.config: + class: phpbb_db_migration_tools_config + arguments: + - @config + tags: + - { name: migrator:tool } + + migrator.tools.module: + class: phpbb_db_migration_tools_module + arguments: + - @db + - @cache + - @user + - %core.root_path% + - %core.php_ext% + tags: + - { name: migrator:tool } + + migrator.tools.permission: + class: phpbb_db_migration_tools_permission + arguments: + - @db + - @cache + - @auth + - %core.root_path% + - %core.php_ext% + tags: + - { name: migrator:tool } + request: class: phpbb_request diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index cfc6dbcfed..a9414cf66c 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,3 +1,4 @@ parameters: tables.config: %core.table_prefix%config tables.ext: %core.table_prefix%ext + tables.migrations: %core.table_prefix%migrations diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3d3e478032..1abafb3b6d 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1258,7 +1258,7 @@ function get_schema_struct() ), ); - $schema_data['phpbb_moderator_cache'] = array( + $schema_data['phpbb_migrations'] = array( 'COLUMNS' => array( 'forum_id' => array('UINT', 0), 'user_id' => array('UINT', 0), @@ -1273,6 +1273,18 @@ function get_schema_struct() ), ); + $schema_data['phpbb_moderator_cache'] = array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + ); + $schema_data['phpbb_modules'] = array( 'COLUMNS' => array( 'module_id' => array('UINT', NULL, 'auto_increment'), diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 2bb016cebd..5329d871c8 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -345,6 +345,16 @@ class phpbb_db_tools } } + /** + * Setter for {@link $return_statements return_statements}. + * + * @param bool $return_statements True if SQL should not be executed but returned as strings + */ + public function set_return_statements($return_statements) + { + $this->return_statements = $return_statements; + } + /** * Gets a list of tables in the database. * diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index 4e83d2570c..1acef2d429 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -26,6 +26,7 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migration { + protected $config; protected $db; protected $db_tools; protected $table_prefix; @@ -38,20 +39,17 @@ class phpbb_db_migration /** * Migration constructor * - * @param dbal $db Connected database abstraction instance - * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools - * @param string $table_prefix The prefix for all table names - * @param string $phpbb_root_path - * @param string $php_ext + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies */ - public function phpbb_db_migration($db, $db_tools, $table_prefix, $phpbb_root_path, $php_ext) + public function phpbb_db_migration(\Symfony\Component\DependencyInjection\ContainerInterface $container) { - $this->db = $db; - $this->db_tools = $db_tools; - $this->table_prefix = $table_prefix; + $this->config = $this->container->get('config'); + $this->db = $this->container->get('dbal.conn'); + $this->db_tools = $this->container->get('dbal.tools'); + $this->table_prefix = $this->container->getParameters('core.table_prefix'); - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; + $this->phpbb_root_path = $this->container->getParameters('core.root_path'); + $this->php_ext = $this->container->getParameters('core.php_ext'); $this->errors = array(); } diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index 294db3d946..a2332c9b59 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.1')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 6d39969d48..07410c5ba1 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.10')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index 06105c5b0d..daac50a631 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration { return array( array('config.add', array('email_max_chunk_size', 50)), + + array('config.update', array('version', '3.0.10-rc1')), ); } } diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index 04161caf28..234e4c5fc7 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.10-rc2')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index 539f0b8fec..075ce35e3e 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.10-rc3')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index 3404272ef9..0bc9b6c4a5 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.11')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index f44226df02..1509120f68 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -24,6 +24,8 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration return array( array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), array('custom', array(array(&$this, 'delete_orphan_private_messages'))), + + array('config.update', array('version', '3.0.11-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2 b/phpBB/includes/db/migration/data/3_0_11_rc2.php similarity index 86% rename from phpBB/includes/db/migration/data/3_0_11_rc2 rename to phpBB/includes/db/migration/data/3_0_11_rc2.php index 6add980c73..f2bed54085 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2 +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -27,5 +27,8 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.11-rc2')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 734a57ecee..e5ff8c5814 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -7,6 +7,9 @@ * */ +/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/ + +/* class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { function depends_on() @@ -16,11 +19,14 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration function update_schema() { - /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ return array(); } function update_data() { + return array( + array('config.update', array('version', '3.0.12-rc1')), + ); } } +*/ \ No newline at end of file diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index 1a696e0003..a3b4810d21 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -44,6 +44,8 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration return array( array('custom', array(array(&$this, 'fix_unset_last_view_time'))), array('custom', array(array(&$this, 'reset_smiley_size'))), + + array('config.update', array('version', '3.0.1-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index a5f94e644b..3469d8d178 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.2')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index 1b4d3bc2b8..d3c2200f14 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration { function depends_on() { @@ -25,6 +25,8 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration array('config.add', array('referer_validation', '1')), array('config.add', array('check_attachment_content', '1')), array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), + + array('config.update', array('version', '3.0.2-rc1')), ); } } diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index 9ddeb60a14..67fd1faec6 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -48,5 +48,8 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.2-rc2')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index f989eea025..dff375f438 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration { function depends_on() { - return array('phpbb_db_migration_data_3_0_2_rc2'); + return array('phpbb_db_migration_data_3_0_3_rc1'); } function update_schema() @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.3')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 737eab4bd3..d5c110eb7d 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -39,6 +39,8 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration array('config.add', array('dbms_version', '')), array('permission.add', array('u_masspm_group', phpbb_auth::IS_GLOBAL), array('custom', array(array(&$this, 'correct_acp_email_permissions'))), + + array('config.update', array('version', '3.0.3-rc1')), )); } diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index cd34fda9ab..4965ac38d0 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration { return array( array('custom', array(array(&$this, 'rename_log_delete_topic'))), + + array('config.update', array('version', '3.0.4')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index 342f1fa910..2964dcebc9 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -59,6 +59,8 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration { return array( array('custom', array(array(&$this, 'update_custom_profile_fields'))), + + array('config.update', array('version', '3.0.4-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 5671832a82..2f80970781 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.5')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 6be8ea9845..1fab0f8873 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -30,5 +30,8 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.5-rc1')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index c2cb59e62a..26176b9437 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.6')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index eefdc1692d..a868d70684 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -155,6 +155,8 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration )), array('custom', array(array(&$this, 'add_newly_registered_group'))), array('custom', array(array(&$this, 'set_user_options_default'))), + + array('config.update', array('version', '3.0.6-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index 07b31a53b9..4092a5fa61 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.6-rc2')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index c19a792bad..ec22d1da77 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration { return array( array('custom', array(array(&$this, 'update_cp_fields'))), + + array('config.update', array('version', '3.0.6-rc3')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index c48b1ca394..e748c7a4ff 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.6-rc4')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index 05781b7b49..f27b56f778 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.7')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index cee7a91a2e..5543d6437a 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.7-pl1')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index b2d49cce63..71584382e8 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -38,6 +38,8 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), array('custom', array(array(&$this, 'delete_text_templates'))), + + array('config.update', array('version', '3.0.7-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index 8a751328bf..e043f35705 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration { return array( array('custom', array(array(&$this, 'update_email_hash'))), + + array('config.update', array('version', '3.0.7-rc2')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index a714a3d2f6..a5defc8278 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.8')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index 73838d9d29..3f51806fd9 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -37,6 +37,8 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration array('config.add', array('load_unreads_search', 1)), array('config.update_if_equals', array(600, 'queue_interval', 60)), array('config.update_if_equals', array(50, 'email_package_size', 20)), + + array('config.update', array('version', '3.0.8-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index 4b2c08a256..eb359e2697 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.9')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index 98d3a26481..256426849c 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -59,6 +59,8 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration array('config.add', array('ip_login_limit_use_forwarded', 0)), array('custom', array(array(&$this, 'update_file_extension_group_names'))), array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))), + + array('config.update', array('version', '3.0.9-rc1')), ); } diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index 589047670a..e3c4716665 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.9-rc2')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index 06061cbcb6..3cdecb96ae 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.9-rc3')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index 04b3ae4b39..c2a92e618a 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration function update_data() { + return array( + array('config.update', array('version', '3.0.9-rc4')), + ); } } diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php new file mode 100644 index 0000000000..987ab94646 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -0,0 +1,283 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_extensions extends phpbb_db_migration +{ + public function depends_on() + { + return array( + 'phpbb_db_migration_data_3_0_11', + 'phpbb_db_migration_data_extensions', + 'phpbb_db_migration_data_style_update_p2', + 'phpbb_db_migration_data_timezone', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + GROUPS_TABLE => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_pm' => array('BOOL', 0), + ), + STYLES_TABLE => array( + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), + REPORTS_TABLE => array( + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + ), + ), + 'change_columns' => array( + GROUPS_TABLE => array( + 'group_legend' => array('UINT', 0), + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), + + array('config.add', array('fulltext_postgres_ts_name', 'simple')), + array('config.add', array('fulltext_postgres_min_word_len', 4)), + array('config.add', array('fulltext_postgres_max_word_len', 254)), + array('config.add', array('fulltext_sphinx_stopwords', 0)), + array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)), + + array('config.add', array('load_jquery_cdn', 0)), + array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')), + + array('config.add', array('use_system_cron', 0)), + + array('config.add', array('legend_sort_groupname', 0)), + array('config.add', array('teampage_forums', 1)), + array('config.add', array('teampage_memberships', 1)), + + array('config.add', array('load_cpf_pm', 0)), + + array('config.add', array('display_last_subject', 1)), + + array('config.add', array('assets_version', 1)), + + array('config.add', array('site_home_url', '')), + array('config.add', array('site_home_text', '')), + + array('module.add', array( + 'acp', + 'ACP_GROUPS', + array( + 'module_basename' => 'acp_groups', + 'modes' => array('position'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_ATTACHMENTS', + array( + 'module_basename' => 'acp_attachments', + 'modes' => array('manage'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_STYLE_MANAGEMENT', + array( + 'module_basename' => 'acp_styles', + 'modes' => array('install', 'cache'), + ), + )), + array('module.add', array( + 'acp', + 'UCP_PROFILE', + array( + 'module_basename' => 'ucp_profile', + 'modes' => array('autologin_keys'), + ), + )), + + array('module.remove', array( + 'acp', + 'ACP_CAT_STYLES', + array( + 'module_basename' => 'styles', + 'modes' => array('imageset', 'theme', 'template'), + ), + )), + + array('custom', array(array($this, 'rename_module_basenames'))), + array('custom', array(array($this, 'add_group_teampage'))), + array('custom', array(array($this, 'update_group_legend'))), + array('custom', array(array($this, 'localise_global_announcements'))), + ); + } + + public function rename_module_basenames() + { + // rename all module basenames to full classname + $sql = 'SELECT module_id, module_basename, module_class + FROM ' . MODULES_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $module_id = (int) $row['module_id']; + unset($row['module_id']); + + if (!empty($row['module_basename']) && !empty($row['module_class'])) + { + // all the class names start with class name or with phpbb_ for auto loading + if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && + strpos($row['module_basename'], 'phpbb_') !== 0) + { + $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; + + $sql_update = $this->db->sql_build_array('UPDATE', $row); + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET ' . $sql_update . ' + WHERE module_id = ' . $module_id; + $this->sql_query($sql); + } + } + } + + $this->db->sql_freeresult($result); + } + + public function add_group_teampage() + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + $this->sql_query($sql); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + $this->sql_query($sql); + } + + public function update_group_legend() + { + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $this->db->sql_query($sql); + + $next_legend = 1; + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + $this->sql_query($sql); + + $next_legend++; + } + $this->db->sql_freeresult($result); + } + + public function localise_global_announcements() + { + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $this->db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $this->db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $this->db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type = ' . FORUM_POST; + $result = $this->db->sql_query_limit($sql, 1); + $ga_forum_id = $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $this->db->sql_query($sql); + $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time'); + $this->db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + $this->sql_query($sql); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $this->db->sql_in_set('topic_id', $global_announcements); + $this->sql_query($sql); + } + unset($table_ary); + } + } +} diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php new file mode 100644 index 0000000000..85d5511ef0 --- /dev/null +++ b/phpBB/includes/db/migration/data/extensions.php @@ -0,0 +1,48 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_extensions extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + EXT_TABLE => array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + ), + ), + ), + ); + } + + public function update_data() + { + return array( + array('module.add', array( + 'acp', + 'ACP_GENERAL_TASKS', + array( + 'module_basename' => 'extensions', + 'modes' => array('main'), + ), + )), + ); + } +} diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php new file mode 100644 index 0000000000..d570caae04 --- /dev/null +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -0,0 +1,99 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array(); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'styles_update'))), + ); + } + + public function styles_update() + { + // Get list of valid 3.1 styles + $available_styles = array('prosilver'); + + $iterator = new DirectoryIterator($phpbb_root_path . 'styles'); + $skip_dirs = array('.', '..', 'prosilver'); + foreach ($iterator as $fileinfo) + { + if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) + { + $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); + if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) + { + // 3.1 style + $available_styles[] = $fileinfo->getFilename(); + } + } + } + + // Get all installed styles + if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id + AND i.imageset_id = s.imageset_id"; + } + else + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id"; + } + $result = $this->db->sql_query($sql); + + $styles = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $styles[] = $row; + } + $this->db->sql_freeresult($result); + + // Decide which styles to keep, all others will be deleted + $valid_styles = array(); + foreach ($styles as $style_row) + { + if ( + // Delete styles with parent style (not supported yet) + $style_row['template_inherits_id'] == 0 && + // Check if components match + $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && + // Check if components are valid + in_array($style_row['template_path'], $available_styles) + ) + { + // Valid style. Keep it + $sql_ary = array( + 'style_path' => $style_row['template_path'], + 'bbcode_bitfield' => $style_row['bbcode_bitfield'], + 'style_parent_id' => 0, + 'style_parent_tree' => '', + ); + $this->sql_query('UPDATE ' . STYLES_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary); + $valid_styles[] = (int) $style_row['style_id']; + } + } + } +} diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php new file mode 100644 index 0000000000..2c0991de59 --- /dev/null +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -0,0 +1,83 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_style_update_p1'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + STYLES_TABLE => array( + 'imageset_id', + 'template_id', + 'theme_id', + ), + ), + + 'drop_tables' => array( + STYLES_IMAGESET_TABLE, + STYLES_IMAGESET_DATA_TABLE, + STYLES_TEMPLATE_TABLE, + STYLES_TEMPLATE_DATA_TABLE, + STYLES_THEME_TABLE, + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'styles_update'))), + ); + } + + public function styles_update() + { + // Remove old entries from styles table + if (!sizeof($valid_styles)) + { + // No valid styles: remove everything and add prosilver + $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + + $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; + $this->sql_query($sql); + + $sql = 'SELECT style_id + FROM ' . $table . " + WHERE style_name = 'prosilver'"; + $result = $this->sql_query($sql); + $default_style = $this->db->sql_fetchfield($result); + $this->db->sql_freeresult($result); + + set_config('default_style', $default_style); + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + $this->sql_query($sql); + } + else + { + // There are valid styles in styles table. Remove styles that are outdated + $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true), $errored, $error_ary); + + // Change default style + if (!in_array($config['default_style'], $valid_styles)) + { + set_config('default_style', $valid_styles[0]); + } + + // Reset styles for users + $this->sql_query('UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true), $errored, $error_ary); + } + } +} diff --git a/phpBB/includes/update_helpers.php b/phpBB/includes/db/migration/data/timezone.php similarity index 74% rename from phpBB/includes/update_helpers.php rename to phpBB/includes/db/migration/data/timezone.php index 69d678b2f8..89fafbad28 100644 --- a/phpBB/includes/update_helpers.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -1,16 +1,62 @@ <?php /** * -* @package phpBB3 +* @package migration * @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* */ -/** -* phpBB Update Helpers -*/ -class phpbb_update_helpers +class phpbb_db_migration_data_timezone extends phpbb_db_migration { + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + USERS_TABLE => array( + 'user_timezone' => array('VCHAR:100', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_timezones'))), + ); + } + + public function update_timezones() + { + // Update user timezones + $sql = 'SELECT user_dst, user_timezone + FROM ' . USERS_TABLE . ' + GROUP BY user_timezone, user_dst'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' + WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' + AND user_dst = " . (int) $row['user_dst']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + + // Update board default timezone + set_config('board_timezone', $this->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); + + // After we have calculated the timezones we can delete user_dst column from user table. + $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); + } + /** * Determine the new timezone for a given phpBB 3.0 timezone and * "Daylight Saving Time" option @@ -19,7 +65,7 @@ class phpbb_update_helpers * @param $dst int Users daylight saving time * @return string Users new php Timezone which is used since 3.1 */ - function convert_phpbb30_timezone($timezone, $dst) + public function convert_phpbb30_timezone($timezone, $dst) { $offset = $timezone + $dst; diff --git a/phpBB/includes/db/migration/tools/base.php b/phpBB/includes/db/migration/tools/base.php deleted file mode 100644 index 61116d8b55..0000000000 --- a/phpBB/includes/db/migration/tools/base.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_tools_base -{ - /** @var phpbb_auth */ - protected $auth = null; - - /** @var phpbb_cache_service */ - protected $cache = null; - - /** @var phpbb_config */ - protected $config = null; - - /** @var dbal */ - protected $db = null; - - /** @var phpbb_template */ - protected $template = null; - - /** @var phpbb_user */ - protected $user = null; - - /** @var string */ - protected $phpbb_root_path = null; - - /** @var string */ - protected $php_ext = null; - - public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) - { - $this->db = $db; - $this->cache = $cache; - $this->template = $template; - $this->user = $user; - $this->auth = $auth; - $this->config = $config; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } -} \ No newline at end of file diff --git a/phpBB/includes/db/migration/tools/config.php b/phpBB/includes/db/migration/tools/config.php index 965ba1d136..2d58c8093c 100644 --- a/phpBB/includes/db/migration/tools/config.php +++ b/phpBB/includes/db/migration/tools/config.php @@ -7,20 +7,14 @@ * */ -class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base +class phpbb_db_migration_tools_config { - /** - * Config Exists - * - * This function is to check to see if a config variable exists or if it does not. - * - * @param string $config_name The name of the config setting you wish to check for. - * - * @return bool true/false if config exists - */ - public function exists($config_name) + /** @var phpbb_config */ + protected $config = null; + + public function __construct(phpbb_config $config) { - return (bool) $this->config->offsetExists($config_name); + $this->config = $config; } /** @@ -34,7 +28,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base */ public function add($config_name, $config_value = '', $is_dynamic = false) { - if ($this->config_exists($config_name)) + if (isset($this->config[$config_name])) { throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name); } @@ -54,7 +48,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base */ public function update($config_name, $config_value = '') { - if (!$this->config_exists($config_name)) + if (!isset($this->config[$config_name])) { throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); } @@ -75,7 +69,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base */ public function update_if_equals($compare, $config_name, $config_value = '') { - if (!$this->config_exists($config_name)) + if (!isset($this->config[$config_name])) { throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); } @@ -94,7 +88,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base */ public function remove($config_name) { - if (!$this->config_exists($config_name)) + if (!isset($this->config[$config_name])) { throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); } diff --git a/phpBB/includes/db/migration/tools/module.php b/phpBB/includes/db/migration/tools/module.php index df1912a022..e17197d73e 100644 --- a/phpBB/includes/db/migration/tools/module.php +++ b/phpBB/includes/db/migration/tools/module.php @@ -7,8 +7,32 @@ * */ -class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base +class phpbb_db_migration_tools_module { + /** @var phpbb_cache_service */ + protected $cache = null; + + /** @var dbal */ + protected $db = null; + + /** @var phpbb_user */ + protected $user = null; + + /** @var string */ + protected $phpbb_root_path = null; + + /** @var string */ + protected $php_ext = null; + + public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $user, $phpbb_root_path, $php_ext) + { + $this->db = $db; + $this->cache = $cache; + $this->user = $user; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + /** * Module Exists * @@ -117,11 +141,15 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base if (!isset($data['module_langname'])) { + /** + * @TODO does not work with 3.1 modules yet, but must continue for old 3.0 versions for + * upgrades from a 3.0.x version to 3.1 + */ // The "automatic" way $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; $basename = str_replace(array('/', '\\'), '', $basename); $class = str_replace(array('/', '\\'), '', $class); - $info_file = "$class/info/{$class}_$basename.$this->phpEx"; + $info_file = "$class/info/{$class}_$basename.{$this->php_ext}"; // The manual and automatic ways both failed... if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) @@ -196,7 +224,7 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base if (!class_exists('acp_modules')) { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->phpEx); + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); $this->user->add_lang('acp/modules'); } $acp_modules = new acp_modules(); @@ -302,7 +330,7 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base // Automatic method $basename = str_replace(array('/', '\\'), '', $module['module_basename']); $class = str_replace(array('/', '\\'), '', $class); - $info_file = "$class/info/{$class}_$basename.$this->phpEx"; + $info_file = "$class/info/{$class}_$basename.{$this->php_ext}"; if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) { @@ -396,7 +424,7 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base if (!class_exists('acp_modules')) { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->phpEx); + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); $this->user->add_lang('acp/modules'); } $acp_modules = new acp_modules(); diff --git a/phpBB/includes/db/migration/tools/permission.php b/phpBB/includes/db/migration/tools/permission.php index 3fbe7c649c..7694bae0cb 100644 --- a/phpBB/includes/db/migration/tools/permission.php +++ b/phpBB/includes/db/migration/tools/permission.php @@ -9,6 +9,30 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base { + /** @var phpbb_auth */ + protected $auth = null; + + /** @var phpbb_cache_service */ + protected $cache = null; + + /** @var dbal */ + protected $db = null; + + /** @var string */ + protected $phpbb_root_path = null; + + /** @var string */ + protected $php_ext = null; + + public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext) + { + $this->db = $db; + $this->cache = $cache; + $this->auth = $auth; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + /** * Permission Exists * @@ -69,7 +93,7 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base if (!class_exists('auth_admin')) { - include($this->phpbb_root_path . 'includes/acp/auth.' . $this->phpEx); + include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); } $auth_admin = new auth_admin(); diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 9187e09869..c9590fccf6 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -22,6 +22,7 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migrator { + protected $container; protected $db; protected $db_tools; protected $table_prefix; @@ -37,24 +38,26 @@ class phpbb_db_migrator /** * Constructor of the database migrator * - * @param dbal $db Connected database abstraction instance - * @param phpbb_db_tools $db_tools Instance of db schema manipulation tools - * @param string $table_prefix The prefix for all table names - * @param string $migrations_table The name of the db table storing - * information on applied migrations - * @param string $phpbb_root_path - * @param string $php_ext + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies */ - public function phpbb_db_migrator($db, $db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext) + public function phpbb_db_migrator(\Symfony\Component\DependencyInjection\ContainerInterface $container, $migrations) { - $this->db = $db; - $this->db_tools = $db_tools; - $this->table_prefix = $table_prefix; - $this->migrations_table = $migrations_table; - $this->migrations = array(); + $this->container = $container; + $this->db = $this->container->get('dbal.conn'); + $this->db_tools = $this->container->get('dbal.tools'); + $this->table_prefix = $this->container->getParameters('core.table_prefix'); + $this->migrations_table = $this->container->getParameters('tables.migrations'); + $this->migrations = $migrations; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; + $this->phpbb_root_path = $this->container->getParameters('core.root_path'); + $this->php_ext = $this->container->getParameters('core.php_ext'); + + /** @todo replace with collection_pass when merged */ + $this->tools = array( + 'config' => new phpbb_db_migration_tools_config, + 'module' => new phpbb_db_migration_tools_module, + 'permission' => new phpbb_db_migration_tools_permission, + ); $this->load_migration_state(); } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1f89035b43..207ad716de 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -881,6 +881,277 @@ function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permissio function database_update_info() { return array( + // Changes from 3.0.0 to the next version + '3.0.0' => array( + // Add the following columns + 'add_columns' => array( + FORUMS_TABLE => array( + 'display_subforum_list' => array('BOOL', 1), + ), + SESSIONS_TABLE => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'drop_keys' => array( + GROUPS_TABLE => array('group_legend'), + ), + 'add_index' => array( + SESSIONS_TABLE => array( + 'session_forum_id' => array('session_forum_id'), + ), + GROUPS_TABLE => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + ), + // No changes from 3.0.1-RC1 to 3.0.1 + '3.0.1-RC1' => array(), + // No changes from 3.0.1 to 3.0.2-RC1 + '3.0.1' => array(), + // Changes from 3.0.2-RC1 to 3.0.2-RC2 + '3.0.2-RC1' => array( + 'change_columns' => array( + DRAFTS_TABLE => array( + 'draft_subject' => array('STEXT_UNI', ''), + ), + FORUMS_TABLE => array( + 'forum_last_post_subject' => array('STEXT_UNI', ''), + ), + POSTS_TABLE => array( + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + ), + PRIVMSGS_TABLE => array( + 'message_subject' => array('STEXT_UNI', ''), + ), + TOPICS_TABLE => array( + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + ), + ), + 'drop_keys' => array( + SESSIONS_TABLE => array('session_forum_id'), + ), + 'add_index' => array( + SESSIONS_TABLE => array( + 'session_fid' => array('session_forum_id'), + ), + ), + ), + // No changes from 3.0.2-RC2 to 3.0.2 + '3.0.2-RC2' => array(), + + // Changes from 3.0.2 to 3.0.3-RC1 + '3.0.2' => array( + // Add the following columns + 'add_columns' => array( + STYLES_TEMPLATE_TABLE => array( + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + GROUPS_TABLE => array( + 'group_max_recipients' => array('UINT', 0), + ), + ), + ), + + // No changes from 3.0.3-RC1 to 3.0.3 + '3.0.3-RC1' => array(), + + // Changes from 3.0.3 to 3.0.4-RC1 + '3.0.3' => array( + 'add_columns' => array( + PROFILE_FIELDS_TABLE => array( + 'field_show_profile' => array('BOOL', 0), + ), + ), + 'change_columns' => array( + STYLES_TABLE => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + 'imageset_id' => array('UINT', 0), + ), + STYLES_IMAGESET_TABLE => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + ), + STYLES_IMAGESET_DATA_TABLE => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_id' => array('UINT', 0), + ), + STYLES_THEME_TABLE => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + ), + STYLES_TEMPLATE_TABLE => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + ), + STYLES_TEMPLATE_DATA_TABLE => array( + 'template_id' => array('UINT', 0), + ), + FORUMS_TABLE => array( + 'forum_style' => array('UINT', 0), + ), + USERS_TABLE => array( + 'user_style' => array('UINT', 0), + ), + ), + ), + + // Changes from 3.0.4-RC1 to 3.0.4 + '3.0.4-RC1' => array(), + + // Changes from 3.0.4 to 3.0.5-RC1 + '3.0.4' => array( + 'change_columns' => array( + FORUMS_TABLE => array( + 'forum_style' => array('UINT', 0), + ), + ), + ), + + // No changes from 3.0.5-RC1 to 3.0.5 + '3.0.5-RC1' => array(), + + // Changes from 3.0.5 to 3.0.6-RC1 + '3.0.5' => array( + 'add_columns' => array( + CONFIRM_TABLE => array( + 'attempts' => array('UINT', 0), + ), + USERS_TABLE => array( + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time'=> array('TIMESTAMP', 0), + ), + GROUPS_TABLE => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + PRIVMSGS_TABLE => array( + 'message_reported' => array('BOOL', 0), + ), + REPORTS_TABLE => array( + 'pm_id' => array('UINT', 0), + ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_vt' => array('BOOL', 0), + ), + FORUMS_TABLE => array( + 'forum_options' => array('UINT:20', 0), + ), + ), + 'change_columns' => array( + USERS_TABLE => array( + 'user_options' => array('UINT:11', 230271), + ), + ), + 'add_index' => array( + REPORTS_TABLE => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), + POSTS_TABLE => array( + 'post_username' => array('post_username:255'), + ), + ), + ), + + // No changes from 3.0.6-RC1 to 3.0.6-RC2 + '3.0.6-RC1' => array(), + // No changes from 3.0.6-RC2 to 3.0.6-RC3 + '3.0.6-RC2' => array(), + // No changes from 3.0.6-RC3 to 3.0.6-RC4 + '3.0.6-RC3' => array(), + // No changes from 3.0.6-RC4 to 3.0.6 + '3.0.6-RC4' => array(), + + // Changes from 3.0.6 to 3.0.7-RC1 + '3.0.6' => array( + 'drop_keys' => array( + LOG_TABLE => array('log_time'), + ), + 'add_index' => array( + TOPICS_TRACK_TABLE => array( + 'topic_id' => array('topic_id'), + ), + ), + ), + + // No changes from 3.0.7-RC1 to 3.0.7-RC2 + '3.0.7-RC1' => array(), + // No changes from 3.0.7-RC2 to 3.0.7 + '3.0.7-RC2' => array(), + // No changes from 3.0.7 to 3.0.7-PL1 + '3.0.7' => array(), + // No changes from 3.0.7-PL1 to 3.0.8-RC1 + '3.0.7-PL1' => array(), + // No changes from 3.0.8-RC1 to 3.0.8 + '3.0.8-RC1' => array(), + // Changes from 3.0.8 to 3.0.9-RC1 + '3.0.8' => array( + 'add_tables' => array( + LOGIN_ATTEMPT_TABLE => array( + 'COLUMNS' => array( + // this column was removed from the database updater + // after 3.0.9-RC3 was released. It might still exist + // in 3.0.9-RCX installations and has to be dropped in + // 3.0.12 after the db_tools class is capable of properly + // removing a primary key. + // 'attempt_id' => array('UINT', NULL, 'auto_increment'), + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + //'PRIMARY_KEY' => 'attempt_id', + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), + ), + ), + 'change_columns' => array( + BBCODES_TABLE => array( + 'bbcode_id' => array('USINT', 0), + ), + ), + ), + // No changes from 3.0.9-RC1 to 3.0.9-RC2 + '3.0.9-RC1' => array(), + // No changes from 3.0.9-RC2 to 3.0.9-RC3 + '3.0.9-RC2' => array(), + // No changes from 3.0.9-RC3 to 3.0.9-RC4 + '3.0.9-RC3' => array(), + // No changes from 3.0.9-RC4 to 3.0.9 + '3.0.9-RC4' => array(), + // No changes from 3.0.9 to 3.0.10-RC1 + '3.0.9' => array(), + // No changes from 3.0.10-RC1 to 3.0.10-RC2 + '3.0.10-RC1' => array(), + // No changes from 3.0.10-RC2 to 3.0.10-RC3 + '3.0.10-RC2' => array(), + // No changes from 3.0.10-RC3 to 3.0.10 + '3.0.10-RC3' => array(), + // No changes from 3.0.10 to 3.0.11-RC1 + '3.0.10' => array(), + // Changes from 3.0.11-RC1 to 3.0.11-RC2 + '3.0.11-RC1' => array( + 'add_columns' => array( + PROFILE_FIELDS_TABLE => array( + 'field_show_novalue' => array('BOOL', 0), + ), + ), + ), + // No changes from 3.0.11-RC2 to 3.0.11 + '3.0.11-RC2' => array(), + // No changes from 3.0.11 to 3.0.12-RC1 + '3.0.11' => array(), + + /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ + // Changes from 3.1.0-dev to 3.1.0-A1 '3.1.0-dev' => array( 'add_tables' => array( @@ -939,6 +1210,1159 @@ function change_database_data(&$no_updates, $version) switch ($version) { + case '3.0.0': + + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_last_view_time = topic_last_post_time + WHERE topic_last_view_time = 0"; + _sql($sql, $errored, $error_ary); + + // Update smiley sizes + $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); + + foreach ($smileys as $smiley) + { + if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) + { + list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET smiley_width = ' . $width . ', smiley_height = ' . $height . " + WHERE smiley_url = '" . $db->sql_escape($smiley) . "'"; + + _sql($sql, $errored, $error_ary); + } + } + + $no_updates = false; + break; + + // No changes from 3.0.1-RC1 to 3.0.1 + case '3.0.1-RC1': + break; + + // changes from 3.0.1 to 3.0.2-RC1 + case '3.0.1': + + set_config('referer_validation', '1'); + set_config('check_attachment_content', '1'); + set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); + + $no_updates = false; + break; + + // No changes from 3.0.2-RC1 to 3.0.2-RC2 + case '3.0.2-RC1': + break; + + // No changes from 3.0.2-RC2 to 3.0.2 + case '3.0.2-RC2': + break; + + // Changes from 3.0.2 to 3.0.3-RC1 + case '3.0.2': + set_config('enable_queue_trigger', '0'); + set_config('queue_trigger_posts', '3'); + + set_config('pm_max_recipients', '0'); + + // Set maximum number of recipients for the registered users, bots, guests group + $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 + WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); + _sql($sql, $errored, $error_ary); + + // Not prefilling yet + set_config('dbms_version', ''); + + // Add new permission u_masspm_group and duplicate settings from u_masspm + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + + // Only add the new permission if it does not already exist + if (empty($auth_admin->acl_options['id']['u_masspm_group'])) + { + $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['u_masspm']; + $new_id = $auth_admin->acl_options['id']['u_masspm_group']; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + // Remove any old permission entries + $auth_admin->acl_clear_prefetch(); + } + + /** + * Do not resync post counts here. An admin may do this later from the ACP + $start = 0; + $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; + _sql($sql, $errored, $error_ary); + + do + { + $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id + FROM ' . POSTS_TABLE . ' + WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' + AND post_postcount = 1 AND post_approved = 1 + GROUP BY poster_id'; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; + _sql($sql, $errored, $error_ary); + } + while ($row = $db->sql_fetchrow($result)); + + $start += $step; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + */ + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_a_email && cfg_email_enable\' + WHERE module_class = \'acp\' + AND module_basename = \'email\''; + _sql($sql, $errored, $error_ary); + + $no_updates = false; + break; + + // Changes from 3.0.3-RC1 to 3.0.3 + case '3.0.3-RC1': + if ($db->sql_layer == 'oracle') + { + // log_operation is CLOB - but we can change this later + $sql = 'UPDATE ' . LOG_TABLE . " + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; + _sql($sql, $errored, $error_ary); + } + else + { + $sql = 'UPDATE ' . LOG_TABLE . " + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation = 'LOG_TOPIC_DELETED'"; + _sql($sql, $errored, $error_ary); + } + + $no_updates = false; + break; + + // Changes from 3.0.3 to 3.0.4-RC1 + case '3.0.3': + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide + FROM ' . PROFILE_FIELDS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + $sql_ary = array( + 'field_required' => 0, + 'field_show_on_reg' => 0, + 'field_hide' => 0, + 'field_show_profile'=> 0, + ); + + if ($row['field_required']) + { + $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_show_on_reg']) + { + $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_hide']) + { + // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module + $sql_ary['field_hide'] = 1; + } + else + { + // equivelant to "none", which is the "Display in user control panel" option + $sql_ary['field_show_profile'] = 1; + } + + _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); + } + $no_updates = false; + + break; + + // Changes from 3.0.4-RC1 to 3.0.4 + case '3.0.4-RC1': + break; + + // Changes from 3.0.4 to 3.0.5-RC1 + case '3.0.4': + + // Captcha config variables + set_config('captcha_gd_wave', 0); + set_config('captcha_gd_3d_noise', 1); + set_config('captcha_gd_fonts', 1); + set_config('confirm_refresh', 1); + + // Maximum number of keywords + set_config('max_num_search_keywords', 10); + + // Remove static config var and put it back as dynamic variable + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET is_dynamic = 1 + WHERE config_name = 'search_indexing_state'"; + _sql($sql, $errored, $error_ary); + + // Hash old MD5 passwords + $sql = 'SELECT user_id, user_password + FROM ' . USERS_TABLE . ' + WHERE user_pass_convert = 1'; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + if (strlen($row['user_password']) == 32) + { + $sql_ary = array( + 'user_password' => phpbb_hash($row['user_password']), + ); + + _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); + } + } + $db->sql_freeresult($result); + + // Adjust bot entry + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + _sql($sql, $errored, $error_ary); + + + // Before we are able to add a unique key to auth_option, we need to remove duplicate entries + + // We get duplicate entries first + $sql = 'SELECT auth_option + FROM ' . ACL_OPTIONS_TABLE . ' + GROUP BY auth_option + HAVING COUNT(*) >= 2'; + $result = $db->sql_query($sql); + + $auth_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $auth_options[] = $row['auth_option']; + } + $db->sql_freeresult($result); + + // Remove specific auth options + if (!empty($auth_options)) + { + foreach ($auth_options as $option) + { + // Select auth_option_ids... the largest id will be preserved + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $db->sql_escape($option) . "' + ORDER BY auth_option_id DESC"; + // sql_query_limit not possible here, due to bug in postgresql layer + $result = $db->sql_query($sql); + + // Skip first row, this is our original auth option we want to preserve + $row = $db->sql_fetchrow($result); + + while ($row = $db->sql_fetchrow($result)) + { + // Ok, remove this auth option... + _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + } + $db->sql_freeresult($result); + } + } + + // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. + $changes = array( + 'drop_keys' => array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + ); + + global $db_tools; + + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + + $changes = array( + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + + $no_updates = false; + + break; + + // No changes from 3.0.5-RC1 to 3.0.5 + case '3.0.5-RC1': + break; + + // Changes from 3.0.5 to 3.0.6-RC1 + case '3.0.5': + // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... + if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) + { + set_config('captcha_plugin', 'phpbb_captcha_gd'); + } + else if (!isset($config['captcha_plugin'])) + { + set_config('captcha_plugin', 'phpbb_captcha_nogd'); + } + + // Entries for the Feed Feature + set_config('feed_enable', '0'); + set_config('feed_limit', '10'); + + set_config('feed_overall_forums', '1'); + set_config('feed_overall_forums_limit', '15'); + + set_config('feed_overall_topics', '0'); + set_config('feed_overall_topics_limit', '15'); + + set_config('feed_forum', '1'); + set_config('feed_topic', '1'); + set_config('feed_item_statistics', '1'); + + // Entries for smiley pagination + set_config('smilies_per_page', '50'); + + // Entry for reporting PMs + set_config('allow_pm_report', '1'); + + // Install modules + $modules_to_install = array( + 'feed' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_FEED_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_BOARD_CONFIGURATION', + 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') + ), + 'warnings' => array( + 'base' => 'users', + 'class' => 'acp', + 'title' => 'ACP_USER_WARNINGS', + 'auth' => 'acl_a_user', + 'display' => 0, + 'cat' => 'ACP_CAT_USERS', + 'after' => array('feedback', 'ACP_USER_FEEDBACK') + ), + 'send_statistics' => array( + 'base' => 'send_statistics', + 'class' => 'acp', + 'title' => 'ACP_SEND_STATISTICS', + 'auth' => 'acl_a_server', + 'cat' => 'ACP_SERVER_CONFIGURATION' + ), + 'setting_forum_copy' => array( + 'base' => 'permissions', + 'class' => 'acp', + 'title' => 'ACP_FORUM_PERMISSIONS_COPY', + 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', + 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', + 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') + ), + 'pm_reports' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_OPEN', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + 'pm_reports_closed' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_CLOSED', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + 'pm_report_details' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORT_DETAILS', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + ); + + _add_modules($modules_to_install); + + // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED'"; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + if (!$group_id) + { + $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; + _sql($sql, $errored, $error_ary); + + $group_id = $db->sql_nextid(); + } + + // Insert new user role... at the end of the chain + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_USER_NEW_MEMBER' + AND role_type = 'u_'"; + $result = $db->sql_query($sql); + $u_role = (int) $db->sql_fetchfield('role_id'); + $db->sql_freeresult($result); + + if (!$u_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'u_'"; + $result = $db->sql_query($sql); + $next_order_id = (int) $db->sql_fetchfield('max_order_id'); + $db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; + _sql($sql, $errored, $error_ary); + $u_role = $db->sql_nextid(); + + if (!$errored) + { + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + _sql($sql, $errored, $error_ary); + + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + _sql($sql, $errored, $error_ary); + } + } + + // Insert new forum role + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' + AND role_type = 'f_'"; + $result = $db->sql_query($sql); + $f_role = (int) $db->sql_fetchfield('role_id'); + $db->sql_freeresult($result); + + if (!$f_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'f_'"; + $result = $db->sql_query($sql); + $next_order_id = (int) $db->sql_fetchfield('max_order_id'); + $db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; + _sql($sql, $errored, $error_ary); + $f_role = $db->sql_nextid(); + + if (!$errored) + { + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + _sql($sql, $errored, $error_ary); + } + } + + // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) + $sql = 'SELECT 1 + FROM ' . USERS_TABLE . ' + WHERE user_new = 0'; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; + _sql($sql, $errored, $error_ary); + } + + // Newly registered users limit + if (!isset($config['new_member_post_limit'])) + { + set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); + } + + if (!isset($config['new_member_group_default'])) + { + set_config('new_member_group_default', 0); + } + + // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... + // Check if the role is already assigned... + $sql = 'SELECT forum_id + FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id = ' . $f_role; + $result = $db->sql_query($sql); + $is_options = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + + // Not assigned at all... :/ + if (!$is_options) + { + // Get postable forums + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type != ' . FORUM_LINK; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); + } + $db->sql_freeresult($result); + } + + // Clear permissions... + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + $auth_admin->acl_clear_prefetch(); + + if (!isset($config['allow_avatar'])) + { + if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) + { + set_config('allow_avatar', '1'); + } + else + { + set_config('allow_avatar', '0'); + } + } + + if (!isset($config['allow_avatar_remote_upload'])) + { + if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) + { + set_config('allow_avatar_remote_upload', '1'); + } + else + { + set_config('allow_avatar_remote_upload', '0'); + } + } + + // Minimum number of characters + if (!isset($config['min_post_chars'])) + { + set_config('min_post_chars', '1'); + } + + if (!isset($config['allow_quick_reply'])) + { + set_config('allow_quick_reply', '1'); + } + + // Set every members user_options column to enable + // bbcode, smilies and URLs for signatures by default + $sql = 'SELECT user_options + FROM ' . USERS_TABLE . ' + WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + $result = $db->sql_query_limit($sql, 1); + $user_option = (int) $db->sql_fetchfield('user_options'); + $db->sql_freeresult($result); + + // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option + if (!($user_option & 1 << 15)) + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + _sql($sql, $errored, $error_ary); + } + + if (!isset($config['delete_time'])) + { + set_config('delete_time', $config['edit_time']); + } + + $no_updates = false; + break; + + // No changes from 3.0.6-RC1 to 3.0.6-RC2 + case '3.0.6-RC1': + break; + + // Changes from 3.0.6-RC2 to 3.0.6-RC3 + case '3.0.6-RC2': + + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' + SET field_show_on_vt = 1 + WHERE field_hide = 0 + AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; + _sql($sql, $errored, $error_ary); + $no_updates = false; + + break; + + // No changes from 3.0.6-RC3 to 3.0.6-RC4 + case '3.0.6-RC3': + break; + + // No changes from 3.0.6-RC4 to 3.0.6 + case '3.0.6-RC4': + break; + + // Changes from 3.0.6 to 3.0.7-RC1 + case '3.0.6': + + // ATOM Feeds + set_config('feed_overall', '1'); + set_config('feed_http_auth', '0'); + set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15)); + set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10)); + set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0')); + set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0')); + + // Delete all text-templates from the template_data + $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' + WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt'); + _sql($sql, $errored, $error_ary); + + $no_updates = false; + break; + + // Changes from 3.0.7-RC1 to 3.0.7-RC2 + case '3.0.7-RC1': + + $sql = 'SELECT user_id, user_email, user_email_hash + FROM ' . USERS_TABLE . ' + WHERE user_type <> ' . USER_IGNORE . " + AND user_email <> ''"; + $result = $db->sql_query($sql); + + $i = 0; + while ($row = $db->sql_fetchrow($result)) + { + // Snapshot of the phpbb_email_hash() function + // We cannot call it directly because the auto updater updates the DB first. :/ + $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); + + if ($user_email_hash != $row['user_email_hash']) + { + $sql_ary = array( + 'user_email_hash' => $user_email_hash, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (int) $row['user_id']; + _sql($sql, $errored, $error_ary, ($i % 100 == 0)); + + ++$i; + } + } + $db->sql_freeresult($result); + + $no_updates = false; + + break; + + // No changes from 3.0.7-RC2 to 3.0.7 + case '3.0.7-RC2': + break; + + // No changes from 3.0.7 to 3.0.7-PL1 + case '3.0.7': + break; + + // Changes from 3.0.7-PL1 to 3.0.8-RC1 + case '3.0.7-PL1': + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + + // The language strings we need are either in language/.../acp/attachments.php + // in the update package if we're updating to 3.0.8-RC1 or later, + // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. + // On an already updated board, they can also already be in language/.../acp/attachments.php + // in the board root. + $lang_files = array( + "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", + "{$phpbb_root_path}language/$lang_dir/install.$phpEx", + "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", + ); + + foreach ($lang_files as $lang_file) + { + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; + _sql($sql, $errored, $error_ary); + + $extension_groups_updated[$lang_key] = true; + } + } + } + $db->sql_freeresult($result); + + // Install modules + $modules_to_install = array( + 'post' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_POST_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_MESSAGES', + 'after' => array('message', 'ACP_MESSAGE_SETTINGS') + ), + ); + + _add_modules($modules_to_install); + + // update + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'avatar\''; + _sql($sql, $errored, $error_ary); + + // add Bing Bot + $bot_name = 'Bing [Bot]'; + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; + $result = $db->sql_query($sql); + $bing_already_added = (bool) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); + + if (!$bing_already_added) + { + $bot_agent = 'bingbot/'; + $bot_ip = ''; + $sql = 'SELECT group_id, group_colour + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $db->sql_query($sql); + $group_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$group_row) + { + // default fallback, should never get here + $group_row['group_id'] = 6; + $group_row['group_colour'] = '9E8DA7'; + } + + if (!function_exists('user_add')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_row['group_id'], + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => $config['default_lang'], + 'user_style' => $config['default_style'], + 'user_timezone' => 'UTC', + 'user_dateformat' => $config['default_dateformat'], + 'user_allow_massemail' => 0, + ); + + $user_id = user_add($user_row); + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )); + + _sql($sql, $errored, $error_ary); + } + // end Bing Bot addition + + // Delete shadow topics pointing to not existing topics + $batch_size = 500; + + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + do + { + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', + ), + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + } + } + while (sizeof($topic_ids) == $batch_size); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + // Unread posts search load switch + set_config('load_unreads_search', '1'); + + // Reduce queue interval to 60 seconds, email package size to 20 + if ($config['queue_interval'] == 600) + { + set_config('queue_interval', '60'); + } + + if ($config['email_package_size'] == 50) + { + set_config('email_package_size', '20'); + } + + $no_updates = false; + break; + + // No changes from 3.0.8-RC1 to 3.0.8 + case '3.0.8-RC1': + break; + + // Changes from 3.0.8 to 3.0.9-RC1 + case '3.0.8': + set_config('ip_login_limit_max', '50'); + set_config('ip_login_limit_time', '21600'); + set_config('ip_login_limit_use_forwarded', '0'); + + // Update file extension group names to use language strings, again. + $sql = 'SELECT group_id, group_name + FROM ' . EXTENSION_GROUPS_TABLE . ' + WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $sql_ary = array( + 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE group_id = ' . $row['group_id']; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + global $db_tools, $table_prefix; + + // Recover from potentially broken Q&A CAPTCHA table on firebird + // Q&A CAPTCHA was uninstallable, so it's safe to remove these + // without data loss + if ($db_tools->sql_layer == 'firebird') + { + $tables = array( + $table_prefix . 'captcha_questions', + $table_prefix . 'captcha_answers', + $table_prefix . 'qa_confirm', + ); + foreach ($tables as $table) + { + if ($db_tools->sql_table_exists($table)) + { + $db_tools->sql_table_drop($table); + } + } + } + + $no_updates = false; + break; + + // No changes from 3.0.9-RC1 to 3.0.9-RC2 + case '3.0.9-RC1': + break; + + // No changes from 3.0.9-RC2 to 3.0.9-RC3 + case '3.0.9-RC2': + break; + + // No changes from 3.0.9-RC3 to 3.0.9-RC4 + case '3.0.9-RC3': + break; + + // No changes from 3.0.9-RC4 to 3.0.9 + case '3.0.9-RC4': + break; + + // Changes from 3.0.9 to 3.0.10-RC1 + case '3.0.9': + if (!isset($config['email_max_chunk_size'])) + { + set_config('email_max_chunk_size', '50'); + } + + $no_updates = false; + break; + + // No changes from 3.0.10-RC1 to 3.0.10-RC2 + case '3.0.10-RC1': + break; + + // No changes from 3.0.10-RC2 to 3.0.10-RC3 + case '3.0.10-RC2': + break; + + // No changes from 3.0.10-RC3 to 3.0.10 + case '3.0.10-RC3': + break; + + // Changes from 3.0.10 to 3.0.11-RC1 + case '3.0.10': + // Updates users having current style a deactivated one + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_active = 0'; + $result = $db->sql_query($sql); + + $deactivated_style_ids = array(); + while ($style_id = $db->sql_fetchfield('style_id', false, $result)) + { + $deactivated_style_ids[] = (int) $style_id; + } + $db->sql_freeresult($result); + + if (!empty($deactivated_style_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $config['default_style'] .' + WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); + _sql($sql, $errored, $error_ary); + } + + // Delete orphan private messages + $batch_size = 500; + + $sql_array = array( + 'SELECT' => 'p.msg_id', + 'FROM' => array( + PRIVMSGS_TABLE => 'p', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), + 'ON' => 'p.msg_id = t.msg_id', + ), + ), + 'WHERE' => 't.user_id IS NULL', + ); + $sql = $db->sql_build_query('SELECT', $sql_array); + + do + { + $result = $db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $db->sql_fetchrow($result)) + { + $delete_pms[] = (int) $row['msg_id']; + } + $db->sql_freeresult($result); + + if (!empty($delete_pms)) + { + $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' + WHERE ' . $db->sql_in_set('msg_id', $delete_pms); + _sql($sql, $errored, $error_ary); + } + } + while (sizeof($delete_pms) == $batch_size); + + $no_updates = false; + break; + + // No changes from 3.0.11-RC1 to 3.0.11-RC2 + case '3.0.11-RC1': + break; + + // No changes from 3.0.11-RC2 to 3.0.11 + case '3.0.11-RC2': + break; + + // Changes from 3.0.11 to 3.0.12-RC1 + case '3.0.11': + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_u_sig\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'signature\''; + _sql($sql, $errored, $error_ary); + + // Update bots + if (!function_exists('user_delete')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + $bots_updates = array( + // Bot Deletions + 'NG-Search [Bot]' => false, + 'Nutch/CVS [Bot]' => false, + 'OmniExplorer [Bot]' => false, + 'Seekport [Bot]' => false, + 'Synoo [Bot]' => false, + 'WiseNut [Bot]' => false, + + // Bot Updates + // Bot name to bot user agent map + 'Baidu [Spider]' => 'Baiduspider', + 'Exabot [Bot]' => 'Exabot', + 'Voyager [Bot]' => 'voyager/', + 'W3C [Validator]' => 'W3C_Validator', + ); + + foreach ($bots_updates as $bot_name => $bot_agent) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_type = ' . USER_IGNORE . " + AND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'"; + $result = $db->sql_query($sql); + $bot_user_id = (int) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); + + if ($bot_user_id) + { + if ($bot_agent === false) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE user_id = $bot_user_id"; + _sql($sql, $errored, $error_ary); + + user_delete('remove', $bot_user_id); + } + else + { + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $db->sql_escape($bot_agent) . "' + WHERE user_id = $bot_user_id"; + _sql($sql, $errored, $error_ary); + } + } + } + + $no_updates = false; + break; + // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': From ced035788b0654614e07f483bf4b6f9f9ea4eac2 Mon Sep 17 00:00:00 2001 From: David King <imkingdavid@gmail.com> Date: Mon, 12 Nov 2012 16:41:02 -0500 Subject: [PATCH 029/174] [feature/migrations] Update phpbb_db_migration class for PHP 5.3.3 PHPBB3-9737 --- phpBB/includes/db/migration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index 1acef2d429..fb030ded44 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -24,7 +24,7 @@ if (!defined('IN_PHPBB')) * * @package db */ -class phpbb_db_migration +abstract class phpbb_db_migration { protected $config; protected $db; @@ -88,7 +88,7 @@ class phpbb_db_migration */ protected function sql_query($sql) { - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "<br />\n{$sql}\n<br />"; } From 61debcf14ca14afbb503b2535ef392a75002e8ae Mon Sep 17 00:00:00 2001 From: David King <imkingdavid@gmail.com> Date: Mon, 12 Nov 2012 16:46:19 -0500 Subject: [PATCH 030/174] [feature/migrations] Update phpbb_db_migrator class for PHP 5.3.3 PHPBB3-9737 --- phpBB/includes/db/migrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index c9590fccf6..216faf9866 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -40,7 +40,7 @@ class phpbb_db_migrator * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies */ - public function phpbb_db_migrator(\Symfony\Component\DependencyInjection\ContainerInterface $container, $migrations) + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $migrations) { $this->container = $container; $this->db = $this->container->get('dbal.conn'); From 826607a40509d40ba5a85e5b0bc72a54f77d41d6 Mon Sep 17 00:00:00 2001 From: David King <imkingdavid@gmail.com> Date: Mon, 12 Nov 2012 16:54:10 -0500 Subject: [PATCH 031/174] [feature/migrations] Add method and property visibility, use __construct() PHPBB3-9737 --- phpBB/includes/db/migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration.php index fb030ded44..10f7b71551 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration.php @@ -41,7 +41,7 @@ abstract class phpbb_db_migration * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies */ - public function phpbb_db_migration(\Symfony\Component\DependencyInjection\ContainerInterface $container) + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container) { $this->config = $this->container->get('config'); $this->db = $this->container->get('dbal.conn'); From 5c91e2569cb3a400acd20bf06cc0e609dd63a778 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 8 Jan 2013 22:09:14 -0600 Subject: [PATCH 032/174] [feature/migrations] Migrations now somewhat works PHPBB3-9737 --- phpBB/config/migrator.yml | 49 + phpBB/config/services.yml | 40 +- phpBB/config/tables.yml | 1 + phpBB/develop/create_schema_files.php | 4 +- phpBB/includes/db/driver/mysqli.php | 1 + .../includes/db/migration/data/3_0_11_rc1.php | 2 +- .../includes/db/migration/data/3_0_12_rc1.php | 101 +- .../includes/db/migration/data/3_0_3_rc1.php | 6 +- phpBB/includes/db/migration/data/3_0_4.php | 2 +- .../includes/db/migration/data/3_0_4_rc1.php | 4 +- .../includes/db/migration/data/3_0_5_rc1.php | 8 +- .../includes/db/migration/data/3_0_6_rc1.php | 60 +- .../includes/db/migration/data/3_0_7_rc2.php | 2 +- .../includes/db/migration/data/3_0_8_rc1.php | 10 +- .../includes/db/migration/data/3_0_9_rc1.php | 2 +- .../includes/db/migration/data/3_1_0_dev.php | 100 +- .../includes/db/migration/data/extensions.php | 3 +- .../db/migration/data/style_update_p1.php | 62 +- .../db/migration/data/style_update_p2.php | 43 +- phpBB/includes/db/migration/data/timezone.php | 5 +- phpBB/includes/db/migration/exception.php | 40 + .../includes/db/{ => migration}/migration.php | 33 +- .../db/migration/{tools => tool}/config.php | 14 +- .../includes/db/migration/tool/interface.php | 18 + .../db/migration/{tools => tool}/module.php | 66 +- .../migration/{tools => tool}/permission.php | 124 +- phpBB/includes/db/migration/tools/umil.php | 3037 ----------------- phpBB/includes/db/migrator.php | 109 +- phpBB/includes/functions.php | 3 +- phpBB/install/database_update.php | 65 +- phpBB/install/schemas/firebird_schema.sql | 29 +- phpBB/install/schemas/mssql_schema.sql | 42 +- phpBB/install/schemas/mysql_40_schema.sql | 26 +- phpBB/install/schemas/mysql_41_schema.sql | 26 +- phpBB/install/schemas/oracle_schema.sql | 32 +- phpBB/install/schemas/postgres_schema.sql | 30 +- phpBB/install/schemas/sqlite_schema.sql | 28 +- phpBB/test.php | 121 + tests/dbal/fixtures/migrator_module.xml | 42 + tests/dbal/fixtures/migrator_permission.xml | 31 + tests/dbal/migrator_test.php | 12 +- tests/dbal/migrator_tool_config_test.php | 97 + tests/dbal/migrator_tool_module.php | 128 + tests/dbal/migrator_tool_permission.php | 136 + 44 files changed, 1375 insertions(+), 3419 deletions(-) create mode 100644 phpBB/config/migrator.yml create mode 100644 phpBB/includes/db/migration/exception.php rename phpBB/includes/db/{ => migration}/migration.php (73%) rename phpBB/includes/db/migration/{tools => tool}/config.php (91%) create mode 100644 phpBB/includes/db/migration/tool/interface.php rename phpBB/includes/db/migration/{tools => tool}/module.php (88%) rename phpBB/includes/db/migration/{tools => tool}/permission.php (78%) delete mode 100644 phpBB/includes/db/migration/tools/umil.php create mode 100644 phpBB/test.php create mode 100644 tests/dbal/fixtures/migrator_module.xml create mode 100644 tests/dbal/fixtures/migrator_permission.xml create mode 100644 tests/dbal/migrator_tool_config_test.php create mode 100644 tests/dbal/migrator_tool_module.php create mode 100644 tests/dbal/migrator_tool_permission.php diff --git a/phpBB/config/migrator.yml b/phpBB/config/migrator.yml new file mode 100644 index 0000000000..999a2d41a3 --- /dev/null +++ b/phpBB/config/migrator.yml @@ -0,0 +1,49 @@ +services: + migrator: + class: phpbb_db_migrator + arguments: + - @config + - @dbal.conn + - @dbal.tools + - %tables.migrations% + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + - @migrator.tool_collection + + migrator.tool_collection: + class: phpbb_di_service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: migrator.tool } + + migrator.tool.config: + class: phpbb_db_migration_tool_config + arguments: + - @config + tags: + - { name: migrator.tool } + + migrator.tool.module: + class: phpbb_db_migration_tool_module + arguments: + - @dbal.conn + - @cache + - @user + - %core.root_path% + - %core.php_ext% + - %tables.modules% + tags: + - { name: migrator.tool } + + migrator.tool.permission: + class: phpbb_db_migration_tool_permission + arguments: + - @dbal.conn + - @cache + - @auth + - %core.root_path% + - %core.php_ext% + tags: + - { name: migrator.tool } diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4125491dd0..ee52ca2800 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -1,6 +1,7 @@ imports: - { resource: tables.yml } - { resource: cron_tasks.yml } + - { resource: migrator.yml } services: auth: @@ -162,45 +163,6 @@ services: tags: - { name: kernel.event_subscriber } - migrator: - class: phpbb_db_migrator - arguments: - - @service_container - - migrator.tools_collection - class: phpbb_di_service_collection - arguments: - - @service_container - - migrator.tools.config: - class: phpbb_db_migration_tools_config - arguments: - - @config - tags: - - { name: migrator:tool } - - migrator.tools.module: - class: phpbb_db_migration_tools_module - arguments: - - @db - - @cache - - @user - - %core.root_path% - - %core.php_ext% - tags: - - { name: migrator:tool } - - migrator.tools.permission: - class: phpbb_db_migration_tools_permission - arguments: - - @db - - @cache - - @auth - - %core.root_path% - - %core.php_ext% - tags: - - { name: migrator:tool } - request: class: phpbb_request diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index a9414cf66c..dd53417b1c 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -2,3 +2,4 @@ parameters: tables.config: %core.table_prefix%config tables.ext: %core.table_prefix%ext tables.migrations: %core.table_prefix%migrations + tables.modules: %core.table_prefix%modules diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 1abafb3b6d..b37dcc246f 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1258,7 +1258,7 @@ function get_schema_struct() ), ); - $schema_data['phpbb_migrations'] = array( + $schema_data['phpbb_moderator_cache'] = array( 'COLUMNS' => array( 'forum_id' => array('UINT', 0), 'user_id' => array('UINT', 0), @@ -1273,7 +1273,7 @@ function get_schema_struct() ), ); - $schema_data['phpbb_moderator_cache'] = array( + $schema_data['phpbb_migrations'] = array( 'COLUMNS' => array( 'migration_name' => array('VCHAR', ''), 'migration_schema_done' => array('BOOL', 0), diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/includes/db/driver/mysqli.php index 7448bf1670..94921a22b7 100644 --- a/phpBB/includes/db/driver/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -24,6 +24,7 @@ if (!defined('IN_PHPBB')) class phpbb_db_driver_mysqli extends phpbb_db_driver { var $multi_insert = true; + var $connect_error = ''; /** diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 1509120f68..daf106accf 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -80,7 +80,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration { $delete_pms[] = (int) $row['msg_id']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (!empty($delete_pms)) { diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index e5ff8c5814..0d8702f19e 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -9,24 +9,115 @@ /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/ -/* class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { - function depends_on() + public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } - function update_schema() + public function update_schema() { return array(); } - function update_data() + public function update_data() { return array( + array('custom', array(array(&$this, 'update_module_auth'))), + array('custom', array(array(&$this, 'update_bots'))), + array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))), + array('config.update', array('version', '3.0.12-rc1')), ); } + + public function disable_bots_from_receiving_pms() + { + // Disable receiving pms for bots + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $this->db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids); + $this->sql_query($sql); + } + } + + public function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_u_sig\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'signature\''; + $this->sql_query($sql); + } + + public function update_bots() + { + // Update bots + if (!function_exists('user_delete')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $bots_updates = array( + // Bot Deletions + 'NG-Search [Bot]' => false, + 'Nutch/CVS [Bot]' => false, + 'OmniExplorer [Bot]' => false, + 'Seekport [Bot]' => false, + 'Synoo [Bot]' => false, + 'WiseNut [Bot]' => false, + + // Bot Updates + // Bot name to bot user agent map + 'Baidu [Spider]' => 'Baiduspider', + 'Exabot [Bot]' => 'Exabot', + 'Voyager [Bot]' => 'voyager/', + 'W3C [Validator]' => 'W3C_Validator', + ); + + foreach ($bots_updates as $bot_name => $bot_agent) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_type = ' . USER_IGNORE . " + AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; + $result = $this->db->sql_query($sql); + $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if ($bot_user_id) + { + if ($bot_agent === false) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + + user_delete('remove', $bot_user_id); + } + else + { + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + } + } + } + } } -*/ \ No newline at end of file diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index d5c110eb7d..2320c4ac4b 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -36,12 +36,12 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration array('config.add', array('queue_trigger_posts', '3')), array('config.add', array('pm_max_recipients', '0')), array('custom', array(array(&$this, 'set_group_default_max_recipients'))), - array('config.add', array('dbms_version', '')), - array('permission.add', array('u_masspm_group', phpbb_auth::IS_GLOBAL), + array('config.add', array('dbms_version', $this->db->sql_server_info(true))), + array('permission.add', array('u_masspm_group', true, 'u_masspm')), array('custom', array(array(&$this, 'correct_acp_email_permissions'))), array('config.update', array('version', '3.0.3-rc1')), - )); + ); } function correct_acp_email_permissions() diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index 4965ac38d0..1af4508331 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -30,7 +30,7 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration function rename_log_delete_topic() { - if ($db->sql_layer == 'oracle') + if ($this->db->sql_layer == 'oracle') { // log_operation is CLOB - but we can change this later $sql = 'UPDATE ' . $this->table_prefix . "log diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index 2964dcebc9..e9bb0e01f5 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -69,7 +69,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration // Update the Custom Profile Fields based on previous settings to the new format $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide FROM ' . PROFILE_FIELDS_TABLE; - $result = $this->sql_query($sql); + $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -101,5 +101,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); } + + $this->db->sql_freeresult($result); } } diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php index 9205f0d5f8..cbf28c0be6 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -32,7 +32,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration return array( array('config.add', array('captcha_gd_wave', 0)), array('config.add', array('captcha_gd_3d_noise', 1)), - array('config.add', array('captcha_gd_refresh', 1)), + array('config.add', array('captcha_gd_fonts', 1)), array('config.add', array('confirm_refresh', 1)), array('config.add', array('max_num_search_keywords', 10)), array('config.remove', array('search_indexing_state')), @@ -47,7 +47,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration $sql = 'SELECT user_id, user_password FROM ' . $this->table_prefix . 'users WHERE user_pass_convert = 1'; - $result = $this->sql_query($sql); + $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -60,7 +60,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); } function update_ichiro_bot() @@ -99,7 +99,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration WHERE auth_option = '" . $db->sql_escape($option) . "' ORDER BY auth_option_id DESC"; // sql_query_limit not possible here, due to bug in postgresql layer - $result = $this->sql_query($sql); + $result = $this->db->sql_query($sql); // Skip first row, this is our original auth option we want to preserve $row = $this->db->sql_fetchrow($result); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index a868d70684..35adcf52be 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -35,7 +35,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration $this->table_prefix . 'reports' => array( 'pm_id' => array('UINT', 0), ), - $this->table_prefix . 'fields' => array( + $this->table_prefix . 'profile_fields' => array( 'field_show_on_vt' => array('BOOL', 0), ), $this->table_prefix . 'forums' => array( @@ -89,19 +89,19 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration array('config.add', array('allow_avatar', 0)), array('if', array( ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), - array('config.add', array('allow_avatar', 1)), + array('config.update', array('allow_avatar', 1)), )), array('config.add', array('allow_avatar_remote_upload', 0)), array('if', array( ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), - array('config.add', array('allow_avatar_remote_upload', 1)), + array('config.update', array('allow_avatar_remote_upload', 1)), )), array('module.add', array( 'acp', 'ACP_BOARD_CONFIGURATION', array( - 'module_basename' => 'board', + 'module_basename' => 'acp_board', 'modes' => array('feed'), ), )), @@ -109,7 +109,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration 'acp', 'ACP_CAT_USERS', array( - 'module_basename' => 'users', + 'module_basename' => 'acp_users', 'modes' => array('warnings'), ), )), @@ -117,7 +117,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration 'acp', 'ACP_SERVER_CONFIGURATION', array( - 'module_basename' => 'send_statistics', + 'module_basename' => 'acp_send_statistics', 'modes' => array('send_statistics'), ), )), @@ -125,7 +125,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration 'acp', 'ACP_FORUM_BASED_PERMISSIONS', array( - 'module_basename' => 'permissions', + 'module_basename' => 'acp_permissions', 'modes' => array('setting_forum_copy'), ), )), @@ -133,24 +133,8 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration 'mcp', 'MCP_REPORTS', array( - 'module_basename' => 'pm_reports', - 'modes' => array('pm_reports'), - ), - )), - array('module.add', array( - 'mcp', - 'MCP_REPORTS', - array( - 'module_basename' => 'pm_reports', - 'modes' => array('pm_reports_closed'), - ), - )), - array('module.add', array( - 'mcp', - 'MCP_REPORTS', - array( - 'module_basename' => 'pm_reports', - 'modes' => array('pm_report_details'), + 'module_basename' => 'mcp_pm_reports', + 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), ), )), array('custom', array(array(&$this, 'add_newly_registered_group'))), @@ -209,17 +193,14 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration $this->sql_query($sql); $u_role = $this->db->sql_nextid(); - if (!$errored) - { - // Now add the correct data to the roles... - // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - $this->sql_query($sql); + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + $this->sql_query($sql); - // Add user role to group - $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - $this->sql_query($sql); - } + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + $this->sql_query($sql); } // Insert new forum role @@ -246,11 +227,8 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration $this->sql_query($sql); $f_role = $this->db->sql_nextid(); - if (!$errored) - { - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - $this->sql_query($sql); - } + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + $this->sql_query($sql); } // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) @@ -294,7 +272,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration } // Clear permissions... - include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->phpEx); + include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); $auth_admin = new auth_admin(); $auth_admin->acl_clear_prefetch(); } diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index e043f35705..e2c6acce1e 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -59,7 +59,7 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration $this->sql_query($sql); } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if ($i < $limit) { diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index 3f51806fd9..b58b0966a5 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -30,7 +30,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration 'acp', 'ACP_MESSAGES', array( - 'module_basename' => 'board', + 'module_basename' => 'acp_board', 'modes' => array('post'), ), )), @@ -60,9 +60,9 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration // On an already updated board, they can also already be in language/.../acp/attachments.php // in the board root. $lang_files = array( - "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$this->phpEx", - "{$this->phpbb_root_path}language/$lang_dir/install.$this->phpEx", - "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.$this->phpEx", + "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}", ); foreach ($lang_files as $lang_file) @@ -140,7 +140,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration if (!function_exists('user_add')) { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); } $user_row = array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index 256426849c..ea49cdbba9 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -44,7 +44,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ), ), 'change_columns' => array( - $this->table_prefix . 'bbcode' => array( + $this->table_prefix . 'bbcodes' => array( 'bbcode_id' => array('USINT', 0), ), ), diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 987ab94646..6eb5a6ddee 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_extensions extends phpbb_db_migration +class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { public function depends_on() { @@ -78,6 +78,8 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration array('config.add', array('site_home_url', '')), array('config.add', array('site_home_text', '')), + array('permission.add', array('u_chgprofileinfo', true, 'u_sig')), + array('module.add', array( 'acp', 'ACP_GROUPS', @@ -103,7 +105,7 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration ), )), array('module.add', array( - 'acp', + 'ucp', 'UCP_PROFILE', array( 'module_basename' => 'ucp_profile', @@ -113,20 +115,104 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration array('module.remove', array( 'acp', - 'ACP_CAT_STYLES', - array( - 'module_basename' => 'styles', - 'modes' => array('imageset', 'theme', 'template'), - ), + false, + 'ACP_TEMPLATES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_THEMES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_IMAGESETS', )), array('custom', array(array($this, 'rename_module_basenames'))), + array('custom', array(array($this, 'rename_styles_module'))), array('custom', array(array($this, 'add_group_teampage'))), array('custom', array(array($this, 'update_group_legend'))), array('custom', array(array($this, 'localise_global_announcements'))), + array('custom', array(array($this, 'update_ucp_pm_basename'))), + array('custom', array(array($this, 'update_ucp_profile_auth'))), + array('custom', array(array($this, 'move_customise_modules'))), + + array('config.update', array('version', '3.1.0-dev')), ); } + public function move_customise_modules() + { + // Move language management to new location in the Customise tab + // First get language module id + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_language'"; + $result = $this->db->sql_query($sql); + $language_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $this->db->sql_query($sql); + $language_management_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + if (!class_exists('acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); + } + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); + } + + public function update_ucp_pm_basename() + { + $sql = 'SELECT module_id, module_basename + FROM ' . MODULES_TABLE . " + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM'"; + $result = $this->db->sql_query_limit($sql, 1); + + if ($row = $this->db->sql_fetchrow($result)) + { + // This update is still not applied. Applying it + + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; + + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } + + public function update_ucp_profile_auth() + { + // Update the auth setting for the module + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'acl_u_chgprofileinfo' + WHERE module_class = 'ucp' + AND module_basename = 'ucp_profile' + AND module_mode = 'profile_info'"; + $this->sql_query($sql); + } + + public function rename_styles_module() + { + // Rename styles module to Customise + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + $this->sql_query($sql); + } + public function rename_module_basenames() { // rename all module basenames to full classname diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index 85d5511ef0..d28e0ebabb 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -39,10 +39,11 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration 'acp', 'ACP_GENERAL_TASKS', array( - 'module_basename' => 'extensions', + 'module_basename' => 'acp_extensions', 'modes' => array('main'), ), )), + array('permission.add', array('a_extensions', true, 'a_styles')), ); } } diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index d570caae04..1c46e4147b 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -31,7 +31,7 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration // Get list of valid 3.1 styles $available_styles = array('prosilver'); - $iterator = new DirectoryIterator($phpbb_root_path . 'styles'); + $iterator = new DirectoryIterator($this->phpbb_root_path . 'styles'); $skip_dirs = array('.', '..', 'prosilver'); foreach ($iterator as $fileinfo) { @@ -91,9 +91,67 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration 'style_parent_id' => 0, 'style_parent_tree' => '', ); - $this->sql_query('UPDATE ' . STYLES_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary); + $this->sql_query('UPDATE ' . STYLES_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE style_id = ' . $style_row['style_id']); $valid_styles[] = (int) $style_row['style_id']; } } + + // Remove old entries from styles table + if (!sizeof($valid_styles)) + { + // No valid styles: remove everything and add prosilver + $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + + $sql_ary = array( + 'style_name' => 'prosilver', + 'style_copyright' => '© phpBB Group', + 'style_active' => 1, + 'style_path' => 'prosilver', + 'bbcode_bitfield' => 'kNg=', + 'style_parent_id' => 0, + 'style_parent_tree' => '', + + // Will be removed in the next step + 'imageset_id' => 0, + 'template_id' => 0, + 'theme_id' => 0, + ); + + $sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->sql_query($sql); + + $sql = 'SELECT style_id + FROM ' . $table . " + WHERE style_name = 'prosilver'"; + $result = $this->sql_query($sql); + $default_style = $this->db->sql_fetchfield($result); + $this->db->sql_freeresult($result); + + set_config('default_style', $default_style); + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + $this->sql_query($sql); + } + else + { + // There are valid styles in styles table. Remove styles that are outdated + $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' + WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true)); + + // Change default style + if (!in_array($this->config['default_style'], $valid_styles)) + { + $this->sql_query('UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $valid_styles[0] . "' + WHERE config_name = 'default_style'"); + } + + // Reset styles for users + $this->sql_query('UPDATE ' . USERS_TABLE . ' + SET user_style = 0 + WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true)); + } } } diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index 2c0991de59..db4b7f1753 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -37,47 +37,6 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration public function update_data() { - return array( - array('custom', array(array($this, 'styles_update'))), - ); - } - - public function styles_update() - { - // Remove old entries from styles table - if (!sizeof($valid_styles)) - { - // No valid styles: remove everything and add prosilver - $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - - $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; - $this->sql_query($sql); - - $sql = 'SELECT style_id - FROM ' . $table . " - WHERE style_name = 'prosilver'"; - $result = $this->sql_query($sql); - $default_style = $this->db->sql_fetchfield($result); - $this->db->sql_freeresult($result); - - set_config('default_style', $default_style); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; - $this->sql_query($sql); - } - else - { - // There are valid styles in styles table. Remove styles that are outdated - $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true), $errored, $error_ary); - - // Change default style - if (!in_array($config['default_style'], $valid_styles)) - { - set_config('default_style', $valid_styles[0]); - } - - // Reset styles for users - $this->sql_query('UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true), $errored, $error_ary); - } + return array(); } } diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 89fafbad28..7734ed4b76 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -51,7 +51,10 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration $this->db->sql_freeresult($result); // Update board default timezone - set_config('board_timezone', $this->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' + WHERE config_name = 'board_timezone'"; + $this->sql_query($sql); // After we have calculated the timezones we can delete user_dst column from user table. $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php new file mode 100644 index 0000000000..19fb39ab23 --- /dev/null +++ b/phpBB/includes/db/migration/exception.php @@ -0,0 +1,40 @@ +<?php +/** +* +* @package db +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* The migrator is responsible for applying new migrations in the correct order. +* +* @package db +*/ +class phpbb_db_migration_exception extends \Exception +{ + protected $parameters; + + public function __construct() + { + $parameters = func_get_args(); + $message = array_shift($parameters); + parent::__construct($message); + + $this->parameters = $parameters; + } + + public function __toString() + { + return $this->message . ': ' . var_export($this->parameters, true); + } +} diff --git a/phpBB/includes/db/migration.php b/phpBB/includes/db/migration/migration.php similarity index 73% rename from phpBB/includes/db/migration.php rename to phpBB/includes/db/migration/migration.php index 10f7b71551..c2c6da855b 100644 --- a/phpBB/includes/db/migration.php +++ b/phpBB/includes/db/migration/migration.php @@ -36,20 +36,20 @@ abstract class phpbb_db_migration protected $errors; + private $queries = array(); + /** * Migration constructor - * - * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies */ - public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container) + public function __construct($config, phpbb_db_driver $db, $db_tools, $phpbb_root_path, $php_ext, $table_prefix) { - $this->config = $this->container->get('config'); - $this->db = $this->container->get('dbal.conn'); - $this->db_tools = $this->container->get('dbal.tools'); - $this->table_prefix = $this->container->getParameters('core.table_prefix'); + $this->config = $config; + $this->db = $db; + $this->db_tools = $db_tools; + $this->table_prefix = $table_prefix; - $this->phpbb_root_path = $this->container->getParameters('core.root_path'); - $this->php_ext = $this->container->getParameters('core.php_ext'); + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; $this->errors = array(); } @@ -88,10 +88,7 @@ abstract class phpbb_db_migration */ protected function sql_query($sql) { - if (defined('DEBUG')) - { - echo "<br />\n{$sql}\n<br />"; - } + $this->queries[] = $sql; $this->db->sql_return_on_error(true); @@ -119,4 +116,14 @@ abstract class phpbb_db_migration return $result; } + + /** + * Get the list of queries run + * + * @return array + */ + public function get_queries() + { + return $this->queries; + } } diff --git a/phpBB/includes/db/migration/tools/config.php b/phpBB/includes/db/migration/tool/config.php similarity index 91% rename from phpBB/includes/db/migration/tools/config.php rename to phpBB/includes/db/migration/tool/config.php index 2d58c8093c..35fa3ce566 100644 --- a/phpBB/includes/db/migration/tools/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_tools_config +class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interface { /** @var phpbb_config */ protected $config = null; @@ -17,6 +17,14 @@ class phpbb_db_migration_tools_config $this->config = $config; } + /** + * {@inheritdoc} + */ + public function get_name() + { + return 'config'; + } + /** * Config Add * @@ -33,7 +41,7 @@ class phpbb_db_migration_tools_config throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name); } - $this->config->set($config_name, $config_value, $is_dynamic); + $this->config->set($config_name, $config_value, !$is_dynamic); return false; } @@ -97,4 +105,4 @@ class phpbb_db_migration_tools_config return false; } -} \ No newline at end of file +} diff --git a/phpBB/includes/db/migration/tool/interface.php b/phpBB/includes/db/migration/tool/interface.php new file mode 100644 index 0000000000..1815f5e8a2 --- /dev/null +++ b/phpBB/includes/db/migration/tool/interface.php @@ -0,0 +1,18 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +interface phpbb_db_migration_tool_interface +{ + /** + * Retrieve a short name used for commands in migrations. + * + * @return string short name + */ + public function get_name(); +} diff --git a/phpBB/includes/db/migration/tools/module.php b/phpBB/includes/db/migration/tool/module.php similarity index 88% rename from phpBB/includes/db/migration/tools/module.php rename to phpBB/includes/db/migration/tool/module.php index e17197d73e..a503f08c01 100644 --- a/phpBB/includes/db/migration/tools/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_tools_module +class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interface { /** @var phpbb_cache_service */ protected $cache = null; @@ -24,13 +24,25 @@ class phpbb_db_migration_tools_module /** @var string */ protected $php_ext = null; - public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $user, $phpbb_root_path, $php_ext) + /** @var string */ + protected $modules_table = null; + + public function __construct(phpbb_db_driver $db, $cache, $user, $phpbb_root_path, $php_ext, $modules_table) { $this->db = $db; $this->cache = $cache; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->modules_table = $modules_table; + } + + /** + * {@inheritdoc} + */ + public function get_name() + { + return 'module'; } /** @@ -63,7 +75,8 @@ class phpbb_db_migration_tools_module if (!is_numeric($parent)) { - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + $sql = 'SELECT module_id + FROM ' . $this->modules_table . " WHERE module_langname = '" . $this->db->sql_escape($parent) . "' AND module_class = '$class'"; $result = $this->db->sql_query($sql); @@ -83,7 +96,8 @@ class phpbb_db_migration_tools_module } } - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + $sql = 'SELECT module_id + FROM ' . $this->modules_table . " WHERE module_class = '$class' $parent_sql AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '$module'"); @@ -149,15 +163,15 @@ class phpbb_db_migration_tools_module $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; $basename = str_replace(array('/', '\\'), '', $basename); $class = str_replace(array('/', '\\'), '', $class); - $info_file = "$class/info/{$class}_$basename.{$this->php_ext}"; + $info_file = "$class/info/$basename.{$this->php_ext}"; // The manual and automatic ways both failed... if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) { - throw new phpbb_db_migration_exception('MODULE_ADD', $class, $info_file); + throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $info_file); } - $classname = "{$class}_{$basename}_info"; + $classname = "{$basename}_info"; if (!class_exists($classname)) { @@ -198,7 +212,8 @@ class phpbb_db_migration_tools_module if (!is_numeric($parent)) { - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + $sql = 'SELECT module_id + FROM ' . $this->modules_table . " WHERE module_langname = '" . $this->db->sql_escape($parent) . "' AND module_class = '$class'"; $result = $this->db->sql_query($sql); @@ -254,40 +269,46 @@ class phpbb_db_migration_tools_module // Move the module if requested above/below an existing one if (isset($data['before']) && $data['before']) { - $sql = 'SELECT left_id FROM ' . MODULES_TABLE . ' + $sql = 'SELECT left_id + FROM ' . $this->modules_table . ' WHERE module_class = \'' . $class . '\' AND parent_id = ' . (int) $parent . ' AND module_langname = \'' . $this->db->sql_escape($data['before']) . '\''; $this->db->sql_query($sql); $to_left = $this->db->sql_fetchfield('left_id'); - $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 + $sql = 'UPDATE ' . $this->modules_table . " + SET left_id = left_id + 2, right_id = right_id + 2 WHERE module_class = '$class' AND left_id >= $to_left AND left_id < {$module_data['left_id']}"; $this->db->sql_query($sql); - $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = $to_left, right_id = " . ($to_left + 1) . " + $sql = 'UPDATE ' . $this->modules_table . " + SET left_id = $to_left, right_id = " . ($to_left + 1) . " WHERE module_class = '$class' AND module_id = {$module_data['module_id']}"; $this->db->sql_query($sql); } else if (isset($data['after']) && $data['after']) { - $sql = 'SELECT right_id FROM ' . MODULES_TABLE . ' + $sql = 'SELECT right_id + FROM ' . $this->modules_table . ' WHERE module_class = \'' . $class . '\' AND parent_id = ' . (int) $parent . ' AND module_langname = \'' . $this->db->sql_escape($data['after']) . '\''; $this->db->sql_query($sql); $to_right = $this->db->sql_fetchfield('right_id'); - $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 + $sql = 'UPDATE ' . $this->modules_table . " + SET left_id = left_id + 2, right_id = right_id + 2 WHERE module_class = '$class' AND left_id >= $to_right AND left_id < {$module_data['left_id']}"; $this->db->sql_query($sql); - $sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " + $sql = 'UPDATE ' . $this->modules_table . ' + SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " WHERE module_class = '$class' AND module_id = {$module_data['module_id']}"; $this->db->sql_query($sql); @@ -330,14 +351,14 @@ class phpbb_db_migration_tools_module // Automatic method $basename = str_replace(array('/', '\\'), '', $module['module_basename']); $class = str_replace(array('/', '\\'), '', $class); - $info_file = "$class/info/{$class}_$basename.{$this->php_ext}"; + $info_file = "$class/info/$basename.{$this->php_ext}"; if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) { throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $info_file); } - $classname = "{$class}_{$basename}_info"; + $classname = "{$basename}_info"; if (!class_exists($classname)) { @@ -374,7 +395,8 @@ class phpbb_db_migration_tools_module if (!is_numeric($parent)) { - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + $sql = 'SELECT module_id + FROM ' . $this->modules_table . " WHERE module_langname = '" . $this->db->sql_escape($parent) . "' AND module_class = '$class'"; $result = $this->db->sql_query($sql); @@ -394,7 +416,8 @@ class phpbb_db_migration_tools_module if (!is_numeric($module)) { $module = $this->db->sql_escape($module); - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + $sql = 'SELECT module_id + FROM ' . $this->modules_table . " WHERE module_langname = '$module' AND module_class = '$class' $parent_sql"; @@ -410,7 +433,8 @@ class phpbb_db_migration_tools_module else { $module = (int) $module; - $sql = 'SELECT module_langname FROM ' . MODULES_TABLE . " + $sql = 'SELECT module_langname + FROM ' . $this->modules_table . " WHERE module_id = $module AND module_class = '$class' $parent_sql"; @@ -439,9 +463,9 @@ class phpbb_db_migration_tools_module } } - $cache->destroy("_modules_$class"); + $this->cache->destroy("_modules_$class"); return false; } } -} \ No newline at end of file +} diff --git a/phpBB/includes/db/migration/tools/permission.php b/phpBB/includes/db/migration/tool/permission.php similarity index 78% rename from phpBB/includes/db/migration/tools/permission.php rename to phpBB/includes/db/migration/tool/permission.php index 7694bae0cb..ebe404bc62 100644 --- a/phpBB/includes/db/migration/tools/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base +class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_interface { /** @var phpbb_auth */ protected $auth = null; @@ -24,7 +24,7 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base /** @var string */ protected $php_ext = null; - public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext) + public function __construct(phpbb_db_driver $db, $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext) { $this->db = $db; $this->cache = $cache; @@ -33,6 +33,14 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base $this->php_ext = $php_ext; } + /** + * {@inheritdoc} + */ + public function get_name() + { + return 'permission'; + } + /** * Permission Exists * @@ -81,7 +89,7 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base * * @return result */ - public function add($auth_option, $global = true) + public function add($auth_option, $global = true, $copy_from = false) { if ($this->exists($auth_option, $global)) { @@ -105,8 +113,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base 'is_local' => 1, ); $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE auth_option = \'' . $this->db->sql_escape($auth_option) . "'"; + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'"; $this->db->sql_query($sql); } else @@ -121,6 +129,38 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base } } + // The permission has been added, now we can copy it if needed + if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) + { + $old_id = $auth_admin->acl_options['id'][$copy_from]; + $new_id = $auth_admin->acl_options['id'][$auth_option]; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = $this->db->sql_query($sql); + + $sql_ary = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $this->db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $this->db->sql_multi_insert($table, $sql_ary); + } + } + + $auth_admin->acl_clear_prefetch(); + } + return false; } @@ -149,7 +189,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base { $type_sql = ' AND is_local = 1'; } - $sql = 'SELECT auth_option_id, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . " + $sql = 'SELECT auth_option_id, is_global, is_local + FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" . $type_sql; $result = $this->db->sql_query($sql); @@ -190,8 +231,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base */ public function role_add($role_name, $role_type = '', $role_description = '') { - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = '" . $this->db->sql_escape($role_name) . "'"; $this->db->sql_query($sql); $role_id = $this->db->sql_fetchfield('role_id'); @@ -200,8 +242,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base throw new phpbb_db_migration_exception('ROLE_ALREADY_EXISTS', $old_role_name); } - $sql = 'SELECT MAX(role_order) AS max FROM ' . ACL_ROLES_TABLE . ' - WHERE role_type = \'' . $this->db->sql_escape($role_type) . '\''; + $sql = 'SELECT MAX(role_order) AS max + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = '" . $this->db->sql_escape($role_type) . "'"; $this->db->sql_query($sql); $role_order = $this->db->sql_fetchfield('max'); $role_order = (!$role_order) ? 1 : $role_order + 1; @@ -227,8 +270,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base */ public function role_update($old_role_name, $new_role_name = '') { - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'"; $this->db->sql_query($sql); $role_id = $this->db->sql_fetchfield('role_id'); @@ -237,9 +281,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base throw new phpbb_db_migration_exception('ROLE_NOT_EXISTS', $old_role_name); } - $sql = 'UPDATE ' . ACL_ROLES_TABLE . ' - SET role_name = \'' . $this->db->sql_escape($new_role_name) . '\' - WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; + $sql = 'UPDATE ' . ACL_ROLES_TABLE . " + SET role_name = '" . $this->db->sql_escape($new_role_name) . "' + WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'"; $this->db->sql_query($sql); return false; @@ -252,8 +296,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base */ public function role_remove($role_name) { - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = '" . $this->db->sql_escape($role_name) . "'"; $this->db->sql_query($sql); $role_id = $this->db->sql_fetchfield('role_id'); @@ -293,7 +338,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base } $new_auth = array(); - $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . ' WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -314,8 +360,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base switch ($type) { case 'role' : - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); $role_id = $this->db->sql_fetchfield('role_id'); @@ -324,7 +371,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name); } - $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' + $sql = 'SELECT auth_option_id, auth_setting + FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE role_id = ' . $role_id; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -335,7 +383,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base break; case 'group' : - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); $group_id = $this->db->sql_fetchfield('group_id'); @@ -345,7 +395,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base } // If the group has a role set for them we will add the requested permissions to that role. - $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' + $sql = 'SELECT auth_role_id + FROM ' . ACL_GROUPS_TABLE . ' WHERE group_id = ' . $group_id . ' AND auth_role_id <> 0 AND forum_id = 0'; @@ -353,7 +404,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base $role_id = $this->db->sql_fetchfield('auth_role_id'); if ($role_id) { - $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' + $sql = 'SELECT role_name + FROM ' . ACL_ROLES_TABLE . ' WHERE role_id = ' . $role_id; $this->db->sql_query($sql); $role_name = $this->db->sql_fetchfield('role_name'); @@ -361,7 +413,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base return $this->set($role_name, $auth_option, 'role', $has_permission); } - $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_GROUPS_TABLE . ' + $sql = 'SELECT auth_option_id, auth_setting + FROM ' . ACL_GROUPS_TABLE . ' WHERE group_id = ' . $group_id; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -430,7 +483,8 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base } $to_remove = array(); - $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . ' WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -449,8 +503,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base switch ($type) { case 'role' : - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); $role_id = $this->db->sql_fetchfield('role_id'); @@ -465,8 +520,9 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base break; case 'group' : - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' - WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); $group_id = $this->db->sql_fetchfield('group_id'); @@ -476,14 +532,16 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base } // If the group has a role set for them we will remove the requested permissions from that role. - $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' + $sql = 'SELECT auth_role_id + FROM ' . ACL_GROUPS_TABLE . ' WHERE group_id = ' . $group_id . ' AND auth_role_id <> 0'; $this->db->sql_query($sql); $role_id = $this->db->sql_fetchfield('auth_role_id'); if ($role_id) { - $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' + $sql = 'SELECT role_name + FROM ' . ACL_ROLES_TABLE . ' WHERE role_id = ' . $role_id; $this->db->sql_query($sql); $role_name = $this->db->sql_fetchfield('role_name'); @@ -501,4 +559,4 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base return false; } -} \ No newline at end of file +} diff --git a/phpBB/includes/db/migration/tools/umil.php b/phpBB/includes/db/migration/tools/umil.php deleted file mode 100644 index ce7b8ff3be..0000000000 --- a/phpBB/includes/db/migration/tools/umil.php +++ /dev/null @@ -1,3037 +0,0 @@ -<?php -/** - * - * @author Nathan Guse (EXreaction) http://lithiumstudios.org - * @author David Lewis (Highway of Life) highwayoflife@gmail.com - * @package umil - * @version $Id$ - * @copyright (c) 2008 phpBB Group - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License - * - */ - -/** - * @ignore - */ -if (!defined('IN_PHPBB')) -{ - exit; -} - -define('UMIL_VERSION', '1.0.4'); - -/** -* Multicall instructions -* -* With the "multicall" (as I am calling it) you can make a single function call and have it repeat the actions multiple times on information sent from an array. -* -* To do this (it does not work on the _exists functions), all you must do is send the first variable in the function call as an array and for each item, send an array for each of the variables in order. -* -* Example: -* $umil->config_add(array( -* array('config_name', 'config_value'), -* array('config_name1', 'config_value1'), -* array('config_name2', 'config_value2', true), -* array('config_name3', 'config_value3', true), -* ); -*/ - -/** -* UMIL - Unified MOD Installation Library class -* -* Cache Functions -* cache_purge($type = '', $style_id = 0) -* -* Config Functions: -* config_exists($config_name, $return_result = false) -* config_add($config_name, $config_value = '', $is_dynamic = false) -* config_update($config_name, $config_value, $is_dynamic = false) -* config_remove($config_name) -* -* Module Functions -* module_exists($class, $parent, $module) -* module_add($class, $parent = 0, $data = array()) -* module_remove($class, $parent = 0, $module = '') -* -* Permissions/Auth Functions -* permission_exists($auth_option, $global = true) -* permission_add($auth_option, $global = true) -* permission_remove($auth_option, $global = true) -* permission_set($name, $auth_option = array(), $type = 'role', $global = true, $has_permission = true) -* permission_unset($name, $auth_option = array(), $type = 'role', $global = true) -* -* Table Functions -* table_exists($table_name) -* table_add($table_name, $table_data = array()) -* table_remove($table_name) -* -* Table Column Functions -* table_column_exists($table_name, $column_name) -* table_column_add($table_name, $column_name = '', $column_data = array()) -* table_column_update($table_name, $column_name = '', $column_data = array()) -* table_column_remove($table_name, $column_name = '') -* -* Table Key/Index Functions -* table_index_exists($table_name, $index_name) -* table_index_add($table_name, $index_name = '', $column = array()) -* table_index_remove($table_name, $index_name = '') -* -* Table Row Functions (note that these actions are not reversed automatically during uninstallation) -* table_row_insert($table_name, $data = array()) -* table_row_remove($table_name, $data = array()) -* table_row_update($table_name, $data = array(), $new_data = array()) -* -* Version Check Function -* version_check($url, $path, $file) -*/ -class umil -{ - /** - * This will hold the text output for the inputted command (if the mod author would like to display the command that was ran) - * - * @var string - */ - var $command = ''; - - /** - * This will hold the text output for the result of the command. $user->lang['SUCCESS'] if everything worked. - * - * @var string - */ - var $result = ''; - - /** - * Auto run $this->display_results after running a command - */ - var $auto_display_results = false; - - /** - * Stand Alone option (this makes it possible to just use the single umil file and not worry about any language stuff - */ - var $stand_alone = false; - - /** - * Were any new permissions added (used in umil_frontend)? - */ - var $permissions_added = false; - - /** - * Database Object - */ - var $db = false; - - /** - * Database Tools Object - */ - var $db_tools = false; - - /** - * Do we want a custom prefix besides the phpBB table prefix? You *probably* should not change this... - */ - var $table_prefix = false; - - /** - * Constructor - */ - function umil($stand_alone = false, $db = false) - { - // Setup $this->db - if ($db !== false) - { - if (!is_object($db) || !method_exists($db, 'sql_query')) - { - trigger_error('Invalid $db Object'); - } - - $this->db = $db; - } - else - { - global $db; - $this->db = $db; - } - - // Setup $this->db_tools - if (!class_exists('phpbb_db_tools')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); - } - $this->db_tools = new phpbb_db_tools($this->db); - - $this->stand_alone = $stand_alone; - - if (!$stand_alone) - { - global $config, $user, $phpbb_root_path, $phpEx; - - /* Does not have the fall back option to use en/ if the user's language file does not exist, so we will not use it...unless that is changed. - if (method_exists('user', 'set_custom_lang_path')) - { - $user->set_custom_lang_path($phpbb_root_path . 'umil/language/'); - $user->add_lang('umil'); - $user->set_custom_lang_path($phpbb_root_path . 'language/'); - } - else - {*/ - // Include the umil language file. First we check if the language file for the user's language is available, if not we check if the board's default language is available, if not we use the english file. - if (isset($user->data['user_lang']) && file_exists("{$phpbb_root_path}umil/language/{$user->data['user_lang']}/umil.$phpEx")) - { - $path = $user->data['user_lang']; - } - else if (file_exists("{$phpbb_root_path}umil/language/" . basename($config['default_lang']) . "/umil.$phpEx")) - { - $path = basename($config['default_lang']); - } - else if (file_exists("{$phpbb_root_path}umil/language/en/umil.$phpEx")) - { - $path = 'en'; - } - else - { - trigger_error('Language Files Missing.<br /><br />Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR); - } - - $user->add_lang('./../../umil/language/' . $path . '/umil'); - //} - - $user->add_lang(array('acp/common', 'acp/permissions')); - - // Check to see if a newer version is available. - $info = $this->version_check('version.phpbb.com', '/umil', ((defined('PHPBB_QA')) ? 'umil_qa.txt' : 'umil.txt')); - if (is_array($info) && isset($info[0]) && isset($info[1])) - { - if (version_compare(UMIL_VERSION, $info[0], '<')) - { - global $template; - - // Make sure user->setup() has been called - if (empty($user->lang)) - { - $user->setup(); - } - - page_header('', false); - - $user->lang['UPDATE_UMIL'] = (isset($user->lang['UPDATE_UMIL'])) ? $user->lang['UPDATE_UMIL'] : 'This version of UMIL is outdated.<br /><br />Please download the latest UMIL (Unified MOD Install Library) from: <a href="%1$s">%1$s</a>'; - $template->assign_vars(array( - 'S_BOARD_DISABLED' => true, - 'L_BOARD_DISABLED' => sprintf($user->lang['UPDATE_UMIL'], $info[1]), - )); - } - } - } - } - - /** - * umil_start - * - * A function which runs (almost) every time a function here is ran - */ - function umil_start() - { - global $user; - - // Set up the command. This will get the arguments sent to the function. - $args = func_get_args(); - $this->command = call_user_func_array(array($this, 'get_output_text'), $args); - - $this->result = (isset($user->lang['SUCCESS'])) ? $user->lang['SUCCESS'] : 'SUCCESS'; - $this->db->sql_return_on_error(true); - - //$this->db->sql_transaction('begin'); - } - - /** - * umil_end - * - * A function which runs (almost) every time a function here is ran - */ - function umil_end() - { - global $user; - - // Set up the result. This will get the arguments sent to the function. - $args = func_get_args(); - $result = call_user_func_array(array($this, 'get_output_text'), $args); - $this->result = ($result) ? $result : $this->result; - - if ($this->db->sql_error_triggered) - { - if ($this->result == ((isset($user->lang['SUCCESS'])) ? $user->lang['SUCCESS'] : 'SUCCESS')) - { - $this->result = 'SQL ERROR ' . $this->db->sql_error_returned['message']; - } - else - { - $this->result .= '<br /><br />SQL ERROR ' . $this->db->sql_error_returned['message']; - } - - //$this->db->sql_transaction('rollback'); - } - else - { - //$this->db->sql_transaction('commit'); - } - - $this->db->sql_return_on_error(false); - - // Auto output if requested. - if ($this->auto_display_results && method_exists($this, 'display_results')) - { - $this->display_results(); - } - - return '<strong>' . $this->command . '</strong><br />' . $this->result; - } - - /** - * Get text for output - * - * Takes the given arguments and prepares them for the UI - * - * First argument sent is used as the language key - * Further arguments (if send) are used on the language key through vsprintf() - * - * @return string Returns the prepared string for output - */ - function get_output_text() - { - global $user; - - // Set up the command. This will get the arguments sent to the function. - $args = func_get_args(); - if (sizeof($args)) - { - $lang_key = array_shift($args); - - if (sizeof($args)) - { - $lang_args = array(); - foreach ($args as $arg) - { - $lang_args[] = (isset($user->lang[$arg])) ? $user->lang[$arg] : $arg; - } - - return @vsprintf(((isset($user->lang[$lang_key])) ? $user->lang[$lang_key] : $lang_key), $lang_args); - } - else - { - return ((isset($user->lang[$lang_key])) ? $user->lang[$lang_key] : $lang_key); - } - } - - return ''; - } - - /** - * Run Actions - * - * Do-It-All function that can do everything required for installing/updating/uninstalling a mod based on an array of actions and the versions. - * - * @param string $action The action. install|update|uninstall - * @param array $versions The array of versions and the actions for each - * @param string $version_config_name The name of the config setting which holds/will hold the currently installed version - * @param string $version_select Added for the UMIL Auto system to allow you to select the version you want to install/update/uninstall to. - */ - function run_actions($action, $versions, $version_config_name, $version_select = '') - { - // We will sort the actions to prevent issues from mod authors incorrectly listing the version numbers - uksort($versions, 'version_compare'); - - // Find the current version to install - $current_version = '0.0.0'; - foreach ($versions as $version => $actions) - { - $current_version = $version; - } - - $db_version = ''; - if ($this->config_exists($version_config_name)) - { - global $config; - $db_version = $config[$version_config_name]; - } - - // Set the action to install from update if nothing is currently installed - if ($action == 'update' && !$db_version) - { - $action = 'install'; - } - - if ($action == 'install' || $action == 'update') - { - $version_installed = $db_version; - foreach ($versions as $version => $version_actions) - { - // If we are updating - if ($db_version && version_compare($version, $db_version, '<=')) - { - continue; - } - - if ($version_select && version_compare($version, $version_select, '>')) - { - break; - } - - foreach ($version_actions as $method => $params) - { - if ($method == 'custom') - { - $this->_call_custom_function($params, $action, $version); - } - else - { - if (method_exists($this, $method)) - { - call_user_func(array($this, $method), $params); - } - } - } - - $version_installed = $version; - } - - // update the version number or add it - if ($this->config_exists($version_config_name)) - { - $this->config_update($version_config_name, $version_installed); - } - else - { - $this->config_add($version_config_name, $version_installed); - } - } - else if ($action == 'uninstall' && $db_version) - { - // reverse version list - $versions = array_reverse($versions); - - foreach ($versions as $version => $version_actions) - { - // Uninstalling and this listed version is newer than installed - if (version_compare($version, $db_version, '>')) - { - continue; - } - - // Version selection stuff - if ($version_select && version_compare($version, $version_select, '<=')) - { - // update the version number - $this->config_update($version_config_name, $version); - break; - } - - $cache_purge = false; - $version_actions = array_reverse($version_actions); - foreach ($version_actions as $method => $params) - { - if ($method == 'custom') - { - $this->_call_custom_function($params, $action, $version); - } - else - { - // This way we always run the cache purge at the end of the version (done for the uninstall because the instructions are reversed, which would cause the cache purge to be run at the beginning if it was meant to run at the end). - if ($method == 'cache_purge') - { - $cache_purge = $params; - continue; - } - - // A few things are not possible for uninstallations update actions and table_row actions - if (strpos($method, 'update') !== false || strpos($method, 'table_insert') !== false || strpos($method, 'table_row_') !== false) - { - continue; - } - - // reverse function call - $method = str_replace(array('add', 'remove', 'temp'), array('temp', 'add', 'remove'), $method); - $method = str_replace(array('set', 'unset', 'temp'), array('temp', 'set', 'unset'), $method); - - if (method_exists($this, $method)) - { - call_user_func(array($this, $method), ((is_array($params) ? array_reverse($params) : $params))); - } - } - } - - if ($cache_purge !== false) - { - $this->cache_purge($cache_purge); - } - } - - if (!$version_select) - { - // Unset the version number - $this->config_remove($version_config_name); - } - } - } - - /** - * Call custom function helper - */ - function _call_custom_function($functions, $action, $version) - { - if (!is_array($functions)) - { - $functions = array($functions); - } - - $return = ''; - - foreach ($functions as $function) - { - if (function_exists($function)) - { - // Must reset before calling the function - $this->umil_start(); - - $returned = call_user_func($function, $action, $version); - if (is_string($returned)) - { - $this->command = $this->get_output_text($returned); - } - else if (is_array($returned) && isset($returned['command'])) - { - if (is_array($returned['command'])) - { - $this->command = call_user_func_array(array($this, 'get_output_text'), $returned['command']); - } - else - { - $this->command = $this->get_output_text($returned['command']); - } - - if (isset($returned['result'])) - { - $this->result = $this->get_output_text($returned['result']); - } - } - else - { - $this->command = $this->get_output_text('UNKNOWN'); - } - - $return .= $this->umil_end() . '<br />'; - } - } - - return $return; - } - - /** - * Multicall Helper - * - * @param mixed $function Function name to call - * @param mixed $params The parameters array - * - * @return bool True if we have done a multicall ($params is an array), false if not ($params is not an array) - */ - function multicall($function, $params) - { - if (is_array($params) && !empty($params)) - { - foreach ($params as $param) - { - if (!is_array($param)) - { - call_user_func(array($this, $function), $param); - } - else - { - call_user_func_array(array($this, $function), $param); - } - } - return true; - } - - return false; - } - - /** - * Cache Purge - * - * This function is for purging either phpBB3’s data cache, authorization cache, or the styles cache. - * - * @param string $type The type of cache you want purged. Available types: auth, imageset, template, theme. Anything else sent will purge the forum's cache. - * @param int $style_id The id of the item you want purged (if the type selected is imageset/template/theme, 0 for all items in that section) - */ - function cache_purge($type = '', $style_id = 0) - { - global $auth, $cache, $user, $phpbb_root_path, $phpEx; - - // Multicall - if ($this->multicall(__FUNCTION__, $type)) - { - return; - } - - $style_id = (int) $style_id; - $type = (string) $type; // Prevent PHP bug. - - switch ($type) - { - case 'auth' : - $this->umil_start('AUTH_CACHE_PURGE'); - $cache->destroy('_acl_options'); - $auth->acl_clear_prefetch(); - - return $this->umil_end(); - break; - - case 'imageset' : - if ($style_id == 0) - { - $return = array(); - $sql = 'SELECT imageset_id - FROM ' . STYLES_IMAGESET_TABLE; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $return[] = $this->cache_purge('imageset', $row['imageset_id']); - } - $this->db->sql_freeresult($result); - - return implode('<br /><br />', $return); - } - else - { - $sql = 'SELECT * - FROM ' . STYLES_IMAGESET_TABLE . " - WHERE imageset_id = $style_id"; - $result = $this->db->sql_query($sql); - $imageset_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$imageset_row) - { - $this->umil_start('IMAGESET_CACHE_PURGE', 'UNKNOWN'); - return $this->umil_end('FAIL'); - } - - $this->umil_start('IMAGESET_CACHE_PURGE', $imageset_row['imageset_name']); - - // The following is from includes/acp/acp_styles.php (edited) - $sql_ary = array(); - - $cfg_data_imageset = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/imageset.cfg"); - - $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . ' - WHERE imageset_id = ' . $style_id; - $result = $this->db->sql_query($sql); - - foreach ($cfg_data_imageset as $image_name => $value) - { - if (strpos($value, '*') !== false) - { - if (substr($value, -1, 1) === '*') - { - list($image_filename, $image_height) = explode('*', $value); - $image_width = 0; - } - else - { - list($image_filename, $image_height, $image_width) = explode('*', $value); - } - } - else - { - $image_filename = $value; - $image_height = $image_width = 0; - } - - if (strpos($image_name, 'img_') === 0 && $image_filename) - { - $image_name = substr($image_name, 4); - - $sql_ary[] = array( - 'image_name' => (string) $image_name, - 'image_filename' => (string) $image_filename, - 'image_height' => (int) $image_height, - 'image_width' => (int) $image_width, - 'imageset_id' => (int) $style_id, - 'image_lang' => '', - ); - } - } - - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg")) - { - $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg"); - foreach ($cfg_data_imageset_data as $image_name => $value) - { - if (strpos($value, '*') !== false) - { - if (substr($value, -1, 1) === '*') - { - list($image_filename, $image_height) = explode('*', $value); - $image_width = 0; - } - else - { - list($image_filename, $image_height, $image_width) = explode('*', $value); - } - } - else - { - $image_filename = $value; - $image_height = $image_width = 0; - } - - if (strpos($image_name, 'img_') === 0 && $image_filename) - { - $image_name = substr($image_name, 4); - $sql_ary[] = array( - 'image_name' => (string) $image_name, - 'image_filename' => (string) $image_filename, - 'image_height' => (int) $image_height, - 'image_width' => (int) $image_width, - 'imageset_id' => (int) $style_id, - 'image_lang' => (string) $row['lang_dir'], - ); - } - } - } - } - $this->db->sql_freeresult($result); - - $this->db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); - - $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); - - return $this->umil_end(); - } - break; - //case 'imageset' : - - case 'template' : - if ($style_id == 0) - { - $return = array(); - $sql = 'SELECT template_id - FROM ' . STYLES_TEMPLATE_TABLE; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $return[] = $this->cache_purge('template', $row['template_id']); - } - $this->db->sql_freeresult($result); - - return implode('<br /><br />', $return); - } - else - { - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_TABLE . " - WHERE template_id = $style_id"; - $result = $this->db->sql_query($sql); - $template_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$template_row) - { - $this->umil_start('TEMPLATE_CACHE_PURGE', 'UNKNOWN'); - return $this->umil_end('FAIL'); - } - - $this->umil_start('TEMPLATE_CACHE_PURGE', $template_row['template_name']); - - // The following is from includes/acp/acp_styles.php - if ($template_row['template_storedb'] && file_exists("{$phpbb_root_path}styles/{$template_row['template_path']}/template/")) - { - $filelist = array('' => array()); - - $sql = 'SELECT template_filename, template_mtime - FROM ' . STYLES_TEMPLATE_DATA_TABLE . " - WHERE template_id = $style_id"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { -// if (@filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/" . $row['template_filename']) > $row['template_mtime']) -// { - // get folder info from the filename - if (($slash_pos = strrpos($row['template_filename'], '/')) === false) - { - $filelist[''][] = $row['template_filename']; - } - else - { - $filelist[substr($row['template_filename'], 0, $slash_pos + 1)][] = substr($row['template_filename'], $slash_pos + 1, strlen($row['template_filename']) - $slash_pos - 1); - } -// } - } - $this->db->sql_freeresult($result); - - $includes = array(); - foreach ($filelist as $pathfile => $file_ary) - { - foreach ($file_ary as $file) - { - if (!($fp = @fopen("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file", 'r'))) - { - return $this->umil_end('FILE_COULD_NOT_READ', "{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file"); - } - $template_data = fread($fp, filesize("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file")); - fclose($fp); - - if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches)) - { - foreach ($matches[1] as $match) - { - $includes[trim($match)][] = $file; - } - } - } - } - - foreach ($filelist as $pathfile => $file_ary) - { - foreach ($file_ary as $file) - { - // Skip index. - if (strpos($file, 'index.') === 0) - { - continue; - } - - // We could do this using extended inserts ... but that could be one - // heck of a lot of data ... - $sql_ary = array( - 'template_id' => (int) $style_id, - 'template_filename' => "$pathfile$file", - 'template_included' => (isset($includes[$file])) ? implode(':', $includes[$file]) . ':' : '', - 'template_mtime' => (int) filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file"), - 'template_data' => (string) file_get_contents("{$phpbb_root_path}styles/{$template_row['template_path']}$pathfile$file"), - ); - - $sql = 'UPDATE ' . STYLES_TEMPLATE_DATA_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " - WHERE template_id = $style_id - AND template_filename = '" . $this->db->sql_escape("$pathfile$file") . "'"; - $this->db->sql_query($sql); - } - } - unset($filelist); - } - - // Purge the forum's cache as well. - $cache->purge(); - - return $this->umil_end(); - } - break; - //case 'template' : - - case 'theme' : - if ($style_id == 0) - { - $return = array(); - $sql = 'SELECT theme_id - FROM ' . STYLES_THEME_TABLE; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $return[] = $this->cache_purge('theme', $row['theme_id']); - } - $this->db->sql_freeresult($result); - - return implode('<br /><br />', $return); - } - else - { - $sql = 'SELECT * - FROM ' . STYLES_THEME_TABLE . " - WHERE theme_id = $style_id"; - $result = $this->db->sql_query($sql); - $theme_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$theme_row) - { - $this->umil_start('THEME_CACHE_PURGE', 'UNKNOWN'); - return $this->umil_end('FAIL'); - } - - $this->umil_start('THEME_CACHE_PURGE', $theme_row['theme_name']); - - // The following is from includes/acp/acp_styles.php - if ($theme_row['theme_storedb'] && file_exists("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css")) - { - $stylesheet = file_get_contents($phpbb_root_path . 'styles/' . $theme_row['theme_path'] . '/theme/stylesheet.css'); - - // Match CSS imports - $matches = array(); - preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches); - - if (sizeof($matches)) - { - foreach ($matches[0] as $idx => $match) - { - if (!file_exists("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/{$matches[1][$idx]}")) - { - continue; - } - - $content = trim(file_get_contents("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/{$matches[1][$idx]}")); - $stylesheet = str_replace($match, $content, $stylesheet); - } - } - - // adjust paths - $db_theme_data = str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet); - - // Save CSS contents - $sql_ary = array( - 'theme_mtime' => (int) filemtime("{$phpbb_root_path}styles/{$theme_row['theme_path']}/theme/stylesheet.css"), - 'theme_data' => $db_theme_data, - ); - - $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " - WHERE theme_id = $style_id"; - $this->db->sql_query($sql); - - $cache->destroy('sql', STYLES_THEME_TABLE); - } - - return $this->umil_end(); - } - break; - //case 'theme' : - - default: - $this->umil_start('CACHE_PURGE'); - $cache->purge(); - - return $this->umil_end(); - break; - } - } - - /** - * Config Exists - * - * This function is to check to see if a config variable exists or if it does not. - * - * @param string $config_name The name of the config setting you wish to check for. - * @param bool $return_result - return the config value/default if true : default false. - * - * @return bool true/false if config exists - */ - function config_exists($config_name, $return_result = false) - { - global $config, $cache; - - $sql = 'SELECT * - FROM ' . CONFIG_TABLE . " - WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - if (!isset($config[$config_name])) - { - $config[$config_name] = $row['config_value']; - - if (!$row['is_dynamic']) - { - $cache->destroy('config'); - } - } - - return ($return_result) ? $row : true; - } - - // this should never happen, but if it does, we need to remove the config from the array - if (isset($config[$config_name])) - { - unset($config[$config_name]); - $cache->destroy('config'); - } - - return false; - } - - /** - * Config Add - * - * This function allows you to add a config setting. - * - * @param string $config_name The name of the config setting you would like to add - * @param mixed $config_value The value of the config setting - * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. - * - * @return result - */ - function config_add($config_name, $config_value = '', $is_dynamic = false) - { - // Multicall - if ($this->multicall(__FUNCTION__, $config_name)) - { - return; - } - - $this->umil_start('CONFIG_ADD', $config_name); - - if ($this->config_exists($config_name)) - { - return $this->umil_end('CONFIG_ALREADY_EXISTS', $config_name); - } - - set_config($config_name, $config_value, $is_dynamic); - - return $this->umil_end(); - } - - /** - * Config Update - * - * This function allows you to update an existing config setting. - * - * @param string $config_name The name of the config setting you would like to update - * @param mixed $config_value The value of the config setting - * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. - * - * @return result - */ - function config_update($config_name, $config_value = '', $is_dynamic = false) - { - // Multicall - if ($this->multicall(__FUNCTION__, $config_name)) - { - return; - } - - $this->umil_start('CONFIG_UPDATE', $config_name); - - if (!$this->config_exists($config_name)) - { - return $this->umil_end('CONFIG_NOT_EXIST', $config_name); - } - - set_config($config_name, $config_value, $is_dynamic); - - return $this->umil_end(); - } - - /** - * Config Remove - * - * This function allows you to remove an existing config setting. - * - * @param string $config_name The name of the config setting you would like to remove - * - * @return result - */ - function config_remove($config_name) - { - global $cache, $config; - - // Multicall - if ($this->multicall(__FUNCTION__, $config_name)) - { - return; - } - - $this->umil_start('CONFIG_REMOVE', $config_name); - - if (!$this->config_exists($config_name)) - { - return $this->umil_end('CONFIG_NOT_EXIST', $config_name); - } - - $sql = 'DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = '" . $this->db->sql_escape($config_name) . "'"; - $this->db->sql_query($sql); - - unset($config[$config_name]); - $cache->destroy('config'); - - return $this->umil_end(); - } - - /** - * Module Exists - * - * Check if a module exists - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. - * @param int|string $module The module_id|module_langname you would like to check for to see if it exists - */ - function module_exists($class, $parent, $module) - { - // the main root directory should return true - if (!$module) - { - return true; - } - - $class = $this->db->sql_escape($class); - $module = $this->db->sql_escape($module); - - $parent_sql = ''; - if ($parent !== false) - { - // Allows '' to be sent as 0 - $parent = (!$parent) ? 0 : $parent; - - if (!is_numeric($parent)) - { - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = '" . $this->db->sql_escape($parent) . "' - AND module_class = '$class'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - return false; - } - - $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; - } - else - { - $parent_sql = 'AND parent_id = ' . (int) $parent; - } - } - - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_class = '$class' - $parent_sql - AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '$module'"); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - return true; - } - - return false; - } - - /** - * Module Add - * - * Add a new module - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string $parent The parent module_id|module_langname (0 for no parent) - * @param array $data an array of the data on the new module. This can be setup in two different ways. - * 1. The "manual" way. For inserting a category or one at a time. It will be merged with the base array shown a bit below, - * but at the least requires 'module_langname' to be sent, and, if you want to create a module (instead of just a category) you must send module_basename and module_mode. - * array( - * 'module_enabled' => 1, - * 'module_display' => 1, - * 'module_basename' => '', - * 'module_class' => $class, - * 'parent_id' => (int) $parent, - * 'module_langname' => '', - * 'module_mode' => '', - * 'module_auth' => '', - * ) - * 2. The "automatic" way. For inserting multiple at a time based on the specs in the info file for the module(s). For this to work the modules must be correctly setup in the info file. - * An example follows (this would insert the settings, log, and flag modes from the includes/acp/info/acp_asacp.php file): - * array( - * 'module_basename' => 'asacp', - * 'modes' => array('settings', 'log', 'flag'), - * ) - * Optionally you may not send 'modes' and it will insert all of the modules in that info file. - * @param string|bool $include_path If you would like to use a custom include path, specify that here - */ - function module_add($class, $parent = 0, $data = array(), $include_path = false) - { - global $cache, $user, $phpbb_root_path, $phpEx; - - // Multicall - if ($this->multicall(__FUNCTION__, $class)) - { - return; - } - - // Prevent stupid things like trying to add a module with no name or any data on it - if (empty($data)) - { - $this->umil_start('MODULE_ADD', $class, 'UNKNOWN'); - return $this->umil_end('FAIL'); - } - - // Allows '' to be sent as 0 - $parent = (!$parent) ? 0 : $parent; - - // allow sending the name as a string in $data to create a category - if (!is_array($data)) - { - $data = array('module_langname' => $data); - } - - if (!isset($data['module_langname'])) - { - // The "automatic" way - $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; - $basename = str_replace(array('/', '\\'), '', $basename); - $class = str_replace(array('/', '\\'), '', $class); - $info_file = "$class/info/{$class}_$basename.$phpEx"; - - // The manual and automatic ways both failed... - if (!file_exists((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file)) - { - $this->umil_start('MODULE_ADD', $class, $info_file); - return $this->umil_end('FAIL'); - } - - $classname = "{$class}_{$basename}_info"; - - if (!class_exists($classname)) - { - include((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file); - } - - $info = new $classname; - $module = $info->module(); - unset($info); - - $result = ''; - foreach ($module['modes'] as $mode => $module_info) - { - if (!isset($data['modes']) || in_array($mode, $data['modes'])) - { - $new_module = array( - 'module_basename' => $basename, - 'module_langname' => $module_info['title'], - 'module_mode' => $mode, - 'module_auth' => $module_info['auth'], - 'module_display' => (isset($module_info['display'])) ? $module_info['display'] : true, - 'before' => (isset($module_info['before'])) ? $module_info['before'] : false, - 'after' => (isset($module_info['after'])) ? $module_info['after'] : false, - ); - - // Run the "manual" way with the data we've collected. - $result .= ((isset($data['spacer'])) ? $data['spacer'] : '<br />') . $this->module_add($class, $parent, $new_module); - } - } - - return $result; - } - - // The "manual" way - $this->umil_start('MODULE_ADD', $class, ((isset($user->lang[$data['module_langname']])) ? $user->lang[$data['module_langname']] : $data['module_langname'])); - add_log('admin', 'LOG_MODULE_ADD', ((isset($user->lang[$data['module_langname']])) ? $user->lang[$data['module_langname']] : $data['module_langname'])); - - $class = $this->db->sql_escape($class); - - if (!is_numeric($parent)) - { - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = '" . $this->db->sql_escape($parent) . "' - AND module_class = '$class'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - return $this->umil_end('PARENT_NOT_EXIST'); - } - - $parent = $data['parent_id'] = $row['module_id']; - } - else if (!$this->module_exists($class, false, $parent)) - { - return $this->umil_end('PARENT_NOT_EXIST'); - } - - if ($this->module_exists($class, $parent, $data['module_langname'])) - { - return $this->umil_end('MODULE_ALREADY_EXIST'); - } - - if (!class_exists('acp_modules')) - { - include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - $user->add_lang('acp/modules'); - } - $acp_modules = new acp_modules(); - - $module_data = array( - 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, - 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, - 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', - 'module_class' => $class, - 'parent_id' => (int) $parent, - 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', - 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', - 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', - ); - $result = $acp_modules->update_module_data($module_data, true); - - // update_module_data can either return a string or an empty array... - if (is_string($result)) - { - // Error - $this->result = $this->get_output_text($result); - } - else - { - // Success - - // Move the module if requested above/below an existing one - if (isset($data['before']) && $data['before']) - { - $sql = 'SELECT left_id FROM ' . MODULES_TABLE . ' - WHERE module_class = \'' . $class . '\' - AND parent_id = ' . (int) $parent . ' - AND module_langname = \'' . $this->db->sql_escape($data['before']) . '\''; - $this->db->sql_query($sql); - $to_left = $this->db->sql_fetchfield('left_id'); - - $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '$class' - AND left_id >= $to_left - AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = $to_left, right_id = " . ($to_left + 1) . " - WHERE module_class = '$class' - AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - else if (isset($data['after']) && $data['after']) - { - $sql = 'SELECT right_id FROM ' . MODULES_TABLE . ' - WHERE module_class = \'' . $class . '\' - AND parent_id = ' . (int) $parent . ' - AND module_langname = \'' . $this->db->sql_escape($data['after']) . '\''; - $this->db->sql_query($sql); - $to_right = $this->db->sql_fetchfield('right_id'); - - $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '$class' - AND left_id >= $to_right - AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . MODULES_TABLE . ' SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " - WHERE module_class = '$class' - AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - } - - // Clear the Modules Cache - $cache->destroy("_modules_$class"); - - return $this->umil_end(); - } - - /** - * Module Remove - * - * Remove a module - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. - * @param int|string $module The module id|module_langname - * @param string|bool $include_path If you would like to use a custom include path, specify that here - */ - function module_remove($class, $parent = 0, $module = '', $include_path = false) - { - global $cache, $user, $phpbb_root_path, $phpEx; - - // Multicall - if ($this->multicall(__FUNCTION__, $class)) - { - return; - } - - // Imitation of module_add's "automatic" and "manual" method so the uninstaller works from the same set of instructions for umil_auto - if (is_array($module)) - { - if (isset($module['module_langname'])) - { - // Manual Method - return $this->module_remove($class, $parent, $module['module_langname'], $include_path); - } - - // Failed. - if (!isset($module['module_basename'])) - { - $this->umil_start('MODULE_REMOVE', $class, 'UNKNOWN'); - return $this->umil_end('FAIL'); - } - - // Automatic method - $basename = str_replace(array('/', '\\'), '', $module['module_basename']); - $class = str_replace(array('/', '\\'), '', $class); - $info_file = "$class/info/{$class}_$basename.$phpEx"; - - if (!file_exists((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file)) - { - $this->umil_start('MODULE_REMOVE', $class, $info_file); - return $this->umil_end('FAIL'); - } - - $classname = "{$class}_{$basename}_info"; - - if (!class_exists($classname)) - { - include((($include_path === false) ? $phpbb_root_path . 'includes/' : $include_path) . $info_file); - } - - $info = new $classname; - $module_info = $info->module(); - unset($info); - - $result = ''; - foreach ($module_info['modes'] as $mode => $info) - { - if (!isset($module['modes']) || in_array($mode, $module['modes'])) - { - $result .= $this->module_remove($class, $parent, $info['title']) . '<br />'; - } - } - return $result; - } - else - { - $class = $this->db->sql_escape($class); - - if (!$this->module_exists($class, $parent, $module)) - { - $this->umil_start('MODULE_REMOVE', $class, ((isset($user->lang[$module])) ? $user->lang[$module] : $module)); - return $this->umil_end('MODULE_NOT_EXIST'); - } - - $parent_sql = ''; - if ($parent !== false) - { - // Allows '' to be sent as 0 - $parent = (!$parent) ? 0 : $parent; - - if (!is_numeric($parent)) - { - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = '" . $this->db->sql_escape($parent) . "' - AND module_class = '$class'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - // we know it exists from the module_exists check - $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; - } - else - { - $parent_sql = 'AND parent_id = ' . (int) $parent; - } - } - - $module_ids = array(); - if (!is_numeric($module)) - { - $module = $this->db->sql_escape($module); - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = '$module' - AND module_class = '$class' - $parent_sql"; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $module_ids[] = (int) $row['module_id']; - } - $this->db->sql_freeresult($result); - - $module_name = $module; - } - else - { - $module = (int) $module; - $sql = 'SELECT module_langname FROM ' . MODULES_TABLE . " - WHERE module_id = $module - AND module_class = '$class' - $parent_sql"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $module_name = $row['module_langname']; - $module_ids[] = $module; - } - - $this->umil_start('MODULE_REMOVE', $class, ((isset($user->lang[$module_name])) ? $user->lang[$module_name] : $module_name)); - add_log('admin', 'LOG_MODULE_REMOVED', ((isset($user->lang[$module_name])) ? $user->lang[$module_name] : $module_name)); - - if (!class_exists('acp_modules')) - { - include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - $user->add_lang('acp/modules'); - } - $acp_modules = new acp_modules(); - $acp_modules->module_class = $class; - - foreach ($module_ids as $module_id) - { - $result = $acp_modules->delete_module($module_id); - if (!empty($result)) - { - if ($this->result == ((isset($user->lang['SUCCESS'])) ? $user->lang['SUCCESS'] : 'SUCCESS')) - { - $this->result = implode('<br />', $result); - } - else - { - $this->result .= '<br />' . implode('<br />', $result); - } - } - } - - $cache->destroy("_modules_$class"); - - return $this->umil_end(); - } - } - - /** - * Permission Exists - * - * Check if a permission (auth) setting exists - * - * @param string $auth_option The name of the permission (auth) option - * @param bool $global True for checking a global permission setting, False for a local permission setting - * - * @return bool true if it exists, false if not - */ - function permission_exists($auth_option, $global = true) - { - if ($global) - { - $type_sql = ' AND is_global = 1'; - } - else - { - $type_sql = ' AND is_local = 1'; - } - - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" - . $type_sql; - $result = $this->db->sql_query($sql); - - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - return true; - } - - return false; - } - - /** - * Permission Add - * - * Add a permission (auth) option - * - * @param string $auth_option The name of the permission (auth) option - * @param bool $global True for checking a global permission setting, False for a local permission setting - * - * @return result - */ - function permission_add($auth_option, $global = true) - { - // Multicall - if ($this->multicall(__FUNCTION__, $auth_option)) - { - return; - } - - $this->umil_start('PERMISSION_ADD', $auth_option); - - if ($this->permission_exists($auth_option, $global)) - { - return $this->umil_end('PERMISSION_ALREADY_EXISTS', $auth_option); - } - - // We've added permissions, so set to true to notify the user. - $this->permissions_added = true; - - if (!class_exists('auth_admin')) - { - global $phpbb_root_path, $phpEx; - - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - } - $auth_admin = new auth_admin(); - - // We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists. If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here. - if ($this->permission_exists($auth_option, !$global)) - { - $sql_ary = array( - 'is_global' => 1, - 'is_local' => 1, - ); - $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE auth_option = \'' . $this->db->sql_escape($auth_option) . "'"; - $this->db->sql_query($sql); - } - else - { - if ($global) - { - $auth_admin->acl_add_option(array('global' => array($auth_option))); - } - else - { - $auth_admin->acl_add_option(array('local' => array($auth_option))); - } - } - - return $this->umil_end(); - } - - /** - * Permission Remove - * - * Remove a permission (auth) option - * - * @param string $auth_option The name of the permission (auth) option - * @param bool $global True for checking a global permission setting, False for a local permission setting - * - * @return result - */ - function permission_remove($auth_option, $global = true) - { - global $auth, $cache; - - // Multicall - if ($this->multicall(__FUNCTION__, $auth_option)) - { - return; - } - - $this->umil_start('PERMISSION_REMOVE', $auth_option); - - if (!$this->permission_exists($auth_option, $global)) - { - return $this->umil_end('PERMISSION_NOT_EXIST', $auth_option); - } - - if ($global) - { - $type_sql = ' AND is_global = 1'; - } - else - { - $type_sql = ' AND is_local = 1'; - } - $sql = 'SELECT auth_option_id, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" . - $type_sql; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $id = $row['auth_option_id']; - - // If it is a local and global permission, do not remove the row! :P - if ($row['is_global'] && $row['is_local']) - { - $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' - SET ' . (($global) ? 'is_global = 0' : 'is_local = 0') . ' - WHERE auth_option_id = ' . $id; - $this->db->sql_query($sql); - } - else - { - // Delete time - $this->db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $id); - $this->db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $id); - $this->db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $id); - $this->db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $id); - } - - // Purge the auth cache - $cache->destroy('_acl_options'); - $auth->acl_clear_prefetch(); - - return $this->umil_end(); - } - - /** - * Add a new permission role - * - * @param string $role_name The new role name - * @param sting $role_type The type (u_, m_, a_) - */ - function permission_role_add($role_name, $role_type = '', $role_description = '') - { - // Multicall - if ($this->multicall(__FUNCTION__, $role_name)) - { - return; - } - - $this->umil_start('PERMISSION_ROLE_ADD', $role_name); - - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); - - if ($role_id) - { - return $this->umil_end('ROLE_ALREADY_EXISTS', $old_role_name); - } - - $sql = 'SELECT MAX(role_order) AS max FROM ' . ACL_ROLES_TABLE . ' - WHERE role_type = \'' . $this->db->sql_escape($role_type) . '\''; - $this->db->sql_query($sql); - $role_order = $this->db->sql_fetchfield('max'); - $role_order = (!$role_order) ? 1 : $role_order + 1; - - $sql_ary = array( - 'role_name' => $role_name, - 'role_description' => $role_description, - 'role_type' => $role_type, - 'role_order' => $role_order, - ); - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->db->sql_query($sql); - - return $this->umil_end(); - } - - /** - * Update the name on a permission role - * - * @param string $old_role_name The old role name - * @param string $new_role_name The new role name - */ - function permission_role_update($old_role_name, $new_role_name = '') - { - // Multicall - if ($this->multicall(__FUNCTION__, $role_name)) - { - return; - } - - $this->umil_start('PERMISSION_ROLE_UPDATE', $old_role_name); - - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); - - if (!$role_id) - { - return $this->umil_end('ROLE_NOT_EXIST', $old_role_name); - } - - $sql = 'UPDATE ' . ACL_ROLES_TABLE . ' - SET role_name = \'' . $this->db->sql_escape($new_role_name) . '\' - WHERE role_name = \'' . $this->db->sql_escape($old_role_name) . '\''; - $this->db->sql_query($sql); - - return $this->umil_end(); - } - - /** - * Remove a permission role - * - * @param string $role_name The role name to remove - */ - function permission_role_remove($role_name) - { - global $auth; - - // Multicall - if ($this->multicall(__FUNCTION__, $role_name)) - { - return; - } - - $this->umil_start('PERMISSION_ROLE_REMOVE', $role_name); - - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($role_name) . '\''; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); - - if (!$role_id) - { - return $this->umil_end('ROLE_NOT_EXIST', $role_name); - } - - $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE role_id = ' . $role_id; - $this->db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_ROLES_TABLE . ' - WHERE role_id = ' . $role_id; - $this->db->sql_query($sql); - - $auth->acl_clear_prefetch(); - - return $this->umil_end(); - } - - /** - * Permission Set - * - * Allows you to set permissions for a certain group/role - * - * @param string $name The name of the role/group - * @param string|array $auth_option The auth_option or array of auth_options you would like to set - * @param string $type The type (role|group) - * @param bool $has_permission True if you want to give them permission, false if you want to deny them permission - */ - function permission_set($name, $auth_option = array(), $type = 'role', $has_permission = true) - { - global $auth; - - // Multicall - if ($this->multicall(__FUNCTION__, $name)) - { - return; - } - - if (!is_array($auth_option)) - { - $auth_option = array($auth_option); - } - - $new_auth = array(); - $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' - WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $new_auth[] = $row['auth_option_id']; - } - $this->db->sql_freeresult($result); - - if (!sizeof($new_auth)) - { - return false; - } - - $current_auth = array(); - - $type = (string) $type; // Prevent PHP bug. - - switch ($type) - { - case 'role' : - $this->umil_start('PERMISSION_SET_ROLE', $name); - - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); - - if (!$role_id) - { - return $this->umil_end('ROLE_NOT_EXIST'); - } - - $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE role_id = ' . $role_id; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $current_auth[$row['auth_option_id']] = $row['auth_setting']; - } - $this->db->sql_freeresult($result); - break; - - case 'group' : - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; - $this->db->sql_query($sql); - $group_id = $this->db->sql_fetchfield('group_id'); - - if (!$group_id) - { - $this->umil_start('PERMISSION_SET_GROUP', $name); - return $this->umil_end('GROUP_NOT_EXIST'); - } - - // If the group has a role set for them we will add the requested permissions to that role. - $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id <> 0 - AND forum_id = 0'; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('auth_role_id'); - if ($role_id) - { - $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' - WHERE role_id = ' . $role_id; - $this->db->sql_query($sql); - $role_name = $this->db->sql_fetchfield('role_name'); - - return $this->permission_set($role_name, $auth_option, 'role', $has_permission); - } - - $this->umil_start('PERMISSION_SET_GROUP', $name); - - $sql = 'SELECT auth_option_id, auth_setting FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $current_auth[$row['auth_option_id']] = $row['auth_setting']; - } - $this->db->sql_freeresult($result); - break; - } - - $sql_ary = array(); - switch ($type) - { - case 'role' : - foreach ($new_auth as $auth_option_id) - { - if (!isset($current_auth[$auth_option_id])) - { - $sql_ary[] = array( - 'role_id' => $role_id, - 'auth_option_id' => $auth_option_id, - 'auth_setting' => $has_permission, - ); - } - } - - $this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); - break; - - case 'group' : - foreach ($new_auth as $auth_option_id) - { - if (!isset($current_auth[$auth_option_id])) - { - $sql_ary[] = array( - 'group_id' => $group_id, - 'auth_option_id' => $auth_option_id, - 'auth_setting' => $has_permission, - ); - } - } - - $this->db->sql_multi_insert(ACL_GROUPS_TABLE, $sql_ary); - break; - } - - $auth->acl_clear_prefetch(); - - return $this->umil_end(); - } - - /** - * Permission Unset - * - * Allows you to unset (remove) permissions for a certain group/role - * - * @param string $name The name of the role/group - * @param string|array $auth_option The auth_option or array of auth_options you would like to set - * @param string $type The type (role|group) - */ - function permission_unset($name, $auth_option = array(), $type = 'role') - { - global $auth; - - // Multicall - if ($this->multicall(__FUNCTION__, $name)) - { - return; - } - - if (!is_array($auth_option)) - { - $auth_option = array($auth_option); - } - - $to_remove = array(); - $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' - WHERE ' . $this->db->sql_in_set('auth_option', $auth_option); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $to_remove[] = $row['auth_option_id']; - } - $this->db->sql_freeresult($result); - - if (!sizeof($to_remove)) - { - return false; - } - - $type = (string) $type; // Prevent PHP bug. - - switch ($type) - { - case 'role' : - $this->umil_start('PERMISSION_UNSET_ROLE', $name); - - $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . ' - WHERE role_name = \'' . $this->db->sql_escape($name) . '\''; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); - - if (!$role_id) - { - return $this->umil_end('ROLE_NOT_EXIST'); - } - - $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove); - $this->db->sql_query($sql); - break; - - case 'group' : - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_name = \'' . $this->db->sql_escape($name) . '\''; - $this->db->sql_query($sql); - $group_id = $this->db->sql_fetchfield('group_id'); - - if (!$group_id) - { - $this->umil_start('PERMISSION_UNSET_GROUP', $name); - return $this->umil_end('GROUP_NOT_EXIST'); - } - - // If the group has a role set for them we will remove the requested permissions from that role. - $sql = 'SELECT auth_role_id FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id <> 0'; - $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('auth_role_id'); - if ($role_id) - { - $sql = 'SELECT role_name FROM ' . ACL_ROLES_TABLE . ' - WHERE role_id = ' . $role_id; - $this->db->sql_query($sql); - $role_name = $this->db->sql_fetchfield('role_name'); - - return $this->permission_unset($role_name, $auth_option, 'role'); - } - - $this->umil_start('PERMISSION_UNSET_GROUP', $name); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove); - $this->db->sql_query($sql); - break; - } - - $auth->acl_clear_prefetch(); - - return $this->umil_end(); - } - - /** - * Table Exists - * - * Check if a table exists in the DB or not - * - * @param string $table_name The table name to check for - * - * @return bool true if the table exists, false if not - */ - function table_exists($table_name) - { - $this->get_table_name($table_name); - - // Use sql_table_exists if available - if (method_exists($this->db_tools, 'sql_table_exists')) - { - $roe = $this->db->return_on_error; - $result = $this->db_tools->sql_table_exists($table_name); - - // db_tools::sql_table_exists resets the return_on_error to false always after completing, so we must make sure we set it to true again if it was before - if ($roe) - { - $this->db->sql_return_on_error(true); - } - - return $result; - } - - if (!function_exists('get_tables')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions_install.' . $phpEx); - } - - $tables = get_tables($this->db); - - if (in_array($table_name, $tables)) - { - return true; - } - else - { - return false; - } - } - - /** - * Table Add - * - * This only supports input from the array format of db_tools or create_schema_files. - */ - function table_add($table_name, $table_data = array()) - { - global $dbms, $user; - - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - /** - * $table_data can be empty when uninstalling a mod and table_remove was used, but no 2rd argument was given. - * In that case we'll assume that it was a column previously added by the mod (if not the author should specify a 2rd argument) and skip this to prevent an error - */ - if (empty($table_data)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_ADD', $table_name); - - if ($this->table_exists($table_name)) - { - return $this->umil_end('TABLE_ALREADY_EXISTS', $table_name); - } - - if (!is_array($table_data)) - { - return $this->umil_end('NO_TABLE_DATA'); - } - - if (!function_exists('get_available_dbms')) - { - global $phpbb_root_path, $phpEx; - include("{$phpbb_root_path}includes/functions_install.$phpEx"); - } - - /* - * This function has had numerous problems and is currently broken, so until phpBB uses it I will not be anymore - if (method_exists($this->db_tools, 'sql_create_table')) - { - // Added in 3.0.5 - $this->db_tools->sql_create_table($table_name, $table_data); - } - else - {*/ - $available_dbms = get_available_dbms($dbms); - - $sql_query = $this->create_table_sql($table_name, $table_data); - $sql_query = split_sql_file($sql_query, $available_dbms[$dbms]['DELIM']); - - foreach ($sql_query as $sql) - { - $this->db->sql_query($sql); - } - //} - - return $this->umil_end(); - } - - /** - * Table Remove - * - * Delete/Drop a DB table - */ - function table_remove($table_name) - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_REMOVE', $table_name); - - if (!$this->table_exists($table_name)) - { - return $this->umil_end('TABLE_NOT_EXIST', $table_name); - } - - if (method_exists($this->db_tools, 'sql_table_drop')) - { - // Added in 3.0.5 - $this->db_tools->sql_table_drop($table_name); - } - else - { - $this->db->sql_query('DROP TABLE ' . $table_name); - } - - return $this->umil_end(); - } - - /** - * Table Column Exists - * - * Check to see if a column exists in a table - */ - function table_column_exists($table_name, $column_name) - { - $this->get_table_name($table_name); - - return $this->db_tools->sql_column_exists($table_name, $column_name); - } - - /** - * Table Column Add - * - * Add a new column to a table. - */ - function table_column_add($table_name, $column_name = '', $column_data = array()) - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - /** - * $column_data can be empty when uninstalling a mod and table_column_remove was used, but no 3rd argument was given. - * In that case we'll assume that it was a column previously added by the mod (if not the author should specify a 3rd argument) and skip this to prevent an error - */ - if (empty($column_data)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_COLUMN_ADD', $table_name, $column_name); - - if ($this->table_column_exists($table_name, $column_name)) - { - return $this->umil_end('TABLE_COLUMN_ALREADY_EXISTS', $table_name, $column_name); - } - - $this->db_tools->sql_column_add($table_name, $column_name, $column_data); - - return $this->umil_end(); - } - - /** - * Table Column Update - * - * Alter/Update a column in a table. You can not change a column name with this. - */ - function table_column_update($table_name, $column_name = '', $column_data = array()) - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_COLUMN_UPDATE', $table_name, $column_name); - - if (!$this->table_column_exists($table_name, $column_name)) - { - return $this->umil_end('TABLE_COLUMN_NOT_EXIST', $table_name, $column_name); - } - - $this->db_tools->sql_column_change($table_name, $column_name, $column_data); - - return $this->umil_end(); - } - - /** - * Table Column Remove - * - * Remove a column from a table - */ - function table_column_remove($table_name, $column_name = '') - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_COLUMN_REMOVE', $table_name, $column_name); - - if (!$this->table_column_exists($table_name, $column_name)) - { - return $this->umil_end('TABLE_COLUMN_NOT_EXIST', $table_name, $column_name); - } - - $this->db_tools->sql_column_remove($table_name, $column_name); - - return $this->umil_end(); - } - - /** - * Table Index Exists - * - * Check if a table key/index exists on a table (can not check primary or unique) - */ - function table_index_exists($table_name, $index_name) - { - $this->get_table_name($table_name); - - $indexes = $this->db_tools->sql_list_index($table_name); - - if (in_array($index_name, $indexes)) - { - return true; - } - - return false; - } - - /** - * Table Index Add - * - * Add a new key/index to a table - */ - function table_index_add($table_name, $index_name = '', $column = array()) - { - global $config; - - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - // Let them skip the column field and just use the index name in that case as the column as well - if (empty($column)) - { - $column = array($index_name); - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_KEY_ADD', $table_name, $index_name); - - if ($this->table_index_exists($table_name, $index_name)) - { - return $this->umil_end('TABLE_KEY_ALREADY_EXIST', $table_name, $index_name); - } - - if (!is_array($column)) - { - $column = array($column); - } - - // remove index length if we are before 3.0.8 - // the feature (required for some types when using MySQL4) - // was added in that release (ticket PHPBB3-8944) - if (version_compare($config['version'], '3.0.7-pl1', '<=')) - { - $column = preg_replace('#:.*$#', '', $column); - } - - $this->db_tools->sql_create_index($table_name, $index_name, $column); - - return $this->umil_end(); - } - - /** - * Table Index Remove - * - * Remove a key/index from a table - */ - function table_index_remove($table_name, $index_name = '') - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_KEY_REMOVE', $table_name, $index_name); - - if (!$this->table_index_exists($table_name, $index_name)) - { - return $this->umil_end('TABLE_KEY_NOT_EXIST', $table_name, $index_name); - } - - $this->db_tools->sql_index_drop($table_name, $index_name); - - return $this->umil_end(); - } - - // Ignore, function was renamed to table_row_insert and keeping for backwards compatibility - function table_insert($table_name, $data = array()) { $this->table_row_insert($table_name, $data); } - - /** - * Table Insert - * - * Insert data into a table - */ - function table_row_insert($table_name, $data = array()) - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_ROW_INSERT_DATA', $table_name); - - if (!$this->table_exists($table_name)) - { - return $this->umil_end('TABLE_NOT_EXIST', $table_name); - } - - $this->db->sql_multi_insert($table_name, $data); - - return $this->umil_end(); - } - - /** - * Table Row Update - * - * Update a row in a table - * - * $data should be an array with the column names as keys and values as the items to check for each column. Example: - * array('user_id' => 123, 'user_name' => 'test user') would become: - * WHERE user_id = 123 AND user_name = 'test user' - * - * $new_data is the new data it will be updated to (same format as you'd enter into $db->sql_build_array('UPDATE' ). - */ - function table_row_update($table_name, $data = array(), $new_data = array()) - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - if (!sizeof($data)) - { - return $this->umil_end('FAIL'); - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_ROW_UPDATE_DATA', $table_name); - - if (!$this->table_exists($table_name)) - { - return $this->umil_end('TABLE_NOT_EXIST', $table_name); - } - - $sql = 'UPDATE ' . $table_name . ' - SET ' . $this->db->sql_build_array('UPDATE', $new_data) . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $this->db->sql_query($sql); - - return $this->umil_end(); - } - - /** - * Table Row Remove - * - * Remove a row from a table - * - * $data should be an array with the column names as keys and values as the items to check for each column. Example: - * array('user_id' => 123, 'user_name' => 'test user') would become: - * WHERE user_id = 123 AND user_name = 'test user' - */ - function table_row_remove($table_name, $data = array()) - { - // Multicall - if ($this->multicall(__FUNCTION__, $table_name)) - { - return; - } - - if (!sizeof($data)) - { - return $this->umil_end('FAIL'); - } - - $this->get_table_name($table_name); - - $this->umil_start('TABLE_ROW_REMOVE_DATA', $table_name); - - if (!$this->table_exists($table_name)) - { - return $this->umil_end('TABLE_NOT_EXIST', $table_name); - } - - $sql = 'DELETE FROM ' . $table_name . ' WHERE ' . $this->db->sql_build_array('SELECT', $data); - $this->db->sql_query($sql); - - return $this->umil_end(); - } - - /** - * Version Checker - * - * Format the file like the following: - * http://www.phpbb.com/updatecheck/30x.txt - * - * @param string $url The url to access (ex: www.phpbb.com) - * @param string $path The path to access (ex: /updatecheck) - * @param string $file The name of the file to access (ex: 30x.txt) - * - * @return array|string Error Message if there was any error, or an array (each line in the file as a value) - */ - function version_check($url, $path, $file, $timeout = 10, $port = 80) - { - if (!function_exists('get_remote_file')) - { - global $phpbb_root_path, $phpEx; - - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - $errstr = $errno = ''; - - $info = get_remote_file($url, $path, $file, $errstr, $errno, $port, $timeout); - - if ($info === false) - { - return $errstr . ' [ ' . $errno . ' ]'; - } - - $info = str_replace("\r\n", "\n", $info); - $info = explode("\n", $info); - - return $info; - } - - /** - * Create table SQL - * - * Create the SQL query for the specified DBMS on the fly from a create_schema_files type of table array - * - * @param string $table_name The name of the table - * @param array $table_data The table data (formatted in the array format used by create_schema_files) - * @param string $dbms The dbms this will be built for (for testing only, leave blank to use the current DBMS) - * - * @return The sql query to run for the submitted dbms to insert the table - */ - function create_table_sql($table_name, $table_data, $dbms = '') - { - // To allow testing - $dbms = ($dbms) ? $dbms : $this->db_tools->sql_layer; - - // A list of types being unsigned for better reference in some db's - $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); - $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); - - $sql = ''; - - // Create Table statement - $generator = $textimage = false; - - switch ($dbms) - { - case 'mysql_40': - case 'mysql_41': - case 'firebird': - case 'oracle': - case 'sqlite': - case 'postgres': - $sql .= "CREATE TABLE {$table_name} (\n"; - break; - - case 'mssql': - $sql .= "CREATE TABLE [{$table_name}] (\n"; - break; - } - - // Table specific so we don't get overlap - $modded_array = array(); - - // Write columns one by one... - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // Get type - if (strpos($column_data[0], ':') !== false) - { - list($orig_column_type, $column_length) = explode(':', $column_data[0]); - if (!is_array($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'])) - { - $column_type = sprintf($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'], $column_length); - } - else - { - if (isset($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['rule'])) - { - switch ($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['rule'][0]) - { - case 'div': - $column_length /= $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['rule'][1]; - $column_length = ceil($column_length); - $column_type = sprintf($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length); - break; - } - } - - if (isset($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'])) - { - switch ($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][0]) - { - case 'mult': - $column_length *= $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][1]; - if ($column_length > $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][2]) - { - $column_type = $this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':']['limit'][3]; - $modded_array[$column_name] = $column_type; - } - else - { - $column_type = sprintf($this->db_tools->dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length); - } - break; - } - } - } - $orig_column_type .= ':'; - } - else - { - $orig_column_type = $column_data[0]; - $column_type = $this->db_tools->dbms_type_map[$dbms][$column_data[0]]; - if ($column_type == 'text' || $column_type == 'blob') - { - $modded_array[$column_name] = $column_type; - } - } - - // Adjust default value if db-dependant specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$dbms])) ? $column_data[1][$dbms] : $column_data[1]['default']; - } - - switch ($dbms) - { - case 'mysql_40': - case 'mysql_41': - $sql .= "\t{$column_name} {$column_type} "; - - // For hexadecimal values do not use single quotes - if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob') - { - $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; - } - $sql .= 'NOT NULL'; - - if (isset($column_data[2])) - { - if ($column_data[2] == 'auto_increment') - { - $sql .= ' auto_increment'; - } - else if ($dbms === 'mysql_41' && $column_data[2] == 'true_sort') - { - $sql .= ' COLLATE utf8_unicode_ci'; - } - } - - $sql .= ",\n"; - break; - - case 'sqlite': - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $sql .= "\t{$column_name} INTEGER PRIMARY KEY "; - $generator = $column_name; - } - else - { - $sql .= "\t{$column_name} {$column_type} "; - } - - $sql .= 'NOT NULL '; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : ''; - $sql .= ",\n"; - break; - - case 'firebird': - $sql .= "\t{$column_name} {$column_type} "; - - if (!is_null($column_data[1])) - { - $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; - } - - $sql .= 'NOT NULL'; - - // This is a UNICODE column and thus should be given it's fair share - if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0])) - { - $sql .= ' COLLATE UNICODE'; - } - - $sql .= ",\n"; - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $generator = $column_name; - } - break; - - case 'mssql': - if ($column_type == '[text]') - { - $textimage = true; - } - - $sql .= "\t[{$column_name}] {$column_type} "; - - if (!is_null($column_data[1])) - { - // For hexadecimal values do not use single quotes - if (strpos($column_data[1], '0x') === 0) - { - $sql .= 'DEFAULT (' . $column_data[1] . ') '; - } - else - { - $sql .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; - } - } - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $sql .= 'IDENTITY (1, 1) '; - } - - $sql .= 'NOT NULL'; - $sql .= " ,\n"; - break; - - case 'oracle': - $sql .= "\t{$column_name} {$column_type} "; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; - - // In Oracle empty strings ('') are treated as NULL. - // Therefore in oracle we allow NULL's for all DEFAULT '' entries - $sql .= ($column_data[1] === '') ? ",\n" : "NOT NULL,\n"; - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $generator = $column_name; - } - break; - - case 'postgres': - $sql .= "\t{$column_name} {$column_type} "; - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $sql .= "DEFAULT nextval('{$table_name}_seq'),\n"; - - // Make sure the sequence will be created before creating the table - $sql = "CREATE SEQUENCE {$table_name}_seq;\n\n" . $sql; - } - else - { - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; - $sql .= "NOT NULL"; - - // Unsigned? Then add a CHECK contraint - if (in_array($orig_column_type, $unsigned_types)) - { - $sql .= " CHECK ({$column_name} >= 0)"; - } - - $sql .= ",\n"; - } - break; - } - } - - switch ($dbms) - { - case 'firebird': - // Remove last line delimiter... - $sql = substr($sql, 0, -2); - $sql .= "\n);;\n\n"; - break; - - case 'mssql': - $sql = substr($sql, 0, -2); - $sql .= "\n) ON [PRIMARY]" . (($textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : '') . "\n"; - $sql .= "GO\n\n"; - break; - } - - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - switch ($dbms) - { - case 'mysql_40': - case 'mysql_41': - case 'postgres': - $sql .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n"; - break; - - case 'firebird': - $sql .= "ALTER TABLE {$table_name} ADD PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ");;\n\n"; - break; - - case 'sqlite': - if ($generator === false || !in_array($generator, $table_data['PRIMARY_KEY'])) - { - $sql .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n"; - } - break; - - case 'mssql': - $sql .= "ALTER TABLE [{$table_name}] WITH NOCHECK ADD \n"; - $sql .= "\tCONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED \n"; - $sql .= "\t(\n"; - $sql .= "\t\t[" . implode("],\n\t\t[", $table_data['PRIMARY_KEY']) . "]\n"; - $sql .= "\t) ON [PRIMARY] \n"; - $sql .= "GO\n\n"; - break; - - case 'oracle': - $sql .= "\tCONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n"; - break; - } - } - - switch ($dbms) - { - case 'oracle': - // UNIQUE contrains to be added? - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - if ($key_data[0] == 'UNIQUE') - { - $sql .= "\tCONSTRAINT u_phpbb_{$key_name} UNIQUE (" . implode(', ', $key_data[1]) . "),\n"; - } - } - } - - // Remove last line delimiter... - $sql = substr($sql, 0, -2); - $sql .= "\n)\n/\n\n"; - break; - - case 'postgres': - // Remove last line delimiter... - $sql = substr($sql, 0, -2); - $sql .= "\n);\n\n"; - break; - - case 'sqlite': - // Remove last line delimiter... - $sql = substr($sql, 0, -2); - $sql .= "\n);\n\n"; - break; - } - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - switch ($dbms) - { - case 'mysql_40': - case 'mysql_41': - $sql .= ($key_data[0] == 'INDEX') ? "\tKEY" : ''; - $sql .= ($key_data[0] == 'UNIQUE') ? "\tUNIQUE" : ''; - foreach ($key_data[1] as $key => $col_name) - { - if (isset($modded_array[$col_name])) - { - switch ($modded_array[$col_name]) - { - case 'text': - case 'blob': - $key_data[1][$key] = $col_name . '(255)'; - break; - } - } - } - $sql .= ' ' . $key_name . ' (' . implode(', ', $key_data[1]) . "),\n"; - break; - - case 'firebird': - $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; - $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; - - $sql .= ' ' . $table_name . '_' . $key_name . ' ON ' . $table_name . '(' . implode(', ', $key_data[1]) . ");;\n"; - break; - - case 'mssql': - $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; - $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; - $sql .= " [{$key_name}] ON [{$table_name}]([" . implode('], [', $key_data[1]) . "]) ON [PRIMARY]\n"; - $sql .= "GO\n\n"; - break; - - case 'oracle': - if ($key_data[0] == 'UNIQUE') - { - continue; - } - - $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; - - $sql .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ")\n"; - $sql .= "/\n"; - break; - - case 'sqlite': - $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; - $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; - - $sql .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n"; - break; - - case 'postgres': - $sql .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : ''; - $sql .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : ''; - - $sql .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n"; - break; - } - } - } - - switch ($dbms) - { - case 'mysql_40': - // Remove last line delimiter... - $sql = substr($sql, 0, -2); - $sql .= "\n);\n\n"; - break; - - case 'mysql_41': - // Remove last line delimiter... - $sql = substr($sql, 0, -2); - $sql .= "\n) CHARACTER SET utf8 COLLATE utf8_bin;\n\n"; - break; - - // Create Generator - case 'firebird': - if ($generator !== false) - { - $sql .= "\nCREATE GENERATOR {$table_name}_gen;;\n"; - $sql .= 'SET GENERATOR ' . $table_name . "_gen TO 0;;\n\n"; - - $sql .= 'CREATE TRIGGER t_' . $table_name . ' FOR ' . $table_name . "\n"; - $sql .= "BEFORE INSERT\nAS\nBEGIN\n"; - $sql .= "\tNEW.{$generator} = GEN_ID({$table_name}_gen, 1);\nEND;;\n\n"; - } - break; - - case 'oracle': - if ($generator !== false) - { - $sql .= "\nCREATE SEQUENCE {$table_name}_seq\n/\n\n"; - - $sql .= "CREATE OR REPLACE TRIGGER t_{$table_name}\n"; - $sql .= "BEFORE INSERT ON {$table_name}\n"; - $sql .= "FOR EACH ROW WHEN (\n"; - $sql .= "\tnew.{$generator} IS NULL OR new.{$generator} = 0\n"; - $sql .= ")\nBEGIN\n"; - $sql .= "\tSELECT {$table_name}_seq.nextval\n"; - $sql .= "\tINTO :new.{$generator}\n"; - $sql .= "\tFROM dual;\nEND;\n/\n\n"; - } - break; - } - - return $sql; - } - - /** - * Get the real table name - * By A_Jelly_Doughnut - * - * @param string $table_name The table name to get the real table name from - */ - function get_table_name(&$table_name) - { - // Use the global table prefix if a custom one is not specified - if ($this->table_prefix === false) - { - global $table_prefix; - } - else - { - $table_prefix = $this->table_prefix; - } - - static $constants = NULL; - - if (is_null($constants)) - { - $constants = get_defined_constants(); - } - - /** - * only do the replace if the table prefix is not already present - * this is required since UMIL supports specifying a table via phpbb_foo - * (where a replace would be needed) - * or by FOO_TABLE (where a replace is already done at constant-define time) - */ - if (!preg_match('#^' . preg_quote($table_prefix, '#') . '#', $table_name) || !in_array($table_name, $constants, true)) - { - $table_name = preg_replace('#^phpbb_#i', $table_prefix, $table_name); - } - } -} - -?> \ No newline at end of file diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 216faf9866..2fd795b659 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migrator { - protected $container; + protected $config; protected $db; protected $db_tools; protected $table_prefix; @@ -33,31 +33,31 @@ class phpbb_db_migrator protected $migrations_table; protected $migration_state; - protected $migrations; + protected $migrations = array(); + + /** @var string Name of the last migration run */ + public $last_run_migration = false; /** * Constructor of the database migrator - * - * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies */ - public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $migrations) + public function __construct($config, phpbb_db_driver $db, $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools) { - $this->container = $container; - $this->db = $this->container->get('dbal.conn'); - $this->db_tools = $this->container->get('dbal.tools'); - $this->table_prefix = $this->container->getParameters('core.table_prefix'); - $this->migrations_table = $this->container->getParameters('tables.migrations'); - $this->migrations = $migrations; + $this->config = $config; + $this->db = $db; + $this->db_tools = $db_tools; - $this->phpbb_root_path = $this->container->getParameters('core.root_path'); - $this->php_ext = $this->container->getParameters('core.php_ext'); + $this->migrations_table = $migrations_table; - /** @todo replace with collection_pass when merged */ - $this->tools = array( - 'config' => new phpbb_db_migration_tools_config, - 'module' => new phpbb_db_migration_tools_module, - 'permission' => new phpbb_db_migration_tools_permission, - ); + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->table_prefix = $table_prefix; + + foreach ($tools as $tool) + { + $this->tools[$tool->get_name()] = $tool; + } $this->load_migration_state(); } @@ -93,13 +93,44 @@ class phpbb_db_migrator $this->migrations = $class_names; } + /** + * Load migration data files from a directory + * + * @param string $path + * @return array Array of migrations with names + */ + public function load_migrations($path) + { + $handle = opendir($path); + while (($file = readdir($handle)) !== false) + { + if (strpos($file, '_') !== 0 && strrpos($file, '.' . $this->php_ext) === (strlen($file) - strlen($this->php_ext) - 1)) + { + $name = 'phpbb_db_migration_data_' . substr($file, 0, -(strlen($this->php_ext) + 1)); + + if (!in_array($name, $this->migrations)) + { + $this->migrations[] = $name; + } + } + } + + foreach ($this->migrations as $name) + { + if ($this->unfulfillable($name)) + { + throw new phpbb_db_migration_exception('MIGRATION NOT FULFILLABLE', $name); + } + } + + return $this->migrations; + } + /** * Runs a single update step from the next migration to be applied. * * The update step can either be a schema or a (partial) data update. To * check if update() needs to be called again use the finished() method. - * - * @return null */ public function update() { @@ -134,7 +165,8 @@ class phpbb_db_migrator return false; } - $migration = new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); + $migration = $this->get_migration($name); + $state = (isset($this->migration_state[$name])) ? $this->migration_state[$name] : array( @@ -157,6 +189,11 @@ class phpbb_db_migrator } } + $this->last_run_migration = array( + 'name' => $name, + 'class' => $migration, + ); + if (!isset($this->migration_state[$name])) { $state['migration_start_time'] = time(); @@ -187,20 +224,20 @@ class phpbb_db_migrator protected function process_data_step($migration) { - $continue = false; + //$continue = false; $steps = $migration->update_data(); foreach ($steps as $step) { $continue = $this->run_step($step); - if (!$continue) + /*if ($continue === false) { return false; - } + }*/ } - return $continue; + //return $continue; } protected function run_step($step) @@ -211,13 +248,12 @@ class phpbb_db_migrator $callable = $callable_and_parameters[0]; $parameters = $callable_and_parameters[1]; - call_user_func_array($callable, $parameters); - - return false; + return call_user_func_array($callable, $parameters); } catch (phpbb_db_migration_exception $e) { - echo $e;die(); + echo $e; + die(); } } @@ -325,7 +361,7 @@ class phpbb_db_migrator return true; } - $migration = new $name($this->db, $this->db_tools, $this->table_prefix, $this->phpbb_root_path, $this->php_ext); + $migration = $this->get_migration($name); $depends = $migration->depends_on(); foreach ($depends as $depend) @@ -374,4 +410,15 @@ class phpbb_db_migrator { $this->db_tools->perform_schema_changes($schema_changes); } + + /** + * Helper to get a migration + * + * @param string $name Name of the migration + * @return phpbb_db_migration + */ + protected function get_migration($name) + { + return new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix); + } } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d0ef2759d5..057bdba0e3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2868,6 +2868,7 @@ function send_status_line($code, $message) else { $version = phpbb_request_http_version(); + header("$version $code $message", true, $code); } } @@ -5582,7 +5583,7 @@ function phpbb_convert_30_dbms_to_31($dbms) /* $reflection = new \ReflectionClass($dbms); - + if ($reflection->isSubclassOf('phpbb_db_driver')) { return $dbms; diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 207ad716de..8950d677ae 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1521,8 +1521,6 @@ function change_database_data(&$no_updates, $version) ), ); - global $db_tools; - $statements = $db_tools->perform_schema_changes($changes); foreach ($statements as $sql) @@ -2164,26 +2162,41 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); - global $db_tools, $table_prefix; - - // Recover from potentially broken Q&A CAPTCHA table on firebird - // Q&A CAPTCHA was uninstallable, so it's safe to remove these - // without data loss + /* + * Due to a bug, vanilla phpbb could not create captcha tables + * in 3.0.8 on firebird. It was possible for board administrators + * to adjust the code to work. If code was manually adjusted by + * board administrators, index names would not be the same as + * what 3.0.9 and newer expect. This code fragment drops captcha + * tables, destroying all entered Q&A captcha configuration, such + * that when Q&A is configured next the respective tables will be + * created with correct index names. + * + * If you wish to preserve your Q&A captcha configuration, you can + * manually rename indexes to the currently expected name: + * phpbb_captcha_questions_lang_iso => phpbb_captcha_questions_lang + * phpbb_captcha_answers_question_id => phpbb_captcha_answers_qid + * + * Again, this needs to be done only if a board was manually modified + * to fix broken captcha code. + * if ($db_tools->sql_layer == 'firebird') { - $tables = array( - $table_prefix . 'captcha_questions', - $table_prefix . 'captcha_answers', - $table_prefix . 'qa_confirm', + $changes = array( + 'drop_tables' => array( + $table_prefix . 'captcha_questions', + $table_prefix . 'captcha_answers', + $table_prefix . 'qa_confirm', + ), ); - foreach ($tables as $table) + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) { - if ($db_tools->sql_table_exists($table)) - { - $db_tools->sql_table_drop($table); - } + _sql($sql, $errored, $error_ary); } } + */ $no_updates = false; break; @@ -2360,6 +2373,26 @@ function change_database_data(&$no_updates, $version) } } + // Disable receiving pms for bots + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $db->sql_in_set('user_id', $bot_user_ids); + _sql($sql, $errored, $error_ary); + } + $no_updates = false; break; diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 43099fc33b..535cbb0df4 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -573,18 +573,6 @@ CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts(attempt_forwar CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts(attempt_time);; CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts(user_id);; -# Table: 'phpbb_migrations' -CREATE TABLE phpbb_migrations ( - migration_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - migration_schema_done INTEGER DEFAULT 0 NOT NULL, - migration_data_done INTEGER DEFAULT 0 NOT NULL, - migration_data_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, - migration_start_time INTEGER DEFAULT 0 NOT NULL, - migration_end_time INTEGER DEFAULT 0 NOT NULL -);; - -CREATE UNIQUE INDEX phpbb_migrations_migration_name ON phpbb_migrations(migration_name);; - # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id INTEGER DEFAULT 0 NOT NULL, @@ -598,6 +586,19 @@ CREATE TABLE phpbb_moderator_cache ( CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache(display_on_index);; CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache(forum_id);; +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + migration_schema_done INTEGER DEFAULT 0 NOT NULL, + migration_data_done INTEGER DEFAULT 0 NOT NULL, + migration_data_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, + migration_start_time INTEGER DEFAULT 0 NOT NULL, + migration_end_time INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_migrations ADD PRIMARY KEY (migration_name);; + + # Table: 'phpbb_modules' CREATE TABLE phpbb_modules ( module_id INTEGER NOT NULL, @@ -924,8 +925,8 @@ CREATE TABLE phpbb_reports ( report_time INTEGER DEFAULT 0 NOT NULL, report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - reported_post_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL + reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + reported_post_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL );; ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 1174cdfa3d..43b8f3e556 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -696,23 +696,6 @@ CREATE INDEX [user_id] ON [phpbb_login_attempts]([user_id]) ON [PRIMARY] GO -/* - Table: 'phpbb_migrations' -*/ -CREATE TABLE [phpbb_migrations] ( - [migration_name] [varchar] (255) DEFAULT ('') NOT NULL , - [migration_schema_done] [int] DEFAULT (0) NOT NULL , - [migration_data_done] [int] DEFAULT (0) NOT NULL , - [migration_data_state] [varchar] (8000) DEFAULT ('') NOT NULL , - [migration_start_time] [int] DEFAULT (0) NOT NULL , - [migration_end_time] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [migration_name] ON [phpbb_migrations]([migration_name]) ON [PRIMARY] -GO - - /* Table: 'phpbb_moderator_cache' */ @@ -733,6 +716,27 @@ CREATE INDEX [forum_id] ON [phpbb_moderator_cache]([forum_id]) ON [PRIMARY] GO +/* + Table: 'phpbb_migrations' +*/ +CREATE TABLE [phpbb_migrations] ( + [migration_name] [varchar] (255) DEFAULT ('') NOT NULL , + [migration_schema_done] [int] DEFAULT (0) NOT NULL , + [migration_data_done] [int] DEFAULT (0) NOT NULL , + [migration_data_state] [varchar] (8000) DEFAULT ('') NOT NULL , + [migration_start_time] [int] DEFAULT (0) NOT NULL , + [migration_end_time] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_migrations] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_migrations] PRIMARY KEY CLUSTERED + ( + [migration_name] + ) ON [PRIMARY] +GO + + /* Table: 'phpbb_modules' */ @@ -1128,8 +1132,8 @@ CREATE TABLE [phpbb_reports] ( [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , [reported_post_text] [text] DEFAULT ('') NOT NULL , - [reported_post_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL + [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [reported_post_bitfield] [varchar] (255) DEFAULT ('') NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index d645c3384d..c46230744a 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -397,18 +397,6 @@ CREATE TABLE phpbb_login_attempts ( ); -# Table: 'phpbb_migrations' -CREATE TABLE phpbb_migrations ( - migration_name varbinary(255) DEFAULT '' NOT NULL, - migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - migration_data_state blob NOT NULL, - migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - UNIQUE migration_name (migration_name) -); - - # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -422,6 +410,18 @@ CREATE TABLE phpbb_moderator_cache ( ); +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name varbinary(255) DEFAULT '' NOT NULL, + migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_state blob NOT NULL, + migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (migration_name) +); + + # Table: 'phpbb_modules' CREATE TABLE phpbb_modules ( module_id mediumint(8) UNSIGNED NOT NULL auto_increment, @@ -661,8 +661,8 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumblob NOT NULL, reported_post_text mediumblob NOT NULL, - reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, reported_post_uid varbinary(8) DEFAULT '' NOT NULL, + reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index d10f2dc55a..fa94598e9c 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -397,18 +397,6 @@ CREATE TABLE phpbb_login_attempts ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -# Table: 'phpbb_migrations' -CREATE TABLE phpbb_migrations ( - migration_name varchar(255) DEFAULT '' NOT NULL, - migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - migration_data_state text NOT NULL, - migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - UNIQUE migration_name (migration_name) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -422,6 +410,18 @@ CREATE TABLE phpbb_moderator_cache ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name varchar(255) DEFAULT '' NOT NULL, + migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + migration_data_state text NOT NULL, + migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (migration_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_modules' CREATE TABLE phpbb_modules ( module_id mediumint(8) UNSIGNED NOT NULL auto_increment, @@ -661,8 +661,8 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumtext NOT NULL, reported_post_text mediumtext NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 9993caeb7a..f8a9d5e1a6 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -780,21 +780,6 @@ CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id) / -/* - Table: 'phpbb_migrations' -*/ -CREATE TABLE phpbb_migrations ( - migration_name varchar2(255) DEFAULT '' , - migration_schema_done number(1) DEFAULT '0' NOT NULL, - migration_data_done number(1) DEFAULT '0' NOT NULL, - migration_data_state clob DEFAULT '' , - migration_start_time number(11) DEFAULT '0' NOT NULL, - migration_end_time number(11) DEFAULT '0' NOT NULL, - CONSTRAINT u_phpbb_migration_name UNIQUE (migration_name) -) -/ - - /* Table: 'phpbb_moderator_cache' */ @@ -813,6 +798,21 @@ CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id) / +/* + Table: 'phpbb_migrations' +*/ +CREATE TABLE phpbb_migrations ( + migration_name varchar2(255) DEFAULT '' , + migration_schema_done number(1) DEFAULT '0' NOT NULL, + migration_data_done number(1) DEFAULT '0' NOT NULL, + migration_data_state clob DEFAULT '' , + migration_start_time number(11) DEFAULT '0' NOT NULL, + migration_end_time number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_migrations PRIMARY KEY (migration_name) +) +/ + + /* Table: 'phpbb_modules' */ @@ -1231,8 +1231,8 @@ CREATE TABLE phpbb_reports ( report_time number(11) DEFAULT '0' NOT NULL, report_text clob DEFAULT '' , reported_post_text clob DEFAULT '' , - reported_post_bitfield varchar2(255) DEFAULT '' , reported_post_uid varchar2(8) DEFAULT '' , + reported_post_bitfield varchar2(255) DEFAULT '' , CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index ef138dac0f..c976659f05 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -557,20 +557,6 @@ CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwa CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); -/* - Table: 'phpbb_migrations' -*/ -CREATE TABLE phpbb_migrations ( - migration_name varchar(255) DEFAULT '' NOT NULL, - migration_schema_done INT2 DEFAULT '0' NOT NULL CHECK (migration_schema_done >= 0), - migration_data_done INT2 DEFAULT '0' NOT NULL CHECK (migration_data_done >= 0), - migration_data_state varchar(8000) DEFAULT '' NOT NULL, - migration_start_time INT4 DEFAULT '0' NOT NULL CHECK (migration_start_time >= 0), - migration_end_time INT4 DEFAULT '0' NOT NULL CHECK (migration_end_time >= 0) -); - -CREATE UNIQUE INDEX phpbb_migrations_migration_name ON phpbb_migrations (migration_name); - /* Table: 'phpbb_moderator_cache' */ @@ -586,6 +572,20 @@ CREATE TABLE phpbb_moderator_cache ( CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index); CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); +/* + Table: 'phpbb_migrations' +*/ +CREATE TABLE phpbb_migrations ( + migration_name varchar(255) DEFAULT '' NOT NULL, + migration_schema_done INT2 DEFAULT '0' NOT NULL CHECK (migration_schema_done >= 0), + migration_data_done INT2 DEFAULT '0' NOT NULL CHECK (migration_data_done >= 0), + migration_data_state varchar(8000) DEFAULT '' NOT NULL, + migration_start_time INT4 DEFAULT '0' NOT NULL CHECK (migration_start_time >= 0), + migration_end_time INT4 DEFAULT '0' NOT NULL CHECK (migration_end_time >= 0), + PRIMARY KEY (migration_name) +); + + /* Table: 'phpbb_modules' */ @@ -869,8 +869,8 @@ CREATE TABLE phpbb_reports ( report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), report_text TEXT DEFAULT '' NOT NULL, reported_post_text TEXT DEFAULT '' NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (report_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 309297779e..31a6f715a0 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -385,18 +385,6 @@ CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwa CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); -# Table: 'phpbb_migrations' -CREATE TABLE phpbb_migrations ( - migration_name varchar(255) NOT NULL DEFAULT '', - migration_schema_done INTEGER UNSIGNED NOT NULL DEFAULT '0', - migration_data_done INTEGER UNSIGNED NOT NULL DEFAULT '0', - migration_data_state text(65535) NOT NULL DEFAULT '', - migration_start_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - migration_end_time INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE UNIQUE INDEX phpbb_migrations_migration_name ON phpbb_migrations (migration_name); - # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', @@ -410,6 +398,18 @@ CREATE TABLE phpbb_moderator_cache ( CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index); CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); +# Table: 'phpbb_migrations' +CREATE TABLE phpbb_migrations ( + migration_name varchar(255) NOT NULL DEFAULT '', + migration_schema_done INTEGER UNSIGNED NOT NULL DEFAULT '0', + migration_data_done INTEGER UNSIGNED NOT NULL DEFAULT '0', + migration_data_state text(65535) NOT NULL DEFAULT '', + migration_start_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + migration_end_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (migration_name) +); + + # Table: 'phpbb_modules' CREATE TABLE phpbb_modules ( module_id INTEGER PRIMARY KEY NOT NULL , @@ -642,8 +642,8 @@ CREATE TABLE phpbb_reports ( report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', report_text mediumtext(16777215) NOT NULL DEFAULT '', reported_post_text mediumtext(16777215) NOT NULL DEFAULT '', - reported_post_bitfield varchar(255) NOT NULL DEFAULT '', - reported_post_uid varchar(8) NOT NULL DEFAULT '' + reported_post_uid varchar(8) NOT NULL DEFAULT '', + reported_post_bitfield varchar(255) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); diff --git a/phpBB/test.php b/phpBB/test.php new file mode 100644 index 0000000000..5887c08d2f --- /dev/null +++ b/phpBB/test.php @@ -0,0 +1,121 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2005 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +/** +* @ignore +*/ +define('IN_PHPBB', true); +$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; +$phpEx = substr(strrchr(__FILE__, '.'), 1); + +require($phpbb_root_path . 'includes/startup.' . $phpEx); + +if (file_exists($phpbb_root_path . 'config.' . $phpEx)) +{ + require($phpbb_root_path . 'config.' . $phpEx); +} + +// Include files +require($phpbb_root_path . 'includes/class_loader.' . $phpEx); + +require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); + +require($phpbb_root_path . 'includes/constants.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +// Set PHP error handler to ours +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); + +// Setup class loader first +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); + +/*$phpbb_container = phpbb_create_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel_pass(), + ), + $phpbb_root_path, $phpEx); +$phpbb_container->compile();*/ + +// Set up container +$container_extensions = array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), +); +$container_passes = array( + new phpbb_di_pass_collection_pass(), + //new phpbb_di_pass_kernel_pass(), +); +$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); + +// Compile the container +foreach ($container_passes as $pass) +{ + $phpbb_container->addCompilerPass($pass); +} +$phpbb_container->compile(); + +// set up caching +$cache = $phpbb_container->get('cache'); + +// Instantiate some basic classes +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); + +// make sure request_var uses this request instance +request_var('', 0, false, false, $request); // "dependency injection" for a function + +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); + +// End startup code + +$db_tools = $phpbb_container->get('dbal.tools'); +if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) +{ + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); +} + +$migrator = $phpbb_container->get('migrator'); +$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); + +while (!$migrator->finished()) +{ + $migrator->update(); + + echo $migrator->last_run_migration['name'] . '<br />'; +} + +echo 'Finished'; diff --git a/tests/dbal/fixtures/migrator_module.xml b/tests/dbal/fixtures/migrator_module.xml new file mode 100644 index 0000000000..32afe7e6f3 --- /dev/null +++ b/tests/dbal/fixtures/migrator_module.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_modules"> + <column>module_id</column> + <column>module_enabled</column> + <column>module_display</column> + <column>module_basename</column> + <column>module_class</column> + <column>parent_id</column> + <column>left_id</column> + <column>right_id</column> + <column>module_langname</column> + <column>module_mode</column> + <column>module_auth</column> + <row> + <value>1</value> + <value>1</value> + <value>1</value> + <value></value> + <value>acp</value> + <value>0</value> + <value>1</value> + <value>4</value> + <value>ACP_CAT</value> + <value></value> + <value></value> + </row> + <row> + <value>2</value> + <value>1</value> + <value>1</value> + <value>acp_test</value> + <value>acp</value> + <value>1</value> + <value>2</value> + <value>3</value> + <value>ACP_MODULE</value> + <value>test</value> + <value></value> + </row> + </table> +</dataset> diff --git a/tests/dbal/fixtures/migrator_permission.xml b/tests/dbal/fixtures/migrator_permission.xml new file mode 100644 index 0000000000..08cec42a42 --- /dev/null +++ b/tests/dbal/fixtures/migrator_permission.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_acl_options"> + <column>auth_option_id</column> + <column>auth_option</column> + <column>is_global</column> + <column>is_local</column> + <column>founder_only</column> + <row> + <value>1</value> + <value>global</value> + <value>1</value> + <value>0</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>local</value> + <value>0</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>3</value> + <value>both</value> + <value>1</value> + <value>1</value> + <value>0</value> + </row> + </table> +</dataset> diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 898a197dfd..463cf9fcec 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/db/migrator.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/migration.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/migration/dummy.php'; @@ -28,11 +28,17 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case public function setUp() { - parent::setup(); + parent::setUp(); $this->db = $this->new_dbal(); $this->db_tools = new phpbb_db_tools($this->db); - $this->migrator = new phpbb_db_migrator($this->db, $this->db_tools, 'phpbb_', MIGRATIONS_TABLE, 'phpBB/', '.php'); + + $this->config = new phpbb_config_db($this->db, new phpbb_mock_cache, 'phpbb_config'); + + $tools = array( + new phpbb_db_migration_tool_config($this->config), + ); + $this->migrator = new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', dirname(__FILE__) . '/../../phpBB/', 'php', 'phpbb_', $tools); } public function tearDown() diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php new file mode 100644 index 0000000000..27511519ca --- /dev/null +++ b/tests/dbal/migrator_tool_config_test.php @@ -0,0 +1,97 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/config.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; + +class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case +{ + public function setup() + { + $this->config = new phpbb_config(array()); + + $this->tool = new phpbb_db_migration_tool_config($this->config); + + parent::setup(); + } + + public function test_add() + { + try + { + $this->tool->add('foo', 'bar'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals('bar', $this->config['foo']); + + try + { + $this->tool->add('foo', 'bar'); + $this->fail('Exception not thrown'); + } + catch (Exception $e) {} + } + + public function test_update() + { + $this->config->set('foo', 'bar'); + try + { + $this->tool->update('foo', 'bar2'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals('bar2', $this->config['foo']); + } + + public function test_update_if_equals() + { + $this->config->set('foo', 'bar'); + + try + { + $this->tool->update_if_equals('', 'foo', 'bar2'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals('bar', $this->config['foo']); + + try + { + $this->tool->update_if_equals('bar', 'foo', 'bar2'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals('bar2', $this->config['foo']); + } + + public function test_remove() + { + $this->config->set('foo', 'bar'); + + try + { + $this->tool->remove('foo'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertFalse(isset($this->config['foo'])); + } +} diff --git a/tests/dbal/migrator_tool_module.php b/tests/dbal/migrator_tool_module.php new file mode 100644 index 0000000000..0b57cbfbcb --- /dev/null +++ b/tests/dbal/migrator_tool_module.php @@ -0,0 +1,128 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/module.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; + +class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_module.xml'); + } + + public function setup() + { + // Need global $db, $user for delete_module function in acp_modules + global $phpbb_root_path, $phpEx, $skip_add_log, $db, $user; + + parent::setup(); + + // Force add_log function to not be used + $skip_add_log = true; + + $db = $this->db = $this->new_dbal(); + $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null()); + $user = $this->user = new phpbb_user(); + + $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx); + } + + public function exists_data() + { + return array( + // Test the category + array( + '', + 'ACP_CAT', + true, + ), + array( + 0, + 'ACP_CAT', + true, + ), + + // Test the module + array( + '', + 'ACP_MODULE', + false, + ), + array( + false, + 'ACP_MODULE', + true, + ), + array( + 'ACP_CAT', + 'ACP_MODULE', + true, + ), + ); + } + + /** + * @dataProvider exists_data + */ + public function test_exists($parent, $module, $expected) + { + $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module)); + } + + public function test_add() + { + try + { + $this->tool->add('acp', 0, 'ACP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 0, 'ACP_NEW_CAT')); + + // Should throw an exception when trying to add a module that already exists + try + { + $this->tool->add('acp', 0, 'ACP_NEW_CAT'); + $this->fail('Exception not thrown'); + } + catch (Exception $e) {} + + try + { + $this->tool->add('acp', ACP_NEW_CAT, array( + 'module_basename' => 'acp_new_module', + 'module_langname' => 'ACP_NEW_MODULE', + 'module_mode' => 'test', + 'module_auth' => '', + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE')); + } + + public function test_remove() + { + try + { + $this->tool->remove('acp', 'ACP_CAT', 'ACP_MODULE'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(false, $this->tool->exists('acp', 'ACP_CAT', 'ACP_MODULE')); + } +} diff --git a/tests/dbal/migrator_tool_permission.php b/tests/dbal/migrator_tool_permission.php new file mode 100644 index 0000000000..2229576cd9 --- /dev/null +++ b/tests/dbal/migrator_tool_permission.php @@ -0,0 +1,136 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/permission.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; + +class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_permission.xml'); + } + + public function setup() + { + // Global $db and $cache are needed in acp/auth.php constructor + global $phpbb_root_path, $phpEx, $db, $cache; + + parent::setup(); + + $db = $this->db = $this->new_dbal(); + $cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null()); + $this->auth = new phpbb_auth(); + + $this->tool = new phpbb_db_migration_tool_permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx); + } + + public function exists_data() + { + return array( + array( + 'global', + true, + true, + ), + array( + 'local', + false, + true, + ), + array( + 'both', + true, + true, + ), + array( + 'both', + false, + true, + ), + array( + 'does_not_exist', + true, + false, + ), + ); + } + + /** + * @dataProvider exists_data + */ + public function test_exists($auth_option, $global, $expected) + { + $this->assertEquals($expected, $this->tool->exists($auth_option, $global)); + } + + public function test_add() + { + try + { + $this->tool->add('new', true); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('new', true)); + $this->assertEquals(false, $this->tool->exists('new', false)); + + try + { + $this->tool->add('new', false); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('new', false)); + + // Should fail (duplicate) + try + { + $this->tool->add('new', true); + $this->fail('Did not throw exception on duplicate'); + } + catch (Exception $e) {} + } + + public function test_remove() + { + try + { + $this->tool->remove('global', true); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(false, $this->tool->exists('global', true)); + + try + { + $this->tool->remove('both', false); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(false, $this->tool->exists('both', false)); + + // Should fail (does not exist) + try + { + $this->tool->remove('new', true); + $this->fail('Did not throw exception on duplicate'); + } + catch (Exception $e) {} + } +} From aceadfd77b620677a838c61085c88db4d28e4a8a Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 8 Jan 2013 22:19:56 -0600 Subject: [PATCH 033/174] [feature/migrations] Remove migration data (separate PR) PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 28 -- phpBB/includes/db/migration/data/3_0_10.php | 28 -- .../includes/db/migration/data/3_0_10_rc1.php | 30 -- .../includes/db/migration/data/3_0_10_rc2.php | 28 -- .../includes/db/migration/data/3_0_10_rc3.php | 28 -- phpBB/includes/db/migration/data/3_0_11.php | 28 -- .../includes/db/migration/data/3_0_11_rc1.php | 98 ----- .../includes/db/migration/data/3_0_11_rc2.php | 34 -- .../includes/db/migration/data/3_0_12_rc1.php | 123 ------ .../includes/db/migration/data/3_0_1_rc1.php | 79 ---- phpBB/includes/db/migration/data/3_0_2.php | 28 -- .../includes/db/migration/data/3_0_2_rc1.php | 32 -- .../includes/db/migration/data/3_0_2_rc2.php | 55 --- phpBB/includes/db/migration/data/3_0_3.php | 28 -- .../includes/db/migration/data/3_0_3_rc1.php | 63 --- phpBB/includes/db/migration/data/3_0_4.php | 49 --- .../includes/db/migration/data/3_0_4_rc1.php | 107 ----- phpBB/includes/db/migration/data/3_0_5.php | 28 -- .../includes/db/migration/data/3_0_5_rc1.php | 119 ------ .../db/migration/data/3_0_5_rc1part2.php | 37 -- phpBB/includes/db/migration/data/3_0_6.php | 28 -- .../includes/db/migration/data/3_0_6_rc1.php | 279 ------------- .../includes/db/migration/data/3_0_6_rc2.php | 28 -- .../includes/db/migration/data/3_0_6_rc3.php | 40 -- .../includes/db/migration/data/3_0_6_rc4.php | 28 -- phpBB/includes/db/migration/data/3_0_7.php | 28 -- .../includes/db/migration/data/3_0_7_pl1.php | 28 -- .../includes/db/migration/data/3_0_7_rc1.php | 53 --- .../includes/db/migration/data/3_0_7_rc2.php | 72 ---- phpBB/includes/db/migration/data/3_0_8.php | 28 -- .../includes/db/migration/data/3_0_8_rc1.php | 225 ----------- phpBB/includes/db/migration/data/3_0_9.php | 28 -- .../includes/db/migration/data/3_0_9_rc1.php | 110 ------ .../includes/db/migration/data/3_0_9_rc2.php | 28 -- .../includes/db/migration/data/3_0_9_rc3.php | 28 -- .../includes/db/migration/data/3_0_9_rc4.php | 28 -- .../includes/db/migration/data/3_1_0_dev.php | 369 ------------------ .../includes/db/migration/data/extensions.php | 49 --- .../db/migration/data/style_update_p1.php | 157 -------- .../db/migration/data/style_update_p2.php | 42 -- phpBB/includes/db/migration/data/timezone.php | 161 -------- 41 files changed, 2887 deletions(-) delete mode 100644 phpBB/includes/db/migration/data/3_0_1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_10_rc3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_11.php delete mode 100644 phpBB/includes/db/migration/data/3_0_11_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_11_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_12_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_1_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_2_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_2_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_3_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_4.php delete mode 100644 phpBB/includes/db/migration/data/3_0_4_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_5.php delete mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1part2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_6_rc4.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7_pl1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_7_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_8.php delete mode 100644 phpBB/includes/db/migration/data/3_0_8_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc1.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc2.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc3.php delete mode 100644 phpBB/includes/db/migration/data/3_0_9_rc4.php delete mode 100644 phpBB/includes/db/migration/data/3_1_0_dev.php delete mode 100644 phpBB/includes/db/migration/data/extensions.php delete mode 100644 phpBB/includes/db/migration/data/style_update_p1.php delete mode 100644 phpBB/includes/db/migration/data/style_update_p2.php delete mode 100644 phpBB/includes/db/migration/data/timezone.php diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php deleted file mode 100644 index a2332c9b59..0000000000 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_1_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php deleted file mode 100644 index 07410c5ba1..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_10_rc3'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.10')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php deleted file mode 100644 index daac50a631..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_9'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.add', array('email_max_chunk_size', 50)), - - array('config.update', array('version', '3.0.10-rc1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php deleted file mode 100644 index 234e4c5fc7..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_10_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.10-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php deleted file mode 100644 index 075ce35e3e..0000000000 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_10_rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.10-rc3')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php deleted file mode 100644 index 0bc9b6c4a5..0000000000 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_11_rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.11')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php deleted file mode 100644 index daf106accf..0000000000 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_10'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), - array('custom', array(array(&$this, 'delete_orphan_private_messages'))), - - array('config.update', array('version', '3.0.11-rc1')), - ); - } - - function cleanup_deactivated_styles() - { - // Updates users having current style a deactivated one - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_active = 0'; - $result = $this->sql_query($sql); - - $deactivated_style_ids = array(); - while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) - { - $deactivated_style_ids[] = (int) $style_id; - } - $this->db->sql_freeresult($result); - - if (!empty($deactivated_style_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $this->config['default_style'] .' - WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); - $this->sql_query($sql); - } - } - - function delete_orphan_private_messages() - { - // Delete orphan private messages - $batch_size = 500; - - $sql_array = array( - 'SELECT' => 'p.msg_id', - 'FROM' => array( - PRIVMSGS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), - 'ON' => 'p.msg_id = t.msg_id', - ), - ), - 'WHERE' => 't.user_id IS NULL', - ); - $sql = $this->db->sql_build_query('SELECT', $sql_array); - - $result = $this->db->sql_query_limit($sql, $batch_size); - - $delete_pms = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $delete_pms[] = (int) $row['msg_id']; - } - $this->db->sql_freeresult($result); - - if (!empty($delete_pms)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); - $this->sql_query($sql); - - return true; - } - else - { - return false; - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php deleted file mode 100644 index f2bed54085..0000000000 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_11_rc1'); - } - - function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_novalue' => array('BOOL', 0), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.11-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php deleted file mode 100644 index 0d8702f19e..0000000000 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/ - -class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration -{ - public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_schema() - { - return array(); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_module_auth'))), - array('custom', array(array(&$this, 'update_bots'))), - array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))), - - array('config.update', array('version', '3.0.12-rc1')), - ); - } - - public function disable_bots_from_receiving_pms() - { - // Disable receiving pms for bots - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $this->db->sql_query($sql); - - $bot_user_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $bot_user_ids[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - if (!empty($bot_user_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids); - $this->sql_query($sql); - } - } - - public function update_module_auth() - { - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_u_sig\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'signature\''; - $this->sql_query($sql); - } - - public function update_bots() - { - // Update bots - if (!function_exists('user_delete')) - { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $bots_updates = array( - // Bot Deletions - 'NG-Search [Bot]' => false, - 'Nutch/CVS [Bot]' => false, - 'OmniExplorer [Bot]' => false, - 'Seekport [Bot]' => false, - 'Synoo [Bot]' => false, - 'WiseNut [Bot]' => false, - - // Bot Updates - // Bot name to bot user agent map - 'Baidu [Spider]' => 'Baiduspider', - 'Exabot [Bot]' => 'Exabot', - 'Voyager [Bot]' => 'voyager/', - 'W3C [Validator]' => 'W3C_Validator', - ); - - foreach ($bots_updates as $bot_name => $bot_agent) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_IGNORE . " - AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; - $result = $this->db->sql_query($sql); - $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); - $this->db->sql_freeresult($result); - - if ($bot_user_id) - { - if ($bot_agent === false) - { - $sql = 'DELETE FROM ' . BOTS_TABLE . " - WHERE user_id = $bot_user_id"; - $this->sql_query($sql); - - user_delete('remove', $bot_user_id); - } - else - { - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' - WHERE user_id = $bot_user_id"; - $this->sql_query($sql); - } - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php deleted file mode 100644 index a3b4810d21..0000000000 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array(); - } - - function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'forums' => array( - 'display_subforum_list' => array('BOOL', 1), - ), - $this->table_prefix . 'sessions' => array( - 'session_forum_id' => array('UINT', 0), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'groups' => array('group_legend'), - ), - 'add_index' => array( - $this->table_prefix . 'sessions' => array( - 'session_forum_id' => array('session_forum_id'), - ), - $this->table_prefix . 'groups' => array( - 'group_legend_name' => array('group_legend', 'group_name'), - ), - ), - ); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'fix_unset_last_view_time'))), - array('custom', array(array(&$this, 'reset_smiley_size'))), - - array('config.update', array('version', '3.0.1-rc1')), - ); - } - - function fix_unset_last_view_time() - { - $sql = 'UPDATE ' . $this->table_prefix . "topics - SET topic_last_view_time = topic_last_post_time - WHERE topic_last_view_time = 0"; - $this->sql_query($sql); - } - - function reset_smiley_size() - { - // Update smiley sizes - $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); - - foreach ($smileys as $smiley) - { - if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley)) - { - list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley); - - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET smiley_width = ' . $width . ', smiley_height = ' . $height . " - WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'"; - - $this->sql_query($sql); - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php deleted file mode 100644 index 3469d8d178..0000000000 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_2_rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php deleted file mode 100644 index d3c2200f14..0000000000 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.add', array('referer_validation', '1')), - array('config.add', array('check_attachment_content', '1')), - array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), - - array('config.update', array('version', '3.0.2-rc1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php deleted file mode 100644 index 67fd1faec6..0000000000 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_2_rc1'); - } - - function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'drafts' => array( - 'draft_subject' => array('STEXT_UNI', ''), - ), - $this->table_prefix . 'forums' => array( - 'forum_last_post_subject' => array('STEXT_UNI', ''), - ), - $this->table_prefix . 'posts' => array( - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - ), - $this->table_prefix . 'privmsgs' => array( - 'message_subject' => array('STEXT_UNI', ''), - ), - $this->table_prefix . 'topics' => array( - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'sessions' => array('session_forum_id'), - ), - 'add_index' => array( - $this->table_prefix . 'sessions' => array( - 'session_fid' => array('session_forum_id'), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.2-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php deleted file mode 100644 index dff375f438..0000000000 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_3_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.3')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php deleted file mode 100644 index 2320c4ac4b..0000000000 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_2'); - } - - function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'styles_template' => array( - 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', ''), - ), - $this->table_prefix . 'groups' => array( - 'group_max_recipients' => array('UINT', 0), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.add', array('enable_queue_trigger', '0')), - array('config.add', array('queue_trigger_posts', '3')), - array('config.add', array('pm_max_recipients', '0')), - array('custom', array(array(&$this, 'set_group_default_max_recipients'))), - array('config.add', array('dbms_version', $this->db->sql_server_info(true))), - array('permission.add', array('u_masspm_group', true, 'u_masspm')), - array('custom', array(array(&$this, 'correct_acp_email_permissions'))), - - array('config.update', array('version', '3.0.3-rc1')), - ); - } - - function correct_acp_email_permissions() - { - $sql = 'UPDATE ' . $this->table_prefix . 'modules - SET module_auth = \'acl_a_email && cfg_email_enable\' - WHERE module_class = \'acp\' - AND module_basename = \'email\''; - $this->sql_query($sql); - } - - function set_group_default_max_recipients() - { - // Set maximum number of recipients for the registered users, bots, guests group - $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 - WHERE ' . $this->db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); - $this->sql_query($sql); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php deleted file mode 100644 index 1af4508331..0000000000 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_4_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'rename_log_delete_topic'))), - - array('config.update', array('version', '3.0.4')), - ); - } - - function rename_log_delete_topic() - { - if ($this->db->sql_layer == 'oracle') - { - // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . $this->table_prefix . "log - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - $this->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . $this->table_prefix . "log - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation = 'LOG_TOPIC_DELETED'"; - $this->sql_query($sql); - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php deleted file mode 100644 index e9bb0e01f5..0000000000 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_3'); - } - - function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'styles' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_imageset' => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_imageset_data' => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_theme' => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template' => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template_data' => array( - 'template_id' => array('UINT', 0), - ), - $this->table_prefix . 'forums' => array( - 'forum_style' => array('UINT', 0), - ), - $this->table_prefix . 'users' => array( - 'user_style' => array('UINT', 0), - ), - ), - ); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'update_custom_profile_fields'))), - - array('config.update', array('version', '3.0.4-rc1')), - ); - } - - function update_custom_profile_fields() - { - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide - FROM ' . PROFILE_FIELDS_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivelant to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); - } - - $this->db->sql_freeresult($result); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php deleted file mode 100644 index 2f80970781..0000000000 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_5_rc1part2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.5')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php deleted file mode 100644 index cbf28c0be6..0000000000 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_4'); - } - - function update_schema() - { - return array( - 'change_columns' => array( - $this->table_prefix . 'forums' => array( - 'forum_style' => array('UINT', 0), - ), - ), - ); - } - - function update_data() - { - $search_indexing_state = $this->config['search_indexing_state']; - - return array( - array('config.add', array('captcha_gd_wave', 0)), - array('config.add', array('captcha_gd_3d_noise', 1)), - array('config.add', array('captcha_gd_fonts', 1)), - array('config.add', array('confirm_refresh', 1)), - array('config.add', array('max_num_search_keywords', 10)), - array('config.remove', array('search_indexing_state')), - array('config.add', array('search_indexing_state', $search_indexing_state, true)), - array('custom', array(array(&$this, 'hash_old_passwords'))), - array('custom', array(array(&$this, 'update_ichiro_bot'))), - ); - } - - function hash_old_passwords() - { - $sql = 'SELECT user_id, user_password - FROM ' . $this->table_prefix . 'users - WHERE user_pass_convert = 1'; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if (strlen($row['user_password']) == 32) - { - $sql_ary = array( - 'user_password' => phpbb_hash($row['user_password']), - ); - - $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); - } - } - $this->db->sql_freeresult($result); - } - - function update_ichiro_bot() - { - // Adjust bot entry - $sql = 'UPDATE ' . $this->table_prefix . "bots - SET bot_agent = 'ichiro/' - WHERE bot_agent = 'ichiro/2'"; - $this->sql_query($sql); - } - - function remove_duplicate_auth_options() - { - // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - $sql = 'SELECT auth_option - FROM ' . $this->table_prefix . 'acl_options - GROUP BY auth_option - HAVING COUNT(*) >= 2'; - $result = $this->db->sql_query($sql); - - $auth_options = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $auth_options[] = $row['auth_option']; - } - $this->db->sql_freeresult($result); - - // Remove specific auth options - if (!empty($auth_options)) - { - foreach ($auth_options as $option) - { - // Select auth_option_ids... the largest id will be preserved - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = '" . $db->sql_escape($option) . "' - ORDER BY auth_option_id DESC"; - // sql_query_limit not possible here, due to bug in postgresql layer - $result = $this->db->sql_query($sql); - - // Skip first row, this is our original auth option we want to preserve - $row = $this->db->sql_fetchrow($result); - - while ($row = $this->db->sql_fetchrow($result)) - { - // Ok, remove this auth option... - $this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); - $this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); - $this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); - $this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); - } - $this->db->sql_freeresult($result); - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php deleted file mode 100644 index 1fab0f8873..0000000000 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_5_rc1'); - } - - function update_schema() - { - return array( - 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), - ), - 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.5-rc1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php deleted file mode 100644 index 26176b9437..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc4'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.6')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php deleted file mode 100644 index 35adcf52be..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ /dev/null @@ -1,279 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_5'); - } - - function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'confirm' => array( - 'attempts' => array('UINT', 0), - ), - $this->table_prefix . 'users' => array( - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time' => array('TIMESTAMP', 0), - ), - $this->table_prefix . 'groups' => array( - 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), - ), - $this->table_prefix . 'privmsgs' => array( - 'message_reported' => array('BOOL', 0), - ), - $this->table_prefix . 'reports' => array( - 'pm_id' => array('UINT', 0), - ), - $this->table_prefix . 'profile_fields' => array( - 'field_show_on_vt' => array('BOOL', 0), - ), - $this->table_prefix . 'forums' => array( - 'forum_options' => array('UINT:20', 0), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'users' => array( - 'user_options' => array('UINT:11', 230271), - ), - ), - 'add_index' => array( - $this->table_prefix . 'reports' => array( - 'post_id' => array('post_id'), - 'pm_id' => array('pm_id'), - ), - $this->table_prefix . 'posts' => array( - 'post_username' => array('post_username:255'), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), - array('if', array( - ($this->config['captcha_gd']), - array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), - )), - - array('config.add', array('feed_enable', 0)), - array('config.add', array('feed_limit', 10)), - array('config.add', array('feed_overall_forums', 1)), - array('config.add', array('feed_overall_forums_limit', 15)), - array('config.add', array('feed_overall_topics', 0)), - array('config.add', array('feed_overall_topics_limit', 15)), - array('config.add', array('feed_forum', 1)), - array('config.add', array('feed_topic', 1)), - array('config.add', array('feed_item_statistics', 1)), - - array('config.add', array('smilies_per_page', 50)), - array('config.add', array('allow_pm_report', 1)), - array('config.add', array('min_post_chars', 1)), - array('config.add', array('allow_quick_reply', 1)), - array('config.add', array('new_member_post_limit', 0)), - array('config.add', array('new_member_group_default', 0)), - array('config.add', array('delete_time', $this->config['edit_time'])), - - array('config.add', array('allow_avatar', 0)), - array('if', array( - ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), - array('config.update', array('allow_avatar', 1)), - )), - array('config.add', array('allow_avatar_remote_upload', 0)), - array('if', array( - ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), - array('config.update', array('allow_avatar_remote_upload', 1)), - )), - - array('module.add', array( - 'acp', - 'ACP_BOARD_CONFIGURATION', - array( - 'module_basename' => 'acp_board', - 'modes' => array('feed'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_CAT_USERS', - array( - 'module_basename' => 'acp_users', - 'modes' => array('warnings'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_SERVER_CONFIGURATION', - array( - 'module_basename' => 'acp_send_statistics', - 'modes' => array('send_statistics'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_FORUM_BASED_PERMISSIONS', - array( - 'module_basename' => 'acp_permissions', - 'modes' => array('setting_forum_copy'), - ), - )), - array('module.add', array( - 'mcp', - 'MCP_REPORTS', - array( - 'module_basename' => 'mcp_pm_reports', - 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), - ), - )), - array('custom', array(array(&$this, 'add_newly_registered_group'))), - array('custom', array(array(&$this, 'set_user_options_default'))), - - array('config.update', array('version', '3.0.6-rc1')), - ); - } - - function set_user_options_default() - { - // 229376 is the added value to enable all three signature options - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; - $this->sql_query($sql); - } - - function add_newly_registered_group() - { - // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED'"; - $result = $this->db->sql_query($sql); - $group_id = (int) $this->db->sql_fetchfield('group_id'); - $this->db->sql_freeresult($result); - - if (!$group_id) - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; - $this->sql_query($sql); - - $group_id = $this->db->sql_nextid(); - } - - // Insert new user role... at the end of the chain - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_USER_NEW_MEMBER' - AND role_type = 'u_'"; - $result = $this->db->sql_query($sql); - $u_role = (int) $this->db->sql_fetchfield('role_id'); - $this->db->sql_freeresult($result); - - if (!$u_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'u_'"; - $result = $this->db->sql_query($sql); - $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); - $this->db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; - $this->sql_query($sql); - $u_role = $this->db->sql_nextid(); - - // Now add the correct data to the roles... - // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - $this->sql_query($sql); - - // Add user role to group - $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - $this->sql_query($sql); - } - - // Insert new forum role - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' - AND role_type = 'f_'"; - $result = $this->db->sql_query($sql); - $f_role = (int) $this->db->sql_fetchfield('role_id'); - $this->db->sql_freeresult($result); - - if (!$f_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'f_'"; - $result = $this->db->sql_query($sql); - $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); - $this->db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; - $this->sql_query($sql); - $f_role = $this->db->sql_nextid(); - - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - $this->sql_query($sql); - } - - // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) - $sql = 'SELECT 1 - FROM ' . USERS_TABLE . ' - WHERE user_new = 0'; - $result = $this->db->sql_query_limit($sql, 1); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - $this->sql_query($sql); - } - - // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... - // Check if the role is already assigned... - $sql = 'SELECT forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id = ' . $f_role; - $result = $this->db->sql_query($sql); - $is_options = (int) $this->db->sql_fetchfield('forum_id'); - $this->db->sql_freeresult($result); - - // Not assigned at all... :/ - if (!$is_options) - { - // Get postable forums - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type != ' . FORUM_LINK; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); - } - $this->db->sql_freeresult($result); - } - - // Clear permissions... - include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); - $auth_admin = new auth_admin(); - $auth_admin->acl_clear_prefetch(); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php deleted file mode 100644 index 4092a5fa61..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.6-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php deleted file mode 100644 index ec22d1da77..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'update_cp_fields'))), - - array('config.update', array('version', '3.0.6-rc3')), - ); - } - - function update_cp_fields() - { - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' - SET field_show_on_vt = 1 - WHERE field_hide = 0 - AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; - $this->sql_query($sql); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php deleted file mode 100644 index e748c7a4ff..0000000000 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_6_rc3'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.6-rc4')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php deleted file mode 100644 index f27b56f778..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_7_rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.7')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php deleted file mode 100644 index 5543d6437a..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_7'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.7-pl1')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php deleted file mode 100644 index 71584382e8..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_6'); - } - - function update_schema() - { - return array( - 'drop_keys' => array( - $this->table_prefix . 'log' => array('log_time'), - ), - 'add_index' => array( - $this->table_prefix . 'topics_track' => array( - 'topic_id' => array('topic_id'), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.add', array('feed_overall', 1)), - array('config.add', array('feed_http_auth', 0)), - array('config.add', array('feed_limit_post', $this->config['feed_limit'])), - array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])), - array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), - array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), - array('custom', array(array(&$this, 'delete_text_templates'))), - - array('config.update', array('version', '3.0.7-rc1')), - ); - } - - function delete_text_templates() - { - // Delete all text-templates from the template_data - $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' - WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); - $this->sql_query($sql); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php deleted file mode 100644 index e2c6acce1e..0000000000 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_7_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'update_email_hash'))), - - array('config.update', array('version', '3.0.7-rc2')), - ); - } - - function update_email_hash($start = 0) - { - $limit = 1000; - - $sql = 'SELECT user_id, user_email, user_email_hash - FROM ' . USERS_TABLE . ' - WHERE user_type <> ' . USER_IGNORE . " - AND user_email <> ''"; - $result = $this->db->sql_query_limit($sql, $limit, $start); - - $i = 0; - while ($row = $this->db->sql_fetchrow($result)) - { - $i++; - - // Snapshot of the phpbb_email_hash() function - // We cannot call it directly because the auto updater updates the DB first. :/ - $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); - - if ($user_email_hash != $row['user_email_hash']) - { - $sql_ary = array( - 'user_email_hash' => $user_email_hash, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $row['user_id']; - $this->sql_query($sql); - } - } - $this->db->sql_freeresult($result); - - if ($i < $limit) - { - // Completed - return false; - } - - return $start + $limit; - } -} diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php deleted file mode 100644 index a5defc8278..0000000000 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_8_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.8')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php deleted file mode 100644 index b58b0966a5..0000000000 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ /dev/null @@ -1,225 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_7_pl1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('custom', array(array(&$this, 'update_file_extension_group_names'))), - array('custom', array(array(&$this, 'update_module_auth'))), - array('custom', array(array(&$this, 'update_bots'))), - array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))), - array('module.add', array( - 'acp', - 'ACP_MESSAGES', - array( - 'module_basename' => 'acp_board', - 'modes' => array('post'), - ), - )), - array('config.add', array('load_unreads_search', 1)), - array('config.update_if_equals', array(600, 'queue_interval', 60)), - array('config.update_if_equals', array(50, 'email_package_size', 20)), - - array('config.update', array('version', '3.0.8-rc1')), - ); - } - - function update_file_extension_group_names() - { - // Update file extension group names to use language strings. - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $this->db->sql_query($sql); - - $extension_groups_updated = array(); - while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) - { - $lang_dir = basename($lang_dir); - - // The language strings we need are either in language/.../acp/attachments.php - // in the update package if we're updating to 3.0.8-RC1 or later, - // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. - // On an already updated board, they can also already be in language/.../acp/attachments.php - // in the board root. - $lang_files = array( - "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}", - "{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}", - "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}", - ); - - foreach ($lang_files as $lang_file) - { - if (!file_exists($lang_file)) - { - continue; - } - - $lang = array(); - include($lang_file); - - foreach($lang as $lang_key => $lang_val) - { - if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) - { - continue; - } - - $sql_ary = array( - 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'"; - $this->sql_query($sql); - - $extension_groups_updated[$lang_key] = true; - } - } - } - $this->db->sql_freeresult($result); - } - - function update_module_auth() - { - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'avatar\''; - $this->sql_query($sql); - } - - function update_bots() - { - $bot_name = 'Bing [Bot]'; - $bot_name_clean = utf8_clean_string($bot_name); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; - $result = $this->db->sql_query($sql); - $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); - $this->db->sql_freeresult($result); - - if (!$bing_already_added) - { - $bot_agent = 'bingbot/'; - $bot_ip = ''; - $sql = 'SELECT group_id, group_colour - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'BOTS'"; - $result = $this->db->sql_query($sql); - $group_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$group_row) - { - // default fallback, should never get here - $group_row['group_id'] = 6; - $group_row['group_colour'] = '9E8DA7'; - } - - if (!function_exists('user_add')) - { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_row['group_id'], - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => $group_row['group_colour'], - 'user_email' => '', - 'user_lang' => $this->config['default_lang'], - 'user_style' => $this->config['default_style'], - 'user_timezone' => 0, - 'user_dateformat' => $this->config['default_dateformat'], - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => (string) $bot_name, - 'user_id' => (int) $user_id, - 'bot_agent' => (string) $bot_agent, - 'bot_ip' => (string) $bot_ip, - )); - - $this->sql_query($sql); - } - } - - function delete_orphan_shadow_topics() - { - // Delete shadow topics pointing to not existing topics - $batch_size = 500; - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - $sql_array = array( - 'SELECT' => 't1.topic_id, t1.forum_id', - 'FROM' => array( - TOPICS_TABLE => 't1', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't2'), - 'ON' => 't1.topic_moved_id = t2.topic_id', - ), - ), - 'WHERE' => 't1.topic_moved_id <> 0 - AND t2.topic_id IS NULL', - ); - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $this->db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); - $this->db->sql_query($sql); - - // Sync the forums we have deleted shadow topics from. - sync('forum', 'forum_id', $sync_forum_ids, true, true); - - return true; - } - else - { - return false; - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php deleted file mode 100644 index eb359e2697..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc4'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.9')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php deleted file mode 100644 index ea49cdbba9..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_8'); - } - - function update_schema() - { - return array( - 'add_tables' => array( - $this->table_prefix . 'login_attempts' => array( - 'COLUMNS' => array( - // this column was removed from the database updater - // after 3.0.9-RC3 was released. It might still exist - // in 3.0.9-RCX installations and has to be dropped in - // 3.0.12 after the db_tools class is capable of properly - // removing a primary key. - // 'attempt_id' => array('UINT', NULL, 'auto_increment'), - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - //'PRIMARY_KEY' => 'attempt_id', - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'bbcodes' => array( - 'bbcode_id' => array('USINT', 0), - ), - ), - ); - } - - function update_data() - { - return array( - array('config.add', array('ip_login_limit_max', 50)), - array('config.add', array('ip_login_limit_time', 21600)), - array('config.add', array('ip_login_limit_use_forwarded', 0)), - array('custom', array(array(&$this, 'update_file_extension_group_names'))), - array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))), - - array('config.update', array('version', '3.0.9-rc1')), - ); - } - - function update_file_extension_group_names() - { - // Update file extension group names to use language strings, again. - $sql = 'SELECT group_id, group_name - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_ary = array( - 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE group_id = ' . $row['group_id']; - $this->sql_query($sql); - } - $this->db->sql_freeresult($result); - } - - function fix_firebird_qa_captcha() - { - // Recover from potentially broken Q&A CAPTCHA table on firebird - // Q&A CAPTCHA was uninstallable, so it's safe to remove these - // without data loss - if ($this->db_tools->sql_layer == 'firebird') - { - $tables = array( - $this->table_prefix . 'captcha_questions', - $this->table_prefix . 'captcha_answers', - $this->table_prefix . 'qa_confirm', - ); - foreach ($tables as $table) - { - if ($this->db_tools->sql_table_exists($table)) - { - $this->db_tools->sql_table_drop($table); - } - } - } - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php deleted file mode 100644 index e3c4716665..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc1'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.9-rc2')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php deleted file mode 100644 index 3cdecb96ae..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc2'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.9-rc3')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php deleted file mode 100644 index c2a92e618a..0000000000 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration -{ - function depends_on() - { - return array('phpbb_db_migration_data_3_0_9_rc3'); - } - - function update_schema() - { - return array(); - } - - function update_data() - { - return array( - array('config.update', array('version', '3.0.9-rc4')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php deleted file mode 100644 index 6eb5a6ddee..0000000000 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ /dev/null @@ -1,369 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration -{ - public function depends_on() - { - return array( - 'phpbb_db_migration_data_3_0_11', - 'phpbb_db_migration_data_extensions', - 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone', - ); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - GROUPS_TABLE => array( - 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), - ), - PROFILE_FIELDS_TABLE => array( - 'field_show_on_pm' => array('BOOL', 0), - ), - STYLES_TABLE => array( - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), - ), - ), - 'change_columns' => array( - GROUPS_TABLE => array( - 'group_legend' => array('UINT', 0), - ), - ), - ); - } - - public function update_data() - { - return array( - array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), - - array('config.add', array('fulltext_postgres_ts_name', 'simple')), - array('config.add', array('fulltext_postgres_min_word_len', 4)), - array('config.add', array('fulltext_postgres_max_word_len', 254)), - array('config.add', array('fulltext_sphinx_stopwords', 0)), - array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)), - - array('config.add', array('load_jquery_cdn', 0)), - array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')), - - array('config.add', array('use_system_cron', 0)), - - array('config.add', array('legend_sort_groupname', 0)), - array('config.add', array('teampage_forums', 1)), - array('config.add', array('teampage_memberships', 1)), - - array('config.add', array('load_cpf_pm', 0)), - - array('config.add', array('display_last_subject', 1)), - - array('config.add', array('assets_version', 1)), - - array('config.add', array('site_home_url', '')), - array('config.add', array('site_home_text', '')), - - array('permission.add', array('u_chgprofileinfo', true, 'u_sig')), - - array('module.add', array( - 'acp', - 'ACP_GROUPS', - array( - 'module_basename' => 'acp_groups', - 'modes' => array('position'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_ATTACHMENTS', - array( - 'module_basename' => 'acp_attachments', - 'modes' => array('manage'), - ), - )), - array('module.add', array( - 'acp', - 'ACP_STYLE_MANAGEMENT', - array( - 'module_basename' => 'acp_styles', - 'modes' => array('install', 'cache'), - ), - )), - array('module.add', array( - 'ucp', - 'UCP_PROFILE', - array( - 'module_basename' => 'ucp_profile', - 'modes' => array('autologin_keys'), - ), - )), - - array('module.remove', array( - 'acp', - false, - 'ACP_TEMPLATES', - )), - array('module.remove', array( - 'acp', - false, - 'ACP_THEMES', - )), - array('module.remove', array( - 'acp', - false, - 'ACP_IMAGESETS', - )), - - array('custom', array(array($this, 'rename_module_basenames'))), - array('custom', array(array($this, 'rename_styles_module'))), - array('custom', array(array($this, 'add_group_teampage'))), - array('custom', array(array($this, 'update_group_legend'))), - array('custom', array(array($this, 'localise_global_announcements'))), - array('custom', array(array($this, 'update_ucp_pm_basename'))), - array('custom', array(array($this, 'update_ucp_profile_auth'))), - array('custom', array(array($this, 'move_customise_modules'))), - - array('config.update', array('version', '3.1.0-dev')), - ); - } - - public function move_customise_modules() - { - // Move language management to new location in the Customise tab - // First get language module id - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_language'"; - $result = $this->db->sql_query($sql); - $language_module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - // Next get language management module id of the one just created - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_LANGUAGE'"; - $result = $this->db->sql_query($sql); - $language_management_module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - - if (!class_exists('acp_modules')) - { - include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); - } - // acp_modules calls adm_back_link, which is undefined at this point - if (!function_exists('adm_back_link')) - { - include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext); - } - $module_manager = new acp_modules(); - $module_manager->module_class = 'acp'; - $module_manager->move_module($language_module_id, $language_management_module_id); - } - - public function update_ucp_pm_basename() - { - $sql = 'SELECT module_id, module_basename - FROM ' . MODULES_TABLE . " - WHERE module_basename <> 'ucp_pm' AND - module_langname='UCP_PM'"; - $result = $this->db->sql_query_limit($sql, 1); - - if ($row = $this->db->sql_fetchrow($result)) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['module_id']; - - $this->sql_query($sql); - } - $this->db->sql_freeresult($result); - } - - public function update_ucp_profile_auth() - { - // Update the auth setting for the module - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_auth = 'acl_u_chgprofileinfo' - WHERE module_class = 'ucp' - AND module_basename = 'ucp_profile' - AND module_mode = 'profile_info'"; - $this->sql_query($sql); - } - - public function rename_styles_module() - { - // Rename styles module to Customise - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_langname = 'ACP_CAT_CUSTOMISE' - WHERE module_langname = 'ACP_CAT_STYLES'"; - $this->sql_query($sql); - } - - public function rename_module_basenames() - { - // rename all module basenames to full classname - $sql = 'SELECT module_id, module_basename, module_class - FROM ' . MODULES_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $module_id = (int) $row['module_id']; - unset($row['module_id']); - - if (!empty($row['module_basename']) && !empty($row['module_class'])) - { - // all the class names start with class name or with phpbb_ for auto loading - if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && - strpos($row['module_basename'], 'phpbb_') !== 0) - { - $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; - - $sql_update = $this->db->sql_build_array('UPDATE', $row); - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET ' . $sql_update . ' - WHERE module_id = ' . $module_id; - $this->sql_query($sql); - } - } - } - - $this->db->sql_freeresult($result); - } - - public function add_group_teampage() - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 1 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'ADMINISTRATORS'"; - $this->sql_query($sql); - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 2 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'GLOBAL_MODERATORS'"; - $this->sql_query($sql); - } - - public function update_group_legend() - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; - $result = $this->db->sql_query($sql); - - $next_legend = 1; - while ($row = $this->db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_legend = ' . $next_legend . ' - WHERE group_id = ' . (int) $row['group_id']; - $this->sql_query($sql); - - $next_legend++; - } - $this->db->sql_freeresult($result); - } - - public function localise_global_announcements() - { - // Localise Global Announcements - $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; - $result = $this->db->sql_query($sql); - - $global_announcements = $update_lastpost_data = array(); - $update_lastpost_data['forum_last_post_time'] = 0; - $update_forum_data = array( - 'forum_posts' => 0, - 'forum_topics' => 0, - 'forum_topics_real' => 0, - ); - - while ($row = $this->db->sql_fetchrow($result)) - { - $global_announcements[] = (int) $row['topic_id']; - - $update_forum_data['forum_posts'] += (int) $row['topic_posts']; - $update_forum_data['forum_topics_real']++; - if ($row['topic_approved']) - { - $update_forum_data['forum_topics']++; - } - - if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) - { - $update_lastpost_data = array( - 'forum_last_post_id' => (int) $row['topic_last_post_id'], - 'forum_last_post_subject' => $row['topic_last_post_subject'], - 'forum_last_post_time' => (int) $row['topic_last_post_time'], - 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], - 'forum_last_poster_name' => $row['topic_last_poster_name'], - 'forum_last_poster_colour' => $row['topic_last_poster_colour'], - ); - } - } - $this->db->sql_freeresult($result); - - if (!empty($global_announcements)) - { - // Update the post/topic-count for the forum and the last-post if needed - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - $result = $this->db->sql_query_limit($sql, 1); - $ga_forum_id = $this->db->sql_fetchfield('forum_id'); - $this->db->sql_freeresult($result); - - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $ga_forum_id; - $result = $this->db->sql_query($sql); - $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time'); - $this->db->sql_freeresult($result); - - $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; - $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; - $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; - if ($lastpost < $update_lastpost_data['forum_last_post_time']) - { - $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $sql_update . ' - WHERE forum_id = ' . $ga_forum_id; - $this->sql_query($sql); - - // Update some forum_ids - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $ga_forum_id - WHERE " . $this->db->sql_in_set('topic_id', $global_announcements); - $this->sql_query($sql); - } - unset($table_ary); - } - } -} diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php deleted file mode 100644 index d28e0ebabb..0000000000 --- a/phpBB/includes/db/migration/data/extensions.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_extensions extends phpbb_db_migration -{ - public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_schema() - { - return array( - 'add_tables' => array( - EXT_TABLE => array( - 'COLUMNS' => array( - 'ext_name' => array('VCHAR', ''), - 'ext_active' => array('BOOL', 0), - 'ext_state' => array('TEXT', ''), - ), - 'KEYS' => array( - 'ext_name' => array('UNIQUE', 'ext_name'), - ), - ), - ), - ); - } - - public function update_data() - { - return array( - array('module.add', array( - 'acp', - 'ACP_GENERAL_TASKS', - array( - 'module_basename' => 'acp_extensions', - 'modes' => array('main'), - ), - )), - array('permission.add', array('a_extensions', true, 'a_styles')), - ); - } -} diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php deleted file mode 100644 index 1c46e4147b..0000000000 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration -{ - public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_schema() - { - return array(); - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'styles_update'))), - ); - } - - public function styles_update() - { - // Get list of valid 3.1 styles - $available_styles = array('prosilver'); - - $iterator = new DirectoryIterator($this->phpbb_root_path . 'styles'); - $skip_dirs = array('.', '..', 'prosilver'); - foreach ($iterator as $fileinfo) - { - if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) - { - $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); - if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) - { - // 3.1 style - $available_styles[] = $fileinfo->getFilename(); - } - } - } - - // Get all installed styles - if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id - AND i.imageset_id = s.imageset_id"; - } - else - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id"; - } - $result = $this->db->sql_query($sql); - - $styles = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $styles[] = $row; - } - $this->db->sql_freeresult($result); - - // Decide which styles to keep, all others will be deleted - $valid_styles = array(); - foreach ($styles as $style_row) - { - if ( - // Delete styles with parent style (not supported yet) - $style_row['template_inherits_id'] == 0 && - // Check if components match - $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && - // Check if components are valid - in_array($style_row['template_path'], $available_styles) - ) - { - // Valid style. Keep it - $sql_ary = array( - 'style_path' => $style_row['template_path'], - 'bbcode_bitfield' => $style_row['bbcode_bitfield'], - 'style_parent_id' => 0, - 'style_parent_tree' => '', - ); - $this->sql_query('UPDATE ' . STYLES_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE style_id = ' . $style_row['style_id']); - $valid_styles[] = (int) $style_row['style_id']; - } - } - - // Remove old entries from styles table - if (!sizeof($valid_styles)) - { - // No valid styles: remove everything and add prosilver - $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - - $sql_ary = array( - 'style_name' => 'prosilver', - 'style_copyright' => '© phpBB Group', - 'style_active' => 1, - 'style_path' => 'prosilver', - 'bbcode_bitfield' => 'kNg=', - 'style_parent_id' => 0, - 'style_parent_tree' => '', - - // Will be removed in the next step - 'imageset_id' => 0, - 'template_id' => 0, - 'theme_id' => 0, - ); - - $sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->sql_query($sql); - - $sql = 'SELECT style_id - FROM ' . $table . " - WHERE style_name = 'prosilver'"; - $result = $this->sql_query($sql); - $default_style = $this->db->sql_fetchfield($result); - $this->db->sql_freeresult($result); - - set_config('default_style', $default_style); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; - $this->sql_query($sql); - } - else - { - // There are valid styles in styles table. Remove styles that are outdated - $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' - WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true)); - - // Change default style - if (!in_array($this->config['default_style'], $valid_styles)) - { - $this->sql_query('UPDATE ' . CONFIG_TABLE . " - SET config_value = '" . $valid_styles[0] . "' - WHERE config_name = 'default_style'"); - } - - // Reset styles for users - $this->sql_query('UPDATE ' . USERS_TABLE . ' - SET user_style = 0 - WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true)); - } - } -} diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php deleted file mode 100644 index db4b7f1753..0000000000 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration -{ - public function depends_on() - { - return array('phpbb_db_migration_data_style_update_p1'); - } - - public function update_schema() - { - return array( - 'drop_columns' => array( - STYLES_TABLE => array( - 'imageset_id', - 'template_id', - 'theme_id', - ), - ), - - 'drop_tables' => array( - STYLES_IMAGESET_TABLE, - STYLES_IMAGESET_DATA_TABLE, - STYLES_TEMPLATE_TABLE, - STYLES_TEMPLATE_DATA_TABLE, - STYLES_THEME_TABLE, - ), - ); - } - - public function update_data() - { - return array(); - } -} diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php deleted file mode 100644 index 7734ed4b76..0000000000 --- a/phpBB/includes/db/migration/data/timezone.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_data_timezone extends phpbb_db_migration -{ - public function depends_on() - { - return array('phpbb_db_migration_data_3_0_11'); - } - - public function update_schema() - { - return array( - 'change_columns' => array( - USERS_TABLE => array( - 'user_timezone' => array('VCHAR:100', ''), - ), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'update_timezones'))), - ); - } - - public function update_timezones() - { - // Update user timezones - $sql = 'SELECT user_dst, user_timezone - FROM ' . USERS_TABLE . ' - GROUP BY user_timezone, user_dst'; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' - WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' - AND user_dst = " . (int) $row['user_dst']; - $this->sql_query($sql); - } - $this->db->sql_freeresult($result); - - // Update board default timezone - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' - WHERE config_name = 'board_timezone'"; - $this->sql_query($sql); - - // After we have calculated the timezones we can delete user_dst column from user table. - $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); - } - - /** - * Determine the new timezone for a given phpBB 3.0 timezone and - * "Daylight Saving Time" option - * - * @param $timezone float Users timezone in 3.0 - * @param $dst int Users daylight saving time - * @return string Users new php Timezone which is used since 3.1 - */ - public function convert_phpbb30_timezone($timezone, $dst) - { - $offset = $timezone + $dst; - - switch ($timezone) - { - case '-12': - return 'Etc/GMT+' . abs($offset); //'[UTC - 12] Baker Island Time' - case '-11': - return 'Etc/GMT+' . abs($offset); //'[UTC - 11] Niue Time, Samoa Standard Time' - case '-10': - return 'Etc/GMT+' . abs($offset); //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' - case '-9.5': - return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' - case '-9': - return 'Etc/GMT+' . abs($offset); //'[UTC - 9] Alaska Standard Time, Gambier Island Time' - case '-8': - return 'Etc/GMT+' . abs($offset); //'[UTC - 8] Pacific Standard Time' - case '-7': - return 'Etc/GMT+' . abs($offset); //'[UTC - 7] Mountain Standard Time' - case '-6': - return 'Etc/GMT+' . abs($offset); //'[UTC - 6] Central Standard Time' - case '-5': - return 'Etc/GMT+' . abs($offset); //'[UTC - 5] Eastern Standard Time' - case '-4.5': - return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' - case '-4': - return 'Etc/GMT+' . abs($offset); //'[UTC - 4] Atlantic Standard Time' - case '-3.5': - return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' - case '-3': - return 'Etc/GMT+' . abs($offset); //'[UTC - 3] Amazon Standard Time, Central Greenland Time' - case '-2': - return 'Etc/GMT+' . abs($offset); //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' - case '-1': - return 'Etc/GMT+' . abs($offset); //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' - case '0': - return (!$dst) ? 'UTC' : 'Etc/GMT-1'; //'[UTC] Western European Time, Greenwich Mean Time' - case '1': - return 'Etc/GMT-' . $offset; //'[UTC + 1] Central European Time, West African Time' - case '2': - return 'Etc/GMT-' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' - case '3': - return 'Etc/GMT-' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' - case '3.5': - return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' - case '4': - return 'Etc/GMT-' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' - case '4.5': - return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' - case '5': - return 'Etc/GMT-' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' - case '5.5': - return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' - case '5.75': - return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' - case '6': - return 'Etc/GMT-' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' - case '6.5': - return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' - case '7': - return 'Etc/GMT-' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' - case '8': - return 'Etc/GMT-' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' - case '8.75': - return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' - case '9': - return 'Etc/GMT-' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' - case '9.5': - return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' - case '10': - return 'Etc/GMT-' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' - case '10.5': - return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' - case '11': - return 'Etc/GMT-' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' - case '11.5': - return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' - case '12': - return 'Etc/GMT-12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' - case '12.75': - return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' - case '13': - return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' - case '14': - return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' - default: - return 'UTC'; - } - } -} From e9bcea5d82fd086ebcf7634ab386623f34ea8d03 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 8 Jan 2013 22:22:44 -0600 Subject: [PATCH 034/174] [feature/migrations] Restore update_helpers.php file This should be removed by the data branch PHPBB3-9737 --- phpBB/includes/update_helpers.php | 112 ++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 phpBB/includes/update_helpers.php diff --git a/phpBB/includes/update_helpers.php b/phpBB/includes/update_helpers.php new file mode 100644 index 0000000000..69d678b2f8 --- /dev/null +++ b/phpBB/includes/update_helpers.php @@ -0,0 +1,112 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +*/ + +/** +* phpBB Update Helpers +*/ +class phpbb_update_helpers +{ + /** + * Determine the new timezone for a given phpBB 3.0 timezone and + * "Daylight Saving Time" option + * + * @param $timezone float Users timezone in 3.0 + * @param $dst int Users daylight saving time + * @return string Users new php Timezone which is used since 3.1 + */ + function convert_phpbb30_timezone($timezone, $dst) + { + $offset = $timezone + $dst; + + switch ($timezone) + { + case '-12': + return 'Etc/GMT+' . abs($offset); //'[UTC - 12] Baker Island Time' + case '-11': + return 'Etc/GMT+' . abs($offset); //'[UTC - 11] Niue Time, Samoa Standard Time' + case '-10': + return 'Etc/GMT+' . abs($offset); //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' + case '-9.5': + return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' + case '-9': + return 'Etc/GMT+' . abs($offset); //'[UTC - 9] Alaska Standard Time, Gambier Island Time' + case '-8': + return 'Etc/GMT+' . abs($offset); //'[UTC - 8] Pacific Standard Time' + case '-7': + return 'Etc/GMT+' . abs($offset); //'[UTC - 7] Mountain Standard Time' + case '-6': + return 'Etc/GMT+' . abs($offset); //'[UTC - 6] Central Standard Time' + case '-5': + return 'Etc/GMT+' . abs($offset); //'[UTC - 5] Eastern Standard Time' + case '-4.5': + return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' + case '-4': + return 'Etc/GMT+' . abs($offset); //'[UTC - 4] Atlantic Standard Time' + case '-3.5': + return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' + case '-3': + return 'Etc/GMT+' . abs($offset); //'[UTC - 3] Amazon Standard Time, Central Greenland Time' + case '-2': + return 'Etc/GMT+' . abs($offset); //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' + case '-1': + return 'Etc/GMT+' . abs($offset); //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' + case '0': + return (!$dst) ? 'UTC' : 'Etc/GMT-1'; //'[UTC] Western European Time, Greenwich Mean Time' + case '1': + return 'Etc/GMT-' . $offset; //'[UTC + 1] Central European Time, West African Time' + case '2': + return 'Etc/GMT-' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' + case '3': + return 'Etc/GMT-' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' + case '3.5': + return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' + case '4': + return 'Etc/GMT-' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' + case '4.5': + return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' + case '5': + return 'Etc/GMT-' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' + case '5.5': + return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' + case '5.75': + return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' + case '6': + return 'Etc/GMT-' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' + case '6.5': + return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' + case '7': + return 'Etc/GMT-' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' + case '8': + return 'Etc/GMT-' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' + case '8.75': + return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' + case '9': + return 'Etc/GMT-' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' + case '9.5': + return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' + case '10': + return 'Etc/GMT-' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' + case '10.5': + return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' + case '11': + return 'Etc/GMT-' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' + case '11.5': + return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' + case '12': + return 'Etc/GMT-12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' + case '12.75': + return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' + case '13': + return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' + case '14': + return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' + default: + return 'UTC'; + } + } +} From e3737978f76a962385a26de910959607d0ae0d30 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 14:27:01 -0600 Subject: [PATCH 035/174] [feature/migrations] Fixing returns of callables and handling data state Lots of comments and some other miscellaneous fixes. PHPBB3-9737 --- phpBB/includes/db/db_tools.php | 1 + phpBB/includes/db/driver/mysqli.php | 1 - phpBB/includes/db/migration/exception.php | 10 + phpBB/includes/db/migration/migration.php | 35 +++- phpBB/includes/db/migration/tool/config.php | 40 ++-- .../includes/db/migration/tool/interface.php | 5 + phpBB/includes/db/migration/tool/module.php | 177 +++++++++--------- .../includes/db/migration/tool/permission.php | 106 ++++++----- phpBB/includes/db/migrator.php | 158 ++++++++++++---- 9 files changed, 329 insertions(+), 204 deletions(-) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 5329d871c8..1d6823d37a 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -349,6 +349,7 @@ class phpbb_db_tools * Setter for {@link $return_statements return_statements}. * * @param bool $return_statements True if SQL should not be executed but returned as strings + * @return null */ public function set_return_statements($return_statements) { diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/includes/db/driver/mysqli.php index 94921a22b7..7448bf1670 100644 --- a/phpBB/includes/db/driver/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -24,7 +24,6 @@ if (!defined('IN_PHPBB')) class phpbb_db_driver_mysqli extends phpbb_db_driver { var $multi_insert = true; - var $connect_error = ''; /** diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php index 19fb39ab23..bd46a4e064 100644 --- a/phpBB/includes/db/migration/exception.php +++ b/phpBB/includes/db/migration/exception.php @@ -22,8 +22,15 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migration_exception extends \Exception { + /** @var array Extra parameters sent to exception to aid in debugging */ protected $parameters; + /** + * Throw an exception. + * + * First argument is the error message. + * Additional arguments will be output with the error message. + */ public function __construct() { $parameters = func_get_args(); @@ -33,6 +40,9 @@ class phpbb_db_migration_exception extends \Exception $this->parameters = $parameters; } + /** + * Output the error as a string + */ public function __toString() { return $this->message . ': ' . var_export($this->parameters, true); diff --git a/phpBB/includes/db/migration/migration.php b/phpBB/includes/db/migration/migration.php index c2c6da855b..5f1f0443db 100644 --- a/phpBB/includes/db/migration/migration.php +++ b/phpBB/includes/db/migration/migration.php @@ -26,22 +26,41 @@ if (!defined('IN_PHPBB')) */ abstract class phpbb_db_migration { + /** @var phpbb_config */ protected $config; + + /** @var phpbb_db_driver */ protected $db; + + /** @var phpbb_db_tools */ protected $db_tools; + + /** @var string */ protected $table_prefix; + /** @var string */ protected $phpbb_root_path; + + /** @var string */ protected $php_ext; + /** @var array Errors, if any occured */ protected $errors; - private $queries = array(); + /** @var array List of queries executed through $this->sql_query() */ + protected $queries = array(); /** - * Migration constructor + * Constructor + * + * @param phpbb_config $config + * @param phpbb_db_driver $db + * @param phpbb_db_tools $db_tools + * @param string $phpbb_root_path + * @param string $php_ext + * @param string $table_prefix */ - public function __construct($config, phpbb_db_driver $db, $db_tools, $phpbb_root_path, $php_ext, $table_prefix) + public function __construct(phpbb_config $config, phpbb_db_driver $db, phpbb_db_tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix) { $this->config = $config; $this->db = $db; @@ -55,7 +74,7 @@ abstract class phpbb_db_migration } /** - * Defines other migrationsto be applied first (abstract method) + * Defines other migrations to be applied first (abstract method) * * @return array An array of migration class names */ @@ -67,7 +86,7 @@ abstract class phpbb_db_migration /** * Updates the database schema by providing a set of change instructions * - * @return array + * @return array Array of schema changes (compatible with db_tools->perform_schema_changes()) */ public function update_schema() { @@ -77,14 +96,18 @@ abstract class phpbb_db_migration /** * Updates data by returning a list of instructions to be executed * - * @return array + * @return array Array of data update instructions */ public function update_data() { + return array(); } /** * Wrapper for running queries to generate user feedback on updates + * + * @param string $sql SQL query to run on the database + * @return mixed Query result from db->sql_query() */ protected function sql_query($sql) { diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/includes/db/migration/tool/config.php index 35fa3ce566..e7239436d2 100644 --- a/phpBB/includes/db/migration/tool/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -7,11 +7,21 @@ * */ +/** +* Migration config tool +* +* @package db +*/ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interface { /** @var phpbb_config */ - protected $config = null; + protected $config; + /** + * Constructor + * + * @param phpbb_config $config + */ public function __construct(phpbb_config $config) { $this->config = $config; @@ -26,13 +36,12 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } /** - * Config Add - * - * This function allows you to add a config setting. + * Add a config setting. * * @param string $config_name The name of the config setting you would like to add * @param mixed $config_value The value of the config setting * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + * @return null */ public function add($config_name, $config_value = '', $is_dynamic = false) { @@ -42,17 +51,14 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } $this->config->set($config_name, $config_value, !$is_dynamic); - - return false; } /** - * Config Update - * - * This function allows you to update an existing config setting. + * Update an existing config setting. * * @param string $config_name The name of the config setting you would like to update * @param mixed $config_value The value of the config setting + * @return null */ public function update($config_name, $config_value = '') { @@ -62,18 +68,15 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } $this->config->set($config_name, $config_value); - - return false; } /** - * Config Update If Equals - * - * This function allows you to update a config setting if the first argument equal to the current config value + * Update a config setting if the first argument equal to the current config value * * @param bool $compare If equal to the current config value, will be updated to the new config value, otherwise not * @param string $config_name The name of the config setting you would like to update * @param mixed $config_value The value of the config setting + * @return null */ public function update_if_equals($compare, $config_name, $config_value = '') { @@ -83,16 +86,13 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } $this->config->set_atomic($config_name, $compare, $config_value); - - return false; } /** - * Config Remove - * - * This function allows you to remove an existing config setting. + * Remove an existing config setting. * * @param string $config_name The name of the config setting you would like to remove + * @return null */ public function remove($config_name) { @@ -102,7 +102,5 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } $this->config->delete($config_name); - - return false; } } diff --git a/phpBB/includes/db/migration/tool/interface.php b/phpBB/includes/db/migration/tool/interface.php index 1815f5e8a2..5d10246ba1 100644 --- a/phpBB/includes/db/migration/tool/interface.php +++ b/phpBB/includes/db/migration/tool/interface.php @@ -7,6 +7,11 @@ * */ +/** +* Migration tool interface +* +* @package db +*/ interface phpbb_db_migration_tool_interface { /** diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index a503f08c01..f1b527bf21 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -7,27 +7,42 @@ * */ +/** +* Migration module management tool +* +* @package db +*/ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interface { /** @var phpbb_cache_service */ - protected $cache = null; + protected $cache; /** @var dbal */ - protected $db = null; + protected $db; /** @var phpbb_user */ - protected $user = null; + protected $user; /** @var string */ - protected $phpbb_root_path = null; + protected $phpbb_root_path; /** @var string */ - protected $php_ext = null; + protected $php_ext; /** @var string */ - protected $modules_table = null; + protected $modules_table; - public function __construct(phpbb_db_driver $db, $cache, $user, $phpbb_root_path, $php_ext, $modules_table) + /** + * Constructor + * + * @param phpbb_db_driver $db + * @param mixed $cache + * @param phpbb_user $user + * @param string $phpbb_root_path + * @param string $php_ext + * @param string $modules_table + */ + public function __construct(phpbb_db_driver $db, phpbb_cache_service $cache, phpbb_user $user, $phpbb_root_path, $php_ext, $modules_table) { $this->db = $db; $this->cache = $cache; @@ -53,7 +68,6 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * @param string $class The module class(acp|mcp|ucp) * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. * @param int|string $module The module_id|module_langname you would like to check for to see if it exists - * * @return bool true/false if module exists */ public function exists($class, $parent, $module) @@ -64,31 +78,28 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac return true; } - $class = $this->db->sql_escape($class); - $module = $this->db->sql_escape($module); - $parent_sql = ''; if ($parent !== false) { // Allows '' to be sent as 0 - $parent = (!$parent) ? 0 : $parent; + $parent = $parent ?: 0; if (!is_numeric($parent)) { $sql = 'SELECT module_id FROM ' . $this->modules_table . " WHERE module_langname = '" . $this->db->sql_escape($parent) . "' - AND module_class = '$class'"; + AND module_class = '" . $this->db->sql_escape($class) . "'"; $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); + $module_id = $this->db->sql_fetchfield('module_id'); $this->db->sql_freeresult($result); - if (!$row) + if (!$module_id) { return false; } - $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; + $parent_sql = 'AND parent_id = ' . (int) $module_id; } else { @@ -98,14 +109,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $sql = 'SELECT module_id FROM ' . $this->modules_table . " - WHERE module_class = '$class' + WHERE module_class = '" . $this->db->sql_escape($class) . "' $parent_sql - AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '$module'"); + AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'"); $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); + $module_id = $this->db->sql_fetchfield('module_id'); $this->db->sql_freeresult($result); - if ($row) + if ($module_id) { return true; } @@ -123,29 +134,30 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * @param array $data an array of the data on the new module. This can be setup in two different ways. * 1. The "manual" way. For inserting a category or one at a time. It will be merged with the base array shown a bit below, * but at the least requires 'module_langname' to be sent, and, if you want to create a module (instead of just a category) you must send module_basename and module_mode. - * array( - * 'module_enabled' => 1, - * 'module_display' => 1, - * 'module_basename' => '', - * 'module_class' => $class, - * 'parent_id' => (int) $parent, - * 'module_langname' => '', - * 'module_mode' => '', - * 'module_auth' => '', - * ) + * array( + * 'module_enabled' => 1, + * 'module_display' => 1, + * 'module_basename' => '', + * 'module_class' => $class, + * 'parent_id' => (int) $parent, + * 'module_langname' => '', + * 'module_mode' => '', + * 'module_auth' => '', + * ) * 2. The "automatic" way. For inserting multiple at a time based on the specs in the info file for the module(s). For this to work the modules must be correctly setup in the info file. * An example follows (this would insert the settings, log, and flag modes from the includes/acp/info/acp_asacp.php file): - * array( - * 'module_basename' => 'asacp', - * 'modes' => array('settings', 'log', 'flag'), - * ) + * array( + * 'module_basename' => 'asacp', + * 'modes' => array('settings', 'log', 'flag'), + * ) * Optionally you may not send 'modes' and it will insert all of the modules in that info file. - * @param string|bool $include_path If you would like to use a custom include path, specify that here + * @param string|bool $include_path If you would like to use a custom include path, specify that here + * @return null */ public function add($class, $parent = 0, $data = array(), $include_path = false) { - // Allows '' to be sent as 0 - $parent = (!$parent) ? 0 : $parent; + // Allows '' to be sent as 0 + $parent = $parent ?: 0; // allow sending the name as a string in $data to create a category if (!is_array($data)) @@ -155,18 +167,16 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if (!isset($data['module_langname'])) { - /** - * @TODO does not work with 3.1 modules yet, but must continue for old 3.0 versions for - * upgrades from a 3.0.x version to 3.1 - */ // The "automatic" way $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; $basename = str_replace(array('/', '\\'), '', $basename); $class = str_replace(array('/', '\\'), '', $class); + + $include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path; $info_file = "$class/info/$basename.{$this->php_ext}"; // The manual and automatic ways both failed... - if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) + if (!file_exists($include_path . $info_file)) { throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $info_file); } @@ -175,7 +185,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if (!class_exists($classname)) { - include((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file); + include($include_path . $info_file); } $info = new $classname; @@ -206,26 +216,25 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac } // The "manual" way - add_log('admin', 'LOG_MODULE_ADD', ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname'])); - - $class = $this->db->sql_escape($class); + $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); + add_log('admin', 'LOG_MODULE_ADD', $module_log_name); if (!is_numeric($parent)) { $sql = 'SELECT module_id FROM ' . $this->modules_table . " WHERE module_langname = '" . $this->db->sql_escape($parent) . "' - AND module_class = '$class'"; + AND module_class = '" . $this->db->sql_escape($class) . "'"; $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); + $module_id = $this->db->sql_fetchfield('module_id'); $this->db->sql_freeresult($result); - if (!$row) + if (!$module_id) { throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); } - $parent = $data['parent_id'] = $row['module_id']; + $parent = $data['parent_id'] = $module_id; } else if (!$this->exists($class, false, $parent)) { @@ -270,46 +279,46 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if (isset($data['before']) && $data['before']) { $sql = 'SELECT left_id - FROM ' . $this->modules_table . ' - WHERE module_class = \'' . $class . '\' - AND parent_id = ' . (int) $parent . ' - AND module_langname = \'' . $this->db->sql_escape($data['before']) . '\''; + FROM ' . $this->modules_table . " + WHERE module_class = '" . $this->db->sql_escape($class) . "' + AND parent_id = " . (int) $parent . " + AND module_langname = '" . $this->db->sql_escape($data['before']) . "'"; $this->db->sql_query($sql); - $to_left = $this->db->sql_fetchfield('left_id'); + $to_left = (int) $this->db->sql_fetchfield('left_id'); $sql = 'UPDATE ' . $this->modules_table . " SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '$class' + WHERE module_class = '" . $this->db->sql_escape($class) . "' AND left_id >= $to_left AND left_id < {$module_data['left_id']}"; $this->db->sql_query($sql); $sql = 'UPDATE ' . $this->modules_table . " SET left_id = $to_left, right_id = " . ($to_left + 1) . " - WHERE module_class = '$class' + WHERE module_class = '" . $this->db->sql_escape($class) . "' AND module_id = {$module_data['module_id']}"; $this->db->sql_query($sql); } else if (isset($data['after']) && $data['after']) { $sql = 'SELECT right_id - FROM ' . $this->modules_table . ' - WHERE module_class = \'' . $class . '\' - AND parent_id = ' . (int) $parent . ' - AND module_langname = \'' . $this->db->sql_escape($data['after']) . '\''; + FROM ' . $this->modules_table . " + WHERE module_class = '" . $this->db->sql_escape($class) . "' + AND parent_id = " . (int) $parent . " + AND module_langname = '" . $this->db->sql_escape($data['after']) . "'"; $this->db->sql_query($sql); - $to_right = $this->db->sql_fetchfield('right_id'); + $to_right = (int) $this->db->sql_fetchfield('right_id'); $sql = 'UPDATE ' . $this->modules_table . " SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '$class' + WHERE module_class = '" . $this->db->sql_escape($class) . "' AND left_id >= $to_right AND left_id < {$module_data['left_id']}"; $this->db->sql_query($sql); $sql = 'UPDATE ' . $this->modules_table . ' SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " - WHERE module_class = '$class' + WHERE module_class = '" . $this->db->sql_escape($class) . "' AND module_id = {$module_data['module_id']}"; $this->db->sql_query($sql); } @@ -317,8 +326,6 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac // Clear the Modules Cache $this->cache->destroy("_modules_$class"); - - return false; } /** @@ -330,6 +337,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. * @param int|string $module The module id|module_langname * @param string|bool $include_path If you would like to use a custom include path, specify that here + * @return null */ public function remove($class, $parent = 0, $module = '', $include_path = false) { @@ -351,9 +359,11 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac // Automatic method $basename = str_replace(array('/', '\\'), '', $module['module_basename']); $class = str_replace(array('/', '\\'), '', $class); + + $include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path; $info_file = "$class/info/$basename.{$this->php_ext}"; - if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file)) + if (!file_exists($include_path . $info_file)) { throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $info_file); } @@ -362,7 +372,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if (!class_exists($classname)) { - include((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file); + include($include_path . $info_file); } $info = new $classname; @@ -376,12 +386,9 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $this->remove($class, $parent, $info['title']) . '<br />'; } } - return false; } else { - $class = $this->db->sql_escape($class); - if (!$this->exists($class, $parent, $module)) { throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', ((isset($this->user->lang[$module])) ? $this->user->lang[$module] : $module)); @@ -391,20 +398,20 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if ($parent !== false) { // Allows '' to be sent as 0 - $parent = (!$parent) ? 0 : $parent; + $parent = ($parent) ?: 0; if (!is_numeric($parent)) { $sql = 'SELECT module_id FROM ' . $this->modules_table . " WHERE module_langname = '" . $this->db->sql_escape($parent) . "' - AND module_class = '$class'"; + AND module_class = '" . $this->db->sql_escape($class) . "'"; $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); + $module_id = $this->db->sql_fetchfield('module_id'); $this->db->sql_freeresult($result); // we know it exists from the module_exists check - $parent_sql = 'AND parent_id = ' . (int) $row['module_id']; + $parent_sql = 'AND parent_id = ' . (int) $module_id; } else { @@ -415,16 +422,15 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $module_ids = array(); if (!is_numeric($module)) { - $module = $this->db->sql_escape($module); $sql = 'SELECT module_id FROM ' . $this->modules_table . " - WHERE module_langname = '$module' - AND module_class = '$class' - $parent_sql"; + WHERE module_langname = '" . $this->db->sql_escape($module) . "' + AND module_class = '" . $this->db->sql_escape($class) . "' + $parent_sql"; $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) + while ($module_id = $this->db->sql_fetchfield('module_id')) { - $module_ids[] = (int) $row['module_id']; + $module_ids[] = (int) $module_id; } $this->db->sql_freeresult($result); @@ -436,13 +442,12 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $sql = 'SELECT module_langname FROM ' . $this->modules_table . " WHERE module_id = $module - AND module_class = '$class' - $parent_sql"; + AND module_class = '" . $this->db->sql_escape($class) . "' + $parent_sql"; $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); + $module_name = $this->db->sql_fetchfield('module_id'); $this->db->sql_freeresult($result); - $module_name = $row['module_langname']; $module_ids[] = $module; } @@ -464,8 +469,6 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac } $this->cache->destroy("_modules_$class"); - - return false; } } } diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index ebe404bc62..97fdbc0df9 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -7,24 +7,38 @@ * */ +/** +* Migration permission management tool +* +* @package db +*/ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_interface { /** @var phpbb_auth */ - protected $auth = null; + protected $auth; /** @var phpbb_cache_service */ - protected $cache = null; + protected $cache; /** @var dbal */ - protected $db = null; + protected $db; /** @var string */ - protected $phpbb_root_path = null; + protected $phpbb_root_path; /** @var string */ - protected $php_ext = null; + protected $php_ext; - public function __construct(phpbb_db_driver $db, $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext) + /** + * Constructor + * + * @param phpbb_db_driver $db + * @param mixed $cache + * @param phpbb_auth $auth + * @param string $phpbb_root_path + * @param string $php_ext + */ + public function __construct(phpbb_db_driver $db, phpbb_cache_service $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext) { $this->db = $db; $this->cache = $cache; @@ -48,7 +62,6 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * * @param string $auth_option The name of the permission (auth) option * @param bool $global True for checking a global permission setting, False for a local permission setting - * * @return bool true if it exists, false if not */ public function exists($auth_option, $global = true) @@ -86,8 +99,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * * @param string $auth_option The name of the permission (auth) option * @param bool $global True for checking a global permission setting, False for a local permission setting - * - * @return result + * @return null */ public function add($auth_option, $global = true, $copy_from = false) { @@ -152,7 +164,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte } $this->db->sql_freeresult($result); - if (sizeof($sql_ary)) + if (!empty($sql_ary)) { $this->db->sql_multi_insert($table, $sql_ary); } @@ -160,8 +172,6 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $auth_admin->acl_clear_prefetch(); } - - return false; } /** @@ -171,8 +181,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * * @param string $auth_option The name of the permission (auth) option * @param bool $global True for checking a global permission setting, False for a local permission setting - * - * @return result + * @return null */ public function remove($auth_option, $global = true) { @@ -197,7 +206,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - $id = $row['auth_option_id']; + $id = (int) $row['auth_option_id']; // If it is a local and global permission, do not remove the row! :P if ($row['is_global'] && $row['is_local']) @@ -210,17 +219,17 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte else { // Delete time - $this->db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $id); - $this->db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $id); - $this->db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $id); - $this->db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $id); + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE, ACL_OPTIONS_TABLE); + foreach ($tables as $table) + { + $this->db->sql_query('DELETE FROM ' . $table . ' + WHERE auth_option_id = ' . $id); + } } // Purge the auth cache $this->cache->destroy('_acl_options'); $this->auth->acl_clear_prefetch(); - - return false; } /** @@ -228,6 +237,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * * @param string $role_name The new role name * @param sting $role_type The type (u_, m_, a_) + * @return null */ public function role_add($role_name, $role_type = '', $role_description = '') { @@ -235,18 +245,18 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($role_name) . "'"; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); + $role_id = (int) $this->db->sql_fetchfield('role_id'); if ($role_id) { throw new phpbb_db_migration_exception('ROLE_ALREADY_EXISTS', $old_role_name); } - $sql = 'SELECT MAX(role_order) AS max + $sql = 'SELECT MAX(role_order) AS max_role_order FROM ' . ACL_ROLES_TABLE . " WHERE role_type = '" . $this->db->sql_escape($role_type) . "'"; $this->db->sql_query($sql); - $role_order = $this->db->sql_fetchfield('max'); + $role_order = (int) $this->db->sql_fetchfield('max_role_order'); $role_order = (!$role_order) ? 1 : $role_order + 1; $sql_ary = array( @@ -258,8 +268,6 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); - - return false; } /** @@ -267,6 +275,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * * @param string $old_role_name The old role name * @param string $new_role_name The new role name + * @return null */ public function role_update($old_role_name, $new_role_name = '') { @@ -274,7 +283,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'"; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); + $role_id = (int) $this->db->sql_fetchfield('role_id'); if (!$role_id) { @@ -285,14 +294,13 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte SET role_name = '" . $this->db->sql_escape($new_role_name) . "' WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'"; $this->db->sql_query($sql); - - return false; } /** * Remove a permission role * * @param string $role_name The role name to remove + * @return null */ public function role_remove($role_name) { @@ -300,7 +308,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($role_name) . "'"; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); + $role_id = (int) $this->db->sql_fetchfield('role_id'); if (!$role_id) { @@ -316,8 +324,6 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_query($sql); $this->auth->acl_clear_prefetch(); - - return false; } /** @@ -329,6 +335,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * @param string|array $auth_option The auth_option or array of auth_options you would like to set * @param string $type The type (role|group) * @param bool $has_permission True if you want to give them permission, false if you want to deny them permission + * @return null */ public function permission_set($name, $auth_option = array(), $type = 'role', $has_permission = true) { @@ -344,13 +351,13 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $new_auth[] = $row['auth_option_id']; + $new_auth[] = (int) $row['auth_option_id']; } $this->db->sql_freeresult($result); - if (!sizeof($new_auth)) + if (empty($new_auth)) { - return false; + return; } $current_auth = array(); @@ -364,7 +371,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); + $role_id = (int) $this->db->sql_fetchfield('role_id'); if (!$role_id) { @@ -387,7 +394,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); - $group_id = $this->db->sql_fetchfield('group_id'); + $group_id = (int) $this->db->sql_fetchfield('group_id'); if (!$group_id) { @@ -401,7 +408,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte AND auth_role_id <> 0 AND forum_id = 0'; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('auth_role_id'); + $role_id = (int) $this->db->sql_fetchfield('auth_role_id'); if ($role_id) { $sql = 'SELECT role_name @@ -437,7 +444,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte 'role_id' => $role_id, 'auth_option_id' => $auth_option_id, 'auth_setting' => $has_permission, - ); + ); } } @@ -453,7 +460,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte 'group_id' => $group_id, 'auth_option_id' => $auth_option_id, 'auth_setting' => $has_permission, - ); + ); } } @@ -462,8 +469,6 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte } $this->auth->acl_clear_prefetch(); - - return false; } /** @@ -474,6 +479,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * @param string $name The name of the role/group * @param string|array $auth_option The auth_option or array of auth_options you would like to set * @param string $type The type (role|group) + * @return null */ public function permission_unset($name, $auth_option = array(), $type = 'role') { @@ -489,13 +495,13 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $to_remove[] = $row['auth_option_id']; + $to_remove[] = (int) $row['auth_option_id']; } $this->db->sql_freeresult($result); - if (!sizeof($to_remove)) + if (empty($to_remove)) { - return false; + return; } $type = (string) $type; // Prevent PHP bug. @@ -507,11 +513,11 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('role_id'); + $role_id = (int) $this->db->sql_fetchfield('role_id'); if (!$role_id) { - throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name); + throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name); } $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' @@ -524,7 +530,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); - $group_id = $this->db->sql_fetchfield('group_id'); + $group_id = (int) $this->db->sql_fetchfield('group_id'); if (!$group_id) { @@ -537,7 +543,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte WHERE group_id = ' . $group_id . ' AND auth_role_id <> 0'; $this->db->sql_query($sql); - $role_id = $this->db->sql_fetchfield('auth_role_id'); + $role_id = (int) $this->db->sql_fetchfield('auth_role_id'); if ($role_id) { $sql = 'SELECT role_name @@ -556,7 +562,5 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte } $this->auth->acl_clear_prefetch(); - - return false; } } diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 2fd795b659..2ba1eba427 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -22,26 +22,40 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migrator { + /** @var phpbb_config */ protected $config; + + /** @var phpbb_db_driver */ protected $db; + + /** @var phpbb_db_tools */ protected $db_tools; + + /** @var string */ protected $table_prefix; + /** @var string */ protected $phpbb_root_path; + + /** @var string */ protected $php_ext; + /** @var string */ protected $migrations_table; + + /** @var array State of all migrations (SELECT * FROM migrations table) */ protected $migration_state; + /** @var array Array of all migrations available to be run */ protected $migrations = array(); - /** @var string Name of the last migration run */ + /** @var array 'name' and 'class' of the last migration run */ public $last_run_migration = false; /** * Constructor of the database migrator */ - public function __construct($config, phpbb_db_driver $db, $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools) + public function __construct(phpbb_config $config, phpbb_db_driver $db, phpbb_db_tools $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools) { $this->config = $config; $this->db = $db; @@ -96,17 +110,42 @@ class phpbb_db_migrator /** * Load migration data files from a directory * - * @param string $path + * This does not loop through sub-directories. + * Migration data files loaded with this function MUST contain + * ONLY ONE class in them (or an exception will be thrown). + * + * @param string $path Path to migration data files + * @param bool $check_fulfillable If TRUE (default), we will check + * if all of the migrations are fulfillable after loading them. + * If FALSE, we will not check. You SHOULD check at least once + * to prevent errors (if including multiple directories, check + * with the last call to prevent throwing errors unnecessarily). * @return array Array of migrations with names */ - public function load_migrations($path) + public function load_migrations($path, $check_fulfillable = true) { $handle = opendir($path); while (($file = readdir($handle)) !== false) { if (strpos($file, '_') !== 0 && strrpos($file, '.' . $this->php_ext) === (strlen($file) - strlen($this->php_ext) - 1)) { - $name = 'phpbb_db_migration_data_' . substr($file, 0, -(strlen($this->php_ext) + 1)); + // We try to find what class existed by comparing the classes declared before and after including the file. + $declared_classes = get_declared_classes(); + + include ($path . $file); + + $added_classes = array_diff(get_declared_classes(), $declared_classes); + + if ( + // The phpbb_db_migrations class may not have been loaded until now, so make sure to ignore it. + !(sizeof($added_classes) == 2 && in_array('phpbb_db_migration', $added_classes)) && + sizeof($added_classes) != 1 + ) + { + throw new phpbb_db_migration_exception('MIGRATION DATA FILE INVALID', $path . $file); + } + + $name = array_pop($added_classes); if (!in_array($name, $this->migrations)) { @@ -115,11 +154,14 @@ class phpbb_db_migrator } } - foreach ($this->migrations as $name) + if ($check_fulfillable) { - if ($this->unfulfillable($name)) + foreach ($this->migrations as $name) { - throw new phpbb_db_migration_exception('MIGRATION NOT FULFILLABLE', $name); + if ($this->unfulfillable($name)) + { + throw new phpbb_db_migration_exception('MIGRATION NOT FULFILLABLE', $name); + } } } @@ -131,6 +173,8 @@ class phpbb_db_migrator * * The update step can either be a schema or a (partial) data update. To * check if update() needs to be called again use the finished() method. + * + * @return null */ public function update() { @@ -207,9 +251,11 @@ class phpbb_db_migrator } else { - $this->process_data_step($migration); - $state['migration_data_done'] = true; - $state['migration_end_time'] = time(); + $state = $this->process_data_step($migration); + + $state['migration_data_state'] = $state; + $state['migration_data_done'] = ($state === true); + $state['migration_end_time'] = ($state === true) ? time() : 0; } $sql = 'UPDATE ' . $this->migrations_table . ' @@ -222,41 +268,74 @@ class phpbb_db_migrator return true; } + /** + * Apply schema changes from a migration + * + * Just calls db_tools->perform_schema_changes + * + * @param array $schema_changes from migration + */ + protected function apply_schema_changes($schema_changes) + { + $this->db_tools->perform_schema_changes($schema_changes); + } + + /** + * Process the data step of the migration + * + * @param phpbb_db_migration $migration + * @return mixed migration status or bool true if everything completed successfully + */ protected function process_data_step($migration) { - //$continue = false; $steps = $migration->update_data(); foreach ($steps as $step) { - $continue = $this->run_step($step); - - /*if ($continue === false) + try { - return false; - }*/ + // Result will be null or true if everything completed correctly + $result = $this->run_step($step); + if ($result !== null && $result !== true) + { + return $result; + } + } + catch (phpbb_db_migration_exception $e) + { + // We should try rolling back here + + echo $e; + die(); + } } - //return $continue; + return true; } + /** + * Run a single step + * + * An exception should be thrown if an error occurs + * + * @param mixed $step + * @return null + */ protected function run_step($step) { - try - { - $callable_and_parameters = $this->get_callable_from_step($step); - $callable = $callable_and_parameters[0]; - $parameters = $callable_and_parameters[1]; + $callable_and_parameters = $this->get_callable_from_step($step); + $callable = $callable_and_parameters[0]; + $parameters = $callable_and_parameters[1]; - return call_user_func_array($callable, $parameters); - } - catch (phpbb_db_migration_exception $e) - { - echo $e; - die(); - } + return call_user_func_array($callable, $parameters); } + /** + * Get a callable statement from a data step + * + * @param mixed $step Data step from migration + * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters + */ public function get_callable_from_step($step) { $type = $step[0]; @@ -291,6 +370,7 @@ class phpbb_db_migrator $callable_and_parameters = $this->get_callable_from_step($step); $callable = $callable_and_parameters[0]; $sub_parameters = $callable_and_parameters[1]; + return array( function ($condition) use ($callable, $sub_parameters) { return call_user_func_array($callable, $sub_parameters); @@ -325,12 +405,19 @@ class phpbb_db_migrator return array( array($this->tools[$class], $method), - $parameters + $parameters, ); break; } } + /** + * Insert migration row into the database + * + * @param string $name Name of the migration + * @param array $state + * @return null + */ protected function insert_migration($name, $state) { $migration_row = $state; @@ -346,8 +433,8 @@ class phpbb_db_migrator /** * Checks if a migration's dependencies can even theoretically be satisfied. * - * @param string $name The class name of the migration - * @return bool Whether the migration cannot be fulfilled + * @param string $name The class name of the migration + * @return bool Whether the migration cannot be fulfilled */ public function unfulfillable($name) { @@ -406,11 +493,6 @@ class phpbb_db_migrator return true; } - protected function apply_schema_changes($schema_changes) - { - $this->db_tools->perform_schema_changes($schema_changes); - } - /** * Helper to get a migration * From edf693e3bd4352ab75c62311b34f12fc98e7ef63 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 15:28:08 -0600 Subject: [PATCH 036/174] [feature/migrations] Store state properly and send past result to callable Fix return on module add PHPBB3-9737 --- phpBB/includes/db/migration/tool/module.php | 4 +- phpBB/includes/db/migrator.php | 56 +++++++++++++++------ 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index f1b527bf21..70a246849a 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -208,11 +208,11 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac ); // Run the "manual" way with the data we've collected. - $result .= ((isset($data['spacer'])) ? $data['spacer'] : '<br />') . $this->add($class, $parent, $new_module); + $this->add($class, $parent, $new_module); } } - return $result; + return; } // The "manual" way diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 2ba1eba427..7aa4cfa719 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -251,11 +251,11 @@ class phpbb_db_migrator } else { - $state = $this->process_data_step($migration); + $result = $this->process_data_step($migration, $state['migration_data_state']); - $state['migration_data_state'] = $state; - $state['migration_data_done'] = ($state === true); - $state['migration_end_time'] = ($state === true) ? time() : 0; + $state['migration_data_state'] = ($result === true) ? '' : $result; + $state['migration_data_done'] = ($result === true); + $state['migration_end_time'] = ($result === true) ? time() : 0; } $sql = 'UPDATE ' . $this->migrations_table . ' @@ -284,27 +284,50 @@ class phpbb_db_migrator * Process the data step of the migration * * @param phpbb_db_migration $migration - * @return mixed migration status or bool true if everything completed successfully + * @param bool|string $state Current state of the migration + * @return bool|string migration state. True if completed, serialized array if not finished */ - protected function process_data_step($migration) + protected function process_data_step($migration, $state) { + $state = ($state) ? unserialize($state) : false; + $steps = $migration->update_data(); foreach ($steps as $step) { + $last_result = false; + if ($state) + { + // Continue until we reach the step that matches the last step called + if ($state['step'] != $step) + { + continue; + } + + // We send the result from last time to the callable function + $last_result = $state['result']; + + // Set state to false since we reached the point we were at + $state = false; + } + try { // Result will be null or true if everything completed correctly - $result = $this->run_step($step); + $result = $this->run_step($step, $last_result); if ($result !== null && $result !== true) { - return $result; + return serialize(array( + 'result' => $result, + 'step' => $step, + )); } } catch (phpbb_db_migration_exception $e) { // We should try rolling back here + var_dump($step); echo $e; die(); } @@ -318,12 +341,13 @@ class phpbb_db_migrator * * An exception should be thrown if an error occurs * - * @param mixed $step + * @param mixed $step Data step from migration + * @param mixed $last_result Result to pass to the callable (only for 'custom' method) * @return null */ - protected function run_step($step) + protected function run_step($step, $last_result = false) { - $callable_and_parameters = $this->get_callable_from_step($step); + $callable_and_parameters = $this->get_callable_from_step($step, $last_result); $callable = $callable_and_parameters[0]; $parameters = $callable_and_parameters[1]; @@ -334,9 +358,10 @@ class phpbb_db_migrator * Get a callable statement from a data step * * @param mixed $step Data step from migration + * @param mixed $last_result Result to pass to the callable (only for 'custom' method) * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters */ - public function get_callable_from_step($step) + public function get_callable_from_step($step, $last_result = false) { $type = $step[0]; $parameters = $step[1]; @@ -375,7 +400,7 @@ class phpbb_db_migrator function ($condition) use ($callable, $sub_parameters) { return call_user_func_array($callable, $sub_parameters); }, - array($condition) + array($condition), ); break; case 'custom': @@ -384,7 +409,10 @@ class phpbb_db_migrator throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step); } - return array($parameters[0], array()); + return array( + $parameters[0], + array($last_result), + ); break; default: From f56e400cd36b6d17ffde90a91e6e221cb83d2dbd Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 15:41:04 -0600 Subject: [PATCH 037/174] [feature/migrations] Comments PHPBB3-9737 --- .../includes/db/migration/tool/permission.php | 12 ++++---- phpBB/includes/db/migrator.php | 28 +++++++++++++++---- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 97fdbc0df9..7b45b24361 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -366,7 +366,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte switch ($type) { - case 'role' : + case 'role': $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($name) . "'"; @@ -389,7 +389,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_freeresult($result); break; - case 'group' : + case 'group': $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $this->db->sql_escape($name) . "'"; @@ -435,7 +435,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $sql_ary = array(); switch ($type) { - case 'role' : + case 'role': foreach ($new_auth as $auth_option_id) { if (!isset($current_auth[$auth_option_id])) @@ -451,7 +451,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); break; - case 'group' : + case 'group': foreach ($new_auth as $auth_option_id) { if (!isset($current_auth[$auth_option_id])) @@ -508,7 +508,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte switch ($type) { - case 'role' : + case 'role': $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($name) . "'"; @@ -525,7 +525,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_query($sql); break; - case 'group' : + case 'group': $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $this->db->sql_escape($name) . "'"; diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 7aa4cfa719..5d8dc12f58 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -43,13 +43,27 @@ class phpbb_db_migrator /** @var string */ protected $migrations_table; - /** @var array State of all migrations (SELECT * FROM migrations table) */ - protected $migration_state; + /** + * State of all migrations + * + * (SELECT * FROM migrations table) + * + * @var array + */ + protected $migration_state = array(); - /** @var array Array of all migrations available to be run */ + /** + * Array of all migrations available to be run + * + * @var array + */ protected $migrations = array(); - /** @var array 'name' and 'class' of the last migration run */ + /** + * 'name' and 'class' of the last migration run + * + * @var array + */ public $last_run_migration = false; /** @@ -83,11 +97,12 @@ class phpbb_db_migrator */ public function load_migration_state() { + $this->migration_state = array(); + $sql = "SELECT * FROM " . $this->migrations_table; $result = $this->db->sql_query($sql); - $this->migration_state = array(); while ($migration = $this->db->sql_fetchrow($result)) { $this->migration_state[$migration['migration_name']] = $migration; @@ -137,8 +152,9 @@ class phpbb_db_migrator $added_classes = array_diff(get_declared_classes(), $declared_classes); if ( - // The phpbb_db_migrations class may not have been loaded until now, so make sure to ignore it. + // If two classes have been added and phpbb_db_migration is one of them, we've only added one real migration !(sizeof($added_classes) == 2 && in_array('phpbb_db_migration', $added_classes)) && + // Otherwise there should only be one class added sizeof($added_classes) != 1 ) { From 445667a62e80c42b5406c981d1116ef99a23df3b Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 16:31:56 -0600 Subject: [PATCH 038/174] [feature/migrations] Fix if method (and create a test for it) PHPBB3-9737 --- phpBB/includes/db/migrator.php | 20 ++++++++++---- tests/dbal/migration/dummy.php | 14 +--------- tests/dbal/migration/if.php | 49 ++++++++++++++++++++++++++++++++++ tests/dbal/migrator_test.php | 35 +++++++++++++++++++----- 4 files changed, 94 insertions(+), 24 deletions(-) create mode 100644 tests/dbal/migration/if.php diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 5d8dc12f58..1042b767e8 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -364,6 +364,12 @@ class phpbb_db_migrator protected function run_step($step, $last_result = false) { $callable_and_parameters = $this->get_callable_from_step($step, $last_result); + + if ($callable_and_parameters === false) + { + return; + } + $callable = $callable_and_parameters[0]; $parameters = $callable_and_parameters[1]; @@ -377,7 +383,7 @@ class phpbb_db_migrator * @param mixed $last_result Result to pass to the callable (only for 'custom' method) * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters */ - public function get_callable_from_step($step, $last_result = false) + protected function get_callable_from_step($step, $last_result = false) { $type = $step[0]; $parameters = $step[1]; @@ -406,6 +412,12 @@ class phpbb_db_migrator } $condition = $parameters[0]; + + if (!$condition) + { + return false; + } + $step = $parameters[1]; $callable_and_parameters = $this->get_callable_from_step($step); @@ -413,10 +425,8 @@ class phpbb_db_migrator $sub_parameters = $callable_and_parameters[1]; return array( - function ($condition) use ($callable, $sub_parameters) { - return call_user_func_array($callable, $sub_parameters); - }, - array($condition), + $callable, + $sub_parameters, ); break; case 'custom': diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php index 942c499bb5..e542493f9f 100644 --- a/tests/dbal/migration/dummy.php +++ b/tests/dbal/migration/dummy.php @@ -19,21 +19,9 @@ class phpbb_dbal_migration_dummy extends phpbb_db_migration return array( 'add_columns' => array( 'phpbb_config' => array( - 'extra_column' => array('UINT', 0), + 'extra_column' => array('UINT', 1), ), ), ); } - - function update_data() - { - return array( - array('if', array(true, array('custom', array(array($this, 'set_extra_column'))))), - ); - } - - public function set_extra_column() - { - $this->sql_query('UPDATE phpbb_config SET extra_column = 1'); - } } diff --git a/tests/dbal/migration/if.php b/tests/dbal/migration/if.php new file mode 100644 index 0000000000..aa9a5dab87 --- /dev/null +++ b/tests/dbal/migration/if.php @@ -0,0 +1,49 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_if extends phpbb_db_migration +{ + function depends_on() + { + return array(); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('if', array( + true, + array('custom', array(array(&$this, 'test_true'))), + )), + array('if', array( + false, + array('custom', array(array(&$this, 'test_false'))), + )), + ); + } + + function test_true() + { + global $migrator_test_if_true_failed; + + $migrator_test_if_true_failed = false; + } + + function test_false() + { + global $migrator_test_if_false_failed; + + $migrator_test_if_false_failed = true; + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 463cf9fcec..dd592d7b05 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -14,6 +14,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/migration/dummy.php'; require_once dirname(__FILE__) . '/migration/unfulfillable.php'; +require_once dirname(__FILE__) . '/migration/if.php'; class phpbb_dbal_migrator_test extends phpbb_database_test_case { @@ -41,12 +42,6 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->migrator = new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', dirname(__FILE__) . '/../../phpBB/', 'php', 'phpbb_', $tools); } - public function tearDown() - { - // cleanup - $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); - } - public function test_update() { $this->migrator->set_migrations(array('phpbb_dbal_migration_dummy')); @@ -85,6 +80,9 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case AND migration_end_time <= " . (time() + 1), 'End time set correctly' ); + + // cleanup + $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); } public function test_unfulfillable() @@ -104,4 +102,29 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case 'Dummy migration was run, even though an unfulfillable migration was found.' ); } + + public function test_if() + { + $this->migrator->set_migrations(array('phpbb_dbal_migration_if')); + + // Don't like this, but I'm not sure there is any other way to do this + global $migrator_test_if_true_failed, $migrator_test_if_false_failed; + $migrator_test_if_true_failed = true; + $migrator_test_if_false_failed = false; + + while (!$this->migrator->finished()) + { + $this->migrator->update(); + } + + if ($migrator_test_if_true_failed) + { + $this->fail('True test failed'); + } + + if ($migrator_test_if_false_failed) + { + $this->fail('False test failed'); + } + } } From 5f9e1f1e89f8df5420fd82b5256a461de0f98604 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 16:56:26 -0600 Subject: [PATCH 039/174] [feature/migrations] Make sure the path sent to load_migrations is a directory Prevent a lot++ of errors PHPBB3-9737 --- phpBB/includes/db/migrator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 1042b767e8..359c34bf5d 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -139,6 +139,11 @@ class phpbb_db_migrator */ public function load_migrations($path, $check_fulfillable = true) { + if (!is_dir($path)) + { + throw new phpbb_db_migration_exception('DIRECTORY INVALID', $path); + } + $handle = opendir($path); while (($file = readdir($handle)) !== false) { From 79818c2139c305147d53ffb7217bec7568ff8b9c Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 17:20:12 -0600 Subject: [PATCH 040/174] [feature/migrations] Stop the update process if we are approaching time limit PHPBB3-9737 --- phpBB/test.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/phpBB/test.php b/phpBB/test.php index 5887c08d2f..ed4c1928ee 100644 --- a/phpBB/test.php +++ b/phpBB/test.php @@ -7,6 +7,8 @@ * */ +$update_start_time = time(); + use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -42,18 +44,6 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); $phpbb_class_loader->register(); -/*$phpbb_container = phpbb_create_container( - array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), - ), - array( - new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel_pass(), - ), - $phpbb_root_path, $phpEx); -$phpbb_container->compile();*/ - // Set up container $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), @@ -111,11 +101,27 @@ if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) $migrator = $phpbb_container->get('migrator'); $migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); +$safe_time_limit = (ini_get('max_execution_time') / 2); + while (!$migrator->finished()) { $migrator->update(); echo $migrator->last_run_migration['name'] . '<br />'; + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $update_start_time) >= $safe_time_limit) + { + //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; + echo 'Update not yet completed.<br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; + + garbage_collection(); + exit_handler(); + } } echo 'Finished'; + +garbage_collection(); +exit_handler(); From 28cd253d19f49a6450bce90a5b81df939d0be2c9 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 17:22:05 -0600 Subject: [PATCH 041/174] [feature/migrations] Comment PHPBB3-9737 --- phpBB/test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/test.php b/phpBB/test.php index ed4c1928ee..7a2dafb7ef 100644 --- a/phpBB/test.php +++ b/phpBB/test.php @@ -101,6 +101,7 @@ if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) $migrator = $phpbb_container->get('migrator'); $migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); +// What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); while (!$migrator->finished()) From 3d4c00619f1c96df7a4c6f8bc1c03eb21abf49d7 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 18:24:32 -0600 Subject: [PATCH 042/174] [feature/migrations] Reverse data functionality If data step fails, attempt to roll back any previous calls from the migration that failed. Fix some failing tests PHPBB3-9737 --- phpBB/includes/db/migration/tool/config.php | 42 ++++++++++++++ .../includes/db/migration/tool/interface.php | 10 ++++ phpBB/includes/db/migration/tool/module.php | 31 +++++++++++ .../includes/db/migration/tool/permission.php | 55 +++++++++++++++++++ phpBB/includes/db/migrator.php | 37 +++++++++---- tests/dbal/migrator_tool_config_test.php | 27 +++++++++ tests/dbal/migrator_tool_module.php | 28 +++++++++- tests/dbal/migrator_tool_permission.php | 25 ++++++++- 8 files changed, 240 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/includes/db/migration/tool/config.php index e7239436d2..6ae419d5e7 100644 --- a/phpBB/includes/db/migration/tool/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -103,4 +103,46 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac $this->config->delete($config_name); } + + /** + * Reverse an original install action + * + * First argument is the original call to the class (e.g. add, remove) + * After the first argument, send the original arguments to the function in the original call + * + * @return null + */ + public function reverse() + { + $arguments = func_get_args(); + $original_call = array_shift($arguments); + + $call = false; + switch ($original_call) + { + case 'add': + $call = 'remove'; + break; + + case 'remove': + $call = 'add'; + break; + + case 'update_if_equals': + $call = 'update_if_equals'; + + // Set to the original value if the current value is what we compared to originally + $arguments = array( + $arguments[2], + $arguments[1], + $arguments[0], + ); + break; + } + + if ($call) + { + return call_user_func_array(array(&$this, $call), $arguments); + } + } } diff --git a/phpBB/includes/db/migration/tool/interface.php b/phpBB/includes/db/migration/tool/interface.php index 5d10246ba1..ced53b2023 100644 --- a/phpBB/includes/db/migration/tool/interface.php +++ b/phpBB/includes/db/migration/tool/interface.php @@ -20,4 +20,14 @@ interface phpbb_db_migration_tool_interface * @return string short name */ public function get_name(); + + /** + * Reverse an original install action + * + * First argument is the original call to the class (e.g. add, remove) + * After the first argument, send the original arguments to the function in the original call + * + * @return null + */ + public function reverse(); } diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index 70a246849a..561faac552 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -471,4 +471,35 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $this->cache->destroy("_modules_$class"); } } + + /** + * Reverse an original install action + * + * First argument is the original call to the class (e.g. add, remove) + * After the first argument, send the original arguments to the function in the original call + * + * @return null + */ + public function reverse() + { + $arguments = func_get_args(); + $original_call = array_shift($arguments); + + $call = false; + switch ($original_call) + { + case 'add': + $call = 'remove'; + break; + + case 'remove': + $call = 'add'; + break; + } + + if ($call) + { + return call_user_func_array(array(&$this, $call), $arguments); + } + } } diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 7b45b24361..a25fdb345e 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -563,4 +563,59 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->auth->acl_clear_prefetch(); } + + /** + * Reverse an original install action + * + * First argument is the original call to the class (e.g. add, remove) + * After the first argument, send the original arguments to the function in the original call + * + * @return null + */ + public function reverse() + { + $arguments = func_get_args(); + $original_call = array_shift($arguments); + + $call = false; + switch ($original_call) + { + case 'add': + $call = 'remove'; + break; + + case 'remove': + $call = 'add'; + break; + + case 'permission_set': + $call = 'permission_unset'; + break; + + case 'permission_unset': + $call = 'permission_set'; + break; + + case 'role_add': + $call = 'role_remove'; + break; + + case 'role_remove': + $call = 'role_add'; + break; + + case 'role_update': + // Set to the original value if the current value is what we compared to originally + $arguments = array( + $arguments[1], + $arguments[0], + ); + break; + } + + if ($call) + { + return call_user_func_array(array(&$this, $call), $arguments); + } + } } diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 359c34bf5d..dc2c746559 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -347,6 +347,17 @@ class phpbb_db_migrator catch (phpbb_db_migration_exception $e) { // We should try rolling back here + foreach ($steps as $reverse_step) + { + // Reverse the step that was run + $result = $this->run_step($step, false, true); + + // If we've reached the current step we can break because we reversed everything that was run + if ($reverse_step === $step) + { + break; + } + } var_dump($step); echo $e; @@ -364,11 +375,12 @@ class phpbb_db_migrator * * @param mixed $step Data step from migration * @param mixed $last_result Result to pass to the callable (only for 'custom' method) + * @param bool $reverse False to install, True to attempt uninstallation by reversing the call * @return null */ - protected function run_step($step, $last_result = false) + protected function run_step($step, $last_result = false, $reverse = false) { - $callable_and_parameters = $this->get_callable_from_step($step, $last_result); + $callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse); if ($callable_and_parameters === false) { @@ -386,9 +398,10 @@ class phpbb_db_migrator * * @param mixed $step Data step from migration * @param mixed $last_result Result to pass to the callable (only for 'custom' method) + * @param bool $reverse False to install, True to attempt uninstallation by reversing the call * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters */ - protected function get_callable_from_step($step, $last_result = false) + protected function get_callable_from_step($step, $last_result = false, $reverse = false) { $type = $step[0]; $parameters = $step[1]; @@ -425,14 +438,7 @@ class phpbb_db_migrator $step = $parameters[1]; - $callable_and_parameters = $this->get_callable_from_step($step); - $callable = $callable_and_parameters[0]; - $sub_parameters = $callable_and_parameters[1]; - - return array( - $callable, - $sub_parameters, - ); + return $this->get_callable_from_step($step); break; case 'custom': if (!is_callable($parameters[0])) @@ -462,6 +468,15 @@ class phpbb_db_migrator throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step); } + // Attempt to reverse operations + if ($reverse) + { + return array( + array($this->tools[$class], 'reverse'), + array_unshift($parameters, $method), + ); + } + return array( array($this->tools[$class], $method), $parameters, diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php index 27511519ca..7d582f230b 100644 --- a/tests/dbal/migrator_tool_config_test.php +++ b/tests/dbal/migrator_tool_config_test.php @@ -94,4 +94,31 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case } $this->assertFalse(isset($this->config['foo'])); } + + public function test_reverse() + { + $this->config->set('foo', 'bar'); + + try + { + $this->tool->reverse('add', 'foo'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertFalse(isset($this->config['foo'])); + + $this->config->set('foo', 'bar'); + + try + { + $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals('test', $this->config['foo']); + } } diff --git a/tests/dbal/migrator_tool_module.php b/tests/dbal/migrator_tool_module.php index 0b57cbfbcb..6937b6f8c5 100644 --- a/tests/dbal/migrator_tool_module.php +++ b/tests/dbal/migrator_tool_module.php @@ -29,10 +29,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $skip_add_log = true; $db = $this->db = $this->new_dbal(); - $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null()); + $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx); $user = $this->user = new phpbb_user(); - $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx); + $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); } public function exists_data() @@ -99,7 +99,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case try { - $this->tool->add('acp', ACP_NEW_CAT, array( + $this->tool->add('acp', 'ACP_NEW_CAT', array( 'module_basename' => 'acp_new_module', 'module_langname' => 'ACP_NEW_MODULE', 'module_mode' => 'test', @@ -125,4 +125,26 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case } $this->assertEquals(false, $this->tool->exists('acp', 'ACP_CAT', 'ACP_MODULE')); } + + public function test_reverse() + { + try + { + $this->tool->add('acp', 0, 'ACP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + + try + { + $this->tool->reverse('add', 'acp', 0, 'ACP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertFalse($this->tool->exists('acp', 0, 'ACP_NEW_CAT')); + } } diff --git a/tests/dbal/migrator_tool_permission.php b/tests/dbal/migrator_tool_permission.php index 2229576cd9..438ab2b28e 100644 --- a/tests/dbal/migrator_tool_permission.php +++ b/tests/dbal/migrator_tool_permission.php @@ -26,7 +26,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case parent::setup(); $db = $this->db = $this->new_dbal(); - $cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null()); + $cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx); $this->auth = new phpbb_auth(); $this->tool = new phpbb_db_migration_tool_permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx); @@ -133,4 +133,27 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case } catch (Exception $e) {} } + + public function test_reverse() + { + try + { + $this->tool->reverse('remove', 'global_test', true); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertTrue($this->tool->exists('global_test', true)); + + try + { + $this->tool->reverse('add', 'global_test', true); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertFalse($this->tool->exists('global_test', true)); + } } From 595246f9bf17f1bef69c285ba8e78534cd91054a Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 18:55:55 -0600 Subject: [PATCH 043/174] [feature/migrations] Some comments in db_tools PHPBB3-9737 --- phpBB/includes/db/db_tools.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 1d6823d37a..b13d4fe978 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -685,6 +685,8 @@ class phpbb_db_tools * Handle passed database update array. * Expected structure... * Key being one of the following + * drop_tables: Drop tables + * add_tables: Add tables * change_columns: Column changes (only type, not name) * add_columns: Add columns to a table * drop_keys: Dropping keys From 44c10f661ee548ae08fe81ba76f47f1c8134b96f Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Wed, 9 Jan 2013 18:59:15 -0600 Subject: [PATCH 044/174] [feature/migrations] Creating revert method to attempt reverting a migration This code is in progress PHPBB3-9737 --- phpBB/includes/db/migration/migration.php | 23 +++++ phpBB/includes/db/migrator.php | 100 ++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/phpBB/includes/db/migration/migration.php b/phpBB/includes/db/migration/migration.php index 5f1f0443db..61fbf04320 100644 --- a/phpBB/includes/db/migration/migration.php +++ b/phpBB/includes/db/migration/migration.php @@ -93,6 +93,16 @@ abstract class phpbb_db_migration return array(); } + /** + * Reverts the database schema by providing a set of change instructions + * + * @return array Array of schema changes (compatible with db_tools->perform_schema_changes()) + */ + public function revert_schema() + { + return array(); + } + /** * Updates data by returning a list of instructions to be executed * @@ -103,6 +113,19 @@ abstract class phpbb_db_migration return array(); } + /** + * Reverts data by returning a list of instructions to be executed + * + * @return array Array of data instructions that will be performed on revert + * NOTE: calls to tools (such as config.add) are automatically reverted when + * possible, so you should not attempt to revert those, this is mostly for + * otherwise unrevertable calls (custom functions for example) + */ + public function revert_data() + { + return array(); + } + /** * Wrapper for running queries to generate user feedback on updates * diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index dc2c746559..e8d3735974 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -289,6 +289,91 @@ class phpbb_db_migrator return true; } + /** + * Runs a single revert step from the last migration installed + * + * The revert step can either be a schema or a (partial) data revert. To + * check if revert() needs to be called again use the migration_installed() method. + * + * @param string $migration String migration name to revert (including any that depend on this migration) + * @return null + */ + public function revert($migration) + { + if (!isset($this->migration_state[$name])) + { + // Not installed + return; + } + + // Iterate through all installed migrations and make sure any dependencies are removed first + foreach ($this->migration_state as $name => $state) + { + $migration_class = $this->get_migration($name); + + if (in_array($migration, $migration_class->depends_on())) + { + $this->revert($name); + } + } + + $this->try_revert($migration); + } + + /** + * Attempts to apply a step of the given migration or one of its dependencies + * + * @param string The class name of the migration + * @return bool Whether any update step was successfully run + */ + protected function try_revert($name) + { + if (!class_exists($name)) + { + return false; + } + + $migration = $this->get_migration($name); + + $state = $this->migration_state[$name]; + + $this->last_run_migration = array( + 'name' => $name, + 'class' => $migration, + ); + + // Left off here + + if (!isset($this->migration_state[$name])) + { + $state['migration_start_time'] = time(); + $this->insert_migration($name, $state); + } + + if (!$state['migration_schema_done']) + { + $this->apply_schema_changes($migration->update_schema()); + $state['migration_schema_done'] = true; + } + else + { + $result = $this->process_data_step($migration, $state['migration_data_state']); + + $state['migration_data_state'] = ($result === true) ? '' : $result; + $state['migration_data_done'] = ($result === true); + $state['migration_end_time'] = ($result === true) ? time() : 0; + } + + $sql = 'UPDATE ' . $this->migrations_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $state) . " + WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; + $this->db->sql_query($sql); + + $this->migration_state[$name] = $state; + + return true; + } + /** * Apply schema changes from a migration * @@ -359,6 +444,7 @@ class phpbb_db_migrator } } + /** TODO Revert Schema **/ var_dump($step); echo $e; die(); @@ -567,6 +653,20 @@ class phpbb_db_migrator return true; } + /** + * Checks whether a migration is installed + * + * @param string $migration String migration name to check if it is installed + * @return bool Whether the migrations have been applied + */ + public function migration_installed($migration) + { + if (isset($this->migration_state[$migration])) + { + return true; + } + } + /** * Helper to get a migration * From ddb1eaab6868cfac70b7b202468cab29315b794d Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 12:49:13 -0600 Subject: [PATCH 045/174] [feature/migrations] Test for calling a step multiple times This is used when a long-running process is needed during an update. For example, iterating over all posts and applying some transformation. This allows the process to be broken apart into multiple shorter steps to prevent hitting the time limit. PHPBB3-9737 --- tests/dbal/migration/recall.php | 43 +++++++++++++++++++++++++++++++++ tests/dbal/migrator_test.php | 23 ++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/dbal/migration/recall.php diff --git a/tests/dbal/migration/recall.php b/tests/dbal/migration/recall.php new file mode 100644 index 0000000000..18d8b4a6d2 --- /dev/null +++ b/tests/dbal/migration/recall.php @@ -0,0 +1,43 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_recall extends phpbb_db_migration +{ + function depends_on() + { + return array(); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'test_call'))), + ); + } + + // This function should be called 10 times + function test_call($input) + { + global $migrator_test_call_input; + + $migrator_test_call_input = (int) $input; + + if ($migrator_test_call_input < 10) + { + return ($migrator_test_call_input + 1); + } + + return; + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index dd592d7b05..9c40eec15a 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -15,6 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/migration/dummy.php'; require_once dirname(__FILE__) . '/migration/unfulfillable.php'; require_once dirname(__FILE__) . '/migration/if.php'; +require_once dirname(__FILE__) . '/migration/recall.php'; class phpbb_dbal_migrator_test extends phpbb_database_test_case { @@ -127,4 +128,26 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->fail('False test failed'); } } + + public function test_recall() + { + $this->migrator->set_migrations(array('phpbb_dbal_migration_recall')); + + global $migrator_test_call_input; + + // Run the schema first + $this->migrator->update(); + + $i = 0; + while (!$this->migrator->finished()) + { + $this->migrator->update(); + + $this->assertSame($i, $migrator_test_call_input); + + $i++; + } + + $this->assertSame(10, $migrator_test_call_input); + } } From 00385aa742da17678f7d147b6d71fa759fcd7e78 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 13:52:11 -0600 Subject: [PATCH 046/174] [feature/migrations] Basic reverting test PHPBB3-9737 --- tests/dbal/migration/revert.php | 45 ++++++++++++++++ .../dbal/migration/revert_with_dependency.php | 16 ++++++ tests/dbal/migrator_test.php | 54 +++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 tests/dbal/migration/revert.php create mode 100644 tests/dbal/migration/revert_with_dependency.php diff --git a/tests/dbal/migration/revert.php b/tests/dbal/migration/revert.php new file mode 100644 index 0000000000..2bb23e31c2 --- /dev/null +++ b/tests/dbal/migration/revert.php @@ -0,0 +1,45 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_revert extends phpbb_db_migration +{ + function depends_on() + { + return array(); + } + + function update_schema() + { + return array( + 'add_columns' => array( + 'phpbb_config' => array( + 'bar_column' => array('UINT', 1), + ), + ), + ); + } + + function revert_schema() + { + return array( + 'drop_columns' => array( + 'phpbb_config' => array( + 'bar_column', + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('foobartest', 0)), + ); + } +} diff --git a/tests/dbal/migration/revert_with_dependency.php b/tests/dbal/migration/revert_with_dependency.php new file mode 100644 index 0000000000..f6820dbf3f --- /dev/null +++ b/tests/dbal/migration/revert_with_dependency.php @@ -0,0 +1,16 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_revert_with_dependency extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_dbal_migration_revert'); + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 9c40eec15a..84bcb109b2 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -16,6 +16,8 @@ require_once dirname(__FILE__) . '/migration/dummy.php'; require_once dirname(__FILE__) . '/migration/unfulfillable.php'; require_once dirname(__FILE__) . '/migration/if.php'; require_once dirname(__FILE__) . '/migration/recall.php'; +require_once dirname(__FILE__) . '/migration/revert.php'; +require_once dirname(__FILE__) . '/migration/revert_with_dependency.php'; class phpbb_dbal_migrator_test extends phpbb_database_test_case { @@ -102,6 +104,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case "SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'", 'Dummy migration was run, even though an unfulfillable migration was found.' ); + + $this->db_tools->sql_column_remove('phpbb_config', 'extra_column'); } public function test_if() @@ -150,4 +154,54 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertSame(10, $migrator_test_call_input); } + + public function test_revert() + { + // Make sure there are no other migrations in the db, this could cause issues + $this->db->sql_query("DELETE FROM phpbb_migrations"); + $this->migrator->load_migration_state(); + + $this->migrator->set_migrations(array('phpbb_dbal_migration_revert', 'phpbb_dbal_migration_revert_with_dependency')); + + $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert')); + $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert_with_dependency')); + + // Install the migration first + while (!$this->migrator->finished()) + { + $this->migrator->update(); + } + + $this->assertTrue($this->migrator->migration_installed('phpbb_dbal_migration_revert')); + $this->assertTrue($this->migrator->migration_installed('phpbb_dbal_migration_revert_with_dependency')); + + $this->assertSqlResultEquals( + array(array('bar_column' => '1')), + "SELECT bar_column FROM phpbb_config WHERE config_name = 'foo'", + 'Installing revert migration failed to create bar_column.' + ); + + $this->assertTrue(isset($this->config['foobartest'])); + + while ($this->migrator->migration_installed('phpbb_dbal_migration_revert')) + { + $this->migrator->revert('phpbb_dbal_migration_revert'); + } + + $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert')); + $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert_with_dependency')); + + $this->assertFalse(isset($this->config['foobartest'])); + + try + { + // Should cause an error + $this->assertSqlResultEquals( + false, + "SELECT bar_column FROM phpbb_config WHERE config_name = 'foo'", + 'Revert did not remove bar_column.' + ); + } + catch (Exception $e) {} + } } From dbe71bb170dc684311174bb025696c81f1d50883 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 13:53:09 -0600 Subject: [PATCH 047/174] [feature/migrations] Revert method completed PHPBB3-9737 --- phpBB/includes/db/migrator.php | 74 +++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index e8d3735974..13114e7df1 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -272,7 +272,7 @@ class phpbb_db_migrator } else { - $result = $this->process_data_step($migration, $state['migration_data_state']); + $result = $this->process_data_step($migration->update_data(), $state['migration_data_state']); $state['migration_data_state'] = ($result === true) ? '' : $result; $state['migration_data_done'] = ($result === true); @@ -300,7 +300,7 @@ class phpbb_db_migrator */ public function revert($migration) { - if (!isset($this->migration_state[$name])) + if (!isset($this->migration_state[$migration])) { // Not installed return; @@ -342,35 +342,40 @@ class phpbb_db_migrator 'class' => $migration, ); - // Left off here - - if (!isset($this->migration_state[$name])) + if ($state['migration_data_done']) { - $state['migration_start_time'] = time(); - $this->insert_migration($name, $state); - } + if ($state['migration_data_state'] !== 'revert_data') + { + $result = $this->process_data_step($migration->update_data(), $state['migration_data_state'], true); - if (!$state['migration_schema_done']) - { - $this->apply_schema_changes($migration->update_schema()); - $state['migration_schema_done'] = true; + $state['migration_data_state'] = ($result === true) ? 'revert_data' : $result; + } + else + { + $result = $this->process_data_step($migration->revert_data(), $state['migration_data_state'], false); + + $state['migration_data_state'] = ($result === true) ? '' : $result; + $state['migration_data_done'] = ($result === true) ? false : true; + } + + $sql = 'UPDATE ' . $this->migrations_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $state) . " + WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; + $this->db->sql_query($sql); + + $this->migration_state[$name] = $state; } else { - $result = $this->process_data_step($migration, $state['migration_data_state']); + $this->apply_schema_changes($migration->revert_schema()); - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true); - $state['migration_end_time'] = ($result === true) ? time() : 0; + $sql = 'DELETE FROM ' . $this->migrations_table . " + WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; + $this->db->sql_query($sql); + + unset($this->migration_state[$name]); } - $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $state) . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - $this->migration_state[$name] = $state; - return true; } @@ -389,23 +394,22 @@ class phpbb_db_migrator /** * Process the data step of the migration * - * @param phpbb_db_migration $migration + * @param array $steps The steps to run * @param bool|string $state Current state of the migration + * @param bool $revert true to revert a data step * @return bool|string migration state. True if completed, serialized array if not finished */ - protected function process_data_step($migration, $state) + protected function process_data_step($steps, $state, $revert = false) { $state = ($state) ? unserialize($state) : false; - $steps = $migration->update_data(); - - foreach ($steps as $step) + foreach ($steps as $step_identifier => $step) { $last_result = false; if ($state) { // Continue until we reach the step that matches the last step called - if ($state['step'] != $step) + if ($state['step'] != $step_identifier) { continue; } @@ -420,12 +424,12 @@ class phpbb_db_migrator try { // Result will be null or true if everything completed correctly - $result = $this->run_step($step, $last_result); + $result = $this->run_step($step, $last_result, $revert); if ($result !== null && $result !== true) { return serialize(array( 'result' => $result, - 'step' => $step, + 'step' => $step_identifier, )); } } @@ -435,7 +439,7 @@ class phpbb_db_migrator foreach ($steps as $reverse_step) { // Reverse the step that was run - $result = $this->run_step($step, false, true); + $result = $this->run_step($step, false, !$revert); // If we've reached the current step we can break because we reversed everything that was run if ($reverse_step === $step) @@ -557,9 +561,11 @@ class phpbb_db_migrator // Attempt to reverse operations if ($reverse) { + array_unshift($parameters, $method); + return array( array($this->tools[$class], 'reverse'), - array_unshift($parameters, $method), + $parameters, ); } @@ -665,6 +671,8 @@ class phpbb_db_migrator { return true; } + + return false; } /** From d50500860fe44a78c8f29e0f2382b96da17c0b62 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 15:09:51 -0600 Subject: [PATCH 048/174] [feature/migrations] Store depends on in the database (serialized) This is required so that when migrations are reverted we can check through all installed migrations and make sure that all dependencies are handled properly and so that we are only required to load the migrations files that could be dependent on the ones installed. I believe in normal proper use the old way might have worked, but in case something happens and an unrelated migration file is installed, but cannot be loaded, this makes sure we do not stop everything unless we absolutely must (one of those files is dependent on something we want to revert). PHPBB3-9737 --- phpBB/develop/create_schema_files.php | 1 + phpBB/includes/db/migrator.php | 79 +++++++++++++---------- phpBB/install/schemas/firebird_schema.sql | 1 + phpBB/install/schemas/mssql_schema.sql | 1 + phpBB/install/schemas/mysql_40_schema.sql | 1 + phpBB/install/schemas/mysql_41_schema.sql | 1 + phpBB/install/schemas/oracle_schema.sql | 1 + phpBB/install/schemas/postgres_schema.sql | 1 + phpBB/install/schemas/sqlite_schema.sql | 1 + phpBB/test.php | 13 +++- tests/dbal/fixtures/migrator.xml | 2 + tests/dbal/migration/fail.php | 46 +++++++++++++ tests/dbal/migrator_test.php | 57 ++++++++++++---- 13 files changed, 157 insertions(+), 48 deletions(-) create mode 100644 tests/dbal/migration/fail.php diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index b37dcc246f..d0864b975d 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1276,6 +1276,7 @@ function get_schema_struct() $schema_data['phpbb_migrations'] = array( 'COLUMNS' => array( 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), 'migration_schema_done' => array('BOOL', 0), 'migration_data_done' => array('BOOL', 0), 'migration_data_state' => array('TEXT', ''), diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 13114e7df1..2ec44a5a45 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -106,6 +106,8 @@ class phpbb_db_migrator while ($migration = $this->db->sql_fetchrow($result)) { $this->migration_state[$migration['migration_name']] = $migration; + + $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); } $this->db->sql_freeresult($result); @@ -235,16 +237,15 @@ class phpbb_db_migrator $state = (isset($this->migration_state[$name])) ? $this->migration_state[$name] : array( + 'migration_depends_on' => $migration->depends_on(), 'migration_schema_done' => false, - 'migration_data_done' => false, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, + 'migration_data_done' => false, + 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, ); - $depends = $migration->depends_on(); - - foreach ($depends as $depend) + foreach ($state['migration_depends_on'] as $depend) { if (!isset($this->migration_state[$depend]) || !$this->migration_state[$depend]['migration_schema_done'] || @@ -272,15 +273,28 @@ class phpbb_db_migrator } else { - $result = $this->process_data_step($migration->update_data(), $state['migration_data_state']); + try + { + $result = $this->process_data_step($migration->update_data(), $state['migration_data_state']); - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true); - $state['migration_end_time'] = ($result === true) ? time() : 0; + $state['migration_data_state'] = ($result === true) ? '' : $result; + $state['migration_data_done'] = ($result === true); + $state['migration_end_time'] = ($result === true) ? time() : 0; + } + catch (phpbb_db_migration_exception $e) + { + // Revert the schema changes + $this->revert($name); + + // Rethrow exception + throw $e; + } } + $insert = $state; + $insert['migration_depends_on'] = serialize($state['migration_depends_on']); $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $state) . " + SET ' . $this->db->sql_build_array('UPDATE', $insert) . " WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); @@ -292,8 +306,9 @@ class phpbb_db_migrator /** * Runs a single revert step from the last migration installed * + * YOU MUST ADD/SET ALL MIGRATIONS THAT COULD BE DEPENDENT ON THE MIGRATION TO REVERT TO BEFORE CALLING THIS METHOD! * The revert step can either be a schema or a (partial) data revert. To - * check if revert() needs to be called again use the migration_installed() method. + * check if revert() needs to be called again use the migration_state() method. * * @param string $migration String migration name to revert (including any that depend on this migration) * @return null @@ -306,12 +321,9 @@ class phpbb_db_migrator return; } - // Iterate through all installed migrations and make sure any dependencies are removed first foreach ($this->migration_state as $name => $state) { - $migration_class = $this->get_migration($name); - - if (in_array($migration, $migration_class->depends_on())) + if (!empty($state['migration_depends_on']) && in_array($migration, $state['migration_depends_on'])) { $this->revert($name); } @@ -358,8 +370,10 @@ class phpbb_db_migrator $state['migration_data_done'] = ($result === true) ? false : true; } + $insert = $state; + $insert['migration_depends_on'] = serialize($state['migration_depends_on']); $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $state) . " + SET ' . $this->db->sql_build_array('UPDATE', $insert) . " WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; $this->db->sql_query($sql); @@ -436,22 +450,20 @@ class phpbb_db_migrator catch (phpbb_db_migration_exception $e) { // We should try rolling back here - foreach ($steps as $reverse_step) + foreach ($steps as $reverse_step_identifier => $reverse_step) { - // Reverse the step that was run - $result = $this->run_step($step, false, !$revert); - // If we've reached the current step we can break because we reversed everything that was run - if ($reverse_step === $step) + if ($reverse_step_identifier == $step_identifier) { break; } + + // Reverse the step that was run + $result = $this->run_step($reverse_step, false, !$revert); } - /** TODO Revert Schema **/ - var_dump($step); - echo $e; - die(); + // rethrow the exception + throw $e; } } @@ -588,6 +600,7 @@ class phpbb_db_migrator { $migration_row = $state; $migration_row['migration_name'] = $name; + $migration_row['migration_depends_on'] = serialize($state['migration_depends_on']); $sql = 'INSERT INTO ' . $this->migrations_table . ' ' . $this->db->sql_build_array('INSERT', $migration_row); @@ -660,19 +673,19 @@ class phpbb_db_migrator } /** - * Checks whether a migration is installed + * Gets a migration state (whether it is installed and to what extent) * * @param string $migration String migration name to check if it is installed - * @return bool Whether the migrations have been applied + * @return bool|array False if the migration has not at all been installed, array */ - public function migration_installed($migration) + public function migration_state($migration) { - if (isset($this->migration_state[$migration])) + if (!isset($this->migration_state[$migration])) { - return true; + return false; } - return false; + return $this->migration_state[$migration]; } /** diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 535cbb0df4..45024c4049 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -589,6 +589,7 @@ CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache(forum_id);; # Table: 'phpbb_migrations' CREATE TABLE phpbb_migrations ( migration_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + migration_depends_on BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, migration_schema_done INTEGER DEFAULT 0 NOT NULL, migration_data_done INTEGER DEFAULT 0 NOT NULL, migration_data_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 43b8f3e556..e261e73d73 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -721,6 +721,7 @@ GO */ CREATE TABLE [phpbb_migrations] ( [migration_name] [varchar] (255) DEFAULT ('') NOT NULL , + [migration_depends_on] [varchar] (8000) DEFAULT ('') NOT NULL , [migration_schema_done] [int] DEFAULT (0) NOT NULL , [migration_data_done] [int] DEFAULT (0) NOT NULL , [migration_data_state] [varchar] (8000) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index c46230744a..0f184d4d05 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -413,6 +413,7 @@ CREATE TABLE phpbb_moderator_cache ( # Table: 'phpbb_migrations' CREATE TABLE phpbb_migrations ( migration_name varbinary(255) DEFAULT '' NOT NULL, + migration_depends_on blob NOT NULL, migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, migration_data_state blob NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index fa94598e9c..b7564ceb7c 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -413,6 +413,7 @@ CREATE TABLE phpbb_moderator_cache ( # Table: 'phpbb_migrations' CREATE TABLE phpbb_migrations ( migration_name varchar(255) DEFAULT '' NOT NULL, + migration_depends_on text NOT NULL, migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, migration_data_state text NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index f8a9d5e1a6..7796c3a729 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -803,6 +803,7 @@ CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id) */ CREATE TABLE phpbb_migrations ( migration_name varchar2(255) DEFAULT '' , + migration_depends_on clob DEFAULT '' , migration_schema_done number(1) DEFAULT '0' NOT NULL, migration_data_done number(1) DEFAULT '0' NOT NULL, migration_data_state clob DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index c976659f05..9fd81ec06a 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -577,6 +577,7 @@ CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); */ CREATE TABLE phpbb_migrations ( migration_name varchar(255) DEFAULT '' NOT NULL, + migration_depends_on varchar(8000) DEFAULT '' NOT NULL, migration_schema_done INT2 DEFAULT '0' NOT NULL CHECK (migration_schema_done >= 0), migration_data_done INT2 DEFAULT '0' NOT NULL CHECK (migration_data_done >= 0), migration_data_state varchar(8000) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 31a6f715a0..9d6d648c00 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -401,6 +401,7 @@ CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); # Table: 'phpbb_migrations' CREATE TABLE phpbb_migrations ( migration_name varchar(255) NOT NULL DEFAULT '', + migration_depends_on text(65535) NOT NULL DEFAULT '', migration_schema_done INTEGER UNSIGNED NOT NULL DEFAULT '0', migration_data_done INTEGER UNSIGNED NOT NULL DEFAULT '0', migration_data_state text(65535) NOT NULL DEFAULT '', diff --git a/phpBB/test.php b/phpBB/test.php index 7a2dafb7ef..6602aa8dcc 100644 --- a/phpBB/test.php +++ b/phpBB/test.php @@ -88,6 +88,7 @@ if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) $db_tools->sql_create_table(MIGRATIONS_TABLE, array( 'COLUMNS' => array( 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), 'migration_schema_done' => array('BOOL', 0), 'migration_data_done' => array('BOOL', 0), 'migration_data_state' => array('TEXT', ''), @@ -106,7 +107,17 @@ $safe_time_limit = (ini_get('max_execution_time') / 2); while (!$migrator->finished()) { - $migrator->update(); + try + { + $migrator->update(); + } + catch (phpbb_db_migration_exception $e) + { + echo $e; + + garbage_collection(); + exit_handler(); + } echo $migrator->last_run_migration['name'] . '<br />'; diff --git a/tests/dbal/fixtures/migrator.xml b/tests/dbal/fixtures/migrator.xml index 1f9079c811..25be4d4129 100644 --- a/tests/dbal/fixtures/migrator.xml +++ b/tests/dbal/fixtures/migrator.xml @@ -2,6 +2,7 @@ <dataset> <table name="phpbb_migrations"> <column>migration_name</column> + <column>migration_depends_on</column> <column>migration_schema_done</column> <column>migration_data_done</column> <column>migration_data_state</column> @@ -9,6 +10,7 @@ <column>migration_end_time</column> <row> <value>installed_migration</value> + <value></value> <value>1</value> <value>1</value> <value></value> diff --git a/tests/dbal/migration/fail.php b/tests/dbal/migration/fail.php new file mode 100644 index 0000000000..8b5c521e09 --- /dev/null +++ b/tests/dbal/migration/fail.php @@ -0,0 +1,46 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_dbal_migration_fail extends phpbb_db_migration +{ + function depends_on() + { + return array(); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'config' => array( + 'test_column' => array('BOOL', 1), + ), + ), + ); + } + + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'config' => array( + 'test_column', + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('foobar3', true)), + array('config.update', array('does_not_exist', true)), + ); + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 84bcb109b2..69db7ca047 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -18,6 +18,7 @@ require_once dirname(__FILE__) . '/migration/if.php'; require_once dirname(__FILE__) . '/migration/recall.php'; require_once dirname(__FILE__) . '/migration/revert.php'; require_once dirname(__FILE__) . '/migration/revert_with_dependency.php'; +require_once dirname(__FILE__) . '/migration/fail.php'; class phpbb_dbal_migrator_test extends phpbb_database_test_case { @@ -163,8 +164,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->migrator->set_migrations(array('phpbb_dbal_migration_revert', 'phpbb_dbal_migration_revert_with_dependency')); - $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert')); - $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert_with_dependency')); + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert')); + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency')); // Install the migration first while (!$this->migrator->finished()) @@ -172,8 +173,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->migrator->update(); } - $this->assertTrue($this->migrator->migration_installed('phpbb_dbal_migration_revert')); - $this->assertTrue($this->migrator->migration_installed('phpbb_dbal_migration_revert_with_dependency')); + $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert') !== false); + $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency') !== false); $this->assertSqlResultEquals( array(array('bar_column' => '1')), @@ -183,25 +184,53 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->assertTrue(isset($this->config['foobartest'])); - while ($this->migrator->migration_installed('phpbb_dbal_migration_revert')) + while ($this->migrator->migration_state('phpbb_dbal_migration_revert') !== false) { $this->migrator->revert('phpbb_dbal_migration_revert'); } - $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert')); - $this->assertFalse($this->migrator->migration_installed('phpbb_dbal_migration_revert_with_dependency')); + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert')); + $this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency')); $this->assertFalse(isset($this->config['foobartest'])); + $sql = 'SELECT * FROM phpbb_config'; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (isset($row['bar_column'])) + { + $this->fail('Revert did not remove test_column.'); + } + } + + public function test_fail() + { + $this->migrator->set_migrations(array('phpbb_dbal_migration_fail')); + + $this->assertFalse(isset($this->config['foobar3'])); + try { - // Should cause an error - $this->assertSqlResultEquals( - false, - "SELECT bar_column FROM phpbb_config WHERE config_name = 'foo'", - 'Revert did not remove bar_column.' - ); + while (!$this->migrator->finished()) + { + $this->migrator->update(); + } + } + catch (phpbb_db_migration_exception $e) {} + + // Failure should have caused an automatic roll-back, so this should not exist. + $this->assertFalse(isset($this->config['foobar3'])); + + $sql = 'SELECT * FROM phpbb_config'; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (isset($row['test_column'])) + { + $this->fail('Revert did not remove test_column.'); } - catch (Exception $e) {} } } From 63780bda8d6e6e968b934b200853de2776e53596 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 15:14:16 -0600 Subject: [PATCH 049/174] [feature/migrations] Move test.php -> install/database_update_migrations.php This should be used as a basis for the database updater using migrations. PHPBB3-9737 --- phpBB/{test.php => install/database_update_migrations.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename phpBB/{test.php => install/database_update_migrations.php} (99%) diff --git a/phpBB/test.php b/phpBB/install/database_update_migrations.php similarity index 99% rename from phpBB/test.php rename to phpBB/install/database_update_migrations.php index 6602aa8dcc..52682dc489 100644 --- a/phpBB/test.php +++ b/phpBB/install/database_update_migrations.php @@ -17,7 +17,7 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; * @ignore */ define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; +$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require($phpbb_root_path . 'includes/startup.' . $phpEx); From ebfa42455a19376a7996980301a81ad5665a1414 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 15:17:36 -0600 Subject: [PATCH 050/174] [feature/migrations] install/database_update_migrations.php Actually, this does not belong in the main PR, moving to the data PR. PHPBB3-9737 --- phpBB/install/database_update_migrations.php | 139 ------------------- 1 file changed, 139 deletions(-) delete mode 100644 phpBB/install/database_update_migrations.php diff --git a/phpBB/install/database_update_migrations.php b/phpBB/install/database_update_migrations.php deleted file mode 100644 index 52682dc489..0000000000 --- a/phpBB/install/database_update_migrations.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/** -* -* @package phpBB3 -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -$update_start_time = time(); - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); - -require($phpbb_root_path . 'includes/startup.' . $phpEx); - -if (file_exists($phpbb_root_path . 'config.' . $phpEx)) -{ - require($phpbb_root_path . 'config.' . $phpEx); -} - -// Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); - -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); - -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - -// Set PHP error handler to ours -set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); - -// Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); -$phpbb_class_loader->register(); - -// Set up container -$container_extensions = array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), -); -$container_passes = array( - new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), -); -$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); - -// Compile the container -foreach ($container_passes as $pass) -{ - $phpbb_container->addCompilerPass($pass); -} -$phpbb_container->compile(); - -// set up caching -$cache = $phpbb_container->get('cache'); - -// Instantiate some basic classes -$phpbb_dispatcher = $phpbb_container->get('dispatcher'); -$request = $phpbb_container->get('request'); -$user = $phpbb_container->get('user'); -$auth = $phpbb_container->get('auth'); -$db = $phpbb_container->get('dbal.conn'); - -// make sure request_var uses this request instance -request_var('', 0, false, false, $request); // "dependency injection" for a function - -// Grab global variables, re-cache if necessary -$config = $phpbb_container->get('config'); -set_config(null, null, null, $config); -set_config_count(null, null, null, $config); - -// End startup code - -$db_tools = $phpbb_container->get('dbal.tools'); -if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) -{ - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); -} - -$migrator = $phpbb_container->get('migrator'); -$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); - -// What is a safe limit of execution time? Half the max execution time should be safe. -$safe_time_limit = (ini_get('max_execution_time') / 2); - -while (!$migrator->finished()) -{ - try - { - $migrator->update(); - } - catch (phpbb_db_migration_exception $e) - { - echo $e; - - garbage_collection(); - exit_handler(); - } - - echo $migrator->last_run_migration['name'] . '<br />'; - - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $update_start_time) >= $safe_time_limit) - { - //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; - echo 'Update not yet completed.<br />'; - echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; - - garbage_collection(); - exit_handler(); - } -} - -echo 'Finished'; - -garbage_collection(); -exit_handler(); From 71e07ecc471f013aec698654cf5cfa928c8ad0e8 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 19:21:12 -0600 Subject: [PATCH 051/174] [ticket/11320] Include functions file as we need phpbb_convert_30_dbms_to_31 PHPBB3-11320 --- tests/test_framework/phpbb_test_case_helpers.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 47459832d5..20ae384f21 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -77,6 +77,11 @@ class phpbb_test_case_helpers { include($test_config); + if (!function_exists('phpbb_convert_30_dbms_to_31')) + { + require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + } + $config = array_merge($config, array( 'dbms' => phpbb_convert_30_dbms_to_31($dbms), 'dbhost' => $dbhost, From db4fcab3bb4aefcabe93dd4acd1f12e8517cf340 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 22:29:49 -0600 Subject: [PATCH 052/174] [feature/migrations] Make depends_on static to call it without dependencies PHPBB3-11318 --- phpBB/includes/db/migration/migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migration/migration.php b/phpBB/includes/db/migration/migration.php index 61fbf04320..4271751362 100644 --- a/phpBB/includes/db/migration/migration.php +++ b/phpBB/includes/db/migration/migration.php @@ -78,7 +78,7 @@ abstract class phpbb_db_migration * * @return array An array of migration class names */ - public function depends_on() + static public function depends_on() { return array(); } From 9f38dc67a80b5fc2a8bb0d01825d7655915e3319 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 22:48:31 -0600 Subject: [PATCH 053/174] [feature/migrations] Make the test depends_on methods static PHPBB3-11318 --- tests/dbal/migration/dummy.php | 2 +- tests/dbal/migration/fail.php | 5 ----- tests/dbal/migration/if.php | 5 ----- tests/dbal/migration/recall.php | 5 ----- tests/dbal/migration/revert.php | 5 ----- tests/dbal/migration/revert_with_dependency.php | 2 +- tests/dbal/migration/unfulfillable.php | 2 +- 7 files changed, 3 insertions(+), 23 deletions(-) diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php index e542493f9f..0ac6e733a1 100644 --- a/tests/dbal/migration/dummy.php +++ b/tests/dbal/migration/dummy.php @@ -9,7 +9,7 @@ class phpbb_dbal_migration_dummy extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('installed_migration'); } diff --git a/tests/dbal/migration/fail.php b/tests/dbal/migration/fail.php index 8b5c521e09..f88d8169f5 100644 --- a/tests/dbal/migration/fail.php +++ b/tests/dbal/migration/fail.php @@ -9,11 +9,6 @@ class phpbb_dbal_migration_fail extends phpbb_db_migration { - function depends_on() - { - return array(); - } - function update_schema() { return array( diff --git a/tests/dbal/migration/if.php b/tests/dbal/migration/if.php index aa9a5dab87..83fe21bd21 100644 --- a/tests/dbal/migration/if.php +++ b/tests/dbal/migration/if.php @@ -9,11 +9,6 @@ class phpbb_dbal_migration_if extends phpbb_db_migration { - function depends_on() - { - return array(); - } - function update_schema() { return array(); diff --git a/tests/dbal/migration/recall.php b/tests/dbal/migration/recall.php index 18d8b4a6d2..6c2f04bf08 100644 --- a/tests/dbal/migration/recall.php +++ b/tests/dbal/migration/recall.php @@ -9,11 +9,6 @@ class phpbb_dbal_migration_recall extends phpbb_db_migration { - function depends_on() - { - return array(); - } - function update_schema() { return array(); diff --git a/tests/dbal/migration/revert.php b/tests/dbal/migration/revert.php index 2bb23e31c2..ac01987cd4 100644 --- a/tests/dbal/migration/revert.php +++ b/tests/dbal/migration/revert.php @@ -9,11 +9,6 @@ class phpbb_dbal_migration_revert extends phpbb_db_migration { - function depends_on() - { - return array(); - } - function update_schema() { return array( diff --git a/tests/dbal/migration/revert_with_dependency.php b/tests/dbal/migration/revert_with_dependency.php index f6820dbf3f..ca2c070e8c 100644 --- a/tests/dbal/migration/revert_with_dependency.php +++ b/tests/dbal/migration/revert_with_dependency.php @@ -9,7 +9,7 @@ class phpbb_dbal_migration_revert_with_dependency extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_dbal_migration_revert'); } diff --git a/tests/dbal/migration/unfulfillable.php b/tests/dbal/migration/unfulfillable.php index 84136ffe6d..6d375e6880 100644 --- a/tests/dbal/migration/unfulfillable.php +++ b/tests/dbal/migration/unfulfillable.php @@ -9,7 +9,7 @@ class phpbb_dbal_migration_unfulfillable extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('installed_migration', 'phpbb_dbal_migration_dummy', 'non_existant_migration'); } From 032f172a073b028f5d1585f997859f7a07c00c98 Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Fri, 11 Jan 2013 14:27:05 +0100 Subject: [PATCH 054/174] [ticket/11321] Recreate schema files with develop/create_schema_files.php PHPBB3-11321 --- phpBB/install/schemas/firebird_schema.sql | 4 ++-- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 767ce68b4a..ef57df29a0 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -912,8 +912,8 @@ CREATE TABLE phpbb_reports ( report_time INTEGER DEFAULT 0 NOT NULL, report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - reported_post_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL + reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + reported_post_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL );; ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 84c975942f..a37fd2b14e 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1111,8 +1111,8 @@ CREATE TABLE [phpbb_reports] ( [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , [reported_post_text] [text] DEFAULT ('') NOT NULL , - [reported_post_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL + [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [reported_post_bitfield] [varchar] (255) DEFAULT ('') NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8aab949103..517e51d3c5 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -649,8 +649,8 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumblob NOT NULL, reported_post_text mediumblob NOT NULL, - reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, reported_post_uid varbinary(8) DEFAULT '' NOT NULL, + reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 04aef2844a..f05322b28f 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -649,8 +649,8 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumtext NOT NULL, reported_post_text mediumtext NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 91f906bc8b..993df9e82a 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1216,8 +1216,8 @@ CREATE TABLE phpbb_reports ( report_time number(11) DEFAULT '0' NOT NULL, report_text clob DEFAULT '' , reported_post_text clob DEFAULT '' , - reported_post_bitfield varchar2(255) DEFAULT '' , reported_post_uid varchar2(8) DEFAULT '' , + reported_post_bitfield varchar2(255) DEFAULT '' , CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 619985e0d6..2acdeb7f45 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -855,8 +855,8 @@ CREATE TABLE phpbb_reports ( report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), report_text TEXT DEFAULT '' NOT NULL, reported_post_text TEXT DEFAULT '' NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (report_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 1690a7dcab..775f67c5c3 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -630,8 +630,8 @@ CREATE TABLE phpbb_reports ( report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', report_text mediumtext(16777215) NOT NULL DEFAULT '', reported_post_text mediumtext(16777215) NOT NULL DEFAULT '', - reported_post_bitfield varchar(255) NOT NULL DEFAULT '', - reported_post_uid varchar(8) NOT NULL DEFAULT '' + reported_post_uid varchar(8) NOT NULL DEFAULT '', + reported_post_bitfield varchar(255) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); From 9affd6f7e7b95442f1ef14894858d8213f3fbd2a Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Fri, 11 Jan 2013 00:41:03 +0100 Subject: [PATCH 055/174] [ticket/11201] Remove MSN/WLM fields WLM will be shutdown in March 2013. Skype is the new replacement. But as Skype uses a different login ID and service, the values in this field are useless. So we can safely remove the field and the links/functions we create. PHPBB3-11201 --- phpBB/adm/style/acp_users_profile.html | 4 - phpBB/develop/benchmark.php | 5 +- phpBB/develop/create_schema_files.php | 1 - phpBB/develop/mysql_upgrader.php | 1 - phpBB/includes/acp/acp_users.php | 4 - phpBB/includes/ucp/ucp_pm_viewmessage.php | 1 - phpBB/includes/ucp/ucp_profile.php | 4 - phpBB/install/convertors/convert_phpbb20.php | 1 - phpBB/install/schemas/firebird_schema.sql | 1 - phpBB/install/schemas/mssql_schema.sql | 1 - phpBB/install/schemas/mysql_40_schema.sql | 1 - phpBB/install/schemas/mysql_41_schema.sql | 1 - phpBB/install/schemas/oracle_schema.sql | 1 - phpBB/install/schemas/postgres_schema.sql | 1 - phpBB/install/schemas/schema_data.sql | 4 +- phpBB/install/schemas/sqlite_schema.sql | 1 - phpBB/language/en/acp/styles.php | 1 - phpBB/language/en/common.php | 3 - phpBB/language/en/memberlist.php | 4 - phpBB/language/en/ucp.php | 1 - phpBB/memberlist.php | 22 +---- .../prosilver/template/memberlist_im.html | 82 +----------------- .../prosilver/template/memberlist_search.html | 4 - .../prosilver/template/memberlist_view.html | 1 - .../template/ucp_pm_viewmessage.html | 3 +- .../template/ucp_profile_profile_info.html | 4 - .../prosilver/template/viewtopic_body.html | 3 +- phpBB/styles/prosilver/theme/bidi.css | 2 +- phpBB/styles/prosilver/theme/buttons.css | 2 - phpBB/styles/prosilver/theme/colours.css | 1 - phpBB/styles/prosilver/theme/imageset.css | 5 -- .../subsilver2/template/memberlist_im.html | 83 +------------------ .../template/memberlist_search.html | 8 +- .../subsilver2/template/memberlist_view.html | 4 - .../template/ucp_profile_profile_info.html | 4 - .../styles/subsilver2/theme/en/stylesheet.css | 5 -- phpBB/styles/subsilver2/theme/stylesheet.css | 5 -- phpBB/viewtopic.php | 4 - 38 files changed, 16 insertions(+), 267 deletions(-) diff --git a/phpBB/adm/style/acp_users_profile.html b/phpBB/adm/style/acp_users_profile.html index 3232e8d1f5..36e9f340d4 100644 --- a/phpBB/adm/style/acp_users_profile.html +++ b/phpBB/adm/style/acp_users_profile.html @@ -10,10 +10,6 @@ <dt><label for="aim">{L_UCP_AIM}{L_COLON}</label></dt> <dd><input type="text" id="aim" name="aim" value="{AIM}" /></dd> </dl> - <dl> - <dt><label for="msn">{L_UCP_MSNM}{L_COLON}</label></dt> - <dd><input type="text" id="msn" name="msn" value="{MSN}" /></dd> - </dl> <dl> <dt><label for="yim">{L_UCP_YIM}{L_COLON}</label></dt> <dd><input type="text" id="yim" name="yim" value="{YIM}" /></dd> diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php index c867b9262e..6517954dfe 100644 --- a/phpBB/develop/benchmark.php +++ b/phpBB/develop/benchmark.php @@ -377,7 +377,6 @@ function make_user($username) $viewemail = 0; $aim = 0; $yim = 0; - $msn = 0; $attachsig = 1; $allowsmilies = 1; $allowhtml = 1; @@ -422,8 +421,8 @@ function make_user($username) } - $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) - VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; + $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) + VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; $sql .= "1, '')"; diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3d3e478032..38d7a2df33 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1833,7 +1833,6 @@ function get_schema_struct() 'user_icq' => array('VCHAR:15', ''), 'user_aim' => array('VCHAR_UNI', ''), 'user_yim' => array('VCHAR_UNI', ''), - 'user_msnm' => array('VCHAR_UNI', ''), 'user_jabber' => array('VCHAR_UNI', ''), 'user_website' => array('VCHAR_UNI:200', ''), 'user_occ' => array('TEXT_UNI', ''), diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index 7f82ebfeab..ca738aabf6 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -1265,7 +1265,6 @@ function get_schema_struct() 'user_icq' => array('VCHAR:15', ''), 'user_aim' => array('VCHAR_UNI', ''), 'user_yim' => array('VCHAR_UNI', ''), - 'user_msnm' => array('VCHAR_UNI', ''), 'user_jabber' => array('VCHAR_UNI', ''), 'user_website' => array('VCHAR_UNI:200', ''), 'user_occ' => array('TEXT_UNI', ''), diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 82d8ef5cbb..2bdbf1441a 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1352,7 +1352,6 @@ class acp_users $data = array( 'icq' => request_var('icq', $user_row['user_icq']), 'aim' => request_var('aim', $user_row['user_aim']), - 'msn' => request_var('msn', $user_row['user_msnm']), 'yim' => request_var('yim', $user_row['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), 'website' => request_var('website', $user_row['user_website']), @@ -1382,7 +1381,6 @@ class acp_users array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), - 'msn' => array('string', true, 5, 255), 'jabber' => array( array('string', true, 5, 255), array('jabber')), @@ -1416,7 +1414,6 @@ class acp_users $sql_ary = array( 'user_icq' => $data['icq'], 'user_aim' => $data['aim'], - 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], @@ -1469,7 +1466,6 @@ class acp_users 'ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], - 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index c85b05f144..a1001cfa74 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -241,7 +241,6 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/' . urlencode($user_info['user_icq']) . '/' : '', 'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $author_id) : '', 'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '', - 'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $author_id) : '', 'U_JABBER' => ($user_info['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $author_id) : '', 'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '', diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index e7cea06a45..c1ad9955b6 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -266,7 +266,6 @@ class ucp_profile $data = array( 'icq' => request_var('icq', $user->data['user_icq']), 'aim' => request_var('aim', $user->data['user_aim']), - 'msn' => request_var('msn', $user->data['user_msnm']), 'yim' => request_var('yim', $user->data['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)), 'website' => request_var('website', $user->data['user_website']), @@ -299,7 +298,6 @@ class ucp_profile array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), - 'msn' => array('string', true, 5, 255), 'jabber' => array( array('string', true, 5, 255), array('jabber')), @@ -351,7 +349,6 @@ class ucp_profile $sql_ary = array( 'user_icq' => $data['icq'], 'user_aim' => $data['aim'], - 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], @@ -423,7 +420,6 @@ class ucp_profile 'ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], - 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index 5f30625980..6792f4ff9c 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -896,7 +896,6 @@ if (!$get_info) array('user_occ', 'users.user_occ', array('function1' => 'phpbb_set_encoding')), array('user_website', 'users.user_website', 'validate_website'), array('user_jabber', '', ''), - array('user_msnm', 'users.user_msnm', array('function1' => 'phpbb_set_encoding')), array('user_yim', 'users.user_yim', array('function1' => 'phpbb_set_encoding')), array('user_aim', 'users.user_aim', array('function1' => 'phpbb_set_encoding')), array('user_icq', 'users.user_icq', array('function1' => 'phpbb_set_encoding')), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index ef57df29a0..9016d8b318 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -1281,7 +1281,6 @@ CREATE TABLE phpbb_users ( user_icq VARCHAR(15) CHARACTER SET NONE DEFAULT '' NOT NULL, user_aim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_yim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index a37fd2b14e..81bd0cbb0f 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1565,7 +1565,6 @@ CREATE TABLE [phpbb_users] ( [user_icq] [varchar] (15) DEFAULT ('') NOT NULL , [user_aim] [varchar] (255) DEFAULT ('') NOT NULL , [user_yim] [varchar] (255) DEFAULT ('') NOT NULL , - [user_msnm] [varchar] (255) DEFAULT ('') NOT NULL , [user_jabber] [varchar] (255) DEFAULT ('') NOT NULL , [user_website] [varchar] (200) DEFAULT ('') NOT NULL , [user_occ] [varchar] (4000) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 517e51d3c5..0797b6ac6b 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -929,7 +929,6 @@ CREATE TABLE phpbb_users ( user_icq varbinary(15) DEFAULT '' NOT NULL, user_aim blob NOT NULL, user_yim blob NOT NULL, - user_msnm blob NOT NULL, user_jabber blob NOT NULL, user_website blob NOT NULL, user_occ blob NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index f05322b28f..414f9f0f2a 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -929,7 +929,6 @@ CREATE TABLE phpbb_users ( user_icq varchar(15) DEFAULT '' NOT NULL, user_aim varchar(255) DEFAULT '' NOT NULL, user_yim varchar(255) DEFAULT '' NOT NULL, - user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, user_occ text NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 993df9e82a..03c9f9fd4c 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1677,7 +1677,6 @@ CREATE TABLE phpbb_users ( user_icq varchar2(15) DEFAULT '' , user_aim varchar2(765) DEFAULT '' , user_yim varchar2(765) DEFAULT '' , - user_msnm varchar2(765) DEFAULT '' , user_jabber varchar2(765) DEFAULT '' , user_website varchar2(600) DEFAULT '' , user_occ clob DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 2acdeb7f45..a6c989fe62 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -1179,7 +1179,6 @@ CREATE TABLE phpbb_users ( user_icq varchar(15) DEFAULT '' NOT NULL, user_aim varchar(255) DEFAULT '' NOT NULL, user_yim varchar(255) DEFAULT '' NOT NULL, - user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, user_occ varchar(4000) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 7c1a7d40f5..19c00ef9fb 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -454,10 +454,10 @@ INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); # -- Users / Anonymous user -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); # -- username: Admin password: admin (change this or remove it once everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- Groups INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, 0, '', '', '', 5); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 775f67c5c3..feec31d727 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -903,7 +903,6 @@ CREATE TABLE phpbb_users ( user_icq varchar(15) NOT NULL DEFAULT '', user_aim varchar(255) NOT NULL DEFAULT '', user_yim varchar(255) NOT NULL DEFAULT '', - user_msnm varchar(255) NOT NULL DEFAULT '', user_jabber varchar(255) NOT NULL DEFAULT '', user_website varchar(200) NOT NULL DEFAULT '', user_occ text(65535) NOT NULL DEFAULT '', diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index e7954ff148..3cb2e741ca 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -186,7 +186,6 @@ $lang = array_merge($lang, array( 'IMG_ICON_CONTACT_EMAIL' => 'Send email', 'IMG_ICON_CONTACT_ICQ' => 'ICQ', 'IMG_ICON_CONTACT_JABBER' => 'Jabber', - 'IMG_ICON_CONTACT_MSNM' => 'WLM', 'IMG_ICON_CONTACT_PM' => 'Send message', 'IMG_ICON_CONTACT_YAHOO' => 'YIM', 'IMG_ICON_CONTACT_WWW' => 'Website', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 6277457af7..6cad4136a2 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -368,7 +368,6 @@ $lang = array_merge($lang, array( 'MODERATORS' => 'Moderators', 'MONTH' => 'Month', 'MOVE' => 'Move', - 'MSNM' => 'WLM', 'NA' => 'N/A', 'NEWEST_USER' => 'Our newest member <strong>%s</strong>', @@ -627,7 +626,6 @@ $lang = array_merge($lang, array( 'TOO_LONG_INTERESTS' => 'The interests you entered is too long.', 'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.', 'TOO_LONG_LOCATION' => 'The location you entered is too long.', - 'TOO_LONG_MSN' => 'The WLM name you entered is too long.', 'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.', 'TOO_LONG_OCCUPATION' => 'The occupation you entered is too long.', 'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.', @@ -648,7 +646,6 @@ $lang = array_merge($lang, array( 'TOO_SHORT_INTERESTS' => 'The interests you entered is too short.', 'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.', 'TOO_SHORT_LOCATION' => 'The location you entered is too short.', - 'TOO_SHORT_MSN' => 'The WLM name you entered is too short.', 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_OCCUPATION' => 'The occupation you entered is too short.', 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index ec21e8e904..bc5a0c100b 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -78,9 +78,6 @@ $lang = array_merge($lang, array( 'IM_JABBER' => 'Please note that users may have selected to not receive unsolicited instant messages.', 'IM_JABBER_SUBJECT' => 'This is an automated message please do not reply! Message from user %1$s at %2$s.', 'IM_MESSAGE' => 'Your message', - 'IM_MSNM' => 'Please note that you need Windows Live Messenger installed to use this.', - 'IM_MSNM_BROWSER' => 'Your browser does not support this.', - 'IM_MSNM_CONNECT' => 'WLM is not connected.\nYou have to connect to WLM to continue.', 'IM_NAME' => 'Your Name', 'IM_NO_DATA' => 'There is no suitable contact information for this user.', 'IM_NO_JABBER' => 'Sorry, direct messaging of Jabber users is not supported on this board. You will need a Jabber client installed on your system to contact the recipient above.', @@ -123,7 +120,6 @@ $lang = array_merge($lang, array( 'SEND_IM' => 'Instant messaging', 'SEND_JABBER_MESSAGE' => 'Send Jabber message', 'SEND_MESSAGE' => 'Message', - 'SEND_MSNM_MESSAGE' => 'Send WLM message', 'SEND_YIM_MESSAGE' => 'Send YIM message', 'SORT_EMAIL' => 'Email', 'SORT_LAST_ACTIVE' => 'Last active', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 267ae00710..2eb34b3713 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -455,7 +455,6 @@ $lang = array_merge($lang, array( 'UCP_MAIN_FRONT' => 'Front page', 'UCP_MAIN_SUBSCRIBED' => 'Manage subscriptions', - 'UCP_MSNM' => 'Windows Live Messenger', 'UCP_NO_ATTACHMENTS' => 'You have posted no files.', 'UCP_PREFS' => 'Board preferences', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 79be9ca432..091379061c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -287,13 +287,6 @@ switch ($mode) $s_action = ''; break; - case 'msnm': - $lang = 'MSNM'; - $sql_field = 'user_msnm'; - $s_select = 'S_SEND_MSNM'; - $s_action = ''; - break; - case 'jabber': $lang = 'JABBER'; $sql_field = 'user_jabber'; @@ -640,7 +633,6 @@ switch ($mode) 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), - 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), @@ -984,8 +976,8 @@ switch ($mode) $template_html = 'memberlist_body.html'; // Sorting - $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']); - $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber'); + $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']); + $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'j' => 'u.user_yim', 'k' => 'u.user_jabber'); if ($auth->acl_get('a_user')) { @@ -1028,7 +1020,7 @@ switch ($mode) $select_single = request_var('select_single', false); // Search URL parameters, if any of these are in the URL we do a search - $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'msn', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); + $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); // We validate form and field here, only id/class allowed $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; @@ -1040,7 +1032,6 @@ switch ($mode) $icq = request_var('icq', ''); $aim = request_var('aim', ''); $yahoo = request_var('yahoo', ''); - $msn = request_var('msn', ''); $jabber = request_var('jabber', ''); $search_group_id = request_var('search_group_id', 0); @@ -1084,7 +1075,6 @@ switch ($mode) $sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : ''; $sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : ''; $sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : ''; - $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : ''; $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; @@ -1317,7 +1307,6 @@ switch ($mode) 'icq' => array('icq', ''), 'aim' => array('aim', ''), 'yahoo' => array('yahoo', ''), - 'msn' => array('msn', ''), 'jabber' => array('jabber', ''), 'search_group_id' => array('search_group_id', 0), 'joined_select' => array('joined_select', 'lt'), @@ -1449,7 +1438,6 @@ switch ($mode) 'ICQ' => $icq, 'AIM' => $aim, 'YAHOO' => $yahoo, - 'MSNM' => $msn, 'JABBER' => $jabber, 'JOINED' => implode('-', $joined), 'ACTIVE' => implode('-', $active), @@ -1605,7 +1593,6 @@ switch ($mode) 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), - 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), @@ -1621,7 +1608,6 @@ switch ($mode) 'U_SORT_LOCATION' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_ICQ' => $sort_url . '&sk=g&sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_AIM' => $sort_url . '&sk=h&sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_MSN' => $sort_url . '&sk=i&sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_YIM' => $sort_url . '&sk=j&sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&sk=l&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '', 'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'), @@ -1748,14 +1734,12 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '', 'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '', 'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&.src=pg' : '', - 'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '', 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', 'LOCATION' => ($data['user_from']) ? $data['user_from'] : '', 'USER_ICQ' => $data['user_icq'], 'USER_AIM' => $data['user_aim'], 'USER_YIM' => $data['user_yim'], - 'USER_MSN' => $data['user_msnm'], 'USER_JABBER' => $data['user_jabber'], 'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index 68aed0b3dd..61b4a1469b 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -1,6 +1,5 @@ <!-- INCLUDE simple_header.html --> -<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger --> <h2 class="solo">{L_SEND_IM}</h2> <form method="post" action="{S_IM_ACTION}"> @@ -13,7 +12,7 @@ <fieldset> <dl class="fields2"> <dt><label>{L_IM_RECIPIENT}{L_COLON}</label></dt> - <dd><strong>{USERNAME}</strong><!-- IF S_SEND_ICQ or S_SEND_AIM or S_SEND_MSNM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --><!-- IF PRESENCE_IMG --> {PRESENCE_IMG}<!-- ENDIF --></dd> + <dd><strong>{USERNAME}</strong><!-- IF S_SEND_ICQ or S_SEND_AIM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --><!-- IF PRESENCE_IMG --> {PRESENCE_IMG}<!-- ENDIF --></dd> </dl> <!-- IF S_SEND_ICQ --> @@ -43,15 +42,6 @@ </dl> <!-- ENDIF --> - <!-- IF S_SEND_MSNM --> - <dl class="fields2"> - <dt> </dt> - <dd><object classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" id="objMessengerApp" width="0" height="0"></object></dd> - <dd><a href="#" onclick="add_contact('{A_IM_CONTACT}'); return false;">{L_IM_ADD_CONTACT}</a></dd> - <dd><a href="#" onclick="im_contact('{A_IM_CONTACT}'); return false;">{L_IM_SEND_MESSAGE}</a></dd> - </dl> - <!-- ENDIF --> - <!-- IF S_SEND_JABBER --> <dl class="fields2"> <dt><label for="message">{L_IM_MESSAGE}{L_COLON}</label></dt> @@ -85,74 +75,4 @@ <a href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a> -<script type="text/javascript"> -// <![CDATA[ - - /** The following will not work with Windows Vista **/ - - var app = document.getElementById('objMessengerApp'); - - /** - * Check whether the browser supports this and whether MSNM is connected - */ - function msn_supported() - { - // Does the browser support the MSNM object? - if (app.MyStatus) - { - // Is MSNM connected? - if (app.MyStatus == 1) - { - alert('{LA_IM_MSNM_CONNECT}'); - return false; - } - } - else - { - alert('{LA_IM_MSNM_BROWSER}'); - return false; - } - return true; - } - - /** - * Add to your contact list - */ - function add_contact(address) - { - if (msn_supported()) - { - // Could return an error while MSNM is connecting, don't want that - try - { - app.AddContact(0, address); - } - catch (e) - { - return; - } - } -} - -/** -* Write IM to contact -*/ -function im_contact(address) -{ - if (msn_supported()) - { - // Could return an error while MSNM is connecting, don't want that - try - { - app.InstantMessage(address); - } - catch (e) - { - return; - } - } -} -// ]]> -</script> - <!-- INCLUDE simple_footer.html --> diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 6fed528cea..1ef8710817 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -71,10 +71,6 @@ function insert_single(user) <dt><label for="yahoo">{L_YIM}{L_COLON}</label></dt> <dd><input type="text" name="yahoo" id="yahoo" value="{YAHOO}" class="inputbox" /></dd> </dl> - <dl> - <dt><label for="msn">{L_MSNM}{L_COLON}</label></dt> - <dd><input type="text" name="msn" id="msn" value="{MSNM}" class="inputbox" /></dd> - </dl> </fieldset> <fieldset class="fields1 column2"> diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 57cfcb86d9..7f33e70e8f 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -62,7 +62,6 @@ <!-- IF U_EMAIL --><dt>{L_EMAIL_ADDRESS}{L_COLON}</dt> <dd><a href="{U_EMAIL}">{L_SEND_EMAIL_USER} {USERNAME}</a></dd><!-- ENDIF --> <!-- IF U_WWW --><dt>{L_WEBSITE}{L_COLON}</dt> <dd><a href="{U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {U_WWW}">{U_WWW}</a></dd><!-- ENDIF --> <!-- IF U_PM --><dt>{L_PM}{L_COLON}</dt> <dd><a href="{U_PM}">{L_SEND_PRIVATE_MESSAGE}</a></dd><!-- ENDIF --> - <!-- IF U_MSN or USER_MSN --><dt>{L_MSNM}{L_COLON}</dt> <dd><!-- IF U_MSN --><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_MSNM_MESSAGE}</a><!-- ELSE -->{USER_MSN}<!-- ENDIF --></dd><!-- ENDIF --> <!-- IF U_YIM or USER_YIM --><dt>{L_YIM}{L_COLON}</dt> <dd><!-- IF U_YIM --><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false;">{L_SEND_YIM_MESSAGE}</a><!-- ELSE -->{USER_YIM}<!-- ENDIF --></dd><!-- ENDIF --> <!-- IF U_AIM or USER_AIM --><dt>{L_AIM}{L_COLON}</dt> <dd><!-- IF U_AIM --><a href="{U_AIM}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_AIM_MESSAGE}</a><!-- ELSE -->{USER_AIM}<!-- ENDIF --></dd><!-- ENDIF --> <!-- IF U_ICQ or USER_ICQ --><dt>{L_ICQ}{L_COLON}</dt> <dd><!-- IF U_ICQ --><a href="{U_ICQ}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_ICQ_MESSAGE}</a><!-- ELSE -->{USER_ICQ}<!-- ENDIF --></dd><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 22149c8b80..23665aa252 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -90,13 +90,12 @@ <!-- END custom_fields --> - <!-- IF U_PM or U_EMAIL or U_WWW or U_MSN or U_ICQ or U_YIM or U_AIM or U_JABBER --> + <!-- IF U_PM or U_EMAIL or U_WWW or U_ICQ or U_YIM or U_AIM or U_JABBER --> <dd> <ul class="profile-icons"> <!-- IF U_PM --><li class="pm-icon"><a href="{U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF --> <!-- IF U_EMAIL --><li class="email-icon"><a href="{U_EMAIL}" title="{L_SEND_EMAIL_USER} {MESSAGE_AUTHOR}"><span>{L_SEND_EMAIL_USER} {MESSAGE_AUTHOR}</span></a></li><!-- ENDIF --> <!-- IF U_WWW --><li class="web-icon"><a href="{U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF --> - <!-- IF U_MSN --><li class="msnm-icon"><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF --> <!-- IF U_ICQ --><li class="icq-icon"><a href="{U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF --> <!-- IF U_YIM --><li class="yahoo-icon"><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF --> <!-- IF U_AIM --><li class="aim-icon"><a href="{U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html index 03d89e8590..e8c6715de8 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html +++ b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html @@ -18,10 +18,6 @@ <dt><label for="aim">{L_UCP_AIM}{L_COLON}</label></dt> <dd><input type="text" name="aim" id="aim" maxlength="255" value="{AIM}" class="inputbox" /></dd> </dl> - <dl> - <dt><label for="msn">{L_UCP_MSNM}{L_COLON}</label></dt> - <dd><input type="text" name="msn" id="msn" maxlength="255" value="{MSN}" class="inputbox" /></dd> - </dl> <dl> <dt><label for="yim">{L_UCP_YIM}{L_COLON}</label></dt> <dd><input type="text" name="yim" id="yim" maxlength="255" value="{YIM}" class="inputbox" /></dd> diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 7688898f5c..9910be34b0 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -216,13 +216,12 @@ <!-- END custom_fields --> <!-- IF not S_IS_BOT --> - <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER --> + <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER --> <dd> <ul class="profile-icons"> <!-- IF postrow.U_PM --><li class="pm-icon"><a href="{postrow.U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_EMAIL --><li class="email-icon"><a href="{postrow.U_EMAIL}" title="{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}"><span>{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_WWW --><li class="web-icon"><a href="{postrow.U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {postrow.U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF --> - <!-- IF postrow.U_MSN --><li class="msnm-icon"><a href="{postrow.U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_ICQ --><li class="icq-icon"><a href="{postrow.U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_YIM --><li class="yahoo-icon"><a href="{postrow.U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_AIM --><li class="aim-icon"><a href="{postrow.U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index 5cff0a811b..a43323d879 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -786,7 +786,7 @@ padding-right: 11px; padding-left: 0; } -.rtl .imageset.icon_contact_aim, .rtl .imageset.icon_contact_email, .rtl .imageset.icon_contact_icq, .rtl .imageset.icon_contact_jabber, .rtl .imageset.icon_contact_msnm, .rtl .imageset.icon_contact_www, .rtl .imageset.icon_contact_yahoo, .rtl .imageset.icon_post_delete, .rtl .imageset.icon_post_info, .rtl .imageset.icon_post_report, .rtl .imageset.icon_user_warn { +.rtl .imageset.icon_contact_aim, .rtl .imageset.icon_contact_email, .rtl .imageset.icon_contact_icq, .rtl .imageset.icon_contact_jabber, .rtl .imageset.icon_contact_www, .rtl .imageset.icon_contact_yahoo, .rtl .imageset.icon_post_delete, .rtl .imageset.icon_post_info, .rtl .imageset.icon_post_report, .rtl .imageset.icon_user_warn { padding-right: 20px; padding-left: 0; } diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index e817380f8e..f74e82a123 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -122,7 +122,6 @@ ul.profile-icons li a:hover { background: none; } .aim-icon, .aim-icon a { background: none top left no-repeat; } .yahoo-icon, .yahoo-icon a { background: none top left no-repeat; } .web-icon, .web-icon a { background: none top left no-repeat; } -.msnm-icon, .msnm-icon a { background: none top left no-repeat; } .icq-icon, .icq-icon a { background: none top left no-repeat; } .jabber-icon, .jabber-icon a { background: none top left no-repeat; } .pm-icon, .pm-icon a { background: none top left no-repeat; } @@ -140,7 +139,6 @@ ul.profile-icons li.email-icon { width: 20px; height: 20px; } ul.profile-icons li.aim-icon { width: 20px; height: 20px; } ul.profile-icons li.yahoo-icon { width: 20px; height: 20px; } ul.profile-icons li.web-icon { width: 20px; height: 20px; } -ul.profile-icons li.msnm-icon { width: 20px; height: 20px; } ul.profile-icons li.icq-icon { width: 20px; height: 20px; } ul.profile-icons li.jabber-icon { width: 20px; height: 20px; } ul.profile-icons li.pm-icon { width: 28px; height: 20px; } diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index a5a18dc6a1..199d7b3059 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -686,7 +686,6 @@ a.sendemail { .aim-icon, .aim-icon a { background-image: url("./images/icon_contact_aim.gif"); } .yahoo-icon, .yahoo-icon a { background-image: url("./images/icon_contact_yahoo.gif"); } .web-icon, .web-icon a { background-image: url("./images/icon_contact_www.gif"); } -.msnm-icon, .msnm-icon a { background-image: url("./images/icon_contact_msnm.gif"); } .icq-icon, .icq-icon a { background-image: url("./images/icon_contact_icq.gif"); } .jabber-icon, .jabber-icon a { background-image: url("./images/icon_contact_jabber.gif"); } .pm-icon, .pm-icon a { background-image: url("./en/icon_contact_pm.gif"); } diff --git a/phpBB/styles/prosilver/theme/imageset.css b/phpBB/styles/prosilver/theme/imageset.css index cb99e9e715..a85e320f98 100644 --- a/phpBB/styles/prosilver/theme/imageset.css +++ b/phpBB/styles/prosilver/theme/imageset.css @@ -280,11 +280,6 @@ span.imageset { padding-left: 20px; padding-top: 20px; } -.imageset.icon_contact_msnm { - background-image: url("./images/icon_contact_msnm.gif"); - padding-left: 20px; - padding-top: 20px; -} .imageset.icon_contact_www { background-image: url("./images/icon_contact_www.gif"); padding-left: 20px; diff --git a/phpBB/styles/subsilver2/template/memberlist_im.html b/phpBB/styles/subsilver2/template/memberlist_im.html index da1ad661c3..e91a1caf11 100644 --- a/phpBB/styles/subsilver2/template/memberlist_im.html +++ b/phpBB/styles/subsilver2/template/memberlist_im.html @@ -2,8 +2,6 @@ <br clear="all" /> -<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger --> - <form method="post" action="{S_IM_ACTION}"> <table class="tablebg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> @@ -14,7 +12,7 @@ </tr> <tr> <td class="row1"><b class="genmed">{L_IM_RECIPIENT}{L_COLON} </b></td> - <td class="row2"><span class="gen"><b>{USERNAME}</b><!-- IF S_SEND_ICQ or S_SEND_AIM or S_SEND_MSNM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --></span> <!-- IF PRESENCE_IMG -->{PRESENCE_IMG}<!-- ENDIF --></td> + <td class="row2"><span class="gen"><b>{USERNAME}</b><!-- IF S_SEND_ICQ or S_SEND_AIM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --></span> <!-- IF PRESENCE_IMG -->{PRESENCE_IMG}<!-- ENDIF --></td> </tr> <!-- IF S_SEND_AIM --> @@ -26,85 +24,6 @@ </tr> <!-- ENDIF --> - <!-- IF S_SEND_MSNM --> - <tr> - <td class="row1" colspan="2" align="center"> - <object classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" id="objMessengerApp" width="0" height="0"></object> - <script type="text/javascript"> - // <![CDATA[ - var app = document.getElementById('objMessengerApp'); - - /** - * Check whether the browser supports this and whether MSNM is connected - */ - function msn_supported() - { - // Does the browser support the MSNM object? - if (app.MyStatus) - { - // Is MSNM connected? - if (app.MyStatus == 1) - { - alert('{LA_IM_MSNM_CONNECT}'); - return false; - } - } - else - { - alert('{LA_IM_MSNM_BROWSER}'); - return false; - } - return true; - } - - /** - * Add to your contact list - */ - function add_contact(address) - { - if (msn_supported()) - { - // Could return an error while MSNM is connecting, don't want that - try - { - app.AddContact(0, address); - } - catch (e) - { - return; - } - } - } - - /** - * Write IM to contact - */ - function im_contact(address) - { - if (msn_supported()) - { - // Could return an error while MSNM is connecting, don't want that - try - { - app.InstantMessage(address); - } - catch (e) - { - return; - } - } - } - // ]]> - </script> - - <a class="gen" href="#" onclick="add_contact('{A_IM_CONTACT}'); return false;">{L_IM_ADD_CONTACT}</a><br /><a class="gen" href="#" onclick="im_contact('{A_IM_CONTACT}'); return false;">{L_IM_SEND_MESSAGE}</a> - </td> - </tr> - <tr> - <td class="cat" colspan="2" align="center"> </td> - </tr> - <!-- ENDIF --> - <!-- IF S_SEND_JABBER --> <tr> <td class="row1"><b class="genmed">{L_IM_MESSAGE}{L_COLON} </b></td> diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index c0434d8110..fb76cacc79 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -102,14 +102,14 @@ <!-- ELSE --> <td colspan="2" class="row1"> </td> <!-- ENDIF --> - <td class="row1"><b class="genmed">{L_MSNM}{L_COLON}</b></td> - <td class="row2"><input class="post" type="text" name="msn" value="{MSNM}" /></td> + <td class="row1"><b class="genmed">{L_JABBER}{L_COLON}</b></td> + <td class="row2"><input class="post" type="text" name="jabber" value="{JABBER}" /></td> </tr> <tr> <td class="row1"><b class="genmed">{L_POSTS}{L_COLON}</b></td> <td class="row2"><select name="count_select">{S_COUNT_OPTIONS}</select> <input class="post" type="text" name="count" value="{COUNT}" /></td> - <td class="row1"><b class="genmed">{L_JABBER}{L_COLON}</b></td> - <td class="row2"><input class="post" type="text" name="jabber" value="{JABBER}" /></td> + <td class="row1"> </td> + <td class="row2"> </td> </tr> <tr> <td class="row1"><b class="genmed">{L_SORT_BY}{L_COLON}</b></td> diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index 464369a7a8..ff22dcc0f7 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -116,10 +116,6 @@ <td><a href="{U_PM}" class="imageset">{PM_IMG}</a></td> </tr> <!-- ENDIF --> - <tr> - <td class="gen" nowrap="nowrap" align="{S_CONTENT_FLOW_END}">{L_MSNM}{L_COLON} </td> - <td><!-- IF U_MSN --><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false" class="imageset">{MSN_IMG}</a><!-- ELSEIF USER_MSN -->{USER_MSN}<!-- ENDIF --></td> - </tr> <tr> <td class="gen" nowrap="nowrap" align="{S_CONTENT_FLOW_END}">{L_YIM}{L_COLON} </td> <td><!-- IF U_YIM --><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false" class="imageset">{YIM_IMG}</a><!-- ELSEIF USER_YIM -->{USER_YIM}<!-- ENDIF --></td> diff --git a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html index 19259aebc8..69da5f6172 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html @@ -20,10 +20,6 @@ <td class="row1" width="35%"><b class="genmed">{L_UCP_AIM}{L_COLON} </b></td> <td class="row2"><input class="post" type="text" name="aim" size="30" maxlength="255" value="{AIM}" /></td> </tr> -<tr> - <td class="row1" width="35%"><b class="genmed">{L_UCP_MSNM}{L_COLON} </b></td> - <td class="row2"><input class="post" type="text" name="msn" size="30" maxlength="255" value="{MSN}" /></td> -</tr> <tr> <td class="row1" width="35%"><b class="genmed">{L_UCP_YIM}{L_COLON} </b></td> <td class="row2"><input class="post" type="text" name="yim" size="30" maxlength="255" value="{YIM}" /></td> diff --git a/phpBB/styles/subsilver2/theme/en/stylesheet.css b/phpBB/styles/subsilver2/theme/en/stylesheet.css index 563492d4fc..6ddecf963b 100644 --- a/phpBB/styles/subsilver2/theme/en/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/en/stylesheet.css @@ -19,11 +19,6 @@ padding-left: 72px; padding-top: 20px; } -.imageset.icon_contact_msnm { - background-image: url("./icon_contact_msnm.gif"); - padding-left: 72px; - padding-top: 20px; -} .imageset.icon_contact_pm { background-image: url("./icon_contact_pm.gif"); padding-left: 72px; diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index 977e5c20c6..e7e64eff32 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -1008,11 +1008,6 @@ a.imageset { padding-left: 72px; padding-top: 20px; } -.imageset.icon_contact_msnm { - background-image: url("./en/icon_contact_msnm.gif"); - padding-left: 72px; - padding-top: 20px; -} .imageset.icon_contact_pm { background-image: url("./en/icon_contact_pm.gif"); padding-left: 72px; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index bd2c7bea77..fcf34a139a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -617,7 +617,6 @@ $template->assign_vars(array( 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'), 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'), 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'), - 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'), 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') , 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), @@ -1095,7 +1094,6 @@ while ($row = $db->sql_fetchrow($result)) 'icq_status_img' => '', 'icq' => '', 'aim' => '', - 'msn' => '', 'yim' => '', 'jabber' => '', 'search' => '', @@ -1163,7 +1161,6 @@ while ($row = $db->sql_fetchrow($result)) 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id"), 'www' => $row['user_website'], 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=aim&u=$poster_id") : '', - 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', @@ -1585,7 +1582,6 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_WWW' => $user_cache[$poster_id]['www'], 'U_ICQ' => $user_cache[$poster_id]['icq'], 'U_AIM' => $user_cache[$poster_id]['aim'], - 'U_MSN' => $user_cache[$poster_id]['msn'], 'U_YIM' => $user_cache[$poster_id]['yim'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], From 93f9ebbb258a06e34198cffda0f5fd8dfdf29597 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sat, 12 Jan 2013 18:27:33 -0600 Subject: [PATCH 056/174] [feature/migrations] Make load_migrations recursive (optionally) PHPBB3-9737 --- phpBB/includes/db/migrator.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 2ec44a5a45..6b249e3ee0 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -127,7 +127,6 @@ class phpbb_db_migrator /** * Load migration data files from a directory * - * This does not loop through sub-directories. * Migration data files loaded with this function MUST contain * ONLY ONE class in them (or an exception will be thrown). * @@ -137,9 +136,10 @@ class phpbb_db_migrator * If FALSE, we will not check. You SHOULD check at least once * to prevent errors (if including multiple directories, check * with the last call to prevent throwing errors unnecessarily). - * @return array Array of migrations with names + * @param bool $recursive Set to true to also load data files from subdirectories + * @return array Array of migration names */ - public function load_migrations($path, $check_fulfillable = true) + public function load_migrations($path, $check_fulfillable = true, $recursive = true) { if (!is_dir($path)) { @@ -149,6 +149,17 @@ class phpbb_db_migrator $handle = opendir($path); while (($file = readdir($handle)) !== false) { + if ($file == '.' || $file == '..') + { + continue; + } + + // Recursion through subdirectories + if (is_dir($path . $file) && $recursive) + { + $this->load_migrations($path . $file . '/', $check_fulfillable, $recursive); + } + if (strpos($file, '_') !== 0 && strrpos($file, '.' . $this->php_ext) === (strlen($file) - strlen($this->php_ext) - 1)) { // We try to find what class existed by comparing the classes declared before and after including the file. From 26c16559c3496f5496ad6e83e55c40f03edda5bd Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sun, 13 Jan 2013 12:39:08 -0600 Subject: [PATCH 057/174] [feature/migrations] Function effectively_installed() in migrations Allows you to check if the migration is effectively installed (entirely optionall) This function is intended to help moving to migrations from a previous database updater, where some migrations may have been installed already even though they are not yet listed in the migrations table. PHPBB3-9737 --- phpBB/includes/db/migration/migration.php | 15 ++++++++++++ phpBB/includes/db/migrator.php | 20 ++++++++++++--- tests/dbal/migration/installed.php | 30 +++++++++++++++++++++++ tests/dbal/migrator_test.php | 21 ++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 tests/dbal/migration/installed.php diff --git a/phpBB/includes/db/migration/migration.php b/phpBB/includes/db/migration/migration.php index 4271751362..cf1e97b3b1 100644 --- a/phpBB/includes/db/migration/migration.php +++ b/phpBB/includes/db/migration/migration.php @@ -83,6 +83,21 @@ abstract class phpbb_db_migration return array(); } + /** + * Allows you to check if the migration is effectively installed (entirely optionall) + * + * This is checked when a migration is installed. If true is returned, the migration will be set as + * installed without performing the database changes. + * This function is intended to help moving to migrations from a previous database updater, where some + * migrations may have been installed already even though they are not yet listed in the migrations table. + * + * @return bool True if this migration is installed, False if this migration is not installed (checked on install) + */ + public function effectively_installed() + { + return false; + } + /** * Updates the database schema by providing a set of change instructions * diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 6b249e3ee0..b56da95b1a 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -271,10 +271,24 @@ class phpbb_db_migrator 'class' => $migration, ); - if (!isset($this->migration_state[$name])) + if ($migration->effectively_installed()) { - $state['migration_start_time'] = time(); - $this->insert_migration($name, $state); + $state = array( + 'migration_depends_on' => $migration->depends_on(), + 'migration_schema_done' => true, + 'migration_data_done' => true, + 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, + ); + } + else + { + if (!isset($this->migration_state[$name])) + { + $state['migration_start_time'] = time(); + $this->insert_migration($name, $state); + } } if (!$state['migration_schema_done']) diff --git a/tests/dbal/migration/installed.php b/tests/dbal/migration/installed.php new file mode 100644 index 0000000000..01829f7a99 --- /dev/null +++ b/tests/dbal/migration/installed.php @@ -0,0 +1,30 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_dbal_migration_installed extends phpbb_db_migration +{ + function effectively_installed() + { + return true; + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'test'))), + ); + } + + function test() + { + global $migrator_test_installed_failed; + + $migrator_test_installed_failed = true; + } +} diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 69db7ca047..9460e76f37 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -19,6 +19,7 @@ require_once dirname(__FILE__) . '/migration/recall.php'; require_once dirname(__FILE__) . '/migration/revert.php'; require_once dirname(__FILE__) . '/migration/revert_with_dependency.php'; require_once dirname(__FILE__) . '/migration/fail.php'; +require_once dirname(__FILE__) . '/migration/installed.php'; class phpbb_dbal_migrator_test extends phpbb_database_test_case { @@ -233,4 +234,24 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->fail('Revert did not remove test_column.'); } } + + public function test_installed() + { + $this->migrator->set_migrations(array('phpbb_dbal_migration_installed')); + + global $migrator_test_installed_failed; + $migrator_test_installed_failed = false; + + while (!$this->migrator->finished()) + { + $this->migrator->update(); + } + + $this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_installed') !== false); + + if ($migrator_test_installed_failed) + { + $this->fail('Installed test failed'); + } + } } From 000b8fefd2788c7f9f6aa6efc1d93658a00e48bd Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sun, 13 Jan 2013 13:21:01 -0600 Subject: [PATCH 058/174] [feature/migrations] Function to populate the migrations table (for install) PHPBB3-9737 --- phpBB/includes/db/migrator.php | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index b56da95b1a..69a5a4dd9c 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -124,6 +124,42 @@ class phpbb_db_migrator $this->migrations = $class_names; } + /** + * This function adds all migrations in a specified directory to the migrations table + * + * THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. + * THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE! + * + * @param string $path Path to migration data files + * @param bool $recursive Set to true to also load data files from subdirectories + * @return null + */ + public function populate_migrations_from_directory($path, $recursive = true) + { + $existing_migrations = $this->migrations; + + $this->migrations = array(); + $this->load_migrations($path, true, $recursive); + + foreach ($this->migrations as $name) + { + if ($this->migration_state($name) === false) + { + $state = array( + 'migration_depends_on' => $name::depends_on(), + 'migration_schema_done' => true, + 'migration_data_done' => true, + 'migration_data_state' => '', + 'migration_start_time' => time(), + 'migration_end_time' => time(), + ); + $this->insert_migration($name, $state); + } + } + + $this->migrations = $existing_migrations; + } + /** * Load migration data files from a directory * From ccd08e21f6ae97ff0ff628ff29935a70bdd7a58d Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sun, 13 Jan 2013 13:34:16 -0600 Subject: [PATCH 059/174] [feature/migrations] Make sure migration data not done before running data step PHPBB3-9737 --- phpBB/includes/db/migrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 69a5a4dd9c..d95283ae01 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -332,7 +332,7 @@ class phpbb_db_migrator $this->apply_schema_changes($migration->update_schema()); $state['migration_schema_done'] = true; } - else + else if (!$state['migration_data_done']) { try { From 4001410c8c80ac9c531343af28310e97b4bbf1fe Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sun, 13 Jan 2013 23:40:07 +0100 Subject: [PATCH 060/174] [ticket/11324] Add PHP 5.5 environment to travis and allow it to fail. PHPBB3-11324 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 94e7086c1e..ba8c1b4a91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,16 @@ php: - 5.3.3 - 5.3 - 5.4 + - 5.5 env: - DB=mysql - DB=postgres +matrix: + allow_failures: + - php: 5.5 + before_script: - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi" - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi" From 90235754b3919eafcb47047a8aac0fa0f075087e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev <oleg@bsdpower.com> Date: Sun, 13 Jan 2013 18:28:51 -0500 Subject: [PATCH 061/174] [ticket/11323] Backport include_define test to olympus. PHPBB3-11323 --- tests/template/template_test.php | 7 +++++++ tests/template/templates/include_define.html | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 tests/template/templates/include_define.html diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 9b3c6ac245..83af63cdd9 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -232,6 +232,13 @@ class phpbb_template_template_test extends phpbb_test_case array(), 'value', ), + array( + 'include_define.html', + array('VARIABLE' => 'value'), + array(), + array(), + 'value', + ), array( 'loop_vars.html', array(), diff --git a/tests/template/templates/include_define.html b/tests/template/templates/include_define.html new file mode 100644 index 0000000000..2419c8cba1 --- /dev/null +++ b/tests/template/templates/include_define.html @@ -0,0 +1,2 @@ +<!-- DEFINE $DEF = 'variable.html' --> +<!-- INCLUDE {$DEF} --> From 4c50a35b62a46de69b439f9ac8007721d76881b0 Mon Sep 17 00:00:00 2001 From: Marc Alexander <admin@m-a-styles.de> Date: Mon, 14 Jan 2013 01:14:29 +0100 Subject: [PATCH 062/174] [ticket/11323] Add tests for inclusion of defined variables This adds 2 tests for the template engine. The test using include_define_variable.html will test if a defined variable, which was defined with another template variable, can be used to include a file. The second test will do the same inside a loop using a loop variable. PHPBB3-11323 --- tests/template/template_test.php | 17 ++++++++++++++++- .../templates/include_define_variable.html | 2 ++ .../template/templates/include_loop_define.html | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/template/templates/include_define_variable.html create mode 100644 tests/template/templates/include_loop_define.html diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 9b3c6ac245..291b424bdd 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -238,7 +238,22 @@ class phpbb_template_template_test extends phpbb_test_case array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), array('loop'), '', - ),/* no top level nested loops + ), + array( + 'include_define_variable.html', + array('VARIABLE' => 'variable.html'), + array(), + array(), + 'variable.html', + ), + array( + 'include_loop_define.html', + array('VARIABLE' => 'value'), + array('loop' => array(array('NESTED_FILE' => 'variable.html'))), + array(), + 'value', + ), + /* no top level nested loops array( 'loop_vars.html', array(), diff --git a/tests/template/templates/include_define_variable.html b/tests/template/templates/include_define_variable.html new file mode 100644 index 0000000000..aff9b574c2 --- /dev/null +++ b/tests/template/templates/include_define_variable.html @@ -0,0 +1,2 @@ +<!-- DEFINE $DEF = '{VARIABLE}' --> +<!-- INCLUDE {$DEF} --> diff --git a/tests/template/templates/include_loop_define.html b/tests/template/templates/include_loop_define.html new file mode 100644 index 0000000000..f539b21396 --- /dev/null +++ b/tests/template/templates/include_loop_define.html @@ -0,0 +1,4 @@ +<!-- BEGIN loop --> +<!-- DEFINE $DEF = '{loop.NESTED_FILE}' --> +<!-- INCLUDE {$DEF} --> +<!-- END loop --> From 63b037b4bd1d1d3650235081b8d834a27719d2e1 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Tue, 15 Jan 2013 23:12:44 +0200 Subject: [PATCH 063/174] [ticket/10431] Adjustments for large buttons Changing CSS for large buttons to display better on Mac browsers. Fixing tabs. PHPBB3-10431 --- phpBB/styles/prosilver/theme/buttons.css | 67 ++++++++++++------------ 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 02f973d0ff..543d9d8183 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -18,56 +18,57 @@ /* Rolloff state */ .buttons div a { - display: inline-block; - line-height: 16px; - font-size: 13px; + display: inline-block; + line-height: 17.5px; + height: 18px; + font-size: 13px; white-space: nowrap; - border: 1px solid #c7c3bf; - border-radius: 4px; + border: 1px solid #c7c3bf; + border-radius: 4px; background: #fff none 0 0 repeat-x; - background-image: -moz-linear-gradient(top, #fff, #e9e9e9); - background-image: -webkit-linear-gradient(top, #fff, #e9e9e9); - background-image: -o-linear-gradient(top, #fff, #e9e9e9); - background-image: linear-gradient(to bottom, #fff, #e9e9e9); + background-image: -moz-linear-gradient(top, #fff, #e9e9e9); + background-image: -webkit-linear-gradient(top, #fff, #e9e9e9); + background-image: -o-linear-gradient(top, #fff, #e9e9e9); + background-image: linear-gradient(to bottom, #fff, #e9e9e9); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#e9e9e9')"; - box-shadow: 0 0 0 1px #fff inset; - -webkit-box-shadow: 0 0 0 1px #fff inset; - text-shadow: 1px 1px 0 #fff, -1px -1px 1px rgba(188, 42, 77, 0.25); - padding: 3px 22px 3px 8px; - font-family: "Futura-Medium", Verdana, Arial, Helvetica; - color: #bc2a4d !important; - position: relative; - text-decoration: none !important; - outline-style: none !important; + box-shadow: 0 0 0 1px #fff inset; + -webkit-box-shadow: 0 0 0 1px #fff inset; + padding: 2px 22px 2px 8px; + font-family: Verdana, Arial, Helvetica; + color: #bc2a4d !important; + position: relative; + text-decoration: none !important; + outline-style: none !important; + vertical-align: bottom; *padding-right: 8px; } .buttons div span { display: none; } .buttons div a:hover { - border-color: #0a8ed0; - background-image: -moz-linear-gradient(top, #e9e9e9, #fff); - background-image: -webkit-linear-gradient(top, #e9e9e9, #fff); - background-image: -o-linear-gradient(top, #e9e9e9, #fff); - background-image: linear-gradient(to bottom, #e9e9e9, #fff); + border-color: #0a8ed0; + background-image: -moz-linear-gradient(top, #e9e9e9, #fff); + background-image: -webkit-linear-gradient(top, #e9e9e9, #fff); + background-image: -o-linear-gradient(top, #e9e9e9, #fff); + background-image: linear-gradient(to bottom, #e9e9e9, #fff); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#e9e9e9', EndColorStr='#ffffff')"; - text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, -1px -1px 0 rgba(188, 42, 77, 0.2); + text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, -1px -1px 0 rgba(188, 42, 77, 0.2); } .buttons div a:after { - content: ''; - display: block; - position: absolute; - top: 50%; - right: 6px; - width: 12px; - height: 12px; + content: ''; + display: block; + position: absolute; + top: 50%; + right: 6px; + width: 12px; + height: 12px; margin-top: -6px; - background: url("images/buttons.png") 0px 0 no-repeat; + background: url("images/buttons.png") 0px 0 no-repeat; } .buttons div a:hover:after { - background-position: 0 -20px; + background-position: 0 -20px; } /* Big button images */ .buttons div.reply-icon a:after, .buttons div.pmreply-icon a:after { background-position: -20px 0; } From 74b09c01ffce189c73053f2d3749740254287aa7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Wed, 16 Jan 2013 00:03:17 +0200 Subject: [PATCH 064/174] [ticket/10431] Remove reply-all custom css Remove CSS for reply-all button that is no longer used PHPBB3-10431 --- phpBB/styles/prosilver/theme/cp.css | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css index da3ec1736e..e32ff8fcb8 100644 --- a/phpBB/styles/prosilver/theme/cp.css +++ b/phpBB/styles/prosilver/theme/cp.css @@ -287,20 +287,6 @@ dl.mini dd { line-height: 2.5em; } -/* PM panel adjustments */ -.reply-all a.left { - background-position: 3px 60%; -} - -.reply-all a.left:hover { - background-position: 0px 60%; -} - -.reply-all { - font-size: 11px; - padding-top: 5px; -} - /* Defined rules list for PM options */ ol.def-rules { padding-left: 0; From 107a9016f1d4677f059cd0e10ccfdd8bd79cfce2 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Wed, 16 Jan 2013 00:09:10 +0200 Subject: [PATCH 065/174] [ticket/10431] Remove .left class from reply-all Remove .left class from .reply-all button PHPBB3-10431 --- phpBB/styles/prosilver/template/ucp_pm_message_header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ucp_pm_message_header.html b/phpBB/styles/prosilver/template/ucp_pm_message_header.html index 29e6a5a46b..f03b7c2c86 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_message_header.html +++ b/phpBB/styles/prosilver/template/ucp_pm_message_header.html @@ -11,7 +11,7 @@ <!-- IF U_POST_REPLY_PM --><div class="pmreply-icon"><a title="{L_POST_REPLY_PM}" href="{U_POST_REPLY_PM}"><span></span>{L_POST_REPLY_PM}</a></div> <!-- ELSEIF U_POST_NEW_TOPIC --><div class="newpm-icon"><a href="{U_POST_NEW_TOPIC}" accesskey="n" title="{L_UCP_PM_COMPOSE}"><span></span>{L_UCP_PM_COMPOSE}</a></div><!-- ENDIF --> <!-- IF U_FORWARD_PM --><div class="forwardpm-icon"><a title="{L_POST_FORWARD_PM}" href="{U_FORWARD_PM}"><span></span>{L_FORWARD_PM}</a></div><!-- ENDIF --> - <!-- IF U_POST_REPLY_PM and S_PM_RECIPIENTS gt 1 --><div class="reply-all"><a class="left" title="{L_REPLY_TO_ALL}" href="{U_POST_REPLY_ALL}">{L_REPLY_TO_ALL}</a></div><!-- ENDIF --> + <!-- IF U_POST_REPLY_PM and S_PM_RECIPIENTS gt 1 --><div class="reply-all"><a title="{L_REPLY_TO_ALL}" href="{U_POST_REPLY_ALL}">{L_REPLY_TO_ALL}</a></div><!-- ENDIF --> </div> <!-- ENDIF --> From 460470229d972b93ef5a98b0d1d97a2a970d684f Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Wed, 16 Jan 2013 01:08:34 +0100 Subject: [PATCH 066/174] [ticket/11201] Remove database column on update PHPBB3-11201 --- phpBB/install/database_update.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8950d677ae..3de9ce2717 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1193,6 +1193,11 @@ function database_update_info() 'user_timezone' => array('VCHAR:100', ''), ), ), + 'drop_columns' => array( + USERS_TABLE => array( + 'user_msnm', + ), + ), ), ); } From de541ac13b44d1f52e1ba4bb626b9ec4e124557f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= <david@davidiq.com> Date: Fri, 20 Apr 2012 00:19:50 -0400 Subject: [PATCH 067/174] [ticket/10786] Javascript toggle member search panel in memberlist.php PHPBB3-10786 --- phpBB/memberlist.php | 8 ++-- phpBB/styles/prosilver/template/forum_fn.js | 37 +++++++++++++++++ .../prosilver/template/memberlist_body.html | 11 ++--- .../prosilver/template/memberlist_search.html | 3 +- .../subsilver2/template/memberlist_body.html | 8 ++-- .../template/memberlist_search.html | 41 ++++++++++++++++++- 6 files changed, 89 insertions(+), 19 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 091379061c..681e51e3fd 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1025,7 +1025,7 @@ switch ($mode) // We validate form and field here, only id/class allowed $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; - if (($mode == 'searchuser' || sizeof(array_intersect($request->variable_names(phpbb_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) + if ((in_array($mode, array('', 'searchuser')) || sizeof(array_intersect($request->variable_names(phpbb_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) { $username = request_var('username', '', true); $email = strtolower(request_var('email', '')); @@ -1377,7 +1377,7 @@ switch ($mode) } // Some search user specific data - if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_'))) + if (in_array($mode, array('', 'searchuser')) && ($config['load_search'] || $auth->acl_get('a_'))) { $group_selected = request_var('search_group_id', 0); $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '> </option>'; @@ -1447,7 +1447,7 @@ switch ($mode) 'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false, 'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false, 'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false, - 'S_SEARCH_USER' => true, + 'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? true : false, 'S_FORM_NAME' => $form, 'S_FIELD_NAME' => $field, 'S_SELECT_SINGLE' => $select_single, @@ -1598,7 +1598,7 @@ switch ($mode) 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', - 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser') ? $u_hide_find_member : '', + 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? $u_hide_find_member : '', 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_FROM' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 995b4b0ab7..527a064fa9 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -433,6 +433,43 @@ function apply_onkeypress_event() } } +/** +* Toggle a section's visibility status +*/ +function toggle_section(link, panel_id, expand_text, collapse_text) +{ + if (jquery_present) + { + var panel = jQuery('#' + panel_id); + if (panel.is(':visible')) + { + jQuery(link).text(expand_text); + panel.slideUp('fast'); + } + else + { + jQuery(link).text(collapse_text); + panel.slideDown('fast'); + } + } + else + { + var panel = document.getElementById(panel_id); + if (panel.style.display == 'none') + { + link.innerHTML = collapse_text; + panel.style.display = ''; + } + else + { + link.innerHTML = expand_text; + panel.style.display = 'none'; + } + } + + return false; +} + /** * Detect JQuery existance. We currently do not deliver it, but some styles do, so why not benefit from it. ;) */ diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 4ba0c5cb2a..023c0e1e4e 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -3,13 +3,11 @@ <!-- INCLUDE memberlist_search.html --> <form method="post" id="results" action="{S_MODE_ACTION}" onsubmit="insert_marked(this.user); return false"> -<!-- ELSEIF S_SEARCH_USER --> - <!-- INCLUDE overall_header.html --> - <!-- INCLUDE memberlist_search.html --> - <form method="post" action="{S_MODE_ACTION}"> - <!-- ELSE --> <!-- INCLUDE overall_header.html --> + <div class="panel" id="memberlist_search"<!-- IF not S_SEARCH_USER --> style="display: none;"<!-- ENDIF -->> + <!-- INCLUDE memberlist_search.html --> + </div> <form method="post" action="{S_MODE_ACTION}"> <!-- ENDIF --> @@ -32,8 +30,7 @@ <ul class="linklist"> <li> - - <!-- IF U_FIND_MEMBER and not S_SEARCH_USER --><a href="{U_FIND_MEMBER}">{L_FIND_USERNAME}</a> • <!-- ELSEIF S_SEARCH_USER and U_HIDE_FIND_MEMBER and not S_IN_SEARCH_POPUP --><a href="{U_HIDE_FIND_MEMBER}">{L_HIDE_MEMBER_SEARCH}</a> • <!-- ENDIF --> + <!-- IF U_FIND_MEMBER and not S_SEARCH_USER --><a href="{U_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_FIND_USERNAME}</a> • <!-- ELSEIF S_SEARCH_USER and U_HIDE_FIND_MEMBER and not S_IN_SEARCH_POPUP --><a href="{U_HIDE_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_HIDE_MEMBER_SEARCH}</a> • <!-- ENDIF --> <strong style="font-size: 0.95em;"> <!-- BEGIN first_char --> <a href="{first_char.U_SORT}">{first_char.DESC}</a> diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 1ef8710817..ad8fb83fe4 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -37,9 +37,8 @@ function insert_single(user) } // ]]> </script> -<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js"></script> <!-- ENDIF --> - +<!-- INCLUDEJS template/forum_fn.js --> <h2 class="solo">{L_FIND_USERNAME}</h2> <form method="post" action="{S_MODE_ACTION}" id="search_memberlist"> diff --git a/phpBB/styles/subsilver2/template/memberlist_body.html b/phpBB/styles/subsilver2/template/memberlist_body.html index 09336fb8a3..c2846dd18a 100644 --- a/phpBB/styles/subsilver2/template/memberlist_body.html +++ b/phpBB/styles/subsilver2/template/memberlist_body.html @@ -4,9 +4,9 @@ <!-- INCLUDE overall_header.html --> <!-- ENDIF --> -<!-- IF S_SEARCH_USER --> +<div class="panel" id="memberlist_search"<!-- IF not S_SEARCH_USER --> style="display: none;"<!-- ENDIF -->> <!-- INCLUDE memberlist_search.html --> -<!-- ENDIF --> +</div> <!-- IF S_SHOW_GROUP --><!-- INCLUDE memberlist_group.html --><!-- ENDIF --> @@ -21,9 +21,9 @@ <!-- END first_char --> </select> <input type="submit" name="char" value="{L_DISPLAY}" class="btnlite" /></td> <!-- IF U_FIND_MEMBER and not S_SEARCH_USER --> - <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_FIND_MEMBER}">{L_FIND_USERNAME}</a></td> + <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_FIND_USERNAME}</a></td> <!-- ELSEIF S_SEARCH_USER and U_HIDE_FIND_MEMBER and not S_IN_SEARCH_POPUP --> - <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_HIDE_FIND_MEMBER}">{L_HIDE_MEMBER_SEARCH}</a></td> + <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_HIDE_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_HIDE_MEMBER_SEARCH}</a></td> <!-- ENDIF --> </tr> </table> diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index fb76cacc79..f1f96e1ecd 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -1,8 +1,8 @@ <!-- You should retain this javascript in your own template! --> -<!-- IF S_IN_SEARCH_POPUP --> <script type="text/javascript"> // <![CDATA[ +<!-- IF S_IN_SEARCH_POPUP --> function insert_user(user) { opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.value = ( opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.value.length && opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.type == "textarea" ) ? opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.value + "\n" + user : user; @@ -60,9 +60,46 @@ } } } +<!-- ENDIF --> + + /** + * Toggle a section's visibility status + */ + function toggle_section(link, panel_id, expand_text, collapse_text) + { + if (window.jQuery) + { + var panel = jQuery('#' + panel_id); + if (panel.is(':visible')) + { + jQuery(link).text(expand_text); + panel.slideUp('fast'); + } + else + { + jQuery(link).text(collapse_text); + panel.slideDown('fast'); + } + } + else + { + var panel = document.getElementById(panel_id); + if (panel.style.display == 'none') + { + link.innerHTML = collapse_text; + panel.style.display = ''; + } + else + { + link.innerHTML = expand_text; + panel.style.display = 'none'; + } + } + + return false; + } // ]]> </script> -<!-- ENDIF --> <form method="post" action="{S_MODE_ACTION}" name="search"> From babe07caefe8a035f711fd76c38b4dbeb0a8e804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= <david@davidiq.com> Date: Tue, 26 Jun 2012 00:37:48 -0400 Subject: [PATCH 068/174] [ticket/10786] Javascript toggle member search panel in memberlist.php Search functions on the memberlist.php page are now rendered by default and displayed via javascript. If javascript is disabled the page still works as it previously did. PHPBB3-10786 --- phpBB/memberlist.php | 6 +-- phpBB/styles/prosilver/template/ajax.js | 13 +++++- phpBB/styles/prosilver/template/forum_fn.js | 37 ----------------- .../prosilver/template/memberlist_body.html | 2 +- .../subsilver2/template/memberlist_body.html | 8 ++-- .../template/memberlist_search.html | 41 +------------------ 6 files changed, 22 insertions(+), 85 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 681e51e3fd..ebc1757810 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1025,7 +1025,7 @@ switch ($mode) // We validate form and field here, only id/class allowed $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; - if ((in_array($mode, array('', 'searchuser')) || sizeof(array_intersect($request->variable_names(phpbb_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) + if ((($mode == '' || $mode == 'searchuser') || sizeof(array_intersect($request->variable_names(phpbb_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) { $username = request_var('username', '', true); $email = strtolower(request_var('email', '')); @@ -1377,7 +1377,7 @@ switch ($mode) } // Some search user specific data - if (in_array($mode, array('', 'searchuser')) && ($config['load_search'] || $auth->acl_get('a_'))) + if (($mode == '' || $mode == 'searchuser') && ($config['load_search'] || $auth->acl_get('a_'))) { $group_selected = request_var('search_group_id', 0); $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '> </option>'; @@ -1447,7 +1447,7 @@ switch ($mode) 'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false, 'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false, 'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false, - 'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? true : false, + 'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)), 'S_FORM_NAME' => $form, 'S_FIELD_NAME' => $field, 'S_SELECT_SINGLE' => $select_single, diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 8583fb565c..968f57bba2 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -192,6 +192,17 @@ $('#quick-mod-select').change(function () { $('#quickmodform').submit(); }); - +/** +* Toggle the member search panel in memberlist.php. +*/ +$('#member_search').click(function () { + $('#memberlist_search').slideToggle('fast'); + phpbb.ajax_callbacks['alt_text'].call(this); + //Focus on the username textbox if it's available and displayed + if ($('#username').length > 0 && $('#memberlist_search').is(':visible')) { + $('#username').focus(); + } + return false; +}); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 527a064fa9..995b4b0ab7 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -433,43 +433,6 @@ function apply_onkeypress_event() } } -/** -* Toggle a section's visibility status -*/ -function toggle_section(link, panel_id, expand_text, collapse_text) -{ - if (jquery_present) - { - var panel = jQuery('#' + panel_id); - if (panel.is(':visible')) - { - jQuery(link).text(expand_text); - panel.slideUp('fast'); - } - else - { - jQuery(link).text(collapse_text); - panel.slideDown('fast'); - } - } - else - { - var panel = document.getElementById(panel_id); - if (panel.style.display == 'none') - { - link.innerHTML = collapse_text; - panel.style.display = ''; - } - else - { - link.innerHTML = expand_text; - panel.style.display = 'none'; - } - } - - return false; -} - /** * Detect JQuery existance. We currently do not deliver it, but some styles do, so why not benefit from it. ;) */ diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 023c0e1e4e..17dc2c33c0 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -30,7 +30,7 @@ <ul class="linklist"> <li> - <!-- IF U_FIND_MEMBER and not S_SEARCH_USER --><a href="{U_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_FIND_USERNAME}</a> • <!-- ELSEIF S_SEARCH_USER and U_HIDE_FIND_MEMBER and not S_IN_SEARCH_POPUP --><a href="{U_HIDE_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_HIDE_MEMBER_SEARCH}</a> • <!-- ENDIF --> + <!-- IF U_FIND_MEMBER and not S_SEARCH_USER --><a href="{U_FIND_MEMBER}" id="member_search" data-alt-text="{LA_HIDE_MEMBER_SEARCH}">{L_FIND_USERNAME}</a> • <!-- ELSEIF S_SEARCH_USER and U_HIDE_FIND_MEMBER and not S_IN_SEARCH_POPUP --><a href="{U_HIDE_FIND_MEMBER}" id="member_search" data-alt-text="{LA_FIND_USERNAME}">{L_HIDE_MEMBER_SEARCH}</a> • <!-- ENDIF --> <strong style="font-size: 0.95em;"> <!-- BEGIN first_char --> <a href="{first_char.U_SORT}">{first_char.DESC}</a> diff --git a/phpBB/styles/subsilver2/template/memberlist_body.html b/phpBB/styles/subsilver2/template/memberlist_body.html index c2846dd18a..c7ba116d34 100644 --- a/phpBB/styles/subsilver2/template/memberlist_body.html +++ b/phpBB/styles/subsilver2/template/memberlist_body.html @@ -4,9 +4,9 @@ <!-- INCLUDE overall_header.html --> <!-- ENDIF --> -<div class="panel" id="memberlist_search"<!-- IF not S_SEARCH_USER --> style="display: none;"<!-- ENDIF -->> +<!-- IF S_SEARCH_USER --> <!-- INCLUDE memberlist_search.html --> -</div> +<!-- ENDIF --> <!-- IF S_SHOW_GROUP --><!-- INCLUDE memberlist_group.html --><!-- ENDIF --> @@ -21,9 +21,9 @@ <!-- END first_char --> </select> <input type="submit" name="char" value="{L_DISPLAY}" class="btnlite" /></td> <!-- IF U_FIND_MEMBER and not S_SEARCH_USER --> - <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_FIND_USERNAME}</a></td> + <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_FIND_MEMBER}">{L_FIND_USERNAME}</a></td> <!-- ELSEIF S_SEARCH_USER and U_HIDE_FIND_MEMBER and not S_IN_SEARCH_POPUP --> - <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_HIDE_FIND_MEMBER}" onclick="return toggle_section(this, 'memberlist_search', '{LA_FIND_USERNAME}', '{LA_HIDE_MEMBER_SEARCH}')">{L_HIDE_MEMBER_SEARCH}</a></td> + <td class="genmed" align="{S_CONTENT_FLOW_END}"><a href="{U_HIDE_FIND_MEMBER}">{L_HIDE_MEMBER_SEARCH}</a></td> <!-- ENDIF --> </tr> </table> diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index f1f96e1ecd..fb76cacc79 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -1,8 +1,8 @@ <!-- You should retain this javascript in your own template! --> +<!-- IF S_IN_SEARCH_POPUP --> <script type="text/javascript"> // <![CDATA[ -<!-- IF S_IN_SEARCH_POPUP --> function insert_user(user) { opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.value = ( opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.value.length && opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.type == "textarea" ) ? opener.document.forms['{S_FORM_NAME}'].{S_FIELD_NAME}.value + "\n" + user : user; @@ -60,46 +60,9 @@ } } } -<!-- ENDIF --> - - /** - * Toggle a section's visibility status - */ - function toggle_section(link, panel_id, expand_text, collapse_text) - { - if (window.jQuery) - { - var panel = jQuery('#' + panel_id); - if (panel.is(':visible')) - { - jQuery(link).text(expand_text); - panel.slideUp('fast'); - } - else - { - jQuery(link).text(collapse_text); - panel.slideDown('fast'); - } - } - else - { - var panel = document.getElementById(panel_id); - if (panel.style.display == 'none') - { - link.innerHTML = collapse_text; - panel.style.display = ''; - } - else - { - link.innerHTML = expand_text; - panel.style.display = 'none'; - } - } - - return false; - } // ]]> </script> +<!-- ENDIF --> <form method="post" action="{S_MODE_ACTION}" name="search"> From 4306a7641f92dd34e8c3a132017a146607b3e2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= <david@davidiq.com> Date: Tue, 26 Jun 2012 21:29:27 -0400 Subject: [PATCH 069/174] [ticket/10786] Javascript toggle member search panel in memberlist.php Search functions on the memberlist.php page are now rendered by default and displayed via javascript. If javascript is disabled the page still works as it previously did. PHPBB3-10786 --- phpBB/styles/prosilver/template/ajax.js | 8 ++++++-- phpBB/styles/subsilver2/template/memberlist_body.html | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 968f57bba2..6ce3b38981 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -194,12 +194,16 @@ $('#quick-mod-select').change(function () { /** * Toggle the member search panel in memberlist.php. +* +* If user returns to search page after viewing results the search panel is automatically displayed. +* In any case the link will toggle the display status of the search panel and link text will be +* appropriately changed based on the status of the search panel. */ $('#member_search').click(function () { $('#memberlist_search').slideToggle('fast'); phpbb.ajax_callbacks['alt_text'].call(this); - //Focus on the username textbox if it's available and displayed - if ($('#username').length > 0 && $('#memberlist_search').is(':visible')) { + // Focus on the username textbox if it's available and displayed + if ($('#memberlist_search').is(':visible')) { $('#username').focus(); } return false; diff --git a/phpBB/styles/subsilver2/template/memberlist_body.html b/phpBB/styles/subsilver2/template/memberlist_body.html index c7ba116d34..09336fb8a3 100644 --- a/phpBB/styles/subsilver2/template/memberlist_body.html +++ b/phpBB/styles/subsilver2/template/memberlist_body.html @@ -4,7 +4,7 @@ <!-- INCLUDE overall_header.html --> <!-- ENDIF --> -<!-- IF S_SEARCH_USER --> +<!-- IF S_SEARCH_USER --> <!-- INCLUDE memberlist_search.html --> <!-- ENDIF --> From 1d5f8a2bbf13305f9ba651c7ed131911dbcfa016 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Wed, 16 Jan 2013 11:37:13 +0200 Subject: [PATCH 070/174] [ticket/11328] Add language variables for buttons New language variables for buttons PHPBB3-11328 --- phpBB/language/en/common.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 6cad4136a2..63241b71b5 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -119,6 +119,17 @@ $lang = array_merge($lang, array( 1 => 'Users browsing this forum: %2$s and %1$d guest', 2 => 'Users browsing this forum: %2$s and %1$d guests', ), + 'BUTTON_EDIT' => 'Edit', + 'BUTTON_FORUM_LOCKED' => 'Locked', + 'BUTTON_NEW_TOPIC' => 'New Topic', + 'BUTTON_PM' => 'PM', + 'BUTTON_PM_FORWARD' => 'Forward', + 'BUTTON_PM_NEW' => 'New PM', + 'BUTTON_PM_REPLY' => 'Send Reply', + 'BUTTON_PM_REPLY_ALL' => 'Reply All', + 'BUTTON_POST_REPLY' => 'Post Reply', + 'BUTTON_QUOTE' => 'Quote', + 'BUTTON_TOPIC_LOCKED' => 'Locked', 'BYTES' => 'Bytes', 'CANCEL' => 'Cancel', From d68c4697be5847a7fd3f7e92f56e24d366da83b1 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Wed, 16 Jan 2013 11:37:50 +0200 Subject: [PATCH 071/174] [ticket/11328] Replace long buttons text with short text Replace long buttons text with short text, like it was on images PHPBB3-11328 --- .../styles/prosilver/template/ucp_pm_message_header.html | 8 ++++---- phpBB/styles/prosilver/template/viewforum_body.html | 4 ++-- phpBB/styles/prosilver/template/viewtopic_body.html | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_pm_message_header.html b/phpBB/styles/prosilver/template/ucp_pm_message_header.html index 4d48782c10..7a80f72348 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_message_header.html +++ b/phpBB/styles/prosilver/template/ucp_pm_message_header.html @@ -8,10 +8,10 @@ <!-- IF FOLDER_STATUS and FOLDER_MAX_MESSAGES neq 0 --><p>{FOLDER_STATUS}</p><!-- ENDIF --> <!-- IF U_POST_REPLY_PM or U_POST_NEW_TOPIC or U_FORWARD_PM --> <div class="buttons"> - <!-- IF U_POST_REPLY_PM --><div class="pmreply-icon"><a title="{L_POST_REPLY_PM}" href="{U_POST_REPLY_PM}"><span></span>{L_POST_REPLY_PM}</a></div> - <!-- ELSEIF U_POST_NEW_TOPIC --><div class="newpm-icon"><a href="{U_POST_NEW_TOPIC}" accesskey="n" title="{L_UCP_PM_COMPOSE}"><span></span>{L_UCP_PM_COMPOSE}</a></div><!-- ENDIF --> - <!-- IF U_FORWARD_PM --><div class="forwardpm-icon"><a title="{L_POST_FORWARD_PM}" href="{U_FORWARD_PM}"><span></span>{L_FORWARD_PM}</a></div><!-- ENDIF --> - <!-- IF U_POST_REPLY_PM and S_PM_RECIPIENTS gt 1 --><div class="reply-all"><a title="{L_REPLY_TO_ALL}" href="{U_POST_REPLY_ALL}">{L_REPLY_TO_ALL}</a></div><!-- ENDIF --> + <!-- IF U_POST_REPLY_PM --><div class="pmreply-icon"><a title="{L_POST_REPLY_PM}" href="{U_POST_REPLY_PM}"><span></span>{L_BUTTON_PM_REPLY}</a></div> + <!-- ELSEIF U_POST_NEW_TOPIC --><div class="newpm-icon"><a href="{U_POST_NEW_TOPIC}" accesskey="n" title="{L_UCP_PM_COMPOSE}"><span></span>{L_BUTTON_PM_NEW}</a></div><!-- ENDIF --> + <!-- IF U_FORWARD_PM --><div class="forwardpm-icon"><a title="{L_POST_FORWARD_PM}" href="{U_FORWARD_PM}"><span></span>{L_BUTTON_PM_FORWARD}</a></div><!-- ENDIF --> + <!-- IF U_POST_REPLY_PM and S_PM_RECIPIENTS gt 1 --><div class="reply-all"><a title="{L_REPLY_TO_ALL}" href="{U_POST_REPLY_ALL}">{L_BUTTON_PM_REPLY_ALL}</a></div><!-- ENDIF --> </div> <!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index b47c13d573..e0aef4f290 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -39,7 +39,7 @@ <!-- IF not S_IS_BOT and S_DISPLAY_POST_INFO --> <div class="buttons"> - <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->" title="<!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span></span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></a></div> + <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->" title="<!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span></span><!-- IF S_IS_LOCKED -->{L_BUTTON_FORUM_LOCKED}<!-- ELSE -->{L_BUTTON_NEW_TOPIC}<!-- ENDIF --></a></div> </div> <!-- ENDIF --> @@ -205,7 +205,7 @@ <div class="topic-actions"> <!-- IF not S_IS_BOT and S_DISPLAY_POST_INFO --> <div class="buttons"> - <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->" title="<!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span></span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></a></div> + <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->" title="<!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span></span><!-- IF S_IS_LOCKED -->{L_BUTTON_FORUM_LOCKED}<!-- ELSE -->{L_BUTTON_NEW_TOPIC}<!-- ENDIF --></a></div> </div> <!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 9910be34b0..e7bd3d5059 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -29,7 +29,7 @@ <div class="buttons"> <!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO --> - <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED_SHORT}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div> + <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_BUTTON_TOPIC_LOCKED}<!-- ELSE -->{L_BUTTON_POST_REPLY}<!-- ENDIF --></a></div> <!-- ENDIF --> </div> @@ -263,7 +263,7 @@ <div class="topic-actions"> <div class="buttons"> <!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO --> - <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED_SHORT}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div> + <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_BUTTON_TOPIC_LOCKED}<!-- ELSE -->{L_BUTTON_POST_REPLY}<!-- ENDIF --></a></div> <!-- ENDIF --> </div> From 3122aeff263b5fee51440ff49274897ccb6ea46f Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Thu, 17 Jan 2013 14:32:15 +0100 Subject: [PATCH 072/174] [ticket/9492] Retain custom ranks and avatars when setting users default group PHPBB3-9492 --- phpBB/includes/functions_user.php | 83 ++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6abcdee8f2..22272b20f3 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3208,8 +3208,8 @@ function remove_default_avatar($group_id, $user_ids) user_avatar_width = 0, user_avatar_height = 0 WHERE group_id = " . (int) $group_id . " - AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "' - AND " . $db->sql_in_set('user_id', $user_ids); + AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "' + AND " . $db->sql_in_set('user_id', $user_ids); $db->sql_query($sql); } @@ -3246,9 +3246,9 @@ function remove_default_rank($group_id, $user_ids) $sql = 'UPDATE ' . USERS_TABLE . ' SET user_rank = 0 WHERE group_id = ' . (int)$group_id . ' - AND user_rank <> 0 - AND user_rank = ' . (int)$row['group_rank'] . ' - AND ' . $db->sql_in_set('user_id', $user_ids); + AND user_rank <> 0 + AND user_rank = ' . (int)$row['group_rank'] . ' + AND ' . $db->sql_in_set('user_id', $user_ids); $db->sql_query($sql); } @@ -3277,7 +3277,8 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna case 'demote': case 'promote': - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . " + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id AND user_pending = 1 AND " . $db->sql_in_set('user_id', $user_id_ary); @@ -3375,7 +3376,8 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna return 'NO_USERS'; } - $sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . ' + $sql = 'SELECT user_id, group_id + FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true); $result = $db->sql_query($sql); @@ -3509,45 +3511,63 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } - // Before we update the user attributes, we will make a list of those having now the group avatar assigned + $updated_sql_ary = $sql_ary; + + // Before we update the user attributes, we will update the rank for users that don't have a custom rank + if (isset($sql_ary['user_rank'])) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', array('user_rank' => $sql_ary['user_rank'])) . ' + WHERE user_rank = 0 + AND ' . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); + unset($sql_ary['user_rank']); + } + + // Before we update the user attributes, we will update the avatar for users that don't have a custom avatar if (isset($sql_ary['user_avatar'])) { - // Ok, get the original avatar data from users having an uploaded one (we need to remove these from the filesystem) - $sql = 'SELECT user_id, group_id, user_avatar - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . ' - AND user_avatar_type = ' . AVATAR_UPLOAD; - $result = $db->sql_query($sql); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', array( + 'user_avatar' => $sql_ary['user_avatar'], + 'user_avatar_type' => $sql_ary['user_avatar_type'], + 'user_avatar_height' => $sql_ary['user_avatar_height'], + 'user_avatar_width' => $sql_ary['user_avatar_width'], + )) . " + WHERE user_avatar = '' + AND " . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - avatar_delete('user', $row); - } - $db->sql_freeresult($result); + unset($sql_ary['user_avatar']); } - else + + unset($sql_ary['user_avatar_type']); + unset($sql_ary['user_avatar_height']); + unset($sql_ary['user_avatar_width']); + + if (!empty($sql_ary)) { - unset($sql_ary['user_avatar_type']); - unset($sql_ary['user_avatar_height']); - unset($sql_ary['user_avatar_width']); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE ' . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); } - $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - if (isset($sql_ary['user_colour'])) { // Update any cached colour information for these users - $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' WHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary); $db->sql_query($sql); - $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' WHERE " . $db->sql_in_set('topic_poster', $user_id_ary); $db->sql_query($sql); - $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' WHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary); $db->sql_query($sql); @@ -3559,6 +3579,9 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } + // Make all values available for the event + $sql_ary = $updated_sql_ary; + /** * Event when the default group is set for an array of users * From 50542a389cfb6189334ed704c1d5c984f3ddf76b Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Thu, 17 Jan 2013 14:35:37 +0100 Subject: [PATCH 073/174] [ticket/9492] Add unit tests for custom ranks and avatars PHPBB3-9492 --- .../fixtures/group_user_attributes.xml | 121 ++++++++++++++ .../group_user_attributes_test.php | 149 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/functions_user/fixtures/group_user_attributes.xml create mode 100644 tests/functions_user/group_user_attributes_test.php diff --git a/tests/functions_user/fixtures/group_user_attributes.xml b/tests/functions_user/fixtures/group_user_attributes.xml new file mode 100644 index 0000000000..f4edbdca49 --- /dev/null +++ b/tests/functions_user/fixtures/group_user_attributes.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_groups"> + <column>group_id</column> + <column>group_avatar</column> + <column>group_rank</column> + <column>group_desc</column> + <row> + <value>1</value> + <value>default</value> + <value>1</value> + <value></value> + </row> + <row> + <value>2</value> + <value></value> + <value>0</value> + <value></value> + </row> + <row> + <value>3</value> + <value>default2</value> + <value>3</value> + <value></value> + </row> + </table> + <table name="phpbb_users"> + <column>user_id</column> + <column>group_id</column> + <column>user_avatar</column> + <column>user_rank</column> + <column>username_clean</column> + <column>user_permissions</column> + <column>user_sig</column> + <column>user_occ</column> + <column>user_interests</column> + <row> + <value>1</value> + <value>1</value> + <value></value> + <value>0</value> + <value>barfoo</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>2</value> + <value>1</value> + <value>default</value> + <value>1</value> + <value>foobar</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + <row> + <value>3</value> + <value>1</value> + <value>custom</value> + <value>2</value> + <value>bertie</value> + <value></value> + <value></value> + <value></value> + <value></value> + </row> + </table> + <table name="phpbb_user_group"> + <column>user_id</column> + <column>group_id</column> + <column>user_pending</column> + <row> + <value>1</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>2</value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>3</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>2</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>3</value> + <value>0</value> + </row> + <row> + <value>3</value> + <value>1</value> + <value>0</value> + </row> + <row> + <value>3</value> + <value>2</value> + <value>0</value> + </row> + <row> + <value>3</value> + <value>3</value> + <value>0</value> + </row> + </table> +</dataset> diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php new file mode 100644 index 0000000000..35d0b9e348 --- /dev/null +++ b/tests/functions_user/group_user_attributes_test.php @@ -0,0 +1,149 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; + +class phpbb_functions_user_group_user_attributes_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/group_user_attributes.xml'); + } + + public function group_user_attributes_data() + { + return array( + array( + 'Setting new default group without settings for user with no settings - no change', + 1, + 2, + array( + 'group_avatar' => '', + 'group_avatar_type' => 0, + 'group_avatar_height' => 0, + 'group_avatar_width' => 0, + 'group_rank' => 0, + ), + array( + 'user_avatar' => '', + 'user_rank' => 0, + ), + ), + array( + 'Setting new default group without settings for user with default settings - user settings overwritten', + 2, + 2, + array( + 'group_avatar' => '', + 'group_avatar_type' => 0, + 'group_avatar_height' => 0, + 'group_avatar_width' => 0, + 'group_rank' => 0, + ), + array( + 'user_avatar' => '', + 'user_rank' => 0, + ), + ), + array( + 'Setting new default group without settings for user with custom settings - no change', + 3, + 2, + array( + 'group_avatar' => '', + 'group_avatar_type' => 0, + 'group_avatar_height' => 0, + 'group_avatar_width' => 0, + 'group_rank' => 0, + ), + array( + 'user_avatar' => 'custom', + 'user_rank' => 2, + ), + ), + array( + 'Setting new default group with settings for user with no settings - user settings overwritten', + 1, + 3, + array( + 'group_avatar' => 'default2', + 'group_avatar_type' => 1, + 'group_avatar_height' => 1, + 'group_avatar_width' => 1, + 'group_rank' => 3, + ), + array( + 'user_avatar' => 'default2', + 'user_rank' => 3, + ), + ), + array( + 'Setting new default group with settings for user with default settings - user settings overwritten', + 2, + 3, + array( + 'group_avatar' => 'default2', + 'group_avatar_type' => 1, + 'group_avatar_height' => 1, + 'group_avatar_width' => 1, + 'group_rank' => 3, + ), + array( + 'user_avatar' => 'default2', + 'user_rank' => 3, + ), + ), + array( + 'Setting new default group with settings for user with custom settings - no change', + 3, + 3, + array( + 'group_avatar' => 'default2', + 'group_avatar_type' => 1, + 'group_avatar_height' => 1, + 'group_avatar_width' => 1, + 'group_rank' => 3, + ), + array( + 'user_avatar' => 'custom', + 'user_rank' => 2, + ), + ), + ); + } + + /** + * @dataProvider group_user_attributes_data + */ + public function test_group_user_attributes($description, $user_id, $group_id, $group_row, $expected) + { + global $auth, $cache, $db, $phpbb_dispatcher, $user; + + $user->ip = ''; + $cache = new phpbb_mock_cache; + $db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $auth = $this->getMock('phpbb_auth'); + $auth->expects($this->any()) + ->method('acl_clear_prefetch'); + + group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); + + $sql = 'SELECT user_avatar, user_rank + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + + $this->assertEquals(array($expected), $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } +} From 64c27013d4835f9bede202f208679e34fb0ec7bf Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Thu, 17 Jan 2013 14:40:58 +0100 Subject: [PATCH 074/174] [ticket/9492] Fix undefined user_avatar_* values when updating the group avatar PHPBB3-9492 --- phpBB/includes/functions_user.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 22272b20f3..3b7c9eea92 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3525,25 +3525,31 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } // Before we update the user attributes, we will update the avatar for users that don't have a custom avatar + $avatar_options = array('user_avatar', 'user_avatar_type', 'user_avatar_height', 'user_avatar_width'); + if (isset($sql_ary['user_avatar'])) { + $avatar_sql_ary = array(); + foreach ($avatar_options as $avatar_option) + { + if (isset($sql_ary[$avatar_option])) + { + $avatar_sql_ary[$avatar_option] = $sql_ary[$avatar_option]; + } + } + $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', array( - 'user_avatar' => $sql_ary['user_avatar'], - 'user_avatar_type' => $sql_ary['user_avatar_type'], - 'user_avatar_height' => $sql_ary['user_avatar_height'], - 'user_avatar_width' => $sql_ary['user_avatar_width'], - )) . " + SSET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " WHERE user_avatar = '' AND " . $db->sql_in_set('user_id', $user_id_ary); $db->sql_query($sql); - - unset($sql_ary['user_avatar']); } - unset($sql_ary['user_avatar_type']); - unset($sql_ary['user_avatar_height']); - unset($sql_ary['user_avatar_width']); + // Remove the avatar options, as we already updated them + foreach ($avatar_options as $avatar_option) + { + unset($sql_ary[$avatar_option]); + } if (!empty($sql_ary)) { From bd87b068587a519b4a6275209525e069e7690ded Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Thu, 17 Jan 2013 14:43:00 +0100 Subject: [PATCH 075/174] [ticket/9492] Ensure to update all avatar values when the avatar is changed PHPBB3-9492 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/ucp/ucp_groups.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index b604e20094..9145a20400 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -439,7 +439,7 @@ class acp_groups foreach ($test_variables as $test => $type) { - if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || in_array($test, $set_attributes))) + if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes))) { settype($submit_ary[$test], $type); $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index d92aea91f8..b9a06bc3b4 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -618,7 +618,7 @@ class ucp_groups foreach ($test_variables as $test => $type) { - if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) + if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0)) { settype($submit_ary[$test], $type); $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; From 9a6219d8b391eedbbd5626f845b00c3acd738e12 Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Thu, 17 Jan 2013 14:45:40 +0100 Subject: [PATCH 076/174] [ticket/9492] Ensure to delete the avatar/rank data when we change it PHPBB3-9492 --- phpBB/includes/functions_user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3b7c9eea92..d47e04cbe5 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2698,12 +2698,12 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow } $db->sql_freeresult($result); - if (isset($sql_ary['group_avatar']) && !$sql_ary['group_avatar']) + if (isset($sql_ary['group_avatar'])) { remove_default_avatar($group_id, $user_ary); } - if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank']) + if (isset($sql_ary['group_rank'])) { remove_default_rank($group_id, $user_ary); } From 6a972da4c7d0cc8008ff95d41b5fb71cb17e107e Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Sun, 20 Jan 2013 20:58:46 +0100 Subject: [PATCH 077/174] [ticket/9492] Fix typo in SQL query PHPBB3-9492 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d47e04cbe5..b7878ddfc7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3539,7 +3539,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } $sql = 'UPDATE ' . USERS_TABLE . ' - SSET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " + SET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " WHERE user_avatar = '' AND " . $db->sql_in_set('user_id', $user_id_ary); $db->sql_query($sql); From ddec4e00d54c3c6e409cdf005442d36ccd9cf120 Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Sun, 20 Jan 2013 20:59:27 +0100 Subject: [PATCH 078/174] [ticket/9492] Fix missing phpbb_container in unit tests PHPBB3-9492 --- tests/functions_user/group_user_attributes_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 35d0b9e348..f13156c2cc 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -125,7 +125,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes */ public function test_group_user_attributes($description, $user_id, $group_id, $group_row, $expected) { - global $auth, $cache, $db, $phpbb_dispatcher, $user; + global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container; $user->ip = ''; $cache = new phpbb_mock_cache; @@ -134,6 +134,13 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) ->method('acl_clear_prefetch'); + $cache_driver = new phpbb_cache_driver_null(); + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container + ->expects($this->any()) + ->method('get') + ->with('cache.driver') + ->will($this->returnValue($cache_driver)); group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); From 95c9095a1c7149c3ad0b98e59bc8e951e12e6a7a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin <cyberalien@gmail.com> Date: Mon, 21 Jan 2013 12:34:28 +0200 Subject: [PATCH 079/174] [ticket/11329] Moving colors to colours.css Moving color values from buttons.css to colours.css PHPBB3-11329 --- phpBB/styles/prosilver/theme/buttons.css | 25 ++++------------------ phpBB/styles/prosilver/theme/colours.css | 27 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 543d9d8183..c3210887b6 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -23,19 +23,11 @@ height: 18px; font-size: 13px; white-space: nowrap; - border: 1px solid #c7c3bf; + border: 1px solid transparent; border-radius: 4px; - background: #fff none 0 0 repeat-x; - background-image: -moz-linear-gradient(top, #fff, #e9e9e9); - background-image: -webkit-linear-gradient(top, #fff, #e9e9e9); - background-image: -o-linear-gradient(top, #fff, #e9e9e9); - background-image: linear-gradient(to bottom, #fff, #e9e9e9); - -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#e9e9e9')"; - box-shadow: 0 0 0 1px #fff inset; - -webkit-box-shadow: 0 0 0 1px #fff inset; + background: transparent none 0 0 repeat-x; padding: 2px 22px 2px 8px; font-family: Verdana, Arial, Helvetica; - color: #bc2a4d !important; position: relative; text-decoration: none !important; outline-style: none !important; @@ -45,16 +37,6 @@ .buttons div span { display: none; } -.buttons div a:hover { - border-color: #0a8ed0; - background-image: -moz-linear-gradient(top, #e9e9e9, #fff); - background-image: -webkit-linear-gradient(top, #e9e9e9, #fff); - background-image: -o-linear-gradient(top, #e9e9e9, #fff); - background-image: linear-gradient(to bottom, #e9e9e9, #fff); - -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#e9e9e9', EndColorStr='#ffffff')"; - text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, -1px -1px 0 rgba(188, 42, 77, 0.2); -} - .buttons div a:after { content: ''; display: block; @@ -64,12 +46,13 @@ width: 12px; height: 12px; margin-top: -6px; - background: url("images/buttons.png") 0px 0 no-repeat; + background: transparent 0 0 no-repeat; } .buttons div a:hover:after { background-position: 0 -20px; } + /* Big button images */ .buttons div.reply-icon a:after, .buttons div.pmreply-icon a:after { background-position: -20px 0; } .buttons div.reply-icon a:hover:after, .buttons div.pmreply-icon a:hover:after { background-position: -20px -20px; } diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 0a8e011171..65d27ed58d 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -657,6 +657,33 @@ a.sendemail { background-image: url("./images/icon_sendemail.gif"); } +.buttons div a { + border-color: #C7C3BF; + background-color: #FFFFFF; + background-image: -moz-linear-gradient(top, #FFFFFF, #E9E9E9); + background-image: -webkit-linear-gradient(top, #FFFFFF, #E9E9E9); + background-image: -o-linear-gradient(top, #FFFFFF, #E9E9E9); + background-image: linear-gradient(to bottom, #FFFFFF, #E9E9E9); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#FFFFFF', EndColorStr='#E9E9E9')"; + box-shadow: 0 0 0 1px #FFFFFF inset; + -webkit-box-shadow: 0 0 0 1px #FFFFFF inset; + color: #BC2A4D !important; +} + +.buttons div a:hover { + border-color: #0a8ed0; + background-image: -moz-linear-gradient(top, #E9E9E9, #FFFFFF); + background-image: -webkit-linear-gradient(top, #E9E9E9, #FFFFFF); + background-image: -o-linear-gradient(top, #E9E9E9, #FFFFFF); + background-image: linear-gradient(to bottom, #E9E9E9, #FFFFFF); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#E9E9E9', EndColorStr='#FFFFFF')"; + text-shadow: 1px 1px 0 #FFFFFF, -1px -1px 0 #FFFFFF, -1px -1px 0 rgba(188, 42, 77, 0.2); +} + +.buttons div a:after { + background-image: url("images/buttons.png"); +} + /* Icon images ---------------------------------------- */ .sitehome { background-image: url("./images/icon_home.gif"); } From aa7350eba731496e11956b78d99d57aeaafaad58 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Tue, 22 Jan 2013 20:12:24 +0100 Subject: [PATCH 080/174] [ticket/11338] Travis: Define Redis hostname so unit tests for Redis run. PHPBB3-11338 --- travis/phpunit-mysql-travis.xml | 1 + travis/phpunit-postgres-travis.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index cc033ff959..f5f1aa2417 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -34,6 +34,7 @@ <server name="PHPBB_TEST_DBNAME" value="phpbb_tests" /> <server name="PHPBB_TEST_DBUSER" value="root" /> <server name="PHPBB_TEST_DBPASSWD" value="" /> + <server name="PHPBB_TEST_REDIS_HOST" value="localhost" /> <server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/> </php> </phpunit> diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 5019c225b4..a202ec4a36 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -36,6 +36,7 @@ <server name="PHPBB_TEST_DBNAME" value="phpbb_tests" /> <server name="PHPBB_TEST_DBUSER" value="postgres" /> <server name="PHPBB_TEST_DBPASSWD" value="" /> + <server name="PHPBB_TEST_REDIS_HOST" value="localhost" /> <server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/> </php> </phpunit> From dfabdbca508a3fbd60c8df57ea756a974f4f135b Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Tue, 22 Jan 2013 13:19:49 -0600 Subject: [PATCH 081/174] [ticket/9737] Fix a few minor things in migrations PHPBB3-9737 --- phpBB/includes/db/migration/exception.php | 7 ++++++- phpBB/includes/db/migrator.php | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php index bd46a4e064..ffdcd97780 100644 --- a/phpBB/includes/db/migration/exception.php +++ b/phpBB/includes/db/migration/exception.php @@ -22,7 +22,10 @@ if (!defined('IN_PHPBB')) */ class phpbb_db_migration_exception extends \Exception { - /** @var array Extra parameters sent to exception to aid in debugging */ + /** + * Extra parameters sent to exception to aid in debugging + * @var array + */ protected $parameters; /** @@ -42,6 +45,8 @@ class phpbb_db_migration_exception extends \Exception /** * Output the error as a string + * + * @return string */ public function __toString() { diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index d95283ae01..4456600b0a 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -394,7 +394,7 @@ class phpbb_db_migrator } /** - * Attempts to apply a step of the given migration or one of its dependencies + * Attempts to revert a step of the given migration or one of its dependencies * * @param string The class name of the migration * @return bool Whether any update step was successfully run @@ -559,12 +559,12 @@ class phpbb_db_migrator /** * Get a callable statement from a data step * - * @param mixed $step Data step from migration + * @param array $step Data step from migration * @param mixed $last_result Result to pass to the callable (only for 'custom' method) * @param bool $reverse False to install, True to attempt uninstallation by reversing the call * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters */ - protected function get_callable_from_step($step, $last_result = false, $reverse = false) + protected function get_callable_from_step(array $step, $last_result = false, $reverse = false) { $type = $step[0]; $parameters = $step[1]; From 317964174e9a70972d4c783feb318cb138e2bd57 Mon Sep 17 00:00:00 2001 From: Senky <jakubsenko@gmail.com> Date: Sat, 19 Jan 2013 12:31:53 +0100 Subject: [PATCH 082/174] [ticket/10050] adding .topicrow to template condition PHPBB3-10050 --- phpBB/styles/prosilver/template/viewforum_body.html | 2 +- phpBB/styles/subsilver2/template/viewforum_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 02f42fa097..4b9c514932 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -57,7 +57,7 @@ <!-- IF PAGINATION or TOTAL_POSTS or TOTAL_TOPICS --> <div class="pagination"> - <!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a> • <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF --> + <!-- IF not S_IS_BOT and U_MARK_TOPICS and .topicrow --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a> • <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF --> <!-- IF PAGE_NUMBER --> <!-- IF PAGINATION --> • <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> • <span>{PAGINATION}</span><!-- ELSE --> • {PAGE_NUMBER}<!-- ENDIF --> <!-- ENDIF --> diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index 6511fa5349..ee6ec26ab2 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -155,7 +155,7 @@ <table width="100%" cellspacing="0"> <tr class="nav"> <td valign="middle"> <!-- IF S_WATCH_FORUM_LINK and not S_IS_BOT --><a href="{S_WATCH_FORUM_LINK}">{S_WATCH_FORUM_TITLE}</a><!-- ENDIF --></td> - <td align="{S_CONTENT_FLOW_END}" valign="middle"><!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a><!-- ENDIF --> </td> + <td align="{S_CONTENT_FLOW_END}" valign="middle"><!-- IF not S_IS_BOT and U_MARK_TOPICS and .topicrow --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a><!-- ENDIF --> </td> </tr> </table> </td> From bd180b8e3867c0b66d7ce4edd96502244d9d71c1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Wed, 23 Jan 2013 01:39:39 +0100 Subject: [PATCH 083/174] [ticket/11338] Travis CI: Install PHP extension for redis key-value store. PHPBB3-11338 --- .travis.yml | 1 + travis/install-php-extensions.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 travis/install-php-extensions.sh diff --git a/.travis.yml b/.travis.yml index d7c472cd72..616bd7d4db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_script: - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi" - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" + - travis/install-php-extensions.sh - pyrus set auto_discover 1 - pyrus install --force phpunit/DbUnit - phpenv rehash diff --git a/travis/install-php-extensions.sh b/travis/install-php-extensions.sh new file mode 100755 index 0000000000..55955c2905 --- /dev/null +++ b/travis/install-php-extensions.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# @copyright (c) 2013 phpBB Group +# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +# +set -e + +function add_ext_to_php_ini +{ + echo "extension=$1.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` +} + +# redis +git clone git://github.com/nicolasff/phpredis.git +cd phpredis +phpize +./configure +make +make install +cd .. +add_ext_to_php_ini 'redis' From dee1b38ebcf4249a0204773c255e8ac8e348cb23 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Tue, 22 Jan 2013 19:54:48 +0100 Subject: [PATCH 084/174] [ticket/11337] Run functional tests on travis using nginx and php-fpm. PHPBB3-11337 --- .travis.yml | 1 + travis/phpunit-mysql-travis.xml | 1 + travis/phpunit-postgres-travis.xml | 1 + travis/setup-webserver.sh | 53 ++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100755 travis/setup-webserver.sh diff --git a/.travis.yml b/.travis.yml index ba8c1b4a91..09c5059749 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ before_script: - cd phpBB - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then php ../composer.phar install --dev; fi" - cd .. + - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then travis/setup-webserver.sh; fi" script: - phpunit --configuration travis/phpunit-$DB-travis.xml diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index 5366494c8b..df97f1c0f0 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -35,5 +35,6 @@ <server name="PHPBB_TEST_DBUSER" value="root" /> <server name="PHPBB_TEST_DBPASSWD" value="" /> <server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/> + <server name="PHPBB_FUNCTIONAL_URL" value="http://localhost/" /> </php> </phpunit> diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 0383edd9d6..49c001b717 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -37,5 +37,6 @@ <server name="PHPBB_TEST_DBUSER" value="postgres" /> <server name="PHPBB_TEST_DBPASSWD" value="" /> <server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/> + <server name="PHPBB_FUNCTIONAL_URL" value="http://localhost/" /> </php> </phpunit> diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh new file mode 100755 index 0000000000..c475f0f7ff --- /dev/null +++ b/travis/setup-webserver.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# @copyright (c) 2013 phpBB Group +# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +# + +sudo apt-get update -qq +sudo apt-get install -qq nginx realpath + +sudo service nginx stop + +DIR=$(dirname "$0") +PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB") + +NGINX_CONF="/etc/nginx/sites-enabled/default" + +PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm" +PHP_FPM_CONF="$DIR/php-fpm.conf" +PHP_FPM_SOCK=$(realpath "$DIR")/php-fpm.sock + +USER=$(whoami) + +# php-fpm configuration +echo " +[global] + +[travis] +user = $USER +group = $USER +listen = $PHP_FPM_SOCK +pm = static +pm.max_children = 2 + +php_admin_value[memory_limit] = 128M +" | sudo tee $PHP_FPM_CONF + +# nginx configuration +echo " +server { + listen 80; + root $PHPBB_ROOT_PATH/; + index index.php index.html; + + location ~ \.php$ { + fastcgi_pass unix:$PHP_FPM_SOCK; + include fastcgi_params; + } +} +" | sudo tee $NGINX_CONF + +# Start daemons +sudo $PHP_FPM_BIN --fpm-config "$DIR/php-fpm.conf" +sudo service nginx start From d2f09a9e65c71aaae6753e7f715333374a0bd455 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Tue, 22 Jan 2013 20:21:19 +0100 Subject: [PATCH 085/174] [ticket/11337] php-fpm.conf is no longer owned by root. PHPBB3-11337 --- travis/setup-webserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index c475f0f7ff..d2ee42f862 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -32,7 +32,7 @@ pm = static pm.max_children = 2 php_admin_value[memory_limit] = 128M -" | sudo tee $PHP_FPM_CONF +" > $PHP_FPM_CONF # nginx configuration echo " From ea1c8ee85a30d44ceb63a4c8210541bfb01edff2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Tue, 22 Jan 2013 20:21:41 +0100 Subject: [PATCH 086/174] [ticket/11337] Silence nginx config file writing. PHPBB3-11337 --- travis/setup-webserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index d2ee42f862..ad63508ca6 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -46,7 +46,7 @@ server { include fastcgi_params; } } -" | sudo tee $NGINX_CONF +" | sudo tee $NGINX_CONF > /dev/null # Start daemons sudo $PHP_FPM_BIN --fpm-config "$DIR/php-fpm.conf" From 9860cf6b165f71b58c69da0bfc42e27bea1c24c9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Wed, 23 Jan 2013 00:26:38 +0100 Subject: [PATCH 087/174] [ticket/11337] Only run functional tests on 5.3.19 or higher. No FPM otherwise. There is no php-fpm for PHP 5.3.3. Make sure PHP version is at least 5.3.19, which is what 5.3 is currently aliased to. PHPBB3-11337 --- .travis.yml | 2 +- travis/phpunit-mysql-travis.xml | 2 +- travis/phpunit-postgres-travis.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09c5059749..0bb6920412 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: - cd phpBB - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then php ../composer.phar install --dev; fi" - cd .. - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then travis/setup-webserver.sh; fi" + - sh -c "if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` = "1" ]; then travis/setup-webserver.sh; fi" script: - phpunit --configuration travis/phpunit-$DB-travis.xml diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index df97f1c0f0..179a2a358e 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -17,7 +17,7 @@ <exclude>tests/functional</exclude> </testsuite> <testsuite name="phpBB Functional Tests"> - <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">../tests/functional</directory> + <directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory> </testsuite> </testsuites> diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 49c001b717..12e20547ba 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -17,7 +17,7 @@ <exclude>tests/functional</exclude> </testsuite> <testsuite name="phpBB Functional Tests"> - <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">../tests/functional</directory> + <directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory> </testsuite> </testsuites> From 4b9c163969cfffc302780d48015453a3ce472dca Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Wed, 23 Jan 2013 00:55:11 +0100 Subject: [PATCH 088/174] [ticket/11337] Abort setup-webserver.sh script when an error occurs. PHPBB3-11337 --- travis/setup-webserver.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index ad63508ca6..beb04b0fef 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -3,6 +3,7 @@ # @copyright (c) 2013 phpBB Group # @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 # +set -e sudo apt-get update -qq sudo apt-get install -qq nginx realpath From 7338bfe3f08b829b97a2045b6bb029dd6b3ba54a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Wed, 23 Jan 2013 09:45:20 -0600 Subject: [PATCH 089/174] [ticket/9737] Fix some comments PHPBB3-9737 --- phpBB/includes/db/migration/migration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migration/migration.php b/phpBB/includes/db/migration/migration.php index cf1e97b3b1..5f14a6953c 100644 --- a/phpBB/includes/db/migration/migration.php +++ b/phpBB/includes/db/migration/migration.php @@ -74,7 +74,7 @@ abstract class phpbb_db_migration } /** - * Defines other migrations to be applied first (abstract method) + * Defines other migrations to be applied first * * @return array An array of migration class names */ @@ -84,7 +84,7 @@ abstract class phpbb_db_migration } /** - * Allows you to check if the migration is effectively installed (entirely optionall) + * Allows you to check if the migration is effectively installed (entirely optional) * * This is checked when a migration is installed. If true is returned, the migration will be set as * installed without performing the database changes. From 80283646e26661c32dbac14c059a453c7285deb4 Mon Sep 17 00:00:00 2001 From: Senky <jakubsenko@gmail.com> Date: Thu, 24 Jan 2013 22:54:12 +0100 Subject: [PATCH 090/174] [ticket/10050] removing prosilver edits PHPBB3-10050 --- phpBB/styles/prosilver/template/viewforum_body.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 4b9c514932..02f42fa097 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -57,7 +57,7 @@ <!-- IF PAGINATION or TOTAL_POSTS or TOTAL_TOPICS --> <div class="pagination"> - <!-- IF not S_IS_BOT and U_MARK_TOPICS and .topicrow --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a> • <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF --> + <!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a> • <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF --> <!-- IF PAGE_NUMBER --> <!-- IF PAGINATION --> • <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> • <span>{PAGINATION}</span><!-- ELSE --> • {PAGE_NUMBER}<!-- ENDIF --> <!-- ENDIF --> From 7203f39f87b7910d8565eccca2523313cacf828f Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Fri, 25 Jan 2013 17:10:43 +0100 Subject: [PATCH 091/174] [ticket/11295] Correct cases: replace postgres with phpbb_db_driver_postgres. PHPBB3-11295 --- .../test_framework/phpbb_database_test_connection_manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index c9bdd185d6..29058cc815 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -186,7 +186,7 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; - case 'postgres': + case 'phpbb_db_driver_postgres': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -429,7 +429,7 @@ class phpbb_database_test_connection_manager } break; - case 'postgres': + case 'phpbb_db_driver_postgres': $sql = 'SELECT sequence_name FROM information_schema.sequences'; $result = $this->pdo->query($sql); From 305b2b8f4876e9a11c30a36b10a92b112db47864 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Fri, 25 Jan 2013 19:49:02 +0100 Subject: [PATCH 092/174] [ticket/11343] Use === when checking stored user_actkey against user input. Use strict comparison when checking whether stored user_actkey is equal to user input. PHPBB3-11343 --- phpBB/includes/ucp/ucp_activate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 82c1937919..1177d55c12 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -51,7 +51,7 @@ class ucp_activate trigger_error('ALREADY_ACTIVATED'); } - if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] != $key) + if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] !== $key) { trigger_error('WRONG_ACTIVATION'); } From 8421aa0b0e5607765593126de959bab113427272 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Fri, 25 Jan 2013 19:51:17 +0100 Subject: [PATCH 093/174] [ticket/11343] Remove spare space. PHPBB3-11343 --- phpBB/includes/ucp/ucp_activate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 1177d55c12..9e545cd747 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -51,7 +51,7 @@ class ucp_activate trigger_error('ALREADY_ACTIVATED'); } - if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] !== $key) + if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] !== $key) { trigger_error('WRONG_ACTIVATION'); } From 5a146df07f62f9963b3ec313ef27a72183f295db Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Fri, 25 Jan 2013 19:52:02 +0100 Subject: [PATCH 094/174] [ticket/11343] Remove spare parentheses. PHPBB3-11343 --- phpBB/includes/ucp/ucp_activate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 9e545cd747..b262dc5c1c 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -51,7 +51,7 @@ class ucp_activate trigger_error('ALREADY_ACTIVATED'); } - if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] !== $key) + if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL || $user_row['user_actkey'] !== $key) { trigger_error('WRONG_ACTIVATION'); } From 36b7d7560e55ee570a2e2f5991982be6c8e66487 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Mon, 28 Jan 2013 22:26:20 +0530 Subject: [PATCH 095/174] [ticket/11233] prohibit selecting anonymous user as a PM recipient While composing pm, it should not be allowed to add anonymous user as a PM recipient PHPBB3-11233 --- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index d1786dd9ba..8e82188aff 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -359,7 +359,7 @@ function compose_pm($id, $mode, $action, $user_folders = array()) $message_attachment = 0; $message_text = $message_subject = ''; - if ($to_user_id && $action == 'post') + if ($to_user_id && $to_user_id != ANONYMOUS && $action == 'post') { $address_list['u'][$to_user_id] = 'to'; } From 75244eafd946bb157ec5e54d5ec2ba3a309ae3ab Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Wed, 30 Jan 2013 16:20:50 -0600 Subject: [PATCH 096/174] [feature/migrations] Revert unrelated changes to functions.php PHPBB3-9737 --- phpBB/includes/functions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 057bdba0e3..d0ef2759d5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2868,7 +2868,6 @@ function send_status_line($code, $message) else { $version = phpbb_request_http_version(); - header("$version $code $message", true, $code); } } @@ -5583,7 +5582,7 @@ function phpbb_convert_30_dbms_to_31($dbms) /* $reflection = new \ReflectionClass($dbms); - + if ($reflection->isSubclassOf('phpbb_db_driver')) { return $dbms; From cf3edb2c6e7f18e143e6627a8f9a5848df74f6ec Mon Sep 17 00:00:00 2001 From: Crizz0 <mail@crizzo.de> Date: Sun, 27 Jan 2013 21:13:49 +0100 Subject: [PATCH 097/174] [ticket/11220] Improvement to the info pop-up from "list=" A improvement to the info popup which is displayed when the cursor is over the bbcode-button [list=] in the posting-editor PHPBB3-11220 --- phpBB/language/en/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index 24f3204c57..dfc5065a05 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -54,9 +54,9 @@ $lang = array_merge($lang, array( 'BBCODE_IS_OFF' => '%sBBCode%s is <em>OFF</em>', 'BBCODE_IS_ON' => '%sBBCode%s is <em>ON</em>', 'BBCODE_I_HELP' => 'Italic text: [i]text[/i]', - 'BBCODE_L_HELP' => 'List: [list]text[/list]', - 'BBCODE_LISTITEM_HELP' => 'List item: [*]text[/*]', - 'BBCODE_O_HELP' => 'Ordered list: [list=]text[/list]', + 'BBCODE_L_HELP' => 'List: [list][*]text[/list]', + 'BBCODE_LISTITEM_HELP' => 'List item: [*]text', + 'BBCODE_O_HELP' => 'Ordered list: e.g. [list=1][*]First point[/list] or [list=a][*]Point a[/list]', 'BBCODE_P_HELP' => 'Insert image: [img]http://image_url[/img]', 'BBCODE_Q_HELP' => 'Quote text: [quote]text[/quote]', 'BBCODE_S_HELP' => 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000', From a54128b3bc146fa6f46bd10c712253e568352ec8 Mon Sep 17 00:00:00 2001 From: Marc Alexander <admin@m-a-styles.de> Date: Sun, 3 Feb 2013 15:51:29 +0100 Subject: [PATCH 098/174] [ticket/11342] Mark active topics read when marking forums read Marking forums read while viewing a category will also mark the active topics inside that category read. Therefore, the active topics should also be marked read. With this patch the ajax callback "mark_forums_read" will check if the active topics id ("active_topics") exists and also mark topics read if it does. As the active topics will only be displayed in categories, which can't have any other topics, this is a proper approach. PHPBB3-11342 --- phpBB/styles/prosilver/template/ajax.js | 18 +++++++++++++++--- .../prosilver/template/viewforum_body.html | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 6ce3b38981..b2a27089f7 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -37,14 +37,24 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) { // Mark subforums read $('a.subforum[class*="unread"]').removeClass('unread').addClass('read'); + // Mark topics read if we are watching a category and showing active topics + if ($('#active_topics').length) { + phpbb.ajaxCallbacks['mark_topics_read'].call(this, res, false); + } + // Update mark forums read links $('[data-ajax="mark_forums_read"]').attr('href', res.U_MARK_FORUMS); phpbb.closeDarkenWrapper(3000); }); -// This callback will mark all topic icons read -phpbb.addAjaxCallback('mark_topics_read', function(res) { +/** +* This callback will mark all topic icons read +* +* @param update_topic_links bool Wether "Mark topics read" links should be +* updated. Defaults to true. +*/ +phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links = true) { var readTitle = res.NO_UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS; var iconsArray = { @@ -85,7 +95,9 @@ phpbb.addAjaxCallback('mark_topics_read', function(res) { $('a').has('span.icon_topic_newest').remove(); // Update mark topics read links - $('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS); + if (update_topic_links) { + $('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS); + } phpbb.closeDarkenWrapper(3000); }); diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index e0aef4f290..38566dece0 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -130,7 +130,7 @@ <ul class="topiclist"> <li class="header"> <dl class="icon"> - <dt><!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS}<!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) -->{L_ANNOUNCEMENTS}<!-- ELSE -->{L_TOPICS}<!-- ENDIF --></dt> + <dt<!-- IF S_DISPLAY_ACTIVE --> id="active_topics"<!-- ENDIF -->><!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS}<!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) -->{L_ANNOUNCEMENTS}<!-- ELSE -->{L_TOPICS}<!-- ENDIF --></dt> <dd class="posts">{L_REPLIES}</dd> <dd class="views">{L_VIEWS}</dd> <dd class="lastpost"><span>{L_LAST_POST}</span></dd> From 336187151a2010197ddda1bcdabc311fd10c1c87 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Mon, 4 Feb 2013 01:30:04 +0100 Subject: [PATCH 099/174] [ticket/11201] Revert WLM dropping because it is still used in China. Windows Live Messenger is still in use in china which accounts for ~20% of world population. Revert WLM dropping which has been merged under the assumption that WLM data and features are completely useless. This commit reverts commits - 460470229d972b93ef5a98b0d1d97a2a970d684f - 9affd6f7e7b95442f1ef14894858d8213f3fbd2a which have been merged by d59431691c27c73fba8ae9934b84b34a13280dd2. PHPBB3-11201 --- phpBB/adm/style/acp_users_profile.html | 4 + phpBB/develop/benchmark.php | 5 +- phpBB/develop/create_schema_files.php | 1 + phpBB/develop/mysql_upgrader.php | 1 + phpBB/includes/acp/acp_users.php | 4 + phpBB/includes/ucp/ucp_pm_viewmessage.php | 1 + phpBB/includes/ucp/ucp_profile.php | 4 + phpBB/install/convertors/convert_phpbb20.php | 1 + phpBB/install/database_update.php | 5 -- phpBB/install/schemas/firebird_schema.sql | 1 + phpBB/install/schemas/mssql_schema.sql | 1 + phpBB/install/schemas/mysql_40_schema.sql | 1 + phpBB/install/schemas/mysql_41_schema.sql | 1 + phpBB/install/schemas/oracle_schema.sql | 1 + phpBB/install/schemas/postgres_schema.sql | 1 + phpBB/install/schemas/schema_data.sql | 4 +- phpBB/install/schemas/sqlite_schema.sql | 1 + phpBB/language/en/acp/styles.php | 1 + phpBB/language/en/common.php | 3 + phpBB/language/en/memberlist.php | 4 + phpBB/language/en/ucp.php | 1 + phpBB/memberlist.php | 22 ++++- .../prosilver/template/memberlist_im.html | 82 +++++++++++++++++- .../prosilver/template/memberlist_search.html | 4 + .../prosilver/template/memberlist_view.html | 1 + .../template/ucp_pm_viewmessage.html | 3 +- .../template/ucp_profile_profile_info.html | 4 + .../prosilver/template/viewtopic_body.html | 3 +- phpBB/styles/prosilver/theme/bidi.css | 2 +- phpBB/styles/prosilver/theme/buttons.css | 2 + phpBB/styles/prosilver/theme/colours.css | 1 + phpBB/styles/prosilver/theme/imageset.css | 5 ++ .../subsilver2/template/memberlist_im.html | 83 ++++++++++++++++++- .../template/memberlist_search.html | 8 +- .../subsilver2/template/memberlist_view.html | 4 + .../template/ucp_profile_profile_info.html | 4 + .../styles/subsilver2/theme/en/stylesheet.css | 5 ++ phpBB/styles/subsilver2/theme/stylesheet.css | 5 ++ phpBB/viewtopic.php | 4 + 39 files changed, 267 insertions(+), 21 deletions(-) diff --git a/phpBB/adm/style/acp_users_profile.html b/phpBB/adm/style/acp_users_profile.html index 36e9f340d4..3232e8d1f5 100644 --- a/phpBB/adm/style/acp_users_profile.html +++ b/phpBB/adm/style/acp_users_profile.html @@ -10,6 +10,10 @@ <dt><label for="aim">{L_UCP_AIM}{L_COLON}</label></dt> <dd><input type="text" id="aim" name="aim" value="{AIM}" /></dd> </dl> + <dl> + <dt><label for="msn">{L_UCP_MSNM}{L_COLON}</label></dt> + <dd><input type="text" id="msn" name="msn" value="{MSN}" /></dd> + </dl> <dl> <dt><label for="yim">{L_UCP_YIM}{L_COLON}</label></dt> <dd><input type="text" id="yim" name="yim" value="{YIM}" /></dd> diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php index 6517954dfe..c867b9262e 100644 --- a/phpBB/develop/benchmark.php +++ b/phpBB/develop/benchmark.php @@ -377,6 +377,7 @@ function make_user($username) $viewemail = 0; $aim = 0; $yim = 0; + $msn = 0; $attachsig = 1; $allowsmilies = 1; $allowhtml = 1; @@ -421,8 +422,8 @@ function make_user($username) } - $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) - VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; + $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) + VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; $sql .= "1, '')"; diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index c6012a633f..0ae75c2681 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1836,6 +1836,7 @@ function get_schema_struct() 'user_icq' => array('VCHAR:15', ''), 'user_aim' => array('VCHAR_UNI', ''), 'user_yim' => array('VCHAR_UNI', ''), + 'user_msnm' => array('VCHAR_UNI', ''), 'user_jabber' => array('VCHAR_UNI', ''), 'user_website' => array('VCHAR_UNI:200', ''), 'user_occ' => array('TEXT_UNI', ''), diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index ca738aabf6..7f82ebfeab 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -1265,6 +1265,7 @@ function get_schema_struct() 'user_icq' => array('VCHAR:15', ''), 'user_aim' => array('VCHAR_UNI', ''), 'user_yim' => array('VCHAR_UNI', ''), + 'user_msnm' => array('VCHAR_UNI', ''), 'user_jabber' => array('VCHAR_UNI', ''), 'user_website' => array('VCHAR_UNI:200', ''), 'user_occ' => array('TEXT_UNI', ''), diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 2bdbf1441a..82d8ef5cbb 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1352,6 +1352,7 @@ class acp_users $data = array( 'icq' => request_var('icq', $user_row['user_icq']), 'aim' => request_var('aim', $user_row['user_aim']), + 'msn' => request_var('msn', $user_row['user_msnm']), 'yim' => request_var('yim', $user_row['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), 'website' => request_var('website', $user_row['user_website']), @@ -1381,6 +1382,7 @@ class acp_users array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), + 'msn' => array('string', true, 5, 255), 'jabber' => array( array('string', true, 5, 255), array('jabber')), @@ -1414,6 +1416,7 @@ class acp_users $sql_ary = array( 'user_icq' => $data['icq'], 'user_aim' => $data['aim'], + 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], @@ -1466,6 +1469,7 @@ class acp_users 'ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], + 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index a1001cfa74..c85b05f144 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -241,6 +241,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/' . urlencode($user_info['user_icq']) . '/' : '', 'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $author_id) : '', 'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '', + 'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $author_id) : '', 'U_JABBER' => ($user_info['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $author_id) : '', 'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '', diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index c1ad9955b6..e7cea06a45 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -266,6 +266,7 @@ class ucp_profile $data = array( 'icq' => request_var('icq', $user->data['user_icq']), 'aim' => request_var('aim', $user->data['user_aim']), + 'msn' => request_var('msn', $user->data['user_msnm']), 'yim' => request_var('yim', $user->data['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)), 'website' => request_var('website', $user->data['user_website']), @@ -298,6 +299,7 @@ class ucp_profile array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), + 'msn' => array('string', true, 5, 255), 'jabber' => array( array('string', true, 5, 255), array('jabber')), @@ -349,6 +351,7 @@ class ucp_profile $sql_ary = array( 'user_icq' => $data['icq'], 'user_aim' => $data['aim'], + 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], @@ -420,6 +423,7 @@ class ucp_profile 'ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], + 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index 6792f4ff9c..5f30625980 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -896,6 +896,7 @@ if (!$get_info) array('user_occ', 'users.user_occ', array('function1' => 'phpbb_set_encoding')), array('user_website', 'users.user_website', 'validate_website'), array('user_jabber', '', ''), + array('user_msnm', 'users.user_msnm', array('function1' => 'phpbb_set_encoding')), array('user_yim', 'users.user_yim', array('function1' => 'phpbb_set_encoding')), array('user_aim', 'users.user_aim', array('function1' => 'phpbb_set_encoding')), array('user_icq', 'users.user_icq', array('function1' => 'phpbb_set_encoding')), diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4a61d189a3..4e17a1429c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1196,11 +1196,6 @@ function database_update_info() 'user_timezone' => array('VCHAR:100', ''), ), ), - 'drop_columns' => array( - USERS_TABLE => array( - 'user_msnm', - ), - ), ), ); } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index b475303fde..bd97fefb36 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -1284,6 +1284,7 @@ CREATE TABLE phpbb_users ( user_icq VARCHAR(15) CHARACTER SET NONE DEFAULT '' NOT NULL, user_aim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_yim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 0420738828..bb0890e439 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1568,6 +1568,7 @@ CREATE TABLE [phpbb_users] ( [user_icq] [varchar] (15) DEFAULT ('') NOT NULL , [user_aim] [varchar] (255) DEFAULT ('') NOT NULL , [user_yim] [varchar] (255) DEFAULT ('') NOT NULL , + [user_msnm] [varchar] (255) DEFAULT ('') NOT NULL , [user_jabber] [varchar] (255) DEFAULT ('') NOT NULL , [user_website] [varchar] (200) DEFAULT ('') NOT NULL , [user_occ] [varchar] (4000) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 18f8560e87..bf3d7fecfa 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -932,6 +932,7 @@ CREATE TABLE phpbb_users ( user_icq varbinary(15) DEFAULT '' NOT NULL, user_aim blob NOT NULL, user_yim blob NOT NULL, + user_msnm blob NOT NULL, user_jabber blob NOT NULL, user_website blob NOT NULL, user_occ blob NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index bc3cfb4249..372b63d83c 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -932,6 +932,7 @@ CREATE TABLE phpbb_users ( user_icq varchar(15) DEFAULT '' NOT NULL, user_aim varchar(255) DEFAULT '' NOT NULL, user_yim varchar(255) DEFAULT '' NOT NULL, + user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, user_occ text NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index f20b96cd38..671347ebe1 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1680,6 +1680,7 @@ CREATE TABLE phpbb_users ( user_icq varchar2(15) DEFAULT '' , user_aim varchar2(765) DEFAULT '' , user_yim varchar2(765) DEFAULT '' , + user_msnm varchar2(765) DEFAULT '' , user_jabber varchar2(765) DEFAULT '' , user_website varchar2(600) DEFAULT '' , user_occ clob DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 301654bf25..4c13bf0ba9 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -1182,6 +1182,7 @@ CREATE TABLE phpbb_users ( user_icq varchar(15) DEFAULT '' NOT NULL, user_aim varchar(255) DEFAULT '' NOT NULL, user_yim varchar(255) DEFAULT '' NOT NULL, + user_msnm varchar(255) DEFAULT '' NOT NULL, user_jabber varchar(255) DEFAULT '' NOT NULL, user_website varchar(200) DEFAULT '' NOT NULL, user_occ varchar(4000) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 19c00ef9fb..7c1a7d40f5 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -454,10 +454,10 @@ INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); # -- Users / Anonymous user -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); # -- username: Admin password: admin (change this or remove it once everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', ''); +INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- Groups INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, 0, '', '', '', 5); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 397cfc139a..46a96a1edd 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -906,6 +906,7 @@ CREATE TABLE phpbb_users ( user_icq varchar(15) NOT NULL DEFAULT '', user_aim varchar(255) NOT NULL DEFAULT '', user_yim varchar(255) NOT NULL DEFAULT '', + user_msnm varchar(255) NOT NULL DEFAULT '', user_jabber varchar(255) NOT NULL DEFAULT '', user_website varchar(200) NOT NULL DEFAULT '', user_occ text(65535) NOT NULL DEFAULT '', diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index 3cb2e741ca..e7954ff148 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -186,6 +186,7 @@ $lang = array_merge($lang, array( 'IMG_ICON_CONTACT_EMAIL' => 'Send email', 'IMG_ICON_CONTACT_ICQ' => 'ICQ', 'IMG_ICON_CONTACT_JABBER' => 'Jabber', + 'IMG_ICON_CONTACT_MSNM' => 'WLM', 'IMG_ICON_CONTACT_PM' => 'Send message', 'IMG_ICON_CONTACT_YAHOO' => 'YIM', 'IMG_ICON_CONTACT_WWW' => 'Website', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 63241b71b5..8158209a68 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -379,6 +379,7 @@ $lang = array_merge($lang, array( 'MODERATORS' => 'Moderators', 'MONTH' => 'Month', 'MOVE' => 'Move', + 'MSNM' => 'WLM', 'NA' => 'N/A', 'NEWEST_USER' => 'Our newest member <strong>%s</strong>', @@ -637,6 +638,7 @@ $lang = array_merge($lang, array( 'TOO_LONG_INTERESTS' => 'The interests you entered is too long.', 'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.', 'TOO_LONG_LOCATION' => 'The location you entered is too long.', + 'TOO_LONG_MSN' => 'The WLM name you entered is too long.', 'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.', 'TOO_LONG_OCCUPATION' => 'The occupation you entered is too long.', 'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.', @@ -657,6 +659,7 @@ $lang = array_merge($lang, array( 'TOO_SHORT_INTERESTS' => 'The interests you entered is too short.', 'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.', 'TOO_SHORT_LOCATION' => 'The location you entered is too short.', + 'TOO_SHORT_MSN' => 'The WLM name you entered is too short.', 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_OCCUPATION' => 'The occupation you entered is too short.', 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index bc5a0c100b..ec21e8e904 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -78,6 +78,9 @@ $lang = array_merge($lang, array( 'IM_JABBER' => 'Please note that users may have selected to not receive unsolicited instant messages.', 'IM_JABBER_SUBJECT' => 'This is an automated message please do not reply! Message from user %1$s at %2$s.', 'IM_MESSAGE' => 'Your message', + 'IM_MSNM' => 'Please note that you need Windows Live Messenger installed to use this.', + 'IM_MSNM_BROWSER' => 'Your browser does not support this.', + 'IM_MSNM_CONNECT' => 'WLM is not connected.\nYou have to connect to WLM to continue.', 'IM_NAME' => 'Your Name', 'IM_NO_DATA' => 'There is no suitable contact information for this user.', 'IM_NO_JABBER' => 'Sorry, direct messaging of Jabber users is not supported on this board. You will need a Jabber client installed on your system to contact the recipient above.', @@ -120,6 +123,7 @@ $lang = array_merge($lang, array( 'SEND_IM' => 'Instant messaging', 'SEND_JABBER_MESSAGE' => 'Send Jabber message', 'SEND_MESSAGE' => 'Message', + 'SEND_MSNM_MESSAGE' => 'Send WLM message', 'SEND_YIM_MESSAGE' => 'Send YIM message', 'SORT_EMAIL' => 'Email', 'SORT_LAST_ACTIVE' => 'Last active', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 2eb34b3713..267ae00710 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -455,6 +455,7 @@ $lang = array_merge($lang, array( 'UCP_MAIN_FRONT' => 'Front page', 'UCP_MAIN_SUBSCRIBED' => 'Manage subscriptions', + 'UCP_MSNM' => 'Windows Live Messenger', 'UCP_NO_ATTACHMENTS' => 'You have posted no files.', 'UCP_PREFS' => 'Board preferences', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index ebc1757810..e222d4478d 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -287,6 +287,13 @@ switch ($mode) $s_action = ''; break; + case 'msnm': + $lang = 'MSNM'; + $sql_field = 'user_msnm'; + $s_select = 'S_SEND_MSNM'; + $s_action = ''; + break; + case 'jabber': $lang = 'JABBER'; $sql_field = 'user_jabber'; @@ -633,6 +640,7 @@ switch ($mode) 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), + 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), @@ -976,8 +984,8 @@ switch ($mode) $template_html = 'memberlist_body.html'; // Sorting - $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']); - $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'j' => 'u.user_yim', 'k' => 'u.user_jabber'); + $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']); + $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber'); if ($auth->acl_get('a_user')) { @@ -1020,7 +1028,7 @@ switch ($mode) $select_single = request_var('select_single', false); // Search URL parameters, if any of these are in the URL we do a search - $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); + $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'msn', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); // We validate form and field here, only id/class allowed $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; @@ -1032,6 +1040,7 @@ switch ($mode) $icq = request_var('icq', ''); $aim = request_var('aim', ''); $yahoo = request_var('yahoo', ''); + $msn = request_var('msn', ''); $jabber = request_var('jabber', ''); $search_group_id = request_var('search_group_id', 0); @@ -1075,6 +1084,7 @@ switch ($mode) $sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : ''; $sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : ''; $sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : ''; + $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : ''; $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; @@ -1307,6 +1317,7 @@ switch ($mode) 'icq' => array('icq', ''), 'aim' => array('aim', ''), 'yahoo' => array('yahoo', ''), + 'msn' => array('msn', ''), 'jabber' => array('jabber', ''), 'search_group_id' => array('search_group_id', 0), 'joined_select' => array('joined_select', 'lt'), @@ -1438,6 +1449,7 @@ switch ($mode) 'ICQ' => $icq, 'AIM' => $aim, 'YAHOO' => $yahoo, + 'MSNM' => $msn, 'JABBER' => $jabber, 'JOINED' => implode('-', $joined), 'ACTIVE' => implode('-', $active), @@ -1593,6 +1605,7 @@ switch ($mode) 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), + 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), @@ -1608,6 +1621,7 @@ switch ($mode) 'U_SORT_LOCATION' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_ICQ' => $sort_url . '&sk=g&sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_AIM' => $sort_url . '&sk=h&sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'), + 'U_SORT_MSN' => $sort_url . '&sk=i&sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_YIM' => $sort_url . '&sk=j&sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&sk=l&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '', 'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'), @@ -1734,12 +1748,14 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '', 'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '', 'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&.src=pg' : '', + 'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '', 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', 'LOCATION' => ($data['user_from']) ? $data['user_from'] : '', 'USER_ICQ' => $data['user_icq'], 'USER_AIM' => $data['user_aim'], 'USER_YIM' => $data['user_yim'], + 'USER_MSN' => $data['user_msnm'], 'USER_JABBER' => $data['user_jabber'], 'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index 61b4a1469b..68aed0b3dd 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -1,5 +1,6 @@ <!-- INCLUDE simple_header.html --> +<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger --> <h2 class="solo">{L_SEND_IM}</h2> <form method="post" action="{S_IM_ACTION}"> @@ -12,7 +13,7 @@ <fieldset> <dl class="fields2"> <dt><label>{L_IM_RECIPIENT}{L_COLON}</label></dt> - <dd><strong>{USERNAME}</strong><!-- IF S_SEND_ICQ or S_SEND_AIM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --><!-- IF PRESENCE_IMG --> {PRESENCE_IMG}<!-- ENDIF --></dd> + <dd><strong>{USERNAME}</strong><!-- IF S_SEND_ICQ or S_SEND_AIM or S_SEND_MSNM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --><!-- IF PRESENCE_IMG --> {PRESENCE_IMG}<!-- ENDIF --></dd> </dl> <!-- IF S_SEND_ICQ --> @@ -42,6 +43,15 @@ </dl> <!-- ENDIF --> + <!-- IF S_SEND_MSNM --> + <dl class="fields2"> + <dt> </dt> + <dd><object classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" id="objMessengerApp" width="0" height="0"></object></dd> + <dd><a href="#" onclick="add_contact('{A_IM_CONTACT}'); return false;">{L_IM_ADD_CONTACT}</a></dd> + <dd><a href="#" onclick="im_contact('{A_IM_CONTACT}'); return false;">{L_IM_SEND_MESSAGE}</a></dd> + </dl> + <!-- ENDIF --> + <!-- IF S_SEND_JABBER --> <dl class="fields2"> <dt><label for="message">{L_IM_MESSAGE}{L_COLON}</label></dt> @@ -75,4 +85,74 @@ <a href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a> +<script type="text/javascript"> +// <![CDATA[ + + /** The following will not work with Windows Vista **/ + + var app = document.getElementById('objMessengerApp'); + + /** + * Check whether the browser supports this and whether MSNM is connected + */ + function msn_supported() + { + // Does the browser support the MSNM object? + if (app.MyStatus) + { + // Is MSNM connected? + if (app.MyStatus == 1) + { + alert('{LA_IM_MSNM_CONNECT}'); + return false; + } + } + else + { + alert('{LA_IM_MSNM_BROWSER}'); + return false; + } + return true; + } + + /** + * Add to your contact list + */ + function add_contact(address) + { + if (msn_supported()) + { + // Could return an error while MSNM is connecting, don't want that + try + { + app.AddContact(0, address); + } + catch (e) + { + return; + } + } +} + +/** +* Write IM to contact +*/ +function im_contact(address) +{ + if (msn_supported()) + { + // Could return an error while MSNM is connecting, don't want that + try + { + app.InstantMessage(address); + } + catch (e) + { + return; + } + } +} +// ]]> +</script> + <!-- INCLUDE simple_footer.html --> diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index ad8fb83fe4..9de3ccf41b 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -70,6 +70,10 @@ function insert_single(user) <dt><label for="yahoo">{L_YIM}{L_COLON}</label></dt> <dd><input type="text" name="yahoo" id="yahoo" value="{YAHOO}" class="inputbox" /></dd> </dl> + <dl> + <dt><label for="msn">{L_MSNM}{L_COLON}</label></dt> + <dd><input type="text" name="msn" id="msn" value="{MSNM}" class="inputbox" /></dd> + </dl> </fieldset> <fieldset class="fields1 column2"> diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 7f33e70e8f..57cfcb86d9 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -62,6 +62,7 @@ <!-- IF U_EMAIL --><dt>{L_EMAIL_ADDRESS}{L_COLON}</dt> <dd><a href="{U_EMAIL}">{L_SEND_EMAIL_USER} {USERNAME}</a></dd><!-- ENDIF --> <!-- IF U_WWW --><dt>{L_WEBSITE}{L_COLON}</dt> <dd><a href="{U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {U_WWW}">{U_WWW}</a></dd><!-- ENDIF --> <!-- IF U_PM --><dt>{L_PM}{L_COLON}</dt> <dd><a href="{U_PM}">{L_SEND_PRIVATE_MESSAGE}</a></dd><!-- ENDIF --> + <!-- IF U_MSN or USER_MSN --><dt>{L_MSNM}{L_COLON}</dt> <dd><!-- IF U_MSN --><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_MSNM_MESSAGE}</a><!-- ELSE -->{USER_MSN}<!-- ENDIF --></dd><!-- ENDIF --> <!-- IF U_YIM or USER_YIM --><dt>{L_YIM}{L_COLON}</dt> <dd><!-- IF U_YIM --><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false;">{L_SEND_YIM_MESSAGE}</a><!-- ELSE -->{USER_YIM}<!-- ENDIF --></dd><!-- ENDIF --> <!-- IF U_AIM or USER_AIM --><dt>{L_AIM}{L_COLON}</dt> <dd><!-- IF U_AIM --><a href="{U_AIM}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_AIM_MESSAGE}</a><!-- ELSE -->{USER_AIM}<!-- ENDIF --></dd><!-- ENDIF --> <!-- IF U_ICQ or USER_ICQ --><dt>{L_ICQ}{L_COLON}</dt> <dd><!-- IF U_ICQ --><a href="{U_ICQ}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_ICQ_MESSAGE}</a><!-- ELSE -->{USER_ICQ}<!-- ENDIF --></dd><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 23665aa252..22149c8b80 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -90,12 +90,13 @@ <!-- END custom_fields --> - <!-- IF U_PM or U_EMAIL or U_WWW or U_ICQ or U_YIM or U_AIM or U_JABBER --> + <!-- IF U_PM or U_EMAIL or U_WWW or U_MSN or U_ICQ or U_YIM or U_AIM or U_JABBER --> <dd> <ul class="profile-icons"> <!-- IF U_PM --><li class="pm-icon"><a href="{U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF --> <!-- IF U_EMAIL --><li class="email-icon"><a href="{U_EMAIL}" title="{L_SEND_EMAIL_USER} {MESSAGE_AUTHOR}"><span>{L_SEND_EMAIL_USER} {MESSAGE_AUTHOR}</span></a></li><!-- ENDIF --> <!-- IF U_WWW --><li class="web-icon"><a href="{U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF --> + <!-- IF U_MSN --><li class="msnm-icon"><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF --> <!-- IF U_ICQ --><li class="icq-icon"><a href="{U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF --> <!-- IF U_YIM --><li class="yahoo-icon"><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF --> <!-- IF U_AIM --><li class="aim-icon"><a href="{U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html index e8c6715de8..03d89e8590 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html +++ b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html @@ -18,6 +18,10 @@ <dt><label for="aim">{L_UCP_AIM}{L_COLON}</label></dt> <dd><input type="text" name="aim" id="aim" maxlength="255" value="{AIM}" class="inputbox" /></dd> </dl> + <dl> + <dt><label for="msn">{L_UCP_MSNM}{L_COLON}</label></dt> + <dd><input type="text" name="msn" id="msn" maxlength="255" value="{MSN}" class="inputbox" /></dd> + </dl> <dl> <dt><label for="yim">{L_UCP_YIM}{L_COLON}</label></dt> <dd><input type="text" name="yim" id="yim" maxlength="255" value="{YIM}" class="inputbox" /></dd> diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index e7bd3d5059..c9a6882b6f 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -216,12 +216,13 @@ <!-- END custom_fields --> <!-- IF not S_IS_BOT --> - <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER --> + <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER --> <dd> <ul class="profile-icons"> <!-- IF postrow.U_PM --><li class="pm-icon"><a href="{postrow.U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_EMAIL --><li class="email-icon"><a href="{postrow.U_EMAIL}" title="{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}"><span>{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_WWW --><li class="web-icon"><a href="{postrow.U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {postrow.U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF --> + <!-- IF postrow.U_MSN --><li class="msnm-icon"><a href="{postrow.U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_ICQ --><li class="icq-icon"><a href="{postrow.U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_YIM --><li class="yahoo-icon"><a href="{postrow.U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF --> <!-- IF postrow.U_AIM --><li class="aim-icon"><a href="{postrow.U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF --> diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index a43323d879..5cff0a811b 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -786,7 +786,7 @@ padding-right: 11px; padding-left: 0; } -.rtl .imageset.icon_contact_aim, .rtl .imageset.icon_contact_email, .rtl .imageset.icon_contact_icq, .rtl .imageset.icon_contact_jabber, .rtl .imageset.icon_contact_www, .rtl .imageset.icon_contact_yahoo, .rtl .imageset.icon_post_delete, .rtl .imageset.icon_post_info, .rtl .imageset.icon_post_report, .rtl .imageset.icon_user_warn { +.rtl .imageset.icon_contact_aim, .rtl .imageset.icon_contact_email, .rtl .imageset.icon_contact_icq, .rtl .imageset.icon_contact_jabber, .rtl .imageset.icon_contact_msnm, .rtl .imageset.icon_contact_www, .rtl .imageset.icon_contact_yahoo, .rtl .imageset.icon_post_delete, .rtl .imageset.icon_post_info, .rtl .imageset.icon_post_report, .rtl .imageset.icon_user_warn { padding-right: 20px; padding-left: 0; } diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 7739d511fa..c3210887b6 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -139,6 +139,7 @@ ul.profile-icons li a:hover { background: none; } .aim-icon, .aim-icon a { background: none top left no-repeat; } .yahoo-icon, .yahoo-icon a { background: none top left no-repeat; } .web-icon, .web-icon a { background: none top left no-repeat; } +.msnm-icon, .msnm-icon a { background: none top left no-repeat; } .icq-icon, .icq-icon a { background: none top left no-repeat; } .jabber-icon, .jabber-icon a { background: none top left no-repeat; } .pm-icon, .pm-icon a { background: none top left no-repeat; } @@ -156,6 +157,7 @@ ul.profile-icons li.email-icon { width: 20px; height: 20px; } ul.profile-icons li.aim-icon { width: 20px; height: 20px; } ul.profile-icons li.yahoo-icon { width: 20px; height: 20px; } ul.profile-icons li.web-icon { width: 20px; height: 20px; } +ul.profile-icons li.msnm-icon { width: 20px; height: 20px; } ul.profile-icons li.icq-icon { width: 20px; height: 20px; } ul.profile-icons li.jabber-icon { width: 20px; height: 20px; } ul.profile-icons li.pm-icon { width: 28px; height: 20px; } diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index a68692444a..364bca0cf0 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -705,6 +705,7 @@ a.sendemail { .aim-icon, .aim-icon a { background-image: url("./images/icon_contact_aim.gif"); } .yahoo-icon, .yahoo-icon a { background-image: url("./images/icon_contact_yahoo.gif"); } .web-icon, .web-icon a { background-image: url("./images/icon_contact_www.gif"); } +.msnm-icon, .msnm-icon a { background-image: url("./images/icon_contact_msnm.gif"); } .icq-icon, .icq-icon a { background-image: url("./images/icon_contact_icq.gif"); } .jabber-icon, .jabber-icon a { background-image: url("./images/icon_contact_jabber.gif"); } .pm-icon, .pm-icon a { background-image: url("./en/icon_contact_pm.gif"); } diff --git a/phpBB/styles/prosilver/theme/imageset.css b/phpBB/styles/prosilver/theme/imageset.css index a85e320f98..cb99e9e715 100644 --- a/phpBB/styles/prosilver/theme/imageset.css +++ b/phpBB/styles/prosilver/theme/imageset.css @@ -280,6 +280,11 @@ span.imageset { padding-left: 20px; padding-top: 20px; } +.imageset.icon_contact_msnm { + background-image: url("./images/icon_contact_msnm.gif"); + padding-left: 20px; + padding-top: 20px; +} .imageset.icon_contact_www { background-image: url("./images/icon_contact_www.gif"); padding-left: 20px; diff --git a/phpBB/styles/subsilver2/template/memberlist_im.html b/phpBB/styles/subsilver2/template/memberlist_im.html index e91a1caf11..da1ad661c3 100644 --- a/phpBB/styles/subsilver2/template/memberlist_im.html +++ b/phpBB/styles/subsilver2/template/memberlist_im.html @@ -2,6 +2,8 @@ <br clear="all" /> +<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger --> + <form method="post" action="{S_IM_ACTION}"> <table class="tablebg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> @@ -12,7 +14,7 @@ </tr> <tr> <td class="row1"><b class="genmed">{L_IM_RECIPIENT}{L_COLON} </b></td> - <td class="row2"><span class="gen"><b>{USERNAME}</b><!-- IF S_SEND_ICQ or S_SEND_AIM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --></span> <!-- IF PRESENCE_IMG -->{PRESENCE_IMG}<!-- ENDIF --></td> + <td class="row2"><span class="gen"><b>{USERNAME}</b><!-- IF S_SEND_ICQ or S_SEND_AIM or S_SEND_MSNM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --></span> <!-- IF PRESENCE_IMG -->{PRESENCE_IMG}<!-- ENDIF --></td> </tr> <!-- IF S_SEND_AIM --> @@ -24,6 +26,85 @@ </tr> <!-- ENDIF --> + <!-- IF S_SEND_MSNM --> + <tr> + <td class="row1" colspan="2" align="center"> + <object classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" id="objMessengerApp" width="0" height="0"></object> + <script type="text/javascript"> + // <![CDATA[ + var app = document.getElementById('objMessengerApp'); + + /** + * Check whether the browser supports this and whether MSNM is connected + */ + function msn_supported() + { + // Does the browser support the MSNM object? + if (app.MyStatus) + { + // Is MSNM connected? + if (app.MyStatus == 1) + { + alert('{LA_IM_MSNM_CONNECT}'); + return false; + } + } + else + { + alert('{LA_IM_MSNM_BROWSER}'); + return false; + } + return true; + } + + /** + * Add to your contact list + */ + function add_contact(address) + { + if (msn_supported()) + { + // Could return an error while MSNM is connecting, don't want that + try + { + app.AddContact(0, address); + } + catch (e) + { + return; + } + } + } + + /** + * Write IM to contact + */ + function im_contact(address) + { + if (msn_supported()) + { + // Could return an error while MSNM is connecting, don't want that + try + { + app.InstantMessage(address); + } + catch (e) + { + return; + } + } + } + // ]]> + </script> + + <a class="gen" href="#" onclick="add_contact('{A_IM_CONTACT}'); return false;">{L_IM_ADD_CONTACT}</a><br /><a class="gen" href="#" onclick="im_contact('{A_IM_CONTACT}'); return false;">{L_IM_SEND_MESSAGE}</a> + </td> + </tr> + <tr> + <td class="cat" colspan="2" align="center"> </td> + </tr> + <!-- ENDIF --> + <!-- IF S_SEND_JABBER --> <tr> <td class="row1"><b class="genmed">{L_IM_MESSAGE}{L_COLON} </b></td> diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index fb76cacc79..c0434d8110 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -102,14 +102,14 @@ <!-- ELSE --> <td colspan="2" class="row1"> </td> <!-- ENDIF --> - <td class="row1"><b class="genmed">{L_JABBER}{L_COLON}</b></td> - <td class="row2"><input class="post" type="text" name="jabber" value="{JABBER}" /></td> + <td class="row1"><b class="genmed">{L_MSNM}{L_COLON}</b></td> + <td class="row2"><input class="post" type="text" name="msn" value="{MSNM}" /></td> </tr> <tr> <td class="row1"><b class="genmed">{L_POSTS}{L_COLON}</b></td> <td class="row2"><select name="count_select">{S_COUNT_OPTIONS}</select> <input class="post" type="text" name="count" value="{COUNT}" /></td> - <td class="row1"> </td> - <td class="row2"> </td> + <td class="row1"><b class="genmed">{L_JABBER}{L_COLON}</b></td> + <td class="row2"><input class="post" type="text" name="jabber" value="{JABBER}" /></td> </tr> <tr> <td class="row1"><b class="genmed">{L_SORT_BY}{L_COLON}</b></td> diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index ff22dcc0f7..464369a7a8 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -116,6 +116,10 @@ <td><a href="{U_PM}" class="imageset">{PM_IMG}</a></td> </tr> <!-- ENDIF --> + <tr> + <td class="gen" nowrap="nowrap" align="{S_CONTENT_FLOW_END}">{L_MSNM}{L_COLON} </td> + <td><!-- IF U_MSN --><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false" class="imageset">{MSN_IMG}</a><!-- ELSEIF USER_MSN -->{USER_MSN}<!-- ENDIF --></td> + </tr> <tr> <td class="gen" nowrap="nowrap" align="{S_CONTENT_FLOW_END}">{L_YIM}{L_COLON} </td> <td><!-- IF U_YIM --><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false" class="imageset">{YIM_IMG}</a><!-- ELSEIF USER_YIM -->{USER_YIM}<!-- ENDIF --></td> diff --git a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html index 69da5f6172..19259aebc8 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_profile_info.html @@ -20,6 +20,10 @@ <td class="row1" width="35%"><b class="genmed">{L_UCP_AIM}{L_COLON} </b></td> <td class="row2"><input class="post" type="text" name="aim" size="30" maxlength="255" value="{AIM}" /></td> </tr> +<tr> + <td class="row1" width="35%"><b class="genmed">{L_UCP_MSNM}{L_COLON} </b></td> + <td class="row2"><input class="post" type="text" name="msn" size="30" maxlength="255" value="{MSN}" /></td> +</tr> <tr> <td class="row1" width="35%"><b class="genmed">{L_UCP_YIM}{L_COLON} </b></td> <td class="row2"><input class="post" type="text" name="yim" size="30" maxlength="255" value="{YIM}" /></td> diff --git a/phpBB/styles/subsilver2/theme/en/stylesheet.css b/phpBB/styles/subsilver2/theme/en/stylesheet.css index 6ddecf963b..563492d4fc 100644 --- a/phpBB/styles/subsilver2/theme/en/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/en/stylesheet.css @@ -19,6 +19,11 @@ padding-left: 72px; padding-top: 20px; } +.imageset.icon_contact_msnm { + background-image: url("./icon_contact_msnm.gif"); + padding-left: 72px; + padding-top: 20px; +} .imageset.icon_contact_pm { background-image: url("./icon_contact_pm.gif"); padding-left: 72px; diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index e7e64eff32..977e5c20c6 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -1008,6 +1008,11 @@ a.imageset { padding-left: 72px; padding-top: 20px; } +.imageset.icon_contact_msnm { + background-image: url("./en/icon_contact_msnm.gif"); + padding-left: 72px; + padding-top: 20px; +} .imageset.icon_contact_pm { background-image: url("./en/icon_contact_pm.gif"); padding-left: 72px; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index fcf34a139a..bd2c7bea77 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -617,6 +617,7 @@ $template->assign_vars(array( 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'), 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'), 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'), + 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'), 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') , 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), @@ -1094,6 +1095,7 @@ while ($row = $db->sql_fetchrow($result)) 'icq_status_img' => '', 'icq' => '', 'aim' => '', + 'msn' => '', 'yim' => '', 'jabber' => '', 'search' => '', @@ -1161,6 +1163,7 @@ while ($row = $db->sql_fetchrow($result)) 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id"), 'www' => $row['user_website'], 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=aim&u=$poster_id") : '', + 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', @@ -1582,6 +1585,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_WWW' => $user_cache[$poster_id]['www'], 'U_ICQ' => $user_cache[$poster_id]['icq'], 'U_AIM' => $user_cache[$poster_id]['aim'], + 'U_MSN' => $user_cache[$poster_id]['msn'], 'U_YIM' => $user_cache[$poster_id]['yim'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], From 77df9109b61ec93c28a8120a8d81a045961b24ac Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Mon, 4 Feb 2013 13:46:23 -0600 Subject: [PATCH 100/174] [feature/migrations] Remove default values from necessary parameters Clean up some comments PHPBB3-9737 --- phpBB/includes/db/migration/tool/config.php | 34 +++++++------- phpBB/includes/db/migration/tool/module.php | 44 +++++++++++-------- .../includes/db/migration/tool/permission.php | 33 +++++++------- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/includes/db/migration/tool/config.php index 6ae419d5e7..d9cc20053e 100644 --- a/phpBB/includes/db/migration/tool/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -38,12 +38,14 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac /** * Add a config setting. * - * @param string $config_name The name of the config setting you would like to add + * @param string $config_name The name of the config setting + * you would like to add * @param mixed $config_value The value of the config setting - * @param bool $is_dynamic True if it is dynamic (changes very often) and should not be stored in the cache, false if not. + * @param bool $is_dynamic True if it is dynamic (changes very often) + * and should not be stored in the cache, false if not. * @return null */ - public function add($config_name, $config_value = '', $is_dynamic = false) + public function add($config_name, $config_value, $is_dynamic = false) { if (isset($this->config[$config_name])) { @@ -56,11 +58,12 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac /** * Update an existing config setting. * - * @param string $config_name The name of the config setting you would like to update + * @param string $config_name The name of the config setting you would + * like to update * @param mixed $config_value The value of the config setting * @return null */ - public function update($config_name, $config_value = '') + public function update($config_name, $config_value) { if (!isset($this->config[$config_name])) { @@ -71,14 +74,17 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } /** - * Update a config setting if the first argument equal to the current config value + * Update a config setting if the first argument equal to the + * current config value * - * @param bool $compare If equal to the current config value, will be updated to the new config value, otherwise not - * @param string $config_name The name of the config setting you would like to update + * @param string $compare If equal to the current config value, will be + * updated to the new config value, otherwise not + * @param string $config_name The name of the config setting you would + * like to update * @param mixed $config_value The value of the config setting * @return null */ - public function update_if_equals($compare, $config_name, $config_value = '') + public function update_if_equals($compare, $config_name, $config_value) { if (!isset($this->config[$config_name])) { @@ -91,7 +97,8 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac /** * Remove an existing config setting. * - * @param string $config_name The name of the config setting you would like to remove + * @param string $config_name The name of the config setting you would + * like to remove * @return null */ public function remove($config_name) @@ -105,12 +112,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac } /** - * Reverse an original install action - * - * First argument is the original call to the class (e.g. add, remove) - * After the first argument, send the original arguments to the function in the original call - * - * @return null + * {@inheritdoc} */ public function reverse() { diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index 561faac552..afe1f21ec5 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -66,8 +66,10 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * Check if a module exists * * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. - * @param int|string $module The module_id|module_langname you would like to check for to see if it exists + * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). + * Use false to ignore the parent check and check class wide. + * @param int|string $module The module_id|module_langname you would like to + * check for to see if it exists * @return bool true/false if module exists */ public function exists($class, $parent, $module) @@ -131,10 +133,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * * @param string $class The module class(acp|mcp|ucp) * @param int|string $parent The parent module_id|module_langname (0 for no parent) - * @param array $data an array of the data on the new module. This can be setup in two different ways. - * 1. The "manual" way. For inserting a category or one at a time. It will be merged with the base array shown a bit below, - * but at the least requires 'module_langname' to be sent, and, if you want to create a module (instead of just a category) you must send module_basename and module_mode. - * array( + * @param array $data an array of the data on the new module. + * This can be setup in two different ways. + * 1. The "manual" way. For inserting a category or one at a time. + * It will be merged with the base array shown a bit below, + * but at the least requires 'module_langname' to be sent, and, + * if you want to create a module (instead of just a category) you must + * send module_basename and module_mode. + * array( * 'module_enabled' => 1, * 'module_display' => 1, * 'module_basename' => '', @@ -144,14 +150,19 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * 'module_mode' => '', * 'module_auth' => '', * ) - * 2. The "automatic" way. For inserting multiple at a time based on the specs in the info file for the module(s). For this to work the modules must be correctly setup in the info file. - * An example follows (this would insert the settings, log, and flag modes from the includes/acp/info/acp_asacp.php file): + * 2. The "automatic" way. For inserting multiple at a time based on the + * specs in the info file for the module(s). For this to work the + * modules must be correctly setup in the info file. + * An example follows (this would insert the settings, log, and flag + * modes from the includes/acp/info/acp_asacp.php file): * array( * 'module_basename' => 'asacp', * 'modes' => array('settings', 'log', 'flag'), * ) - * Optionally you may not send 'modes' and it will insert all of the modules in that info file. - * @param string|bool $include_path If you would like to use a custom include path, specify that here + * Optionally you may not send 'modes' and it will insert all of the + * modules in that info file. + * @param string|bool $include_path If you would like to use a custom include + * path, specify that here * @return null */ public function add($class, $parent = 0, $data = array(), $include_path = false) @@ -334,9 +345,11 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac * Remove a module * * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). Use false to ignore the parent check and check class wide. + * @param int|string|bool $parent The parent module_id|module_langname(0 for no parent). + * Use false to ignore the parent check and check class wide. * @param int|string $module The module id|module_langname - * @param string|bool $include_path If you would like to use a custom include path, specify that here + * @param string|bool $include_path If you would like to use a custom include path, + * specify that here * @return null */ public function remove($class, $parent = 0, $module = '', $include_path = false) @@ -473,12 +486,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac } /** - * Reverse an original install action - * - * First argument is the original call to the class (e.g. add, remove) - * After the first argument, send the original arguments to the function in the original call - * - * @return null + * {@inheritdoc} */ public function reverse() { diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index a25fdb345e..001d090f5a 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -61,7 +61,8 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * Check if a permission (auth) setting exists * * @param string $auth_option The name of the permission (auth) option - * @param bool $global True for checking a global permission setting, False for a local permission setting + * @param bool $global True for checking a global permission setting, + * False for a local permission setting * @return bool true if it exists, false if not */ public function exists($auth_option, $global = true) @@ -98,7 +99,8 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * Add a permission (auth) option * * @param string $auth_option The name of the permission (auth) option - * @param bool $global True for checking a global permission setting, False for a local permission setting + * @param bool $global True for checking a global permission setting, + * False for a local permission setting * @return null */ public function add($auth_option, $global = true, $copy_from = false) @@ -180,7 +182,8 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * Remove a permission (auth) option * * @param string $auth_option The name of the permission (auth) option - * @param bool $global True for checking a global permission setting, False for a local permission setting + * @param bool $global True for checking a global permission setting, + * False for a local permission setting * @return null */ public function remove($auth_option, $global = true) @@ -239,7 +242,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * @param sting $role_type The type (u_, m_, a_) * @return null */ - public function role_add($role_name, $role_type = '', $role_description = '') + public function role_add($role_name, $role_type, $role_description = '') { $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . " @@ -277,7 +280,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * @param string $new_role_name The new role name * @return null */ - public function role_update($old_role_name, $new_role_name = '') + public function role_update($old_role_name, $new_role_name) { $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . " @@ -332,12 +335,14 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * Allows you to set permissions for a certain group/role * * @param string $name The name of the role/group - * @param string|array $auth_option The auth_option or array of auth_options you would like to set + * @param string|array $auth_option The auth_option or array of + * auth_options you would like to set * @param string $type The type (role|group) - * @param bool $has_permission True if you want to give them permission, false if you want to deny them permission + * @param bool $has_permission True if you want to give them permission, + * false if you want to deny them permission * @return null */ - public function permission_set($name, $auth_option = array(), $type = 'role', $has_permission = true) + public function permission_set($name, $auth_option, $type = 'role', $has_permission = true) { if (!is_array($auth_option)) { @@ -477,11 +482,12 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte * Allows you to unset (remove) permissions for a certain group/role * * @param string $name The name of the role/group - * @param string|array $auth_option The auth_option or array of auth_options you would like to set + * @param string|array $auth_option The auth_option or array of + * auth_options you would like to set * @param string $type The type (role|group) * @return null */ - public function permission_unset($name, $auth_option = array(), $type = 'role') + public function permission_unset($name, $auth_option, $type = 'role') { if (!is_array($auth_option)) { @@ -565,12 +571,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte } /** - * Reverse an original install action - * - * First argument is the original call to the class (e.g. add, remove) - * After the first argument, send the original arguments to the function in the original call - * - * @return null + * {@inheritdoc} */ public function reverse() { From 293b65e3efbf94f6521acebe1b9f3e7bbca20286 Mon Sep 17 00:00:00 2001 From: David Tobin <dtobin08@gmail.com> Date: Thu, 5 Jul 2012 02:47:49 +0100 Subject: [PATCH 101/174] [ticket/10896] Adds email validation to email settings in ACP Adds a new validation type to the ACP validate_config_vars function and implements it on the board_contact and board_email settings. PHPBB3-10896 --- phpBB/adm/index.php | 7 +++++++ phpBB/includes/acp/acp_board.php | 4 ++-- phpBB/language/en/common.php | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 2e4089c02e..2da8a130cc 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -449,6 +449,13 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) } break; + case 'email': + if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) + { + $error[] = $user->lang['EMAIL_INVALID']; + } + break; + // Absolute path case 'script_path': if (!$cfg_array[$config_name]) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index f437dca8f9..ebbf66657e 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -408,8 +408,8 @@ class acp_board 'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true), 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true), - 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true), - 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true), + 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true), + 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true), 'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true), 'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 844d5ef3ef..9f8799b6d6 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -160,6 +160,7 @@ $lang = array_merge($lang, array( 'EDIT_POST' => 'Edit post', 'EMAIL' => 'E-mail', // Short form for EMAIL_ADDRESS 'EMAIL_ADDRESS' => 'E-mail address', + 'EMAIL_INVALID' => 'The email address you entered is invalid.', 'EMAIL_SMTP_ERROR_RESPONSE' => 'Ran into problems sending e-mail at <strong>Line %1$s</strong>. Response: %2$s.', 'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.', 'EMPTY_MESSAGE_SUBJECT' => 'You must specify a subject when composing a new message.', From 5aec7600a68adb9466fb7ce034ba22070ac8a244 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Mon, 4 Feb 2013 23:13:47 -0600 Subject: [PATCH 102/174] [ticket/10896] Move EMAIL_INVALID_EMAIL to common, replace EMAIL_INVALID PHPBB3-10896 --- phpBB/adm/index.php | 2 +- phpBB/language/en/common.php | 2 +- phpBB/language/en/ucp.php | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 2da8a130cc..85908476a1 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -452,7 +452,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) case 'email': if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) { - $error[] = $user->lang['EMAIL_INVALID']; + $error[] = $user->lang['EMAIL_INVALID_EMAIL']; } break; diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 9f8799b6d6..6dd390ed24 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -160,7 +160,7 @@ $lang = array_merge($lang, array( 'EDIT_POST' => 'Edit post', 'EMAIL' => 'E-mail', // Short form for EMAIL_ADDRESS 'EMAIL_ADDRESS' => 'E-mail address', - 'EMAIL_INVALID' => 'The email address you entered is invalid.', + 'EMAIL_INVALID_EMAIL' => 'The e-mail address you entered is invalid.', 'EMAIL_SMTP_ERROR_RESPONSE' => 'Ran into problems sending e-mail at <strong>Line %1$s</strong>. Response: %2$s.', 'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.', 'EMPTY_MESSAGE_SUBJECT' => 'You must specify a subject when composing a new message.', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 5152c4b50b..0dce2961e5 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -176,7 +176,6 @@ $lang = array_merge($lang, array( 'EDIT_DRAFT_EXPLAIN' => 'Here you are able to edit your draft. Drafts do not contain attachment and poll information.', 'EMAIL_BANNED_EMAIL' => 'The e-mail address you entered is not allowed to be used.', - 'EMAIL_INVALID_EMAIL' => 'The e-mail address you entered is invalid.', 'EMAIL_REMIND' => 'This must be the e-mail address associated with your account. If you have not changed this via your user control panel then it is the e-mail address you registered your account with.', 'EMAIL_TAKEN_EMAIL' => 'The entered e-mail address is already in use.', 'EMPTY_DRAFT' => 'You must enter a message to submit your changes.', From 8d3a82a4fa8ced50fbc1d1019ef439d1d5c81e71 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 19:32:39 -0600 Subject: [PATCH 103/174] [feature/migrations] Make the container available to extension installers This allows extensions to load and install migrations easily as per their needs. PHPBB3-11318 --- phpBB/config/services.yml | 1 + phpBB/includes/extension/base.php | 15 +++++++++++++++ phpBB/includes/extension/manager.php | 13 ++++++++++--- phpBB/install/database_update.php | 4 ++-- phpBB/install/install_install.php | 4 ++-- tests/extension/manager_test.php | 2 ++ tests/extension/metadata_manager_test.php | 1 + .../test_framework/phpbb_functional_test_case.php | 1 + 8 files changed, 34 insertions(+), 7 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index ee52ca2800..028ab88229 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -112,6 +112,7 @@ services: ext.manager: class: phpbb_extension_manager arguments: + - @service_container - @dbal.conn - @config - %tables.ext% diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php index 9d076eb6c5..d51589d719 100644 --- a/phpBB/includes/extension/base.php +++ b/phpBB/includes/extension/base.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\DependencyInjection\ContainerInterface; + /** * A base class for extensions without custom enable/disable/purge code. * @@ -22,6 +24,19 @@ if (!defined('IN_PHPBB')) */ class phpbb_extension_base implements phpbb_extension_interface { + /** @var ContainerInterface */ + protected $container; + + /** + * Constructor + * + * @param ContainerInterface $container Container object + */ + public function __construct(ContainerInterface $container) + { + $this->container = $container; + } + /** * Single enable step that does nothing * diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index de6f364320..8136dfa90b 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\DependencyInjection\ContainerInterface; + /** * The extension manager provides means to activate/deactivate extensions. * @@ -22,6 +24,9 @@ if (!defined('IN_PHPBB')) */ class phpbb_extension_manager { + /** @var ContainerInterface */ + protected $container; + protected $db; protected $config; protected $cache; @@ -34,6 +39,7 @@ class phpbb_extension_manager /** * Creates a manager and loads information from database * + * @param ContainerInterface $container A container * @param phpbb_db_driver $db A database connection * @param phpbb_config $config phpbb_config * @param string $extension_table The name of the table holding extensions @@ -42,8 +48,9 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { + $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; @@ -126,11 +133,11 @@ class phpbb_extension_manager if (class_exists($extension_class_name)) { - return new $extension_class_name; + return new $extension_class_name($this->container); } else { - return new phpbb_extension_base; + return new phpbb_extension_base($this->container); } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4e17a1429c..0a065573bf 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -685,12 +685,12 @@ function _write_result($no_updates, $errored, $error_ary) function _add_modules($modules_to_install) { - global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config; + global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config, $phpbb_container; // modules require an extension manager if (empty($phpbb_extension_manager)) { - $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx"); + $phpbb_extension_manager = $phpbb_container->get('ext.manager'); } include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 1ab9caee0a..dd90335480 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1456,12 +1456,12 @@ class install_install extends module */ function add_modules($mode, $sub) { - global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config; + global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config, $phpbb_container; // modules require an extension manager if (empty($phpbb_extension_manager)) { - $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx"); + $phpbb_extension_manager = $phpbb_container->get('ext.manager'); } include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 5cde5bccdb..5c0b419540 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -26,6 +26,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case parent::setUp(); $this->extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), $this->new_dbal(), new phpbb_config(array()), 'phpbb_ext', @@ -90,6 +91,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case public function test_enabled_no_cache() { $extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), $this->new_dbal(), new phpbb_config(array()), 'phpbb_ext', diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index ce7be0dea5..7a04229a9c 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -48,6 +48,7 @@ class metadata_manager_test extends phpbb_database_test_case ); $this->extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), $this->db, $this->config, 'phpbb_ext', diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index e346223a4b..cb0a475278 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -137,6 +137,7 @@ class phpbb_functional_test_case extends phpbb_test_case if (!$this->extension_manager) { $this->extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), $this->get_db(), new phpbb_config(array()), self::$config['table_prefix'] . 'ext', From aa67fa6dd83e329c3b6edbb356eae3eeda1ba69f Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 31 Jan 2013 13:53:33 -0600 Subject: [PATCH 104/174] [feature/migrations] Automatically install/revert migrations for extensions Migrations from ext/ext_name/migrations/ are automatically installed when enabling the extension and automatically reverted when the extension is purged. PHPBB3-11318 --- phpBB/includes/extension/manager.php | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 8136dfa90b..018324d5d6 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -173,6 +173,12 @@ class phpbb_extension_manager $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; + // Returns false if not completed + if (!$this->handle_migrations($name, 'enable')) + { + return true; + } + $extension = $this->get_extension($name); $state = $extension->enable_step($old_state); @@ -324,6 +330,12 @@ class phpbb_extension_manager $old_state = unserialize($this->extensions[$name]['ext_state']); + // Returns false if not completed + if (!$this->handle_migrations($name, 'purge')) + { + return true; + } + $extension = $this->get_extension($name); $state = $extension->purge_step($old_state); @@ -497,4 +509,54 @@ class phpbb_extension_manager { return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); } + + /** + * Handle installing/reverting migrations + * + * @param string $extension_name Name of the extension + * @param string $mode enable or purge + * @return bool True if completed, False if not completed + */ + protected function handle_migrations($extension_name, $mode) + { + $migrator = $this->container->get('migrator'); + $migrations_path = $this->get_extension_path($extension_name) . 'migrations'; + if (file_exists($migrations_path) && is_dir($migrations_path)) + { + $migrator->load_migrations($migrations_path); + } + + // What is a safe limit of execution time? Half the max execution time should be safe. + $safe_time_limit = (ini_get('max_execution_time') / 2); + $start_time = time(); + + if ($mode == 'enable') + { + while (!$migrator->finished()) + { + $migrator->update(); + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + return false; + } + } + } + else if ($mode == 'purge') + { + while ($migrator->migration_state() !== false) + { + $migrator->revert(); + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + return false; + } + } + } + + return true; + } } From fb4f7470d481bd73dd505e7ce0522907f67773ef Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 15:34:03 -0600 Subject: [PATCH 105/174] [feature/migrations] Rebuilding migrations data on develop So this is easy to merge later. PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 28 ++ phpBB/includes/db/migration/data/3_0_10.php | 28 ++ .../includes/db/migration/data/3_0_10_rc1.php | 30 ++ .../includes/db/migration/data/3_0_10_rc2.php | 28 ++ .../includes/db/migration/data/3_0_10_rc3.php | 28 ++ phpBB/includes/db/migration/data/3_0_11.php | 28 ++ .../includes/db/migration/data/3_0_11_rc1.php | 94 +++++ .../includes/db/migration/data/3_0_11_rc2.php | 34 ++ .../includes/db/migration/data/3_0_12_rc1.php | 123 ++++++ .../includes/db/migration/data/3_0_1_rc1.php | 102 +++++ phpBB/includes/db/migration/data/3_0_2.php | 28 ++ .../includes/db/migration/data/3_0_2_rc1.php | 32 ++ .../includes/db/migration/data/3_0_2_rc2.php | 55 +++ phpBB/includes/db/migration/data/3_0_3.php | 28 ++ .../includes/db/migration/data/3_0_3_rc1.php | 63 +++ phpBB/includes/db/migration/data/3_0_4.php | 49 +++ .../includes/db/migration/data/3_0_4_rc1.php | 107 +++++ phpBB/includes/db/migration/data/3_0_5.php | 28 ++ .../includes/db/migration/data/3_0_5_rc1.php | 119 ++++++ .../db/migration/data/3_0_5_rc1part2.php | 37 ++ phpBB/includes/db/migration/data/3_0_6.php | 28 ++ .../includes/db/migration/data/3_0_6_rc1.php | 279 +++++++++++++ .../includes/db/migration/data/3_0_6_rc2.php | 28 ++ .../includes/db/migration/data/3_0_6_rc3.php | 40 ++ .../includes/db/migration/data/3_0_6_rc4.php | 28 ++ phpBB/includes/db/migration/data/3_0_7.php | 28 ++ .../includes/db/migration/data/3_0_7_pl1.php | 28 ++ .../includes/db/migration/data/3_0_7_rc1.php | 53 +++ .../includes/db/migration/data/3_0_7_rc2.php | 72 ++++ phpBB/includes/db/migration/data/3_0_8.php | 28 ++ .../includes/db/migration/data/3_0_8_rc1.php | 221 +++++++++++ phpBB/includes/db/migration/data/3_0_9.php | 28 ++ .../includes/db/migration/data/3_0_9_rc1.php | 110 +++++ .../includes/db/migration/data/3_0_9_rc2.php | 28 ++ .../includes/db/migration/data/3_0_9_rc3.php | 28 ++ .../includes/db/migration/data/3_0_9_rc4.php | 28 ++ .../includes/db/migration/data/3_1_0_dev.php | 375 ++++++++++++++++++ .../includes/db/migration/data/extensions.php | 55 +++ .../db/migration/data/style_update_p1.php | 157 ++++++++ .../db/migration/data/style_update_p2.php | 42 ++ .../migration/data/timezone.php} | 63 ++- phpBB/install/database_update_migrations.php | 139 +++++++ 42 files changed, 2948 insertions(+), 7 deletions(-) create mode 100644 phpBB/includes/db/migration/data/3_0_1.php create mode 100644 phpBB/includes/db/migration/data/3_0_10.php create mode 100644 phpBB/includes/db/migration/data/3_0_10_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_10_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_10_rc3.php create mode 100644 phpBB/includes/db/migration/data/3_0_11.php create mode 100644 phpBB/includes/db/migration/data/3_0_11_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_11_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_12_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_1_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_2.php create mode 100644 phpBB/includes/db/migration/data/3_0_2_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_2_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_3.php create mode 100644 phpBB/includes/db/migration/data/3_0_3_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_4.php create mode 100644 phpBB/includes/db/migration/data/3_0_4_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_5.php create mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_5_rc1part2.php create mode 100644 phpBB/includes/db/migration/data/3_0_6.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc3.php create mode 100644 phpBB/includes/db/migration/data/3_0_6_rc4.php create mode 100644 phpBB/includes/db/migration/data/3_0_7.php create mode 100644 phpBB/includes/db/migration/data/3_0_7_pl1.php create mode 100644 phpBB/includes/db/migration/data/3_0_7_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_7_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_8.php create mode 100644 phpBB/includes/db/migration/data/3_0_8_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_9.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc1.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc2.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc3.php create mode 100644 phpBB/includes/db/migration/data/3_0_9_rc4.php create mode 100644 phpBB/includes/db/migration/data/3_1_0_dev.php create mode 100644 phpBB/includes/db/migration/data/extensions.php create mode 100644 phpBB/includes/db/migration/data/style_update_p1.php create mode 100644 phpBB/includes/db/migration/data/style_update_p2.php rename phpBB/includes/{update_helpers.php => db/migration/data/timezone.php} (72%) create mode 100644 phpBB/install/database_update_migrations.php diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php new file mode 100644 index 0000000000..a2332c9b59 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_1_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php new file mode 100644 index 0000000000..07410c5ba1 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_10_rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.10')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php new file mode 100644 index 0000000000..daac50a631 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -0,0 +1,30 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_9'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.add', array('email_max_chunk_size', 50)), + + array('config.update', array('version', '3.0.10-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php new file mode 100644 index 0000000000..234e4c5fc7 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_10_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.10-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php new file mode 100644 index 0000000000..075ce35e3e --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_10_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.10-rc3')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php new file mode 100644 index 0000000000..0bc9b6c4a5 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_11_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.11')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php new file mode 100644 index 0000000000..752efd72b2 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -0,0 +1,94 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_10'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), + array('custom', array(array(&$this, 'delete_orphan_private_messages'))), + + array('config.update', array('version', '3.0.11-rc1')), + ); + } + + function cleanup_deactivated_styles() + { + // Updates users having current style a deactivated one + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_active = 0'; + $result = $this->sql_query($sql); + + $deactivated_style_ids = array(); + while ($style_id = $this->db->sql_fetchfield('style_id', false, $result)) + { + $deactivated_style_ids[] = (int) $style_id; + } + $this->db->sql_freeresult($result); + + if (!empty($deactivated_style_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $this->config['default_style'] .' + WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids); + $this->sql_query($sql); + } + } + + function delete_orphan_private_messages() + { + // Delete orphan private messages + $batch_size = 500; + + $sql_array = array( + 'SELECT' => 'p.msg_id', + 'FROM' => array( + PRIVMSGS_TABLE => 'p', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), + 'ON' => 'p.msg_id = t.msg_id', + ), + ), + 'WHERE' => 't.user_id IS NULL', + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + + $result = $this->db->sql_query_limit($sql, $batch_size); + + $delete_pms = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $delete_pms[] = (int) $row['msg_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($delete_pms)) + { + $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' + WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); + $this->sql_query($sql); + + return false; + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php new file mode 100644 index 0000000000..f2bed54085 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -0,0 +1,34 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_11_rc1'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue' => array('BOOL', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.11-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php new file mode 100644 index 0000000000..0d8702f19e --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -0,0 +1,123 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/ + +class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array(); + } + + public function update_data() + { + return array( + array('custom', array(array(&$this, 'update_module_auth'))), + array('custom', array(array(&$this, 'update_bots'))), + array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))), + + array('config.update', array('version', '3.0.12-rc1')), + ); + } + + public function disable_bots_from_receiving_pms() + { + // Disable receiving pms for bots + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $this->db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids); + $this->sql_query($sql); + } + } + + public function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_u_sig\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'signature\''; + $this->sql_query($sql); + } + + public function update_bots() + { + // Update bots + if (!function_exists('user_delete')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $bots_updates = array( + // Bot Deletions + 'NG-Search [Bot]' => false, + 'Nutch/CVS [Bot]' => false, + 'OmniExplorer [Bot]' => false, + 'Seekport [Bot]' => false, + 'Synoo [Bot]' => false, + 'WiseNut [Bot]' => false, + + // Bot Updates + // Bot name to bot user agent map + 'Baidu [Spider]' => 'Baiduspider', + 'Exabot [Bot]' => 'Exabot', + 'Voyager [Bot]' => 'voyager/', + 'W3C [Validator]' => 'W3C_Validator', + ); + + foreach ($bots_updates as $bot_name => $bot_agent) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_type = ' . USER_IGNORE . " + AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; + $result = $this->db->sql_query($sql); + $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if ($bot_user_id) + { + if ($bot_agent === false) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + + user_delete('remove', $bot_user_id); + } + else + { + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' + WHERE user_id = $bot_user_id"; + $this->sql_query($sql); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php new file mode 100644 index 0000000000..cf067d2e2c --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -0,0 +1,102 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array(); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list' => array('BOOL', 1), + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'groups' => array('group_legend'), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array('session_forum_id'), + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + ); + } + + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'forums' => array( + 'display_subforum_list', + ), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + ), + 'add_index' => array( + $this->table_prefix . 'groups' => array( + 'group_legend' => 'group_legend', + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array('session_forum_id'), + $this->table_prefix . 'groups' => array('group_legend_name'), + ), + ); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'fix_unset_last_view_time'))), + array('custom', array(array(&$this, 'reset_smiley_size'))), + + array('config.update', array('version', '3.0.1-rc1')), + ); + } + + function fix_unset_last_view_time() + { + $sql = 'UPDATE ' . $this->table_prefix . "topics + SET topic_last_view_time = topic_last_post_time + WHERE topic_last_view_time = 0"; + $this->sql_query($sql); + } + + function reset_smiley_size() + { + // Update smiley sizes + $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); + + foreach ($smileys as $smiley) + { + if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley)) + { + list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET smiley_width = ' . $width . ', smiley_height = ' . $height . " + WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'"; + + $this->sql_query($sql); + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php new file mode 100644 index 0000000000..3469d8d178 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_2_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php new file mode 100644 index 0000000000..d3c2200f14 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -0,0 +1,32 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.add', array('referer_validation', '1')), + array('config.add', array('check_attachment_content', '1')), + array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), + + array('config.update', array('version', '3.0.2-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php new file mode 100644 index 0000000000..67fd1faec6 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -0,0 +1,55 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_2_rc1'); + } + + function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'drafts' => array( + 'draft_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'forums' => array( + 'forum_last_post_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'posts' => array( + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_subject' => array('STEXT_UNI', ''), + ), + $this->table_prefix . 'topics' => array( + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array('session_forum_id'), + ), + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid' => array('session_forum_id'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.2-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php new file mode 100644 index 0000000000..dff375f438 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_3_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.3')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php new file mode 100644 index 0000000000..2320c4ac4b --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -0,0 +1,63 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_2'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('enable_queue_trigger', '0')), + array('config.add', array('queue_trigger_posts', '3')), + array('config.add', array('pm_max_recipients', '0')), + array('custom', array(array(&$this, 'set_group_default_max_recipients'))), + array('config.add', array('dbms_version', $this->db->sql_server_info(true))), + array('permission.add', array('u_masspm_group', true, 'u_masspm')), + array('custom', array(array(&$this, 'correct_acp_email_permissions'))), + + array('config.update', array('version', '3.0.3-rc1')), + ); + } + + function correct_acp_email_permissions() + { + $sql = 'UPDATE ' . $this->table_prefix . 'modules + SET module_auth = \'acl_a_email && cfg_email_enable\' + WHERE module_class = \'acp\' + AND module_basename = \'email\''; + $this->sql_query($sql); + } + + function set_group_default_max_recipients() + { + // Set maximum number of recipients for the registered users, bots, guests group + $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 + WHERE ' . $this->db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); + $this->sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php new file mode 100644 index 0000000000..1af4508331 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -0,0 +1,49 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_4_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'rename_log_delete_topic'))), + + array('config.update', array('version', '3.0.4')), + ); + } + + function rename_log_delete_topic() + { + if ($this->db->sql_layer == 'oracle') + { + // log_operation is CLOB - but we can change this later + $sql = 'UPDATE ' . $this->table_prefix . "log + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; + $this->sql_query($sql); + } + else + { + $sql = 'UPDATE ' . $this->table_prefix . "log + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation = 'LOG_TOPIC_DELETED'"; + $this->sql_query($sql); + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php new file mode 100644 index 0000000000..e9bb0e01f5 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -0,0 +1,107 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_3'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile' => array('BOOL', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'styles' => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_imageset' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_id' => array('UINT', 0), + ), + $this->table_prefix . 'styles_theme' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + ), + $this->table_prefix . 'styles_template_data' => array( + 'template_id' => array('UINT', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_style' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'update_custom_profile_fields'))), + + array('config.update', array('version', '3.0.4-rc1')), + ); + } + + function update_custom_profile_fields() + { + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide + FROM ' . PROFILE_FIELDS_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql_ary = array( + 'field_required' => 0, + 'field_show_on_reg' => 0, + 'field_hide' => 0, + 'field_show_profile'=> 0, + ); + + if ($row['field_required']) + { + $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_show_on_reg']) + { + $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_hide']) + { + // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module + $sql_ary['field_hide'] = 1; + } + else + { + // equivelant to "none", which is the "Display in user control panel" option + $sql_ary['field_show_profile'] = 1; + } + + $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); + } + + $this->db->sql_freeresult($result); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php new file mode 100644 index 0000000000..2f80970781 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_5_rc1part2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.5')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php new file mode 100644 index 0000000000..cbf28c0be6 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -0,0 +1,119 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_4'); + } + + function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_style' => array('UINT', 0), + ), + ), + ); + } + + function update_data() + { + $search_indexing_state = $this->config['search_indexing_state']; + + return array( + array('config.add', array('captcha_gd_wave', 0)), + array('config.add', array('captcha_gd_3d_noise', 1)), + array('config.add', array('captcha_gd_fonts', 1)), + array('config.add', array('confirm_refresh', 1)), + array('config.add', array('max_num_search_keywords', 10)), + array('config.remove', array('search_indexing_state')), + array('config.add', array('search_indexing_state', $search_indexing_state, true)), + array('custom', array(array(&$this, 'hash_old_passwords'))), + array('custom', array(array(&$this, 'update_ichiro_bot'))), + ); + } + + function hash_old_passwords() + { + $sql = 'SELECT user_id, user_password + FROM ' . $this->table_prefix . 'users + WHERE user_pass_convert = 1'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + if (strlen($row['user_password']) == 32) + { + $sql_ary = array( + 'user_password' => phpbb_hash($row['user_password']), + ); + + $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']); + } + } + $this->db->sql_freeresult($result); + } + + function update_ichiro_bot() + { + // Adjust bot entry + $sql = 'UPDATE ' . $this->table_prefix . "bots + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + $this->sql_query($sql); + } + + function remove_duplicate_auth_options() + { + // Before we are able to add a unique key to auth_option, we need to remove duplicate entries + $sql = 'SELECT auth_option + FROM ' . $this->table_prefix . 'acl_options + GROUP BY auth_option + HAVING COUNT(*) >= 2'; + $result = $this->db->sql_query($sql); + + $auth_options = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $auth_options[] = $row['auth_option']; + } + $this->db->sql_freeresult($result); + + // Remove specific auth options + if (!empty($auth_options)) + { + foreach ($auth_options as $option) + { + // Select auth_option_ids... the largest id will be preserved + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $db->sql_escape($option) . "' + ORDER BY auth_option_id DESC"; + // sql_query_limit not possible here, due to bug in postgresql layer + $result = $this->db->sql_query($sql); + + // Skip first row, this is our original auth option we want to preserve + $row = $this->db->sql_fetchrow($result); + + while ($row = $this->db->sql_fetchrow($result)) + { + // Ok, remove this auth option... + $this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + $this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']); + } + $this->db->sql_freeresult($result); + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php new file mode 100644 index 0000000000..1fab0f8873 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -0,0 +1,37 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_5_rc1'); + } + + function update_schema() + { + return array( + 'drop_keys' => array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.5-rc1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php new file mode 100644 index 0000000000..26176b9437 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_6_rc4'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.6')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php new file mode 100644 index 0000000000..35adcf52be --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -0,0 +1,279 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_5'); + } + + function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'confirm' => array( + 'attempts' => array('UINT', 0), + ), + $this->table_prefix . 'users' => array( + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time' => array('TIMESTAMP', 0), + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported' => array('BOOL', 0), + ), + $this->table_prefix . 'reports' => array( + 'pm_id' => array('UINT', 0), + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_vt' => array('BOOL', 0), + ), + $this->table_prefix . 'forums' => array( + 'forum_options' => array('UINT:20', 0), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_options' => array('UINT:11', 230271), + ), + ), + 'add_index' => array( + $this->table_prefix . 'reports' => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), + $this->table_prefix . 'posts' => array( + 'post_username' => array('post_username:255'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), + array('if', array( + ($this->config['captcha_gd']), + array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), + )), + + array('config.add', array('feed_enable', 0)), + array('config.add', array('feed_limit', 10)), + array('config.add', array('feed_overall_forums', 1)), + array('config.add', array('feed_overall_forums_limit', 15)), + array('config.add', array('feed_overall_topics', 0)), + array('config.add', array('feed_overall_topics_limit', 15)), + array('config.add', array('feed_forum', 1)), + array('config.add', array('feed_topic', 1)), + array('config.add', array('feed_item_statistics', 1)), + + array('config.add', array('smilies_per_page', 50)), + array('config.add', array('allow_pm_report', 1)), + array('config.add', array('min_post_chars', 1)), + array('config.add', array('allow_quick_reply', 1)), + array('config.add', array('new_member_post_limit', 0)), + array('config.add', array('new_member_group_default', 0)), + array('config.add', array('delete_time', $this->config['edit_time'])), + + array('config.add', array('allow_avatar', 0)), + array('if', array( + ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), + array('config.update', array('allow_avatar', 1)), + )), + array('config.add', array('allow_avatar_remote_upload', 0)), + array('if', array( + ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), + array('config.update', array('allow_avatar_remote_upload', 1)), + )), + + array('module.add', array( + 'acp', + 'ACP_BOARD_CONFIGURATION', + array( + 'module_basename' => 'acp_board', + 'modes' => array('feed'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_CAT_USERS', + array( + 'module_basename' => 'acp_users', + 'modes' => array('warnings'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_SERVER_CONFIGURATION', + array( + 'module_basename' => 'acp_send_statistics', + 'modes' => array('send_statistics'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_FORUM_BASED_PERMISSIONS', + array( + 'module_basename' => 'acp_permissions', + 'modes' => array('setting_forum_copy'), + ), + )), + array('module.add', array( + 'mcp', + 'MCP_REPORTS', + array( + 'module_basename' => 'mcp_pm_reports', + 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), + ), + )), + array('custom', array(array(&$this, 'add_newly_registered_group'))), + array('custom', array(array(&$this, 'set_user_options_default'))), + + array('config.update', array('version', '3.0.6-rc1')), + ); + } + + function set_user_options_default() + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + $this->sql_query($sql); + } + + function add_newly_registered_group() + { + // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED'"; + $result = $this->db->sql_query($sql); + $group_id = (int) $this->db->sql_fetchfield('group_id'); + $this->db->sql_freeresult($result); + + if (!$group_id) + { + $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; + $this->sql_query($sql); + + $group_id = $this->db->sql_nextid(); + } + + // Insert new user role... at the end of the chain + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_USER_NEW_MEMBER' + AND role_type = 'u_'"; + $result = $this->db->sql_query($sql); + $u_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + + if (!$u_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'u_'"; + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; + $this->sql_query($sql); + $u_role = $this->db->sql_nextid(); + + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + $this->sql_query($sql); + + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + $this->sql_query($sql); + } + + // Insert new forum role + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' + AND role_type = 'f_'"; + $result = $this->db->sql_query($sql); + $f_role = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + + if (!$f_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'f_'"; + $result = $this->db->sql_query($sql); + $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); + $this->db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; + $this->sql_query($sql); + $f_role = $this->db->sql_nextid(); + + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + $this->sql_query($sql); + } + + // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) + $sql = 'SELECT 1 + FROM ' . USERS_TABLE . ' + WHERE user_new = 0'; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; + $this->sql_query($sql); + } + + // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... + // Check if the role is already assigned... + $sql = 'SELECT forum_id + FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id = ' . $f_role; + $result = $this->db->sql_query($sql); + $is_options = (int) $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + // Not assigned at all... :/ + if (!$is_options) + { + // Get postable forums + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type != ' . FORUM_LINK; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); + } + $this->db->sql_freeresult($result); + } + + // Clear permissions... + include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); + $auth_admin = new auth_admin(); + $auth_admin->acl_clear_prefetch(); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php new file mode 100644 index 0000000000..4092a5fa61 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_6_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.6-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php new file mode 100644 index 0000000000..ec22d1da77 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -0,0 +1,40 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_6_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'update_cp_fields'))), + + array('config.update', array('version', '3.0.6-rc3')), + ); + } + + function update_cp_fields() + { + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' + SET field_show_on_vt = 1 + WHERE field_hide = 0 + AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; + $this->sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php new file mode 100644 index 0000000000..e748c7a4ff --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_6_rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.6-rc4')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php new file mode 100644 index 0000000000..f27b56f778 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_7_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.7')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php new file mode 100644 index 0000000000..5543d6437a --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_7'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.7-pl1')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php new file mode 100644 index 0000000000..71584382e8 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -0,0 +1,53 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_6'); + } + + function update_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'log' => array('log_time'), + ), + 'add_index' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id' => array('topic_id'), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('feed_overall', 1)), + array('config.add', array('feed_http_auth', 0)), + array('config.add', array('feed_limit_post', $this->config['feed_limit'])), + array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])), + array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])), + array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), + array('custom', array(array(&$this, 'delete_text_templates'))), + + array('config.update', array('version', '3.0.7-rc1')), + ); + } + + function delete_text_templates() + { + // Delete all text-templates from the template_data + $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' + WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt'); + $this->sql_query($sql); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php new file mode 100644 index 0000000000..4e380c810d --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -0,0 +1,72 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_7_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'update_email_hash'))), + + array('config.update', array('version', '3.0.7-rc2')), + ); + } + + function update_email_hash($start = 0) + { + $limit = 1000; + + $sql = 'SELECT user_id, user_email, user_email_hash + FROM ' . USERS_TABLE . ' + WHERE user_type <> ' . USER_IGNORE . " + AND user_email <> ''"; + $result = $this->db->sql_query_limit($sql, $limit, $start); + + $i = 0; + while ($row = $this->db->sql_fetchrow($result)) + { + $i++; + + // Snapshot of the phpbb_email_hash() function + // We cannot call it directly because the auto updater updates the DB first. :/ + $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); + + if ($user_email_hash != $row['user_email_hash']) + { + $sql_ary = array( + 'user_email_hash' => $user_email_hash, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (int) $row['user_id']; + $this->sql_query($sql); + } + } + $this->db->sql_freeresult($result); + + if ($i < $limit) + { + // Completed + return; + } + + return $start + $limit; + } +} diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php new file mode 100644 index 0000000000..a5defc8278 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_8_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.8')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php new file mode 100644 index 0000000000..78db06b512 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -0,0 +1,221 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_7_pl1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('custom', array(array(&$this, 'update_file_extension_group_names'))), + array('custom', array(array(&$this, 'update_module_auth'))), + array('custom', array(array(&$this, 'update_bots'))), + array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))), + array('module.add', array( + 'acp', + 'ACP_MESSAGES', + array( + 'module_basename' => 'acp_board', + 'modes' => array('post'), + ), + )), + array('config.add', array('load_unreads_search', 1)), + array('config.update_if_equals', array(600, 'queue_interval', 60)), + array('config.update_if_equals', array(50, 'email_package_size', 20)), + + array('config.update', array('version', '3.0.8-rc1')), + ); + } + + function update_file_extension_group_names() + { + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $this->db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $this->db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + + // The language strings we need are either in language/.../acp/attachments.php + // in the update package if we're updating to 3.0.8-RC1 or later, + // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. + // On an already updated board, they can also already be in language/.../acp/attachments.php + // in the board root. + $lang_files = array( + "{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}", + "{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}", + ); + + foreach ($lang_files as $lang_file) + { + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'"; + $this->sql_query($sql); + + $extension_groups_updated[$lang_key] = true; + } + } + } + $this->db->sql_freeresult($result); + } + + function update_module_auth() + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'avatar\''; + $this->sql_query($sql); + } + + function update_bots() + { + $bot_name = 'Bing [Bot]'; + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; + $result = $this->db->sql_query($sql); + $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); + $this->db->sql_freeresult($result); + + if (!$bing_already_added) + { + $bot_agent = 'bingbot/'; + $bot_ip = ''; + $sql = 'SELECT group_id, group_colour + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $this->db->sql_query($sql); + $group_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$group_row) + { + // default fallback, should never get here + $group_row['group_id'] = 6; + $group_row['group_colour'] = '9E8DA7'; + } + + if (!function_exists('user_add')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_row['group_id'], + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => $this->config['default_lang'], + 'user_style' => $this->config['default_style'], + 'user_timezone' => 0, + 'user_dateformat' => $this->config['default_dateformat'], + 'user_allow_massemail' => 0, + ); + + $user_id = user_add($user_row); + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )); + + $this->sql_query($sql); + } + } + + function delete_orphan_shadow_topics() + { + // Delete shadow topics pointing to not existing topics + $batch_size = 500; + + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', + ), + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $this->db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); + $this->db->sql_query($sql); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + return false; + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php new file mode 100644 index 0000000000..eb359e2697 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_9_rc4'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.9')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php new file mode 100644 index 0000000000..ea49cdbba9 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -0,0 +1,110 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_8'); + } + + function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'login_attempts' => array( + 'COLUMNS' => array( + // this column was removed from the database updater + // after 3.0.9-RC3 was released. It might still exist + // in 3.0.9-RCX installations and has to be dropped in + // 3.0.12 after the db_tools class is capable of properly + // removing a primary key. + // 'attempt_id' => array('UINT', NULL, 'auto_increment'), + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + //'PRIMARY_KEY' => 'attempt_id', + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), + ), + ), + 'change_columns' => array( + $this->table_prefix . 'bbcodes' => array( + 'bbcode_id' => array('USINT', 0), + ), + ), + ); + } + + function update_data() + { + return array( + array('config.add', array('ip_login_limit_max', 50)), + array('config.add', array('ip_login_limit_time', 21600)), + array('config.add', array('ip_login_limit_use_forwarded', 0)), + array('custom', array(array(&$this, 'update_file_extension_group_names'))), + array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))), + + array('config.update', array('version', '3.0.9-rc1')), + ); + } + + function update_file_extension_group_names() + { + // Update file extension group names to use language strings, again. + $sql = 'SELECT group_id, group_name + FROM ' . EXTENSION_GROUPS_TABLE . ' + WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql_ary = array( + 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE group_id = ' . $row['group_id']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } + + function fix_firebird_qa_captcha() + { + // Recover from potentially broken Q&A CAPTCHA table on firebird + // Q&A CAPTCHA was uninstallable, so it's safe to remove these + // without data loss + if ($this->db_tools->sql_layer == 'firebird') + { + $tables = array( + $this->table_prefix . 'captcha_questions', + $this->table_prefix . 'captcha_answers', + $this->table_prefix . 'qa_confirm', + ); + foreach ($tables as $table) + { + if ($this->db_tools->sql_table_exists($table)) + { + $this->db_tools->sql_table_drop($table); + } + } + } + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php new file mode 100644 index 0000000000..e3c4716665 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_9_rc1'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.9-rc2')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php new file mode 100644 index 0000000000..3cdecb96ae --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_9_rc2'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.9-rc3')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php new file mode 100644 index 0000000000..c2a92e618a --- /dev/null +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -0,0 +1,28 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration +{ + function depends_on() + { + return array('phpbb_db_migration_data_3_0_9_rc3'); + } + + function update_schema() + { + return array(); + } + + function update_data() + { + return array( + array('config.update', array('version', '3.0.9-rc4')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php new file mode 100644 index 0000000000..2771d82d83 --- /dev/null +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -0,0 +1,375 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration +{ + public function depends_on() + { + return array( + 'phpbb_db_migration_data_3_0_11', + 'phpbb_db_migration_data_extensions', + 'phpbb_db_migration_data_style_update_p2', + 'phpbb_db_migration_data_timezone', + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + GROUPS_TABLE => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_pm' => array('BOOL', 0), + ), + STYLES_TABLE => array( + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), + REPORTS_TABLE => array( + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + ), + ), + 'change_columns' => array( + GROUPS_TABLE => array( + 'group_legend' => array('UINT', 0), + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), + + array('config.add', array('fulltext_postgres_ts_name', 'simple')), + array('config.add', array('fulltext_postgres_min_word_len', 4)), + array('config.add', array('fulltext_postgres_max_word_len', 254)), + array('config.add', array('fulltext_sphinx_stopwords', 0)), + array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)), + + array('config.add', array('load_jquery_cdn', 0)), + array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')), + + array('config.add', array('use_system_cron', 0)), + + array('config.add', array('legend_sort_groupname', 0)), + array('config.add', array('teampage_forums', 1)), + array('config.add', array('teampage_memberships', 1)), + + array('config.add', array('load_cpf_pm', 0)), + + array('config.add', array('display_last_subject', 1)), + + array('config.add', array('assets_version', 1)), + + array('config.add', array('site_home_url', '')), + array('config.add', array('site_home_text', '')), + + array('permission.add', array('u_chgprofileinfo', true, 'u_sig')), + + array('module.add', array( + 'acp', + 'ACP_GROUPS', + array( + 'module_basename' => 'acp_groups', + 'modes' => array('position'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_ATTACHMENTS', + array( + 'module_basename' => 'acp_attachments', + 'modes' => array('manage'), + ), + )), + array('module.add', array( + 'acp', + 'ACP_STYLE_MANAGEMENT', + array( + 'module_basename' => 'acp_styles', + 'modes' => array('install', 'cache'), + ), + )), + array('module.add', array( + 'ucp', + 'UCP_PROFILE', + array( + 'module_basename' => 'ucp_profile', + 'modes' => array('autologin_keys'), + ), + )), + // Module will be renamed later + array('module.add', array( + 'acp', + 'ACP_CAT_STYLES', + 'ACP_LANGUAGE' + )), + + array('module.remove', array( + 'acp', + false, + 'ACP_TEMPLATES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_THEMES', + )), + array('module.remove', array( + 'acp', + false, + 'ACP_IMAGESETS', + )), + + array('custom', array(array($this, 'rename_module_basenames'))), + array('custom', array(array($this, 'rename_styles_module'))), + array('custom', array(array($this, 'add_group_teampage'))), + array('custom', array(array($this, 'update_group_legend'))), + array('custom', array(array($this, 'localise_global_announcements'))), + array('custom', array(array($this, 'update_ucp_pm_basename'))), + array('custom', array(array($this, 'update_ucp_profile_auth'))), + array('custom', array(array($this, 'move_customise_modules'))), + + array('config.update', array('version', '3.1.0-dev')), + ); + } + + public function move_customise_modules() + { + // Move language management to new location in the Customise tab + // First get language module id + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'acp_language'"; + $result = $this->db->sql_query($sql); + $language_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $this->db->sql_query($sql); + $language_management_module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + if (!class_exists('acp_modules')) + { + include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); + } + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); + } + + public function update_ucp_pm_basename() + { + $sql = 'SELECT module_id, module_basename + FROM ' . MODULES_TABLE . " + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM'"; + $result = $this->db->sql_query_limit($sql, 1); + + if ($row = $this->db->sql_fetchrow($result)) + { + // This update is still not applied. Applying it + + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; + + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } + + public function update_ucp_profile_auth() + { + // Update the auth setting for the module + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'acl_u_chgprofileinfo' + WHERE module_class = 'ucp' + AND module_basename = 'ucp_profile' + AND module_mode = 'profile_info'"; + $this->sql_query($sql); + } + + public function rename_styles_module() + { + // Rename styles module to Customise + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + $this->sql_query($sql); + } + + public function rename_module_basenames() + { + // rename all module basenames to full classname + $sql = 'SELECT module_id, module_basename, module_class + FROM ' . MODULES_TABLE; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $module_id = (int) $row['module_id']; + unset($row['module_id']); + + if (!empty($row['module_basename']) && !empty($row['module_class'])) + { + // all the class names start with class name or with phpbb_ for auto loading + if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && + strpos($row['module_basename'], 'phpbb_') !== 0) + { + $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; + + $sql_update = $this->db->sql_build_array('UPDATE', $row); + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET ' . $sql_update . ' + WHERE module_id = ' . $module_id; + $this->sql_query($sql); + } + } + } + + $this->db->sql_freeresult($result); + } + + public function add_group_teampage() + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + $this->sql_query($sql); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + $this->sql_query($sql); + } + + public function update_group_legend() + { + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $this->db->sql_query($sql); + + $next_legend = 1; + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + $this->sql_query($sql); + + $next_legend++; + } + $this->db->sql_freeresult($result); + } + + public function localise_global_announcements() + { + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $this->db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $this->db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $this->db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type = ' . FORUM_POST; + $result = $this->db->sql_query_limit($sql, 1); + $ga_forum_id = $this->db->sql_fetchfield('forum_id'); + $this->db->sql_freeresult($result); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $this->db->sql_query($sql); + $lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time'); + $this->db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + $this->sql_query($sql); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $this->db->sql_in_set('topic_id', $global_announcements); + $this->sql_query($sql); + } + unset($table_ary); + } + } +} diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php new file mode 100644 index 0000000000..b8379483a3 --- /dev/null +++ b/phpBB/includes/db/migration/data/extensions.php @@ -0,0 +1,55 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_extensions extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + EXT_TABLE => array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + ), + ), + ), + ); + } + + public function update_data() + { + return array( + // Module will be renamed later + array('module.add', array( + 'acp', + 'ACP_CAT_STYLES', + 'ACP_EXTENSION_MANAGEMENT' + )), + array('module.add', array( + 'acp', + 'ACP_EXTENSION_MANAGEMENT', + array( + 'module_basename' => 'acp_extensions', + 'modes' => array('main'), + ), + )), + array('permission.add', array('a_extensions', true, 'a_styles')), + ); + } +} diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php new file mode 100644 index 0000000000..387b37de8e --- /dev/null +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -0,0 +1,157 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array(); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'styles_update'))), + ); + } + + public function styles_update() + { + // Get list of valid 3.1 styles + $available_styles = array('prosilver'); + + $iterator = new DirectoryIterator($this->phpbb_root_path . 'styles'); + $skip_dirs = array('.', '..', 'prosilver'); + foreach ($iterator as $fileinfo) + { + if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) + { + $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); + if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) + { + // 3.1 style + $available_styles[] = $fileinfo->getFilename(); + } + } + } + + // Get all installed styles + if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id + AND i.imageset_id = s.imageset_id"; + } + else + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id"; + } + $result = $this->db->sql_query($sql); + + $styles = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $styles[] = $row; + } + $this->db->sql_freeresult($result); + + // Decide which styles to keep, all others will be deleted + $valid_styles = array(); + foreach ($styles as $style_row) + { + if ( + // Delete styles with parent style (not supported yet) + $style_row['template_inherits_id'] == 0 && + // Check if components match + $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && + // Check if components are valid + in_array($style_row['template_path'], $available_styles) + ) + { + // Valid style. Keep it + $sql_ary = array( + 'style_path' => $style_row['template_path'], + 'bbcode_bitfield' => $style_row['bbcode_bitfield'], + 'style_parent_id' => 0, + 'style_parent_tree' => '', + ); + $this->sql_query('UPDATE ' . STYLES_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE style_id = ' . $style_row['style_id']); + $valid_styles[] = (int) $style_row['style_id']; + } + } + + // Remove old entries from styles table + if (!sizeof($valid_styles)) + { + // No valid styles: remove everything and add prosilver + $this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + + $sql_ary = array( + 'style_name' => 'prosilver', + 'style_copyright' => '© phpBB Group', + 'style_active' => 1, + 'style_path' => 'prosilver', + 'bbcode_bitfield' => 'lNg=', + 'style_parent_id' => 0, + 'style_parent_tree' => '', + + // Will be removed in the next step + 'imageset_id' => 0, + 'template_id' => 0, + 'theme_id' => 0, + ); + + $sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); + $this->sql_query($sql); + + $sql = 'SELECT style_id + FROM ' . $table . " + WHERE style_name = 'prosilver'"; + $result = $this->sql_query($sql); + $default_style = $this->db->sql_fetchfield($result); + $this->db->sql_freeresult($result); + + set_config('default_style', $default_style); + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + $this->sql_query($sql); + } + else + { + // There are valid styles in styles table. Remove styles that are outdated + $this->sql_query('DELETE FROM ' . STYLES_TABLE . ' + WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true)); + + // Change default style + if (!in_array($this->config['default_style'], $valid_styles)) + { + $this->sql_query('UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $valid_styles[0] . "' + WHERE config_name = 'default_style'"); + } + + // Reset styles for users + $this->sql_query('UPDATE ' . USERS_TABLE . ' + SET user_style = 0 + WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true)); + } + } +} diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php new file mode 100644 index 0000000000..db4b7f1753 --- /dev/null +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -0,0 +1,42 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_style_update_p1'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + STYLES_TABLE => array( + 'imageset_id', + 'template_id', + 'theme_id', + ), + ), + + 'drop_tables' => array( + STYLES_IMAGESET_TABLE, + STYLES_IMAGESET_DATA_TABLE, + STYLES_TEMPLATE_TABLE, + STYLES_TEMPLATE_DATA_TABLE, + STYLES_THEME_TABLE, + ), + ); + } + + public function update_data() + { + return array(); + } +} diff --git a/phpBB/includes/update_helpers.php b/phpBB/includes/db/migration/data/timezone.php similarity index 72% rename from phpBB/includes/update_helpers.php rename to phpBB/includes/db/migration/data/timezone.php index 69d678b2f8..7734ed4b76 100644 --- a/phpBB/includes/update_helpers.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -1,16 +1,65 @@ <?php /** * -* @package phpBB3 +* @package migration * @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* */ -/** -* phpBB Update Helpers -*/ -class phpbb_update_helpers +class phpbb_db_migration_data_timezone extends phpbb_db_migration { + public function depends_on() + { + return array('phpbb_db_migration_data_3_0_11'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + USERS_TABLE => array( + 'user_timezone' => array('VCHAR:100', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_timezones'))), + ); + } + + public function update_timezones() + { + // Update user timezones + $sql = 'SELECT user_dst, user_timezone + FROM ' . USERS_TABLE . ' + GROUP BY user_timezone, user_dst'; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' + WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' + AND user_dst = " . (int) $row['user_dst']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + + // Update board default timezone + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' + WHERE config_name = 'board_timezone'"; + $this->sql_query($sql); + + // After we have calculated the timezones we can delete user_dst column from user table. + $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); + } + /** * Determine the new timezone for a given phpBB 3.0 timezone and * "Daylight Saving Time" option @@ -19,7 +68,7 @@ class phpbb_update_helpers * @param $dst int Users daylight saving time * @return string Users new php Timezone which is used since 3.1 */ - function convert_phpbb30_timezone($timezone, $dst) + public function convert_phpbb30_timezone($timezone, $dst) { $offset = $timezone + $dst; diff --git a/phpBB/install/database_update_migrations.php b/phpBB/install/database_update_migrations.php new file mode 100644 index 0000000000..52682dc489 --- /dev/null +++ b/phpBB/install/database_update_migrations.php @@ -0,0 +1,139 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2005 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +$update_start_time = time(); + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +/** +* @ignore +*/ +define('IN_PHPBB', true); +$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; +$phpEx = substr(strrchr(__FILE__, '.'), 1); + +require($phpbb_root_path . 'includes/startup.' . $phpEx); + +if (file_exists($phpbb_root_path . 'config.' . $phpEx)) +{ + require($phpbb_root_path . 'config.' . $phpEx); +} + +// Include files +require($phpbb_root_path . 'includes/class_loader.' . $phpEx); + +require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); + +require($phpbb_root_path . 'includes/constants.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +// Set PHP error handler to ours +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); + +// Setup class loader first +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); + +// Set up container +$container_extensions = array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), +); +$container_passes = array( + new phpbb_di_pass_collection_pass(), + //new phpbb_di_pass_kernel_pass(), +); +$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); + +// Compile the container +foreach ($container_passes as $pass) +{ + $phpbb_container->addCompilerPass($pass); +} +$phpbb_container->compile(); + +// set up caching +$cache = $phpbb_container->get('cache'); + +// Instantiate some basic classes +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); + +// make sure request_var uses this request instance +request_var('', 0, false, false, $request); // "dependency injection" for a function + +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); + +// End startup code + +$db_tools = $phpbb_container->get('dbal.tools'); +if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) +{ + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); +} + +$migrator = $phpbb_container->get('migrator'); +$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); + +// What is a safe limit of execution time? Half the max execution time should be safe. +$safe_time_limit = (ini_get('max_execution_time') / 2); + +while (!$migrator->finished()) +{ + try + { + $migrator->update(); + } + catch (phpbb_db_migration_exception $e) + { + echo $e; + + garbage_collection(); + exit_handler(); + } + + echo $migrator->last_run_migration['name'] . '<br />'; + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $update_start_time) >= $safe_time_limit) + { + //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; + echo 'Update not yet completed.<br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; + + garbage_collection(); + exit_handler(); + } +} + +echo 'Finished'; + +garbage_collection(); +exit_handler(); From bb99a2609d9fcdd3c20ea9c910ae6e05d9da56cd Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 16:00:58 -0600 Subject: [PATCH 106/174] [feature/migrations] Replace database_update.php with migrations updater PHPBB3-9737 --- phpBB/install/database_update.php | 2951 +----------------- phpBB/install/database_update_migrations.php | 139 - 2 files changed, 125 insertions(+), 2965 deletions(-) delete mode 100644 phpBB/install/database_update_migrations.php diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4e17a1429c..7431c96231 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1,39 +1,23 @@ <?php /** * -* @package install -* @copyright (c) 2006 phpBB Group +* @package phpBB3 +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ +$update_start_time = time(); + use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -define('UPDATES_TO_VERSION', '3.1.0-dev'); - -// Enter any version to update from to test updates. The version within the db will not be updated. -define('DEBUG_FROM_VERSION', false); - -// Which oldest version does this updater support? -define('OLDEST_FROM_VERSION', '3.0.0'); - -// Return if we "just include it" to find out for which version the database update is responsible for -if (defined('IN_PHPBB') && defined('IN_INSTALL')) -{ - $updates_to_version = UPDATES_TO_VERSION; - $debug_from_version = DEBUG_FROM_VERSION; - $oldest_from_version = OLDEST_FROM_VERSION; - - return; -} - /** +* @ignore */ define('IN_PHPBB', true); define('IN_INSTALL', true); - $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); @@ -59,15 +43,7 @@ if (!function_exists('phpbb_require_updated')) phpbb_require_updated('includes/startup.' . $phpEx); -$updates_to_version = UPDATES_TO_VERSION; -$debug_from_version = DEBUG_FROM_VERSION; -$oldest_from_version = OLDEST_FROM_VERSION; - -@set_time_limit(0); - -// Include essential scripts include($phpbb_root_path . 'config.' . $phpEx); - if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) { die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update."); @@ -81,38 +57,36 @@ $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_ro require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/functions_container.' . $phpEx); -phpbb_require_updated('includes/functions_content.' . $phpEx, true); - -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -phpbb_require_updated('includes/db/db_tools.' . $phpEx); - -// new table constants are separately defined here in case the updater is run -// before the files are updated -if (!defined('LOGIN_ATTEMPT_TABLE')) -{ - define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); -} -if (!defined('EXT_TABLE')) -{ - define('EXT_TABLE', $table_prefix . 'ext'); -} +// Set PHP error handler to ours +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); $phpbb_class_loader->register(); -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); -$phpbb_class_loader_ext->register(); -// Set up container -$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); +// Set up container (must be done here because extensions table may not exist) +$container_extensions = array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), +); +$container_passes = array( + new phpbb_di_pass_collection_pass(), + //new phpbb_di_pass_kernel_pass(), +); +$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); -$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); -$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); +// Compile the container +foreach ($container_passes as $pass) +{ + $phpbb_container->addCompilerPass($pass); +} +$phpbb_container->compile(); // set up caching $cache = $phpbb_container->get('cache'); @@ -127,6 +101,16 @@ $db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); +$orig_version = $config['version']; + +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx); + // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) { @@ -144,129 +128,7 @@ else $phpbb_hook = false; } -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - -$user->ip = ''; -if ($request->server('REMOTE_ADDR')) -{ - $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : $request->server('REMOTE_ADDR'); -} - -$sql = "SELECT config_value - FROM " . CONFIG_TABLE . " - WHERE config_name = 'default_lang'"; -$result = $db->sql_query($sql); -$row = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -$language = basename(request_var('language', '')); - -if (!$language) -{ - $language = $row['config_value']; -} - -if (!file_exists($phpbb_root_path . 'language/' . $language)) -{ - die('No language found!'); -} - -// And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); - -// Set PHP error handler to ours -//set_error_handler('msg_handler'); - -// Define some variables for the database update -$inline_update = (request_var('type', 0)) ? true : false; - -// To let set_config() calls succeed, we need to make the config array available globally -$config = new phpbb_config_db($db, $phpbb_container->get('cache.driver'), CONFIG_TABLE); -set_config(null, null, null, $config); -set_config_count(null, null, null, $config); - -// Update asset_version -if (isset($config['assets_version'])) -{ - set_config('assets_version', $config['assets_version'] + 1); -} - -// phpbb_db_tools will be taken from new files (under install/update/new) -// if possible, falling back to the board's copy. -$db_tools = new phpbb_db_tools($db, true); - -$database_update_info = database_update_info(); - -$error_ary = array(); -$errored = false; - -$sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; -$result = $db->sql_query_limit($sql, 1); -$has_global = (int) $db->sql_fetchfield('topic_id'); -$db->sql_freeresult($result); -$ga_forum_id = request_var('ga_forum_id', 0); - -if ($has_global && !$ga_forum_id) -{ - ?> - <!DOCTYPE html> - <html dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>"> - <head> - <meta charset="utf-8"> - - <title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title> - - <link href="<?php echo htmlspecialchars($phpbb_admin_path); ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" /> - - </head> - - <body> - <div id="wrap"> - <div id="page-header"> </div> - - <div id="page-body"> - <div id="acp"> - <div class="panel"> - <span class="corners-top"><span></span></span> - <div id="content"> - <div id="main" class="install-body"> - - <h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1> - - <br /> - - <form action="" method="post" id="select_ga_forum_id"> - <?php - if (isset($lang['SELECT_FORUM_GA'])) - { - // Language string is available: - echo $lang['SELECT_FORUM_GA']; - } - else - { - echo 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):'; - } - ?> - <select id="ga_forum_id" name="ga_forum_id"><?php echo make_forum_select(false, false, true, true) ?></select> - - <input type="submit" name="post" value="<?php echo $lang['SUBMIT']; ?>" class="button1" /> - </form> - <?php - _print_footer(); - exit_handler(); -} - header('Content-type: text/html; charset=UTF-8'); - ?> <!DOCTYPE html> <html dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>"> @@ -280,2674 +142,111 @@ header('Content-type: text/html; charset=UTF-8'); </head> <body> -<div id="wrap"> - <div id="page-header"> </div> + <div id="wrap"> + <div id="page-header"> </div> - <div id="page-body"> - <div id="acp"> - <div class="panel"> - <span class="corners-top"><span></span></span> - <div id="content"> - <div id="main" class="install-body"> + <div id="page-body"> + <div id="acp"> + <div class="panel"> + <span class="corners-top"><span></span></span> + <div id="content"> + <div id="main" class="install-body"> - <h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1> + <h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1> - <br /> + <br /> - <p><?php echo $lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br /> -<?php - -if ($debug_from_version !== false) -{ - $config['version'] = $debug_from_version; -} - -echo $lang['PREVIOUS_VERSION'] . ' :: <strong>' . $config['version'] . '</strong><br />'; -echo $lang['UPDATED_VERSION'] . ' :: <strong>' . $updates_to_version . '</strong></p>'; - -$current_version = str_replace('rc', 'RC', strtolower($config['version'])); -$latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); -$orig_version = $config['version']; - -// Fill DB version -if (empty($config['dbms_version'])) -{ - set_config('dbms_version', $db->sql_server_info(true)); -} - -// Firebird update from Firebird 2.0 to 2.1+ required? -if ($db->sql_layer == 'firebird') -{ - // We do not trust any PHP5 function enabled, we will simply test for a function new in 2.1 - $db->sql_return_on_error(true); - - $sql = 'SELECT 1 FROM RDB$DATABASE - WHERE BIN_AND(10, 1) = 0'; - $result = $db->sql_query($sql); - - if (!$result || $db->sql_error_triggered) - { - echo '<br /><br />'; - echo '<h1>' . $lang['ERROR'] . '</h1><br />'; - - echo '<p>' . $lang['FIREBIRD_DBMS_UPDATE_REQUIRED'] . '</p>'; - - _print_footer(); - - exit_handler(); - exit; - } - - $db->sql_freeresult($result); - $db->sql_return_on_error(false); -} - -// MySQL update from MySQL 3.x/4.x to > 4.1.x required? -if ($db->sql_layer == 'mysql' || $db->sql_layer == 'mysql4' || $db->sql_layer == 'mysqli') -{ - // Verify by fetching column... if the column type matches the new type we update dbms_version... - $sql = "SHOW COLUMNS FROM " . CONFIG_TABLE; - $result = $db->sql_query($sql); - - $column_type = ''; - while ($row = $db->sql_fetchrow($result)) - { - $field = strtolower($row['Field']); - - if ($field == 'config_value') - { - $column_type = strtolower($row['Type']); - break; - } - } - $db->sql_freeresult($result); - - // If column type is blob, but mysql version says we are on > 4.1.3, then the schema needs an update - if (strpos($column_type, 'blob') !== false && version_compare($db->sql_server_info(true), '4.1.3', '>=')) - { - echo '<br /><br />'; - echo '<h1>' . $lang['ERROR'] . '</h1><br />'; - - echo '<p>' . sprintf($lang['MYSQL_SCHEMA_UPDATE_REQUIRED'], $config['dbms_version'], $db->sql_server_info(true)) . '</p>'; - - _print_footer(); - - exit_handler(); - exit; - } -} - -// Now check if the user wants to update from a version we no longer support updates from -if (version_compare($current_version, $oldest_from_version, '<')) -{ - echo '<br /><br /><h1>' . $lang['ERROR'] . '</h1><br />'; - echo '<p>' . sprintf($lang['DB_UPDATE_NOT_SUPPORTED'], $oldest_from_version, $current_version) . '</p>'; - - _print_footer(); - exit_handler(); - exit; -} - -// If the latest version and the current version are 'unequal', we will update the version_update_from, else we do not update anything. -if ($inline_update) -{ - if ($current_version !== $latest_version) - { - set_config('version_update_from', $orig_version); - } -} -else -{ - // If not called from the update script, we will actually remove the traces - $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); -} - -// Schema updates -?> - <br /><br /> - - <h1><?php echo $lang['UPDATE_DATABASE_SCHEMA']; ?></h1> - - <br /> - <p><?php echo $lang['PROGRESS']; ?> :: <strong> + <p><?php echo $lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br /> + <?php echo $lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br /> <?php -flush(); - -// We go through the schema changes from the lowest to the highest version -// We try to also include versions 'in-between'... -$no_updates = true; -$versions = array_keys($database_update_info); -for ($i = 0; $i < sizeof($versions); $i++) -{ - $version = $versions[$i]; - $schema_changes = $database_update_info[$version]; - - $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; - - // If the installed version to be updated to is < than the current version, and if the current version is >= as the version to be updated to next, we will skip the process - if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>=')) - { - continue; - } - - if (!sizeof($schema_changes)) - { - continue; - } - - $no_updates = false; - - // We run one index after the other... to be consistent with schema changes... - foreach ($schema_changes as $key => $changes) - { - $statements = $db_tools->perform_schema_changes(array($key => $changes)); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } -} - -_write_result($no_updates, $errored, $error_ary); - -// Data updates -$error_ary = array(); -$errored = $no_updates = false; - -?> - -<br /><br /> -<h1><?php echo $lang['UPDATING_DATA']; ?></h1> -<br /> -<p><?php echo $lang['PROGRESS']; ?> :: <strong> - -<?php - -flush(); - -$no_updates = true; -$versions = array_keys($database_update_info); - -// some code magic -for ($i = 0; $i < sizeof($versions); $i++) -{ - $version = $versions[$i]; - $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; - - // If the installed version to be updated to is < than the current version, and if the current version is >= as the version to be updated to next, we will skip the process - if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>=')) - { - continue; - } - - change_database_data($no_updates, $version); -} - -_write_result($no_updates, $errored, $error_ary); - -$error_ary = array(); -$errored = $no_updates = false; - -?> - -<br /><br /> -<h1><?php echo $lang['UPDATE_VERSION_OPTIMIZE']; ?></h1> -<br /> -<p><?php echo $lang['PROGRESS']; ?> :: <strong> - -<?php - -flush(); - -if ($debug_from_version === false) -{ - // update the version - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '$updates_to_version' - WHERE config_name = 'version'"; - _sql($sql, $errored, $error_ary); -} - -// Reset permissions -$sql = 'UPDATE ' . USERS_TABLE . " - SET user_permissions = '', - user_perm_from = 0"; -_sql($sql, $errored, $error_ary); - -// Update the dbms version if everything is ok... -set_config('dbms_version', $db->sql_server_info(true)); - -/* Optimize/vacuum analyze the tables where appropriate -// this should be done for each version in future along with -// the version number update -switch ($db->sql_layer) -{ - case 'mysql': - case 'mysqli': - case 'mysql4': - $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; - _sql($sql, $errored, $error_ary); - break; - - case 'postgresql': - _sql("VACUUM ANALYZE", $errored, $error_ary); - break; -} -*/ - -_write_result($no_updates, $errored, $error_ary); - -?> - -<br /> -<h1><?php echo $lang['UPDATE_COMPLETED']; ?></h1> - -<br /> - -<?php - -if (!$inline_update) -{ -?> - - <p style="color:red"><?php echo $lang['UPDATE_FILES_NOTICE']; ?></p> - - <p><?php echo $lang['COMPLETE_LOGIN_TO_BOARD']; ?></p> - -<?php -} -else -{ -?> - - <p><?php echo ((isset($lang['INLINE_UPDATE_SUCCESSFUL'])) ? $lang['INLINE_UPDATE_SUCCESSFUL'] : 'The database update was successful. Now you need to continue the update process.'); ?></p> - - <p><a href="<?php echo append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode=update&sub=file_check&language=$language"); ?>" class="button1"><?php echo (isset($lang['CONTINUE_UPDATE_NOW'])) ? $lang['CONTINUE_UPDATE_NOW'] : 'Continue the update process now'; ?></a></p> - -<?php -} - -// Add database update to log -add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version); - -// Now we purge the session table as well as all cache files -$phpbb_container->get('cache.driver')->purge(); - -_print_footer(); - -garbage_collection(); - -if (function_exists('exit_handler')) -{ - exit_handler(); -} - /** -* Print out footer +* @todo firebird/mysql update? */ -function _print_footer() + +// End startup code + +$db_tools = $phpbb_container->get('dbal.tools'); +if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) { - echo <<<EOF - </div> + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); +} + +$migrator = $phpbb_container->get('migrator'); +$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); + +// What is a safe limit of execution time? Half the max execution time should be safe. +$safe_time_limit = (ini_get('max_execution_time') / 2); + +while (!$migrator->finished()) +{ + try + { + $migrator->update(); + } + catch (phpbb_db_migration_exception $e) + { + echo $e; + + end_update($cache); + } + + echo $migrator->last_run_migration['name'] . '<br />'; + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $update_start_time) >= $safe_time_limit) + { + //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; + echo 'Update not yet completed.<br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; + + end_update($cache); + } +} + +if ($orig_version != $config['version']) +{ + add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); +} + +echo 'Finished'; + +end_update($cache); + +function end_update($cache) +{ + $cache->purge(); + +?> + </p> + </div> + </div> + <span class="corners-bottom"><span></span></span> </div> - <span class="corners-bottom"><span></span></span> + </div> </div> + + <div id="page-footer"> + Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group </div> </div> - - <div id="page-footer"> - Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group - </div> -</div> - </body> </html> -EOF; -} - -/** -* Function for triggering an sql statement -*/ -function _sql($sql, &$errored, &$error_ary, $echo_dot = true) -{ - global $db; - - if (defined('DEBUG')) - { - echo "<br />\n{$sql}\n<br />"; - } - - $db->sql_return_on_error(true); - - if ($sql === 'begin') - { - $result = $db->sql_transaction('begin'); - } - else if ($sql === 'commit') - { - $result = $db->sql_transaction('commit'); - } - else - { - $result = $db->sql_query($sql); - if ($db->sql_error_triggered) - { - $errored = true; - $error_ary['sql'][] = $db->sql_error_sql; - $error_ary['error_code'][] = $db->sql_error_returned; - } - } - - $db->sql_return_on_error(false); - - if ($echo_dot) - { - echo ". \n"; - flush(); - } - - return $result; -} - -function _write_result($no_updates, $errored, $error_ary) -{ - global $lang; - - if ($no_updates) - { - echo ' ' . $lang['NO_UPDATES_REQUIRED'] . '</strong></p>'; - } - else - { - echo ' <span class="success">' . $lang['DONE'] . '</span></strong><br />' . $lang['RESULT'] . ' :: '; - - if ($errored) - { - echo ' <strong>' . $lang['SOME_QUERIES_FAILED'] . '</strong> <ul>'; - - for ($i = 0; $i < sizeof($error_ary['sql']); $i++) - { - echo '<li>' . $lang['ERROR'] . ' :: <strong>' . htmlspecialchars($error_ary['error_code'][$i]['message']) . '</strong><br />'; - echo $lang['SQL'] . ' :: <strong>' . htmlspecialchars($error_ary['sql'][$i]) . '</strong><br /><br /></li>'; - } - - echo '</ul> <br /><br />' . $lang['SQL_FAILURE_EXPLAIN'] . '</p>'; - } - else - { - echo '<strong>' . $lang['NO_ERRORS'] . '</strong></p>'; - } - } -} - -function _add_modules($modules_to_install) -{ - global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config; - - // modules require an extension manager - if (empty($phpbb_extension_manager)) - { - $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx"); - } - - include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - - $_module = new acp_modules(); - - foreach ($modules_to_install as $module_mode => $module_data) - { - $_module->module_class = $module_data['class']; - - // Determine parent id first - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['class']) . "' - AND module_langname = '" . $db->sql_escape($module_data['cat']) . "' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - - // There may be more than one categories with the same name - $categories = array(); - while ($row = $db->sql_fetchrow($result)) - { - $categories[] = (int) $row['module_id']; - } - $db->sql_freeresult($result); - - if (!sizeof($categories)) - { - continue; - } - - // Add the module to all categories found - foreach ($categories as $parent_id) - { - // Check if the module already exists - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = '" . $db->sql_escape($module_data['base']) . "' - AND module_class = '" . $db->sql_escape($module_data['class']) . "' - AND module_langname = '" . $db->sql_escape($module_data['title']) . "' - AND module_mode = '" . $db->sql_escape($module_mode) . "' - AND module_auth = '" . $db->sql_escape($module_data['auth']) . "' - AND parent_id = {$parent_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // If it exists, we simply continue with the next category - if ($row) - { - continue; - } - - // Build the module sql row - $module_row = array( - 'module_basename' => $module_data['base'], - 'module_enabled' => (isset($module_data['enabled'])) ? (int) $module_data['enabled'] : 1, - 'module_display' => (isset($module_data['display'])) ? (int) $module_data['display'] : 1, - 'parent_id' => $parent_id, - 'module_class' => $module_data['class'], - 'module_langname' => $module_data['title'], - 'module_mode' => $module_mode, - 'module_auth' => $module_data['auth'], - ); - - $_module->update_module_data($module_row, true); - - // Ok, do we need to re-order the module, move it up or down? - if (!isset($module_data['after'])) - { - continue; - } - - $after_mode = $module_data['after'][0]; - $after_langname = $module_data['after'][1]; - - // First of all, get the module id for the module this one has to be placed after - $sql = 'SELECT left_id - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['class']) . "' - AND module_basename = '" . $db->sql_escape($module_data['base']) . "' - AND module_langname = '" . $db->sql_escape($after_langname) . "' - AND module_mode = '" . $db->sql_escape($after_mode) . "' - AND parent_id = '{$parent_id}'"; - $result = $db->sql_query($sql); - $first_left_id = (int) $db->sql_fetchfield('left_id'); - $db->sql_freeresult($result); - - if (!$first_left_id) - { - continue; - } - - // Ok, count the number of modules between $after_mode and the added module - $sql = 'SELECT COUNT(module_id) as num_modules - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['class']) . "' - AND parent_id = {$parent_id} - AND left_id BETWEEN {$first_left_id} AND {$module_row['left_id']}"; - $result = $db->sql_query($sql); - $steps = (int) $db->sql_fetchfield('num_modules'); - $db->sql_freeresult($result); - - // We need to substract 2 - $steps -= 2; - - if ($steps <= 0) - { - continue; - } - - // Ok, move module up $num_modules times. ;) - $_module->move_module_by($module_row, 'move_up', $steps); - } - } - - $_module->remove_cache_file(); -} - -/** -* Add a new permission, optionally copy permission setting from another -* -* @param auth_admin $auth_admin auth_admin object -* @param phpbb_db_driver $db Database object -* @param string $permission_name Name of the permission to add -* @param bool $is_global True is global, false is local -* @param string $copy_from Optional permission name from which to copy -* @return bool true on success, false on failure -*/ -function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permission_name, $is_global = true, $copy_from = '') -{ - // Only add a permission that don't already exist - if (!empty($auth_admin->acl_options['id'][$permission_name])) - { - return true; - } - - $permission_scope = $is_global ? 'global' : 'local'; - - $result = $auth_admin->acl_add_option(array( - $permission_scope => array($permission_name), - )); - - if (!$result) - { - return $result; - } - - // The permission has been added, now we can copy it if needed - if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) - { - $old_id = $auth_admin->acl_options['id'][$copy_from]; - $new_id = $auth_admin->acl_options['id'][$permission_name]; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - $auth_admin->acl_clear_prefetch(); - } - - return true; -} - -/**************************************************************************** -* ADD YOUR DATABASE SCHEMA CHANGES HERE * -*****************************************************************************/ -function database_update_info() -{ - return array( - // Changes from 3.0.0 to the next version - '3.0.0' => array( - // Add the following columns - 'add_columns' => array( - FORUMS_TABLE => array( - 'display_subforum_list' => array('BOOL', 1), - ), - SESSIONS_TABLE => array( - 'session_forum_id' => array('UINT', 0), - ), - ), - 'drop_keys' => array( - GROUPS_TABLE => array('group_legend'), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_forum_id' => array('session_forum_id'), - ), - GROUPS_TABLE => array( - 'group_legend_name' => array('group_legend', 'group_name'), - ), - ), - ), - // No changes from 3.0.1-RC1 to 3.0.1 - '3.0.1-RC1' => array(), - // No changes from 3.0.1 to 3.0.2-RC1 - '3.0.1' => array(), - // Changes from 3.0.2-RC1 to 3.0.2-RC2 - '3.0.2-RC1' => array( - 'change_columns' => array( - DRAFTS_TABLE => array( - 'draft_subject' => array('STEXT_UNI', ''), - ), - FORUMS_TABLE => array( - 'forum_last_post_subject' => array('STEXT_UNI', ''), - ), - POSTS_TABLE => array( - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - ), - PRIVMSGS_TABLE => array( - 'message_subject' => array('STEXT_UNI', ''), - ), - TOPICS_TABLE => array( - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - ), - ), - 'drop_keys' => array( - SESSIONS_TABLE => array('session_forum_id'), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_fid' => array('session_forum_id'), - ), - ), - ), - // No changes from 3.0.2-RC2 to 3.0.2 - '3.0.2-RC2' => array(), - - // Changes from 3.0.2 to 3.0.3-RC1 - '3.0.2' => array( - // Add the following columns - 'add_columns' => array( - STYLES_TEMPLATE_TABLE => array( - 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', ''), - ), - GROUPS_TABLE => array( - 'group_max_recipients' => array('UINT', 0), - ), - ), - ), - - // No changes from 3.0.3-RC1 to 3.0.3 - '3.0.3-RC1' => array(), - - // Changes from 3.0.3 to 3.0.4-RC1 - '3.0.3' => array( - 'add_columns' => array( - PROFILE_FIELDS_TABLE => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - STYLES_TABLE => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - STYLES_IMAGESET_TABLE => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_IMAGESET_DATA_TABLE => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - STYLES_THEME_TABLE => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_TABLE => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_DATA_TABLE => array( - 'template_id' => array('UINT', 0), - ), - FORUMS_TABLE => array( - 'forum_style' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_style' => array('UINT', 0), - ), - ), - ), - - // Changes from 3.0.4-RC1 to 3.0.4 - '3.0.4-RC1' => array(), - - // Changes from 3.0.4 to 3.0.5-RC1 - '3.0.4' => array( - 'change_columns' => array( - FORUMS_TABLE => array( - 'forum_style' => array('UINT', 0), - ), - ), - ), - - // No changes from 3.0.5-RC1 to 3.0.5 - '3.0.5-RC1' => array(), - - // Changes from 3.0.5 to 3.0.6-RC1 - '3.0.5' => array( - 'add_columns' => array( - CONFIRM_TABLE => array( - 'attempts' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time'=> array('TIMESTAMP', 0), - ), - GROUPS_TABLE => array( - 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), - ), - PRIVMSGS_TABLE => array( - 'message_reported' => array('BOOL', 0), - ), - REPORTS_TABLE => array( - 'pm_id' => array('UINT', 0), - ), - PROFILE_FIELDS_TABLE => array( - 'field_show_on_vt' => array('BOOL', 0), - ), - FORUMS_TABLE => array( - 'forum_options' => array('UINT:20', 0), - ), - ), - 'change_columns' => array( - USERS_TABLE => array( - 'user_options' => array('UINT:11', 230271), - ), - ), - 'add_index' => array( - REPORTS_TABLE => array( - 'post_id' => array('post_id'), - 'pm_id' => array('pm_id'), - ), - POSTS_TABLE => array( - 'post_username' => array('post_username:255'), - ), - ), - ), - - // No changes from 3.0.6-RC1 to 3.0.6-RC2 - '3.0.6-RC1' => array(), - // No changes from 3.0.6-RC2 to 3.0.6-RC3 - '3.0.6-RC2' => array(), - // No changes from 3.0.6-RC3 to 3.0.6-RC4 - '3.0.6-RC3' => array(), - // No changes from 3.0.6-RC4 to 3.0.6 - '3.0.6-RC4' => array(), - - // Changes from 3.0.6 to 3.0.7-RC1 - '3.0.6' => array( - 'drop_keys' => array( - LOG_TABLE => array('log_time'), - ), - 'add_index' => array( - TOPICS_TRACK_TABLE => array( - 'topic_id' => array('topic_id'), - ), - ), - ), - - // No changes from 3.0.7-RC1 to 3.0.7-RC2 - '3.0.7-RC1' => array(), - // No changes from 3.0.7-RC2 to 3.0.7 - '3.0.7-RC2' => array(), - // No changes from 3.0.7 to 3.0.7-PL1 - '3.0.7' => array(), - // No changes from 3.0.7-PL1 to 3.0.8-RC1 - '3.0.7-PL1' => array(), - // No changes from 3.0.8-RC1 to 3.0.8 - '3.0.8-RC1' => array(), - // Changes from 3.0.8 to 3.0.9-RC1 - '3.0.8' => array( - 'add_tables' => array( - LOGIN_ATTEMPT_TABLE => array( - 'COLUMNS' => array( - // this column was removed from the database updater - // after 3.0.9-RC3 was released. It might still exist - // in 3.0.9-RCX installations and has to be dropped in - // 3.0.12 after the db_tools class is capable of properly - // removing a primary key. - // 'attempt_id' => array('UINT', NULL, 'auto_increment'), - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - //'PRIMARY_KEY' => 'attempt_id', - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ), - ), - 'change_columns' => array( - BBCODES_TABLE => array( - 'bbcode_id' => array('USINT', 0), - ), - ), - ), - // No changes from 3.0.9-RC1 to 3.0.9-RC2 - '3.0.9-RC1' => array(), - // No changes from 3.0.9-RC2 to 3.0.9-RC3 - '3.0.9-RC2' => array(), - // No changes from 3.0.9-RC3 to 3.0.9-RC4 - '3.0.9-RC3' => array(), - // No changes from 3.0.9-RC4 to 3.0.9 - '3.0.9-RC4' => array(), - // No changes from 3.0.9 to 3.0.10-RC1 - '3.0.9' => array(), - // No changes from 3.0.10-RC1 to 3.0.10-RC2 - '3.0.10-RC1' => array(), - // No changes from 3.0.10-RC2 to 3.0.10-RC3 - '3.0.10-RC2' => array(), - // No changes from 3.0.10-RC3 to 3.0.10 - '3.0.10-RC3' => array(), - // No changes from 3.0.10 to 3.0.11-RC1 - '3.0.10' => array(), - // Changes from 3.0.11-RC1 to 3.0.11-RC2 - '3.0.11-RC1' => array( - 'add_columns' => array( - PROFILE_FIELDS_TABLE => array( - 'field_show_novalue' => array('BOOL', 0), - ), - ), - ), - // No changes from 3.0.11-RC2 to 3.0.11 - '3.0.11-RC2' => array(), - // No changes from 3.0.11 to 3.0.12-RC1 - '3.0.11' => array(), - - /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ - - // Changes from 3.1.0-dev to 3.1.0-A1 - '3.1.0-dev' => array( - 'add_tables' => array( - EXT_TABLE => array( - 'COLUMNS' => array( - 'ext_name' => array('VCHAR', ''), - 'ext_active' => array('BOOL', 0), - 'ext_state' => array('TEXT', ''), - ), - 'KEYS' => array( - 'ext_name' => array('UNIQUE', 'ext_name'), - ), - ), - ), - 'add_columns' => array( - GROUPS_TABLE => array( - 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), - ), - PROFILE_FIELDS_TABLE => array( - 'field_show_on_pm' => array('BOOL', 0), - ), - STYLES_TABLE => array( - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), - 'reported_post_enable_bbcode' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_magic_url' => array('BOOL', 1), - ), - ), - 'change_columns' => array( - GROUPS_TABLE => array( - 'group_legend' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_timezone' => array('VCHAR:100', ''), - ), - ), - ), - ); -} - -/**************************************************************************** -* ADD YOUR DATABASE DATA CHANGES HERE * -* REMEMBER: You NEED to enter a schema array above and a data array here, * -* even if both or one of them are empty. * -*****************************************************************************/ -function change_database_data(&$no_updates, $version) -{ - global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx; - - $update_helpers = new phpbb_update_helpers(); - - switch ($version) - { - case '3.0.0': - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_view_time = topic_last_post_time - WHERE topic_last_view_time = 0"; - _sql($sql, $errored, $error_ary); - - // Update smiley sizes - $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); - - foreach ($smileys as $smiley) - { - if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) - { - list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley); - - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET smiley_width = ' . $width . ', smiley_height = ' . $height . " - WHERE smiley_url = '" . $db->sql_escape($smiley) . "'"; - - _sql($sql, $errored, $error_ary); - } - } - - $no_updates = false; - break; - - // No changes from 3.0.1-RC1 to 3.0.1 - case '3.0.1-RC1': - break; - - // changes from 3.0.1 to 3.0.2-RC1 - case '3.0.1': - - set_config('referer_validation', '1'); - set_config('check_attachment_content', '1'); - set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); - - $no_updates = false; - break; - - // No changes from 3.0.2-RC1 to 3.0.2-RC2 - case '3.0.2-RC1': - break; - - // No changes from 3.0.2-RC2 to 3.0.2 - case '3.0.2-RC2': - break; - - // Changes from 3.0.2 to 3.0.3-RC1 - case '3.0.2': - set_config('enable_queue_trigger', '0'); - set_config('queue_trigger_posts', '3'); - - set_config('pm_max_recipients', '0'); - - // Set maximum number of recipients for the registered users, bots, guests group - $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 - WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); - _sql($sql, $errored, $error_ary); - - // Not prefilling yet - set_config('dbms_version', ''); - - // Add new permission u_masspm_group and duplicate settings from u_masspm - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_masspm_group'])) - { - $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_masspm']; - $new_id = $auth_admin->acl_options['id']['u_masspm_group']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } - - /** - * Do not resync post counts here. An admin may do this later from the ACP - $start = 0; - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; - _sql($sql, $errored, $error_ary); - - do - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_approved = 1 - GROUP BY poster_id'; - $result = _sql($sql, $errored, $error_ary); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - _sql($sql, $errored, $error_ary); - } - while ($row = $db->sql_fetchrow($result)); - - $start += $step; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - */ - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_a_email && cfg_email_enable\' - WHERE module_class = \'acp\' - AND module_basename = \'email\''; - _sql($sql, $errored, $error_ary); - - $no_updates = false; - break; - - // Changes from 3.0.3-RC1 to 3.0.3 - case '3.0.3-RC1': - if ($db->sql_layer == 'oracle') - { - // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); - } - else - { - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation = 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - break; - - // Changes from 3.0.3 to 3.0.4-RC1 - case '3.0.3': - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide - FROM ' . PROFILE_FIELDS_TABLE; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivelant to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); - } - $no_updates = false; - - break; - - // Changes from 3.0.4-RC1 to 3.0.4 - case '3.0.4-RC1': - break; - - // Changes from 3.0.4 to 3.0.5-RC1 - case '3.0.4': - - // Captcha config variables - set_config('captcha_gd_wave', 0); - set_config('captcha_gd_3d_noise', 1); - set_config('captcha_gd_fonts', 1); - set_config('confirm_refresh', 1); - - // Maximum number of keywords - set_config('max_num_search_keywords', 10); - - // Remove static config var and put it back as dynamic variable - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET is_dynamic = 1 - WHERE config_name = 'search_indexing_state'"; - _sql($sql, $errored, $error_ary); - - // Hash old MD5 passwords - $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' - WHERE user_pass_convert = 1'; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - if (strlen($row['user_password']) == 32) - { - $sql_ary = array( - 'user_password' => phpbb_hash($row['user_password']), - ); - - _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); - } - } - $db->sql_freeresult($result); - - // Adjust bot entry - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = 'ichiro/' - WHERE bot_agent = 'ichiro/2'"; - _sql($sql, $errored, $error_ary); - - - // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - - // We get duplicate entries first - $sql = 'SELECT auth_option - FROM ' . ACL_OPTIONS_TABLE . ' - GROUP BY auth_option - HAVING COUNT(*) >= 2'; - $result = $db->sql_query($sql); - - $auth_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $auth_options[] = $row['auth_option']; - } - $db->sql_freeresult($result); - - // Remove specific auth options - if (!empty($auth_options)) - { - foreach ($auth_options as $option) - { - // Select auth_option_ids... the largest id will be preserved - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = '" . $db->sql_escape($option) . "' - ORDER BY auth_option_id DESC"; - // sql_query_limit not possible here, due to bug in postgresql layer - $result = $db->sql_query($sql); - - // Skip first row, this is our original auth option we want to preserve - $row = $db->sql_fetchrow($result); - - while ($row = $db->sql_fetchrow($result)) - { - // Ok, remove this auth option... - _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - } - $db->sql_freeresult($result); - } - } - - // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. - $changes = array( - 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $changes = array( - 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - - break; - - // No changes from 3.0.5-RC1 to 3.0.5 - case '3.0.5-RC1': - break; - - // Changes from 3.0.5 to 3.0.6-RC1 - case '3.0.5': - // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... - if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_gd'); - } - else if (!isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_nogd'); - } - - // Entries for the Feed Feature - set_config('feed_enable', '0'); - set_config('feed_limit', '10'); - - set_config('feed_overall_forums', '1'); - set_config('feed_overall_forums_limit', '15'); - - set_config('feed_overall_topics', '0'); - set_config('feed_overall_topics_limit', '15'); - - set_config('feed_forum', '1'); - set_config('feed_topic', '1'); - set_config('feed_item_statistics', '1'); - - // Entries for smiley pagination - set_config('smilies_per_page', '50'); - - // Entry for reporting PMs - set_config('allow_pm_report', '1'); - - // Install modules - $modules_to_install = array( - 'feed' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_FEED_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_BOARD_CONFIGURATION', - 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') - ), - 'warnings' => array( - 'base' => 'users', - 'class' => 'acp', - 'title' => 'ACP_USER_WARNINGS', - 'auth' => 'acl_a_user', - 'display' => 0, - 'cat' => 'ACP_CAT_USERS', - 'after' => array('feedback', 'ACP_USER_FEEDBACK') - ), - 'send_statistics' => array( - 'base' => 'send_statistics', - 'class' => 'acp', - 'title' => 'ACP_SEND_STATISTICS', - 'auth' => 'acl_a_server', - 'cat' => 'ACP_SERVER_CONFIGURATION' - ), - 'setting_forum_copy' => array( - 'base' => 'permissions', - 'class' => 'acp', - 'title' => 'ACP_FORUM_PERMISSIONS_COPY', - 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', - 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', - 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') - ), - 'pm_reports' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_OPEN', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_reports_closed' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_CLOSED', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_report_details' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORT_DETAILS', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - ); - - _add_modules($modules_to_install); - - // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; - _sql($sql, $errored, $error_ary); - - $group_id = $db->sql_nextid(); - } - - // Insert new user role... at the end of the chain - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_USER_NEW_MEMBER' - AND role_type = 'u_'"; - $result = $db->sql_query($sql); - $u_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); - - if (!$u_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'u_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $u_role = $db->sql_nextid(); - - if (!$errored) - { - // Now add the correct data to the roles... - // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - _sql($sql, $errored, $error_ary); - - // Add user role to group - $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - _sql($sql, $errored, $error_ary); - } - } - - // Insert new forum role - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' - AND role_type = 'f_'"; - $result = $db->sql_query($sql); - $f_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); - - if (!$f_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'f_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $f_role = $db->sql_nextid(); - - if (!$errored) - { - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - _sql($sql, $errored, $error_ary); - } - } - - // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) - $sql = 'SELECT 1 - FROM ' . USERS_TABLE . ' - WHERE user_new = 0'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - _sql($sql, $errored, $error_ary); - } - - // Newly registered users limit - if (!isset($config['new_member_post_limit'])) - { - set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); - } - - if (!isset($config['new_member_group_default'])) - { - set_config('new_member_group_default', 0); - } - - // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... - // Check if the role is already assigned... - $sql = 'SELECT forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id = ' . $f_role; - $result = $db->sql_query($sql); - $is_options = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - // Not assigned at all... :/ - if (!$is_options) - { - // Get postable forums - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type != ' . FORUM_LINK; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); - } - $db->sql_freeresult($result); - } - - // Clear permissions... - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - $auth_admin->acl_clear_prefetch(); - - if (!isset($config['allow_avatar'])) - { - if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) - { - set_config('allow_avatar', '1'); - } - else - { - set_config('allow_avatar', '0'); - } - } - - if (!isset($config['allow_avatar_remote_upload'])) - { - if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) - { - set_config('allow_avatar_remote_upload', '1'); - } - else - { - set_config('allow_avatar_remote_upload', '0'); - } - } - - // Minimum number of characters - if (!isset($config['min_post_chars'])) - { - set_config('min_post_chars', '1'); - } - - if (!isset($config['allow_quick_reply'])) - { - set_config('allow_quick_reply', '1'); - } - - // Set every members user_options column to enable - // bbcode, smilies and URLs for signatures by default - $sql = 'SELECT user_options - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query_limit($sql, 1); - $user_option = (int) $db->sql_fetchfield('user_options'); - $db->sql_freeresult($result); - - // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option - if (!($user_option & 1 << 15)) - { - // 229376 is the added value to enable all three signature options - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; - _sql($sql, $errored, $error_ary); - } - - if (!isset($config['delete_time'])) - { - set_config('delete_time', $config['edit_time']); - } - - $no_updates = false; - break; - - // No changes from 3.0.6-RC1 to 3.0.6-RC2 - case '3.0.6-RC1': - break; - - // Changes from 3.0.6-RC2 to 3.0.6-RC3 - case '3.0.6-RC2': - - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' - SET field_show_on_vt = 1 - WHERE field_hide = 0 - AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; - _sql($sql, $errored, $error_ary); - $no_updates = false; - - break; - - // No changes from 3.0.6-RC3 to 3.0.6-RC4 - case '3.0.6-RC3': - break; - - // No changes from 3.0.6-RC4 to 3.0.6 - case '3.0.6-RC4': - break; - - // Changes from 3.0.6 to 3.0.7-RC1 - case '3.0.6': - - // ATOM Feeds - set_config('feed_overall', '1'); - set_config('feed_http_auth', '0'); - set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15)); - set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10)); - set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0')); - set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0')); - - // Delete all text-templates from the template_data - $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' - WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt'); - _sql($sql, $errored, $error_ary); - - $no_updates = false; - break; - - // Changes from 3.0.7-RC1 to 3.0.7-RC2 - case '3.0.7-RC1': - - $sql = 'SELECT user_id, user_email, user_email_hash - FROM ' . USERS_TABLE . ' - WHERE user_type <> ' . USER_IGNORE . " - AND user_email <> ''"; - $result = $db->sql_query($sql); - - $i = 0; - while ($row = $db->sql_fetchrow($result)) - { - // Snapshot of the phpbb_email_hash() function - // We cannot call it directly because the auto updater updates the DB first. :/ - $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); - - if ($user_email_hash != $row['user_email_hash']) - { - $sql_ary = array( - 'user_email_hash' => $user_email_hash, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $row['user_id']; - _sql($sql, $errored, $error_ary, ($i % 100 == 0)); - - ++$i; - } - } - $db->sql_freeresult($result); - - $no_updates = false; - - break; - - // No changes from 3.0.7-RC2 to 3.0.7 - case '3.0.7-RC2': - break; - - // No changes from 3.0.7 to 3.0.7-PL1 - case '3.0.7': - break; - - // Changes from 3.0.7-PL1 to 3.0.8-RC1 - case '3.0.7-PL1': - // Update file extension group names to use language strings. - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $extension_groups_updated = array(); - while ($lang_dir = $db->sql_fetchfield('lang_dir')) - { - $lang_dir = basename($lang_dir); - - // The language strings we need are either in language/.../acp/attachments.php - // in the update package if we're updating to 3.0.8-RC1 or later, - // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. - // On an already updated board, they can also already be in language/.../acp/attachments.php - // in the board root. - $lang_files = array( - "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", - "{$phpbb_root_path}language/$lang_dir/install.$phpEx", - "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", - ); - - foreach ($lang_files as $lang_file) - { - if (!file_exists($lang_file)) - { - continue; - } - - $lang = array(); - include($lang_file); - - foreach($lang as $lang_key => $lang_val) - { - if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) - { - continue; - } - - $sql_ary = array( - 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; - _sql($sql, $errored, $error_ary); - - $extension_groups_updated[$lang_key] = true; - } - } - } - $db->sql_freeresult($result); - - // Install modules - $modules_to_install = array( - 'post' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_POST_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_MESSAGES', - 'after' => array('message', 'ACP_MESSAGE_SETTINGS') - ), - ); - - _add_modules($modules_to_install); - - // update - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'avatar\''; - _sql($sql, $errored, $error_ary); - - // add Bing Bot - $bot_name = 'Bing [Bot]'; - $bot_name_clean = utf8_clean_string($bot_name); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; - $result = $db->sql_query($sql); - $bing_already_added = (bool) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if (!$bing_already_added) - { - $bot_agent = 'bingbot/'; - $bot_ip = ''; - $sql = 'SELECT group_id, group_colour - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - // default fallback, should never get here - $group_row['group_id'] = 6; - $group_row['group_colour'] = '9E8DA7'; - } - - if (!function_exists('user_add')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_row['group_id'], - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => $group_row['group_colour'], - 'user_email' => '', - 'user_lang' => $config['default_lang'], - 'user_style' => $config['default_style'], - 'user_timezone' => 'UTC', - 'user_dateformat' => $config['default_dateformat'], - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => (string) $bot_name, - 'user_id' => (int) $user_id, - 'bot_agent' => (string) $bot_agent, - 'bot_ip' => (string) $bot_ip, - )); - - _sql($sql, $errored, $error_ary); - } - // end Bing Bot addition - - // Delete shadow topics pointing to not existing topics - $batch_size = 500; - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - do - { - $sql_array = array( - 'SELECT' => 't1.topic_id, t1.forum_id', - 'FROM' => array( - TOPICS_TABLE => 't1', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't2'), - 'ON' => 't1.topic_moved_id = t2.topic_id', - ), - ), - 'WHERE' => 't1.topic_moved_id <> 0 - AND t2.topic_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - } - while (sizeof($topic_ids) == $batch_size); - - // Sync the forums we have deleted shadow topics from. - sync('forum', 'forum_id', $sync_forum_ids, true, true); - - // Unread posts search load switch - set_config('load_unreads_search', '1'); - - // Reduce queue interval to 60 seconds, email package size to 20 - if ($config['queue_interval'] == 600) - { - set_config('queue_interval', '60'); - } - - if ($config['email_package_size'] == 50) - { - set_config('email_package_size', '20'); - } - - $no_updates = false; - break; - - // No changes from 3.0.8-RC1 to 3.0.8 - case '3.0.8-RC1': - break; - - // Changes from 3.0.8 to 3.0.9-RC1 - case '3.0.8': - set_config('ip_login_limit_max', '50'); - set_config('ip_login_limit_time', '21600'); - set_config('ip_login_limit_use_forwarded', '0'); - - // Update file extension group names to use language strings, again. - $sql = 'SELECT group_id, group_name - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE group_id = ' . $row['group_id']; - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - /* - * Due to a bug, vanilla phpbb could not create captcha tables - * in 3.0.8 on firebird. It was possible for board administrators - * to adjust the code to work. If code was manually adjusted by - * board administrators, index names would not be the same as - * what 3.0.9 and newer expect. This code fragment drops captcha - * tables, destroying all entered Q&A captcha configuration, such - * that when Q&A is configured next the respective tables will be - * created with correct index names. - * - * If you wish to preserve your Q&A captcha configuration, you can - * manually rename indexes to the currently expected name: - * phpbb_captcha_questions_lang_iso => phpbb_captcha_questions_lang - * phpbb_captcha_answers_question_id => phpbb_captcha_answers_qid - * - * Again, this needs to be done only if a board was manually modified - * to fix broken captcha code. - * - if ($db_tools->sql_layer == 'firebird') - { - $changes = array( - 'drop_tables' => array( - $table_prefix . 'captcha_questions', - $table_prefix . 'captcha_answers', - $table_prefix . 'qa_confirm', - ), - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } - */ - - $no_updates = false; - break; - - // No changes from 3.0.9-RC1 to 3.0.9-RC2 - case '3.0.9-RC1': - break; - - // No changes from 3.0.9-RC2 to 3.0.9-RC3 - case '3.0.9-RC2': - break; - - // No changes from 3.0.9-RC3 to 3.0.9-RC4 - case '3.0.9-RC3': - break; - - // No changes from 3.0.9-RC4 to 3.0.9 - case '3.0.9-RC4': - break; - - // Changes from 3.0.9 to 3.0.10-RC1 - case '3.0.9': - if (!isset($config['email_max_chunk_size'])) - { - set_config('email_max_chunk_size', '50'); - } - - $no_updates = false; - break; - - // No changes from 3.0.10-RC1 to 3.0.10-RC2 - case '3.0.10-RC1': - break; - - // No changes from 3.0.10-RC2 to 3.0.10-RC3 - case '3.0.10-RC2': - break; - - // No changes from 3.0.10-RC3 to 3.0.10 - case '3.0.10-RC3': - break; - - // Changes from 3.0.10 to 3.0.11-RC1 - case '3.0.10': - // Updates users having current style a deactivated one - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_active = 0'; - $result = $db->sql_query($sql); - - $deactivated_style_ids = array(); - while ($style_id = $db->sql_fetchfield('style_id', false, $result)) - { - $deactivated_style_ids[] = (int) $style_id; - } - $db->sql_freeresult($result); - - if (!empty($deactivated_style_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $config['default_style'] .' - WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); - _sql($sql, $errored, $error_ary); - } - - // Delete orphan private messages - $batch_size = 500; - - $sql_array = array( - 'SELECT' => 'p.msg_id', - 'FROM' => array( - PRIVMSGS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), - 'ON' => 'p.msg_id = t.msg_id', - ), - ), - 'WHERE' => 't.user_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - - do - { - $result = $db->sql_query_limit($sql, $batch_size); - - $delete_pms = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_pms[] = (int) $row['msg_id']; - } - $db->sql_freeresult($result); - - if (!empty($delete_pms)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_pms); - _sql($sql, $errored, $error_ary); - } - } - while (sizeof($delete_pms) == $batch_size); - - $no_updates = false; - break; - - // No changes from 3.0.11-RC1 to 3.0.11-RC2 - case '3.0.11-RC1': - break; - - // No changes from 3.0.11-RC2 to 3.0.11 - case '3.0.11-RC2': - break; - - // Changes from 3.0.11 to 3.0.12-RC1 - case '3.0.11': - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_u_sig\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'signature\''; - _sql($sql, $errored, $error_ary); - - // Update bots - if (!function_exists('user_delete')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $bots_updates = array( - // Bot Deletions - 'NG-Search [Bot]' => false, - 'Nutch/CVS [Bot]' => false, - 'OmniExplorer [Bot]' => false, - 'Seekport [Bot]' => false, - 'Synoo [Bot]' => false, - 'WiseNut [Bot]' => false, - - // Bot Updates - // Bot name to bot user agent map - 'Baidu [Spider]' => 'Baiduspider', - 'Exabot [Bot]' => 'Exabot', - 'Voyager [Bot]' => 'voyager/', - 'W3C [Validator]' => 'W3C_Validator', - ); - - foreach ($bots_updates as $bot_name => $bot_agent) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_IGNORE . " - AND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'"; - $result = $db->sql_query($sql); - $bot_user_id = (int) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if ($bot_user_id) - { - if ($bot_agent === false) - { - $sql = 'DELETE FROM ' . BOTS_TABLE . " - WHERE user_id = $bot_user_id"; - _sql($sql, $errored, $error_ary); - - user_delete('remove', $bot_user_id); - } - else - { - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $db->sql_escape($bot_agent) . "' - WHERE user_id = $bot_user_id"; - _sql($sql, $errored, $error_ary); - } - } - } - - // Disable receiving pms for bots - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $db->sql_query($sql); - - $bot_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $bot_user_ids[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - if (!empty($bot_user_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE ' . $db->sql_in_set('user_id', $bot_user_ids); - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - break; - - // Changes from 3.1.0-dev to 3.1.0-A1 - case '3.1.0-dev': - - // rename all module basenames to full classname - $sql = 'SELECT module_id, module_basename, module_class - FROM ' . MODULES_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $module_id = (int) $row['module_id']; - unset($row['module_id']); - - if (!empty($row['module_basename']) && !empty($row['module_class'])) - { - // all the class names start with class name or with phpbb_ for auto loading - if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && - strpos($row['module_basename'], 'phpbb_') !== 0) - { - $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; - - $sql_update = $db->sql_build_array('UPDATE', $row); - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET ' . $sql_update . ' - WHERE module_id = ' . $module_id; - _sql($sql, $errored, $error_ary); - } - } - } - - $db->sql_freeresult($result); - - if (substr($config['search_type'], 0, 6) !== 'phpbb_') - { - // try to guess the new auto loaded search class name - // works for native and mysql fulltext - set_config('search_type', 'phpbb_search_' . $config['search_type']); - } - - if (!isset($config['fulltext_postgres_ts_name'])) - { - set_config('fulltext_postgres_ts_name', 'simple'); - } - - if (!isset($config['fulltext_postgres_min_word_len'])) - { - set_config('fulltext_postgres_min_word_len', 4); - } - - if (!isset($config['fulltext_postgres_max_word_len'])) - { - set_config('fulltext_postgres_max_word_len', 254); - } - - if (!isset($config['fulltext_sphinx_stopwords'])) - { - set_config('fulltext_sphinx_stopwords', 0); - } - - if (!isset($config['fulltext_sphinx_indexer_mem_limit'])) - { - set_config('fulltext_sphinx_indexer_mem_limit', 512); - } - - if (!isset($config['load_jquery_cdn'])) - { - set_config('load_jquery_cdn', 0); - set_config('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); - } - - if (!isset($config['use_system_cron'])) - { - set_config('use_system_cron', 0); - } - - $sql = 'SELECT group_teampage - FROM ' . GROUPS_TABLE . ' - WHERE group_teampage > 0'; - $result = $db->sql_query_limit($sql, 1); - $added_groups_teampage = (bool) $db->sql_fetchfield('group_teampage'); - $db->sql_freeresult($result); - - if (!$added_groups_teampage) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 1 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'ADMINISTRATORS'"; - _sql($sql, $errored, $error_ary); - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 2 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'GLOBAL_MODERATORS'"; - _sql($sql, $errored, $error_ary); - } - - if (!isset($config['legend_sort_groupname'])) - { - set_config('legend_sort_groupname', '0'); - set_config('teampage_forums', '1'); - } - - $sql = 'SELECT group_legend - FROM ' . GROUPS_TABLE . ' - WHERE group_teampage > 1'; - $result = $db->sql_query_limit($sql, 1); - $updated_group_legend = (bool) $db->sql_fetchfield('group_teampage'); - $db->sql_freeresult($result); - - if (!$updated_group_legend) - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; - $result = $db->sql_query($sql); - - $next_legend = 1; - while ($row = $db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_legend = ' . $next_legend . ' - WHERE group_id = ' . (int) $row['group_id']; - _sql($sql, $errored, $error_ary); - - $next_legend++; - } - $db->sql_freeresult($result); - unset($next_legend); - } - - // Rename styles module to Customise - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_langname = 'ACP_CAT_CUSTOMISE' - WHERE module_langname = 'ACP_CAT_STYLES'"; - _sql($sql, $errored, $error_ary); - - // Install modules - $modules_to_install = array( - 'position' => array( - 'base' => 'acp_groups', - 'class' => 'acp', - 'title' => 'ACP_GROUPS_POSITION', - 'auth' => 'acl_a_group', - 'cat' => 'ACP_GROUPS', - ), - 'manage' => array( - 'base' => 'acp_attachments', - 'class' => 'acp', - 'title' => 'ACP_MANAGE_ATTACHMENTS', - 'auth' => 'acl_a_attach', - 'cat' => 'ACP_ATTACHMENTS', - ), - 'install' => array( - 'base' => 'acp_styles', - 'class' => 'acp', - 'title' => 'ACP_STYLES_INSTALL', - 'auth' => 'acl_a_styles', - 'cat' => 'ACP_STYLE_MANAGEMENT', - ), - 'cache' => array( - 'base' => 'acp_styles', - 'class' => 'acp', - 'title' => 'ACP_STYLES_CACHE', - 'auth' => 'acl_a_styles', - 'cat' => 'ACP_STYLE_MANAGEMENT', - ), - 'autologin_keys' => array( - 'base' => 'ucp_profile', - 'class' => 'ucp', - 'title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', - 'auth' => '', - 'cat' => 'UCP_PROFILE', - ), - // To add a category, the mode and basename must be empty - // The mode is taken from the array key - '' => array( - 'base' => '', - 'class' => 'acp', - 'title' => 'ACP_EXTENSION_MANAGEMENT', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_CAT_CUSTOMISE', - ), - 'extensions' => array( - 'base' => 'acp_extensions', - 'class' => 'acp', - 'title' => 'ACP_EXTENSIONS', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_EXTENSION_MANAGEMENT', - ), - ); - - _add_modules($modules_to_install); - - // We need a separate array for the new language sub heading - // because it requires another empty key - $modules_to_install = array( - '' => array( - 'base' => '', - 'class' => 'acp', - 'title' => 'ACP_LANGUAGE', - 'auth' => 'acl_a_language', - 'cat' => 'ACP_CAT_CUSTOMISE', - ), - ); - - _add_modules($modules_to_install); - - // Move language management to new location in the Customise tab - // First get language module id - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_language'"; - $result = $db->sql_query($sql); - $language_module_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - // Next get language management module id of the one just created - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_LANGUAGE'"; - $result = $db->sql_query($sql); - $language_management_module_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if (!class_exists('acp_modules')) - { - include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - } - // acp_modules calls adm_back_link, which is undefined at this point - if (!function_exists('adm_back_link')) - { - include($phpbb_root_path . 'includes/functions_acp.' . $phpEx); - } - $module_manager = new acp_modules(); - $module_manager->module_class = 'acp'; - $module_manager->move_module($language_module_id, $language_management_module_id); - - $sql = 'DELETE FROM ' . MODULES_TABLE . " - WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; - _sql($sql, $errored, $error_ary); - - // Localise Global Announcements - $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; - $result = $db->sql_query($sql); - - $global_announcements = $update_lastpost_data = array(); - $update_lastpost_data['forum_last_post_time'] = 0; - $update_forum_data = array( - 'forum_posts' => 0, - 'forum_topics' => 0, - 'forum_topics_real' => 0, - ); - - while ($row = $db->sql_fetchrow($result)) - { - $global_announcements[] = (int) $row['topic_id']; - - $update_forum_data['forum_posts'] += (int) $row['topic_posts']; - $update_forum_data['forum_topics_real']++; - if ($row['topic_approved']) - { - $update_forum_data['forum_topics']++; - } - - if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) - { - $update_lastpost_data = array( - 'forum_last_post_id' => (int) $row['topic_last_post_id'], - 'forum_last_post_subject' => $row['topic_last_post_subject'], - 'forum_last_post_time' => (int) $row['topic_last_post_time'], - 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], - 'forum_last_poster_name' => $row['topic_last_poster_name'], - 'forum_last_poster_colour' => $row['topic_last_poster_colour'], - ); - } - } - $db->sql_freeresult($result); - - if (!empty($global_announcements)) - { - // Update the post/topic-count for the forum and the last-post if needed - $ga_forum_id = request_var('ga_forum_id', 0); - - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $ga_forum_id; - $result = $db->sql_query($sql); - $lastpost = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; - $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; - $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; - if ($lastpost < $update_lastpost_data['forum_last_post_time']) - { - $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $sql_update . ' - WHERE forum_id = ' . $ga_forum_id; - _sql($sql, $errored, $error_ary); - - // Update some forum_ids - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $ga_forum_id - WHERE " . $db->sql_in_set('topic_id', $global_announcements); - _sql($sql, $errored, $error_ary); - } - unset($table_ary); - } - - // Allow custom profile fields in pm templates - if (!isset($config['load_cpf_pm'])) - { - set_config('load_cpf_pm', '0'); - } - - if (!isset($config['teampage_memberships'])) - { - set_config('teampage_memberships', '1'); - } - - // Check if styles table was already updated - if ($db_tools->sql_table_exists(STYLES_THEME_TABLE)) - { - // Get list of valid 3.1 styles - $available_styles = array('prosilver'); - - $iterator = new DirectoryIterator($phpbb_root_path . 'styles'); - $skip_dirs = array('.', '..', 'prosilver'); - foreach ($iterator as $fileinfo) - { - if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) - { - $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); - if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) - { - // 3.1 style - $available_styles[] = $fileinfo->getFilename(); - } - } - } - - // Get all installed styles - if ($db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id - AND i.imageset_id = s.imageset_id"; - } - else - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id"; - } - $result = $db->sql_query($sql); - - $styles = array(); - while ($row = $db->sql_fetchrow($result)) - { - $styles[] = $row; - } - $db->sql_freeresult($result); - - // Decide which styles to keep, all others will be deleted - $valid_styles = array(); - foreach ($styles as $style_row) - { - if ( - // Delete styles with parent style (not supported yet) - $style_row['template_inherits_id'] == 0 && - // Check if components match - $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && - // Check if components are valid - in_array($style_row['template_path'], $available_styles) - ) - { - // Valid style. Keep it - $sql_ary = array( - 'style_path' => $style_row['template_path'], - 'bbcode_bitfield' => $style_row['bbcode_bitfield'], - 'style_parent_id' => 0, - 'style_parent_tree' => '', - ); - _sql('UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary); - $valid_styles[] = (int) $style_row['style_id']; - } - } - - // Remove old styles tables - $changes = array( - 'drop_columns' => array( - STYLES_TABLE => array( - 'imageset_id', - 'template_id', - 'theme_id', - ), - ), - - 'drop_tables' => array( - STYLES_IMAGESET_TABLE, - STYLES_IMAGESET_DATA_TABLE, - STYLES_TEMPLATE_TABLE, - STYLES_TEMPLATE_DATA_TABLE, - STYLES_THEME_TABLE, - ) - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - // Remove old entries from styles table - if (!sizeof($valid_styles)) - { - // No valid styles: remove everything and add prosilver - _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - - $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; - _sql($sql, $errored, $error_ary); - - $sql = 'SELECT style_id - FROM ' . $table . " - WHERE style_name = 'prosilver'"; - $result = _sql($sql, $errored, $error_ary); - $default_style = $db->sql_fetchfield($result); - $db->sql_freeresult($result); - - set_config('default_style', $default_style); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; - _sql($sql, $errored, $error_ary); - } - else - { - // There are valid styles in styles table. Remove styles that are outdated - _sql('DELETE FROM ' . STYLES_TABLE . ' WHERE ' . $db->sql_in_set('style_id', $valid_styles, true), $errored, $error_ary); - - // Change default style - if (!in_array($config['default_style'], $valid_styles)) - { - set_config('default_style', $valid_styles[0]); - } - - // Reset styles for users - _sql('UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE ' . $db->sql_in_set('user_style', $valid_styles, true), $errored, $error_ary); - } - } - - // Create config value for displaying last subject on forum list - if (!isset($config['display_last_subject'])) - { - $config->set('display_last_subject', '1'); - } - - if (!isset($config['assets_version'])) - { - $config->set('assets_version', '1'); - } - - // If the column exists, we did not yet update the users timezone - if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst')) - { - // Update user timezones - $sql = 'SELECT user_dst, user_timezone - FROM ' . USERS_TABLE . ' - GROUP BY user_timezone, user_dst'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_timezone = '" . $db->sql_escape($update_helpers->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' - WHERE user_timezone = '" . $db->sql_escape($row['user_timezone']) . "' - AND user_dst = " . (int) $row['user_dst']; - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - // Update board default timezone - set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); - - // After we have calculated the timezones we can delete user_dst column from user table. - $statements = $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } - - if (!isset($config['site_home_url'])) - { - $config->set('site_home_url', ''); - $config->set('site_home_text', ''); - } - - // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category - - // Get the category wanted while checking, at the same time, if this has already been applied - $sql = 'SELECT module_id, module_basename - FROM ' . MODULES_TABLE . " - WHERE module_basename <> 'ucp_pm' AND - module_langname='UCP_PM' - "; - $result = $db->sql_query_limit($sql, 1); - - if ($row = $db->sql_fetchrow($result)) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['module_id']; - - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - - // Add new permissions - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - _add_permission($auth_admin, $db, 'u_chgprofileinfo', true, 'u_sig'); - _add_permission($auth_admin, $db, 'a_extensions', true, 'a_styles'); - - // Update the auth setting for the module - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_auth = 'acl_u_chgprofileinfo' - WHERE module_class = 'ucp' - AND module_basename = 'ucp_profile' - AND module_mode = 'profile_info'"; - _sql($sql, $errored, $error_ary); - - $no_updates = false; - - break; - } + +<?php + + garbage_collection(); + exit_handler(); } diff --git a/phpBB/install/database_update_migrations.php b/phpBB/install/database_update_migrations.php deleted file mode 100644 index 52682dc489..0000000000 --- a/phpBB/install/database_update_migrations.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/** -* -* @package phpBB3 -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -$update_start_time = time(); - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); - -require($phpbb_root_path . 'includes/startup.' . $phpEx); - -if (file_exists($phpbb_root_path . 'config.' . $phpEx)) -{ - require($phpbb_root_path . 'config.' . $phpEx); -} - -// Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); - -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); - -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - -// Set PHP error handler to ours -set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); - -// Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); -$phpbb_class_loader->register(); - -// Set up container -$container_extensions = array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), -); -$container_passes = array( - new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), -); -$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); - -// Compile the container -foreach ($container_passes as $pass) -{ - $phpbb_container->addCompilerPass($pass); -} -$phpbb_container->compile(); - -// set up caching -$cache = $phpbb_container->get('cache'); - -// Instantiate some basic classes -$phpbb_dispatcher = $phpbb_container->get('dispatcher'); -$request = $phpbb_container->get('request'); -$user = $phpbb_container->get('user'); -$auth = $phpbb_container->get('auth'); -$db = $phpbb_container->get('dbal.conn'); - -// make sure request_var uses this request instance -request_var('', 0, false, false, $request); // "dependency injection" for a function - -// Grab global variables, re-cache if necessary -$config = $phpbb_container->get('config'); -set_config(null, null, null, $config); -set_config_count(null, null, null, $config); - -// End startup code - -$db_tools = $phpbb_container->get('dbal.tools'); -if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) -{ - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); -} - -$migrator = $phpbb_container->get('migrator'); -$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); - -// What is a safe limit of execution time? Half the max execution time should be safe. -$safe_time_limit = (ini_get('max_execution_time') / 2); - -while (!$migrator->finished()) -{ - try - { - $migrator->update(); - } - catch (phpbb_db_migration_exception $e) - { - echo $e; - - garbage_collection(); - exit_handler(); - } - - echo $migrator->last_run_migration['name'] . '<br />'; - - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $update_start_time) >= $safe_time_limit) - { - //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; - echo 'Update not yet completed.<br />'; - echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; - - garbage_collection(); - exit_handler(); - } -} - -echo 'Finished'; - -garbage_collection(); -exit_handler(); From ca55f6c4817d85b94562597cba79037ae440d973 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 17:18:12 -0600 Subject: [PATCH 107/174] [feature/migrations] Revert schema for migration data PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 5 - phpBB/includes/db/migration/data/3_0_10.php | 5 - .../includes/db/migration/data/3_0_10_rc1.php | 5 - .../includes/db/migration/data/3_0_10_rc2.php | 5 - .../includes/db/migration/data/3_0_10_rc3.php | 5 - phpBB/includes/db/migration/data/3_0_11.php | 5 - .../includes/db/migration/data/3_0_11_rc1.php | 5 - .../includes/db/migration/data/3_0_11_rc2.php | 11 +++ .../includes/db/migration/data/3_0_12_rc1.php | 5 - .../includes/db/migration/data/3_0_1_rc1.php | 14 ++- phpBB/includes/db/migration/data/3_0_2.php | 5 - .../includes/db/migration/data/3_0_2_rc1.php | 5 - .../includes/db/migration/data/3_0_2_rc2.php | 22 ++++- phpBB/includes/db/migration/data/3_0_3.php | 5 - .../includes/db/migration/data/3_0_3_rc1.php | 15 +++ phpBB/includes/db/migration/data/3_0_4.php | 5 - .../includes/db/migration/data/3_0_4_rc1.php | 11 +++ phpBB/includes/db/migration/data/3_0_5.php | 5 - .../db/migration/data/3_0_5_rc1part2.php | 4 +- phpBB/includes/db/migration/data/3_0_6.php | 5 - .../includes/db/migration/data/3_0_6_rc1.php | 40 ++++++++ .../includes/db/migration/data/3_0_6_rc2.php | 5 - .../includes/db/migration/data/3_0_6_rc3.php | 5 - .../includes/db/migration/data/3_0_6_rc4.php | 5 - phpBB/includes/db/migration/data/3_0_7.php | 5 - .../includes/db/migration/data/3_0_7_pl1.php | 5 - .../includes/db/migration/data/3_0_7_rc1.php | 20 +++- .../includes/db/migration/data/3_0_7_rc2.php | 5 - phpBB/includes/db/migration/data/3_0_8.php | 5 - .../includes/db/migration/data/3_0_8_rc1.php | 5 - phpBB/includes/db/migration/data/3_0_9.php | 5 - .../includes/db/migration/data/3_0_9_rc1.php | 9 ++ .../includes/db/migration/data/3_0_9_rc2.php | 5 - .../includes/db/migration/data/3_0_9_rc3.php | 5 - .../includes/db/migration/data/3_0_9_rc4.php | 5 - .../includes/db/migration/data/3_1_0_dev.php | 37 +++++-- .../includes/db/migration/data/extensions.php | 11 ++- .../db/migration/data/style_update_p1.php | 11 +-- .../db/migration/data/style_update_p2.php | 98 +++++++++++++++++-- phpBB/includes/db/migration/data/timezone.php | 11 +-- .../db/migration/data/timezone_p2.php | 38 +++++++ 41 files changed, 314 insertions(+), 168 deletions(-) create mode 100644 phpBB/includes/db/migration/data/timezone_p2.php diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index a2332c9b59..d71288c64b 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_1_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 07410c5ba1..17472562f2 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10_rc3'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index daac50a631..eebee44e39 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index 234e4c5fc7..b81fde9bcb 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index 075ce35e3e..d97b0b4aec 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index 0bc9b6c4a5..b149cd374c 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_11_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 752efd72b2..3d4920bf49 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_10'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php index f2bed54085..e0638f02d7 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -25,6 +25,17 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_novalue', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 0d8702f19e..0b35de2ed5 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -16,11 +16,6 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_11'); } - public function update_schema() - { - return array(); - } - public function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index cf067d2e2c..a7af5d052d 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -26,7 +26,9 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ), ), 'drop_keys' => array( - $this->table_prefix . 'groups' => array('group_legend'), + $this->table_prefix . 'groups' => array( + 'group_legend', + ), ), 'add_index' => array( $this->table_prefix . 'sessions' => array( @@ -52,12 +54,16 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ), 'add_index' => array( $this->table_prefix . 'groups' => array( - 'group_legend' => 'group_legend', + 'group_legend' => array('group_legend'), ), ), 'drop_keys' => array( - $this->table_prefix . 'sessions' => array('session_forum_id'), - $this->table_prefix . 'groups' => array('group_legend_name'), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), + $this->table_prefix . 'groups' => array( + 'group_legend_name', + ), ), ); } diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index 3469d8d178..19e9213262 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_2_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index d3c2200f14..7dd321d83c 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index 67fd1faec6..d73f9587c3 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -36,7 +36,9 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ), ), 'drop_keys' => array( - $this->table_prefix . 'sessions' => array('session_forum_id'), + $this->table_prefix . 'sessions' => array( + 'session_forum_id', + ), ), 'add_index' => array( $this->table_prefix . 'sessions' => array( @@ -46,6 +48,24 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'sessions' => array( + 'session_forum_id' => array( + 'session_forum_id', + ), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'sessions' => array( + 'session_fid', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index dff375f438..d671b0cac3 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_3_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 2320c4ac4b..9cce80be74 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -29,6 +29,21 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'styles_template' => array( + 'template_inherits_id', + 'template_inherit_path', + ), + $this->table_prefix . 'groups' => array( + 'group_max_recipients', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index 1af4508331..e734814530 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_4_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index e9bb0e01f5..eb2fcb8d0e 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -55,6 +55,17 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'profile_fields' => array( + 'field_show_profile', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 2f80970781..6d61793d08 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_5_rc1part2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 1fab0f8873..354de748c8 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -18,10 +18,10 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { return array( 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), + $this->table_prefix . 'acl_options' => array('auth_option'), ), 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( + $this->table_prefix . 'acl_options' => array( 'auth_option' => array('auth_option'), ), ), diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index 26176b9437..cc6fccaae2 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc4'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index 35adcf52be..b520bda6d0 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -59,6 +59,46 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'confirm' => array( + 'attempts', + ), + $this->table_prefix . 'users' => array( + 'user_new', + 'user_reminded', + 'user_reminded_time', + ), + $this->table_prefix . 'groups' => array( + 'group_skip_auth', + ), + $this->table_prefix . 'privmsgs' => array( + 'message_reported', + ), + $this->table_prefix . 'reports' => array( + 'pm_id', + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_vt', + ), + $this->table_prefix . 'forums' => array( + 'forum_options', + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'reports' => array( + 'post_id', + 'pm_id', + ), + $this->table_prefix . 'posts' => array( + 'post_username', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index 4092a5fa61..d61c296445 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index ec22d1da77..a3f0dcacdf 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index e748c7a4ff..3855b85551 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_6_rc3'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index f27b56f778..59779c9cb0 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index 5543d6437a..5570a5dc06 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index 71584382e8..84b8f798a8 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -18,7 +18,9 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { return array( 'drop_keys' => array( - $this->table_prefix . 'log' => array('log_time'), + $this->table_prefix . 'log' => array( + 'log_time', + ), ), 'add_index' => array( $this->table_prefix . 'topics_track' => array( @@ -28,6 +30,22 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'log' => array( + 'log_time' => array('log_time'), + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'topics_track' => array( + 'topic_id', + ), + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index 4e380c810d..48aa818ba3 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index a5defc8278..d94fe869fb 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_8_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index 78db06b512..eb4cc5bd1a 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_7_pl1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index eb359e2697..d19a24b45e 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc4'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index ea49cdbba9..4ed48061a4 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -51,6 +51,15 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } + function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'login_attempts', + ), + ); + } + function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index e3c4716665..98ef232cb4 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc1'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index 3cdecb96ae..b84d61031e 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc2'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index c2a92e618a..2a00bba843 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_9_rc3'); } - function update_schema() - { - return array(); - } - function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 2771d82d83..4f7ed07158 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -15,7 +15,7 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration 'phpbb_db_migration_data_3_0_11', 'phpbb_db_migration_data_extensions', 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone', + 'phpbb_db_migration_data_timezone_p2', ); } @@ -23,32 +23,57 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { return array( 'add_columns' => array( - GROUPS_TABLE => array( + $this->table_prefix . 'groups' => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), - PROFILE_FIELDS_TABLE => array( + $this->table_prefix . 'profile_fields' => array( 'field_show_on_pm' => array('BOOL', 0), ), - STYLES_TABLE => array( + $this->table_prefix . 'styles' => array( 'style_path' => array('VCHAR:100', ''), 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), 'style_parent_id' => array('UINT:4', 0), 'style_parent_tree' => array('TEXT', ''), ), - REPORTS_TABLE => array( + $this->table_prefix . 'reports' => array( 'reported_post_text' => array('MTEXT_UNI', ''), 'reported_post_uid' => array('VCHAR:8', ''), 'reported_post_bitfield' => array('VCHAR:255', ''), ), ), 'change_columns' => array( - GROUPS_TABLE => array( + $this->table_prefix . 'groups' => array( 'group_legend' => array('UINT', 0), ), ), ); } + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'groups' => array( + 'group_teampage', + ), + $this->table_prefix . 'profile_fields' => array( + 'field_show_on_pm', + ), + $this->table_prefix . 'styles' => array( + 'style_path', + 'bbcode_bitfield', + 'style_parent_id', + 'style_parent_tree', + ), + $this->table_prefix . 'reports' => array( + 'reported_post_text', + 'reported_post_uid', + 'reported_post_bitfield', + ), + ), + ); + } + public function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index b8379483a3..b5f5b792cf 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration { return array( 'add_tables' => array( - EXT_TABLE => array( + $this->table_prefix . 'ext' => array( 'COLUMNS' => array( 'ext_name' => array('VCHAR', ''), 'ext_active' => array('BOOL', 0), @@ -32,6 +32,15 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration ); } + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'ext', + ), + ); + } + public function update_data() { return array( diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index 387b37de8e..f1b26f525a 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -14,11 +14,6 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration return array('phpbb_db_migration_data_3_0_11'); } - public function update_schema() - { - return array(); - } - public function update_data() { return array( @@ -47,10 +42,10 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration } // Get all installed styles - if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) + if ($this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset')) { $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i + FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . 'styles_theme c, ' . $this->table_prefix . "styles_imageset i WHERE t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imageset_id = s.imageset_id"; @@ -58,7 +53,7 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration else { $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c + FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "stles_theme c WHERE t.template_id = s.template_id AND c.theme_id = s.theme_id"; } diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index db4b7f1753..361eb5a389 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration { return array( 'drop_columns' => array( - STYLES_TABLE => array( + $this->table_prefix . 'styles' => array( 'imageset_id', 'template_id', 'theme_id', @@ -26,17 +26,99 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration ), 'drop_tables' => array( - STYLES_IMAGESET_TABLE, - STYLES_IMAGESET_DATA_TABLE, - STYLES_TEMPLATE_TABLE, - STYLES_TEMPLATE_DATA_TABLE, - STYLES_THEME_TABLE, + $this->table_prefix . 'styles_imageset', + $this->table_prefix . 'styles_imageset_data', + $this->table_prefix . 'styles_template', + $this->table_prefix . 'styles_template_data', + $this->table_prefix . 'styles_theme', ), ); } - public function update_data() + public function revert_schema() { - return array(); + return array( + 'add_columns' => array( + $this->table_prefix . 'styles' => array( + 'imageset_id' => array('UINT', 0), + 'template_id' => array('UINT', 0), + 'theme_id' => array('UINT', 0), + ), + ), + + 'add_tables' => array( + $this->table_prefix . 'styles_imageset' => array( + 'COLUMNS' => array( + 'imageset_id' => array('UINT', NULL, 'auto_increment'), + 'imageset_name' => array('VCHAR_UNI:255', ''), + 'imageset_copyright' => array('VCHAR_UNI', ''), + 'imageset_path' => array('VCHAR:100', ''), + ), + 'PRIMARY_KEY' => 'imageset_id', + 'KEYS' => array( + 'imgset_nm' => array('UNIQUE', 'imageset_name'), + ), + ), + $this->table_prefix . 'styles_imageset_data' => array( + 'COLUMNS' => array( + 'image_id' => array('UINT', NULL, 'auto_increment'), + 'image_name' => array('VCHAR:200', ''), + 'image_filename' => array('VCHAR:200', ''), + 'image_lang' => array('VCHAR:30', ''), + 'image_height' => array('USINT', 0), + 'image_width' => array('USINT', 0), + 'imageset_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'image_id', + 'KEYS' => array( + 'i_d' => array('INDEX', 'imageset_id'), + ), + ), + $this->table_prefix . 'styles_template' => array( + 'COLUMNS' => array( + 'template_id' => array('UINT', NULL, 'auto_increment'), + 'template_name' => array('VCHAR_UNI:255', ''), + 'template_copyright' => array('VCHAR_UNI', ''), + 'template_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'template_storedb' => array('BOOL', 0), + 'template_inherits_id' => array('UINT:4', 0), + 'template_inherit_path' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'template_id', + 'KEYS' => array( + 'tmplte_nm' => array('UNIQUE', 'template_name'), + ), + ), + $this->table_prefix . 'styles_template_data' => array( + 'COLUMNS' => array( + 'template_id' => array('UINT', 0), + 'template_filename' => array('VCHAR:100', ''), + 'template_included' => array('TEXT', ''), + 'template_mtime' => array('TIMESTAMP', 0), + 'template_data' => array('MTEXT_UNI', ''), + ), + 'KEYS' => array( + 'tid' => array('INDEX', 'template_id'), + 'tfn' => array('INDEX', 'template_filename'), + ), + ), + $this->table_prefix . 'styles_theme' => array( + 'COLUMNS' => array( + 'theme_id' => array('UINT', NULL, 'auto_increment'), + 'theme_name' => array('VCHAR_UNI:255', ''), + 'theme_copyright' => array('VCHAR_UNI', ''), + 'theme_path' => array('VCHAR:100', ''), + 'theme_storedb' => array('BOOL', 0), + 'theme_mtime' => array('TIMESTAMP', 0), + 'theme_data' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'theme_id', + 'KEYS' => array( + 'theme_name' => array('UNIQUE', 'theme_name'), + ), + ), + ), + ); } } diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 7734ed4b76..1a7dfe1e19 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { return array( 'change_columns' => array( - USERS_TABLE => array( + $this->table_prefix . 'users' => array( 'user_timezone' => array('VCHAR:100', ''), ), ), @@ -36,13 +36,13 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { // Update user timezones $sql = 'SELECT user_dst, user_timezone - FROM ' . USERS_TABLE . ' + FROM ' . $this->table_prefix . 'users GROUP BY user_timezone, user_dst'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { - $sql = 'UPDATE ' . USERS_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "users SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' AND user_dst = " . (int) $row['user_dst']; @@ -51,13 +51,10 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration $this->db->sql_freeresult($result); // Update board default timezone - $sql = 'UPDATE ' . CONFIG_TABLE . " + $sql = 'UPDATE ' . $this->table_prefix . "config SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' WHERE config_name = 'board_timezone'"; $this->sql_query($sql); - - // After we have calculated the timezones we can delete user_dst column from user table. - $this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } /** diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php new file mode 100644 index 0000000000..85c1cf9456 --- /dev/null +++ b/phpBB/includes/db/migration/data/timezone_p2.php @@ -0,0 +1,38 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration +{ + public function depends_on() + { + return array('phpbb_db_migration_data_timezone'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst' => array('BOOL', 0), + ), + ), + ); + } +} From babdb92aa998728b58eec1e3f2c036b5f2342492 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 17:25:53 -0600 Subject: [PATCH 108/174] [feature/migrations] Remove hardcoded language, use lang instead. PHPBB3-9737 --- phpBB/install/database_update.php | 54 +++++++++++++++---------------- phpBB/language/en/install.php | 3 ++ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7431c96231..cd43f6065b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,26 +21,6 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - phpbb_require_updated('includes/startup.' . $phpEx); include($phpbb_root_path . 'config.' . $phpEx); @@ -200,7 +180,7 @@ while (!$migrator->finished()) { echo $e; - end_update($cache); + phpbb_end_update($cache); } echo $migrator->last_run_migration['name'] . '<br />'; @@ -209,10 +189,10 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; - echo 'Update not yet completed.<br />'; - echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">Continue</a>'; + echo $lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">' . $lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; - end_update($cache); + phpbb_end_update($cache); } } @@ -221,11 +201,31 @@ if ($orig_version != $config['version']) add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -echo 'Finished'; +echo $lang['DATABASE_UPDATE_COMPLETE']; -end_update($cache); +phpbb_end_update($cache); -function end_update($cache) +if (!function_exists('phpbb_require_updated')) +{ + function phpbb_require_updated($path, $optional = false) + { + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + require($new_path); + } + else if (!$optional || file_exists($old_path)) + { + require($old_path); + } + } +} + +function phpbb_end_update($cache) { $cache->purge(); diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index f7820714e1..7607512eab 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -397,7 +397,10 @@ $lang = array_merge($lang, array( 'CURRENT_VERSION' => 'Current version', 'DATABASE_TYPE' => 'Database type', + 'DATABASE_UPDATE_COMPLETE' => 'Database updater has completed!', + 'DATABASE_UPDATE_CONTINUE' => 'Continue database update.', 'DATABASE_UPDATE_INFO_OLD' => 'The database update file within the install directory is outdated. Please make sure you uploaded the correct version of the file.', + 'DATABASE_UPDATE_NOT_COMPLETED' => 'The database update has not yet completed.', 'DELETE_USER_REMOVE' => 'Delete user and remove posts', 'DELETE_USER_RETAIN' => 'Delete user but keep posts', 'DESTINATION' => 'Destination file', From 74f4397451dae0ab83d977d97d96ed9549bf3ab9 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 22:28:48 -0600 Subject: [PATCH 109/174] [feature/migrations] Make depends_on static to call it without dependencies Move installing migrations to migration/install.php and handle figuring out what migrations have been installed based on phpBB version. PHPBB3-11318 --- phpBB/includes/db/migration/data/3_0_1.php | 4 +- phpBB/includes/db/migration/data/3_0_10.php | 4 +- .../includes/db/migration/data/3_0_10_rc1.php | 4 +- .../includes/db/migration/data/3_0_10_rc2.php | 4 +- .../includes/db/migration/data/3_0_10_rc3.php | 4 +- phpBB/includes/db/migration/data/3_0_11.php | 4 +- .../includes/db/migration/data/3_0_11_rc1.php | 8 +- .../includes/db/migration/data/3_0_11_rc2.php | 8 +- .../includes/db/migration/data/3_0_12_rc1.php | 2 +- .../includes/db/migration/data/3_0_1_rc1.php | 15 +- phpBB/includes/db/migration/data/3_0_2.php | 4 +- .../includes/db/migration/data/3_0_2_rc1.php | 4 +- .../includes/db/migration/data/3_0_2_rc2.php | 8 +- phpBB/includes/db/migration/data/3_0_3.php | 4 +- .../includes/db/migration/data/3_0_3_rc1.php | 12 +- phpBB/includes/db/migration/data/3_0_4.php | 6 +- .../includes/db/migration/data/3_0_4_rc1.php | 10 +- phpBB/includes/db/migration/data/3_0_5.php | 4 +- .../includes/db/migration/data/3_0_5_rc1.php | 12 +- .../db/migration/data/3_0_5_rc1part2.php | 6 +- phpBB/includes/db/migration/data/3_0_6.php | 4 +- .../includes/db/migration/data/3_0_6_rc1.php | 12 +- .../includes/db/migration/data/3_0_6_rc2.php | 4 +- .../includes/db/migration/data/3_0_6_rc3.php | 6 +- .../includes/db/migration/data/3_0_6_rc4.php | 4 +- phpBB/includes/db/migration/data/3_0_7.php | 4 +- .../includes/db/migration/data/3_0_7_pl1.php | 4 +- .../includes/db/migration/data/3_0_7_rc1.php | 10 +- .../includes/db/migration/data/3_0_7_rc2.php | 6 +- phpBB/includes/db/migration/data/3_0_8.php | 4 +- .../includes/db/migration/data/3_0_8_rc1.php | 12 +- phpBB/includes/db/migration/data/3_0_9.php | 4 +- .../includes/db/migration/data/3_0_9_rc1.php | 12 +- .../includes/db/migration/data/3_0_9_rc2.php | 4 +- .../includes/db/migration/data/3_0_9_rc3.php | 4 +- .../includes/db/migration/data/3_0_9_rc4.php | 4 +- .../includes/db/migration/data/3_1_0_dev.php | 2 +- .../includes/db/migration/data/extensions.php | 2 +- .../db/migration/data/style_update_p1.php | 2 +- .../db/migration/data/style_update_p2.php | 2 +- phpBB/includes/db/migration/data/timezone.php | 2 +- .../db/migration/data/timezone_p2.php | 2 +- phpBB/includes/db/migration/install.php | 129 ++++++++++++++++++ phpBB/install/database_update.php | 16 +-- 44 files changed, 249 insertions(+), 133 deletions(-) create mode 100644 phpBB/includes/db/migration/install.php diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index d71288c64b..a9eac6f110 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.1')), diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 17472562f2..89afb8a432 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc3'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.10')), diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index eebee44e39..ca8fadec61 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9'); } - function update_data() + public function update_data() { return array( array('config.add', array('email_max_chunk_size', 50)), diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index b81fde9bcb..1f39ea48e0 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.10-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index d97b0b4aec..cd82bb573e 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.10-rc3')), diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index b149cd374c..9f25f0e489 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.11')), diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 3d4920bf49..676e6baa87 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), @@ -24,7 +24,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration ); } - function cleanup_deactivated_styles() + public function cleanup_deactivated_styles() { // Updates users having current style a deactivated one $sql = 'SELECT style_id @@ -48,7 +48,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration } } - function delete_orphan_private_messages() + public function delete_orphan_private_messages() { // Delete orphan private messages $batch_size = 500; diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php index e0638f02d7..e5bb3e44a6 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc1'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -25,7 +25,7 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -36,7 +36,7 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.11-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 0b35de2ed5..4fe0828716 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index a7af5d052d..9f1c04809d 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -9,12 +9,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration { - function depends_on() - { - return array(); - } - - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -41,7 +36,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -68,7 +63,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'fix_unset_last_view_time'))), @@ -78,7 +73,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration ); } - function fix_unset_last_view_time() + public function fix_unset_last_view_time() { $sql = 'UPDATE ' . $this->table_prefix . "topics SET topic_last_view_time = topic_last_post_time @@ -86,7 +81,7 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function reset_smiley_size() + public function reset_smiley_size() { // Update smiley sizes $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index 19e9213262..8661578281 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.2')), diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index 7dd321d83c..851060c3b5 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1'); } - function update_data() + public function update_data() { return array( array('config.add', array('referer_validation', '1')), diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index d73f9587c3..c255e55aef 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc1'); } - function update_schema() + public function update_schema() { return array( 'change_columns' => array( @@ -48,7 +48,7 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'add_index' => array( @@ -66,7 +66,7 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.2-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index d671b0cac3..2873c798fd 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.3')), diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 9cce80be74..49e4170c3f 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -29,7 +29,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -44,7 +44,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('enable_queue_trigger', '0')), @@ -59,7 +59,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration ); } - function correct_acp_email_permissions() + public function correct_acp_email_permissions() { $sql = 'UPDATE ' . $this->table_prefix . 'modules SET module_auth = \'acl_a_email && cfg_email_enable\' @@ -68,7 +68,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function set_group_default_max_recipients() + public function set_group_default_max_recipients() { // Set maximum number of recipients for the registered users, bots, guests group $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index e734814530..590ae3c69f 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4_rc1'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'rename_log_delete_topic'))), @@ -23,7 +23,7 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration ); } - function rename_log_delete_topic() + public function rename_log_delete_topic() { if ($this->db->sql_layer == 'oracle') { diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index eb2fcb8d0e..8f44baf046 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -55,7 +55,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -66,7 +66,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_custom_profile_fields'))), @@ -75,7 +75,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration ); } - function update_custom_profile_fields() + public function update_custom_profile_fields() { // Update the Custom Profile Fields based on previous settings to the new format $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 6d61793d08..65b292207e 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1part2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.5')), diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php index cbf28c0be6..a0893a0dbb 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4'); } - function update_schema() + public function update_schema() { return array( 'change_columns' => array( @@ -25,7 +25,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { $search_indexing_state = $this->config['search_indexing_state']; @@ -42,7 +42,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration ); } - function hash_old_passwords() + public function hash_old_passwords() { $sql = 'SELECT user_id, user_password FROM ' . $this->table_prefix . 'users @@ -63,7 +63,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration $this->db->sql_freeresult($result); } - function update_ichiro_bot() + public function update_ichiro_bot() { // Adjust bot entry $sql = 'UPDATE ' . $this->table_prefix . "bots @@ -72,7 +72,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function remove_duplicate_auth_options() + public function remove_duplicate_auth_options() { // Before we are able to add a unique key to auth_option, we need to remove duplicate entries $sql = 'SELECT auth_option diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 354de748c8..0597fc0ff8 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1'); } - function update_schema() + public function update_schema() { return array( 'drop_keys' => array( @@ -28,7 +28,7 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.5-rc1')), diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index cc6fccaae2..a7b88e510a 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc4'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.6')), diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index b520bda6d0..5ebeceeed7 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5'); } - function update_schema() + public function update_schema() { return array( 'add_columns' => array( @@ -59,7 +59,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_columns' => array( @@ -99,7 +99,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), @@ -184,14 +184,14 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration ); } - function set_user_options_default() + public function set_user_options_default() { // 229376 is the added value to enable all three signature options $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; $this->sql_query($sql); } - function add_newly_registered_group() + public function add_newly_registered_group() { // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) $sql = 'SELECT group_id diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index d61c296445..7cbda4c616 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.6-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index a3f0dcacdf..209057ec70 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc2'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_cp_fields'))), @@ -23,7 +23,7 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration ); } - function update_cp_fields() + public function update_cp_fields() { // Update the Custom Profile Fields based on previous settings to the new format $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index 3855b85551..62f0e91a7d 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc3'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.6-rc4')), diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index 59779c9cb0..3e215ff905 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.7')), diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index 5570a5dc06..ffe0836d02 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.7-pl1')), diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index 84b8f798a8..b30830c21d 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6'); } - function update_schema() + public function update_schema() { return array( 'drop_keys' => array( @@ -30,7 +30,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'add_index' => array( @@ -46,7 +46,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('feed_overall', 1)), @@ -61,7 +61,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration ); } - function delete_text_templates() + public function delete_text_templates() { // Delete all text-templates from the template_data $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index 48aa818ba3..e986be23bf 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc1'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_email_hash'))), @@ -23,7 +23,7 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration ); } - function update_email_hash($start = 0) + public function update_email_hash($start = 0) { $limit = 1000; diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index d94fe869fb..8043b934b0 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.8')), diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index eb4cc5bd1a..8214f44f17 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_pl1'); } - function update_data() + public function update_data() { return array( array('custom', array(array(&$this, 'update_file_extension_group_names'))), @@ -37,7 +37,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration ); } - function update_file_extension_group_names() + public function update_file_extension_group_names() { // Update file extension group names to use language strings. $sql = 'SELECT lang_dir @@ -93,7 +93,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration $this->db->sql_freeresult($result); } - function update_module_auth() + public function update_module_auth() { $sql = 'UPDATE ' . MODULES_TABLE . ' SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' @@ -103,7 +103,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration $this->sql_query($sql); } - function update_bots() + public function update_bots() { $bot_name = 'Bing [Bot]'; $bot_name_clean = utf8_clean_string($bot_name); @@ -167,7 +167,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration } } - function delete_orphan_shadow_topics() + public function delete_orphan_shadow_topics() { // Delete shadow topics pointing to not existing topics $batch_size = 500; diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index d19a24b45e..c562f1f2cf 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc4'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9')), diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index 4ed48061a4..367bb25734 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8'); } - function update_schema() + public function update_schema() { return array( 'add_tables' => array( @@ -51,7 +51,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } - function revert_schema() + public function revert_schema() { return array( 'drop_tables' => array( @@ -60,7 +60,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } - function update_data() + public function update_data() { return array( array('config.add', array('ip_login_limit_max', 50)), @@ -73,7 +73,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration ); } - function update_file_extension_group_names() + public function update_file_extension_group_names() { // Update file extension group names to use language strings, again. $sql = 'SELECT group_id, group_name @@ -95,7 +95,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration $this->db->sql_freeresult($result); } - function fix_firebird_qa_captcha() + public function fix_firebird_qa_captcha() { // Recover from potentially broken Q&A CAPTCHA table on firebird // Q&A CAPTCHA was uninstallable, so it's safe to remove these diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index 98ef232cb4..c8566d54a5 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc1'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9-rc2')), diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index b84d61031e..da977e9666 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc2'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9-rc3')), diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index 2a00bba843..0bfe26985c 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -9,12 +9,12 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration { - function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc3'); } - function update_data() + public function update_data() { return array( array('config.update', array('version', '3.0.9-rc4')), diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 4f7ed07158..14953591d1 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array( 'phpbb_db_migration_data_3_0_11', diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index b5f5b792cf..ff54d0d933 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index f1b26f525a..701afc0d78 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index 361eb5a389..1a8cc9da58 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_style_update_p1'); } diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 1a7dfe1e19..3658120629 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); } diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php index 85c1cf9456..15f1a3e414 100644 --- a/phpBB/includes/db/migration/data/timezone_p2.php +++ b/phpBB/includes/db/migration/data/timezone_p2.php @@ -9,7 +9,7 @@ class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration { - public function depends_on() + static public function depends_on() { return array('phpbb_db_migration_data_timezone'); } diff --git a/phpBB/includes/db/migration/install.php b/phpBB/includes/db/migration/install.php new file mode 100644 index 0000000000..af2ba392b1 --- /dev/null +++ b/phpBB/includes/db/migration/install.php @@ -0,0 +1,129 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_install +{ + /** + * List of phpBB versions/what migration identifier + * contains the updates that should have been installed already + * + * @var array + */ + protected $version_to_migration = array( + '3.0.1-rc1' => 'phpbb_db_migration_data_3_0_1_rc1', + '3.0.1' => 'phpbb_db_migration_data_3_0_1', + '3.0.2-rc1' => 'phpbb_db_migration_data_3_0_2_rc1', + '3.0.2-rc2' => 'phpbb_db_migration_data_3_0_2_rc2', + '3.0.2' => 'phpbb_db_migration_data_3_0_2', + '3.0.3-rc1' => 'phpbb_db_migration_data_3_0_3_rc1', + '3.0.3' => 'phpbb_db_migration_data_3_0_3', + '3.0.4-rc1' => 'phpbb_db_migration_data_3_0_4_rc1', + '3.0.4' => 'phpbb_db_migration_data_3_0_4', + '3.0.5-rc1' => array( + 'phpbb_db_migration_data_3_0_5_rc1', + 'phpbb_db_migration_data_3_0_5_rc1part2', + ), + '3.0.5' => 'phpbb_db_migration_data_3_0_5', + '3.0.6-rc1' => 'phpbb_db_migration_data_3_0_6_rc1', + '3.0.6-rc2' => 'phpbb_db_migration_data_3_0_6_rc2', + '3.0.6-rc3' => 'phpbb_db_migration_data_3_0_6_rc3', + '3.0.6-rc4' => 'phpbb_db_migration_data_3_0_6_rc4', + '3.0.6' => 'phpbb_db_migration_data_3_0_6', + '3.0.7-rc1' => 'phpbb_db_migration_data_3_0_7_rc1', + '3.0.7-rc2' => 'phpbb_db_migration_data_3_0_7_rc2', + '3.0.7' => 'phpbb_db_migration_data_3_0_7', + '3.0.7-pl1' => 'phpbb_db_migration_data_3_0_7_pl1', + '3.0.8-rc1' => 'phpbb_db_migration_data_3_0_8_rc1', + '3.0.8' => 'phpbb_db_migration_data_3_0_8', + '3.0.9-rc1' => 'phpbb_db_migration_data_3_0_9_rc1', + '3.0.9-rc2' => 'phpbb_db_migration_data_3_0_9_rc2', + '3.0.9-rc3' => 'phpbb_db_migration_data_3_0_9_rc3', + '3.0.9-rc4' => 'phpbb_db_migration_data_3_0_9_rc4', + '3.0.9' => 'phpbb_db_migration_data_3_0_9', + '3.0.10-rc1' => 'phpbb_db_migration_data_3_0_10_rc1', + '3.0.10-rc2' => 'phpbb_db_migration_data_3_0_10_rc2', + '3.0.10-rc3' => 'phpbb_db_migration_data_3_0_10_rc3', + '3.0.10' => 'phpbb_db_migration_data_3_0_10', + '3.0.11-rc1' => 'phpbb_db_migration_data_3_0_11_rc1', + '3.0.11-rc2' => 'phpbb_db_migration_data_3_0_11_rc2', + '3.0.11' => 'phpbb_db_migration_data_3_0_11', + '3.0.12-rc1' => 'phpbb_db_migration_data_3_0_12_rc1', + '3.1.0-dev' => array( + 'phpbb_db_migration_data_style_update_p1', + 'phpbb_db_migration_data_style_update_p2', + 'phpbb_db_migration_data_timezone', + 'phpbb_db_migration_data_timezone_p2', + 'phpbb_db_migration_data_extensions', + 'phpbb_db_migration_data_3_1_0_dev', + ), + ); + + public function install(phpbb_db_driver $db, phpbb_db_tools $db_tools, $table_prefix, $version) + { + $this->create_table($db_tools); + + $this->guess_installed_migrations($db, $table_prefix, $version); + } + + protected function create_table(phpbb_db_tools $db_tools) + { + if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) + { + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); + } + } + + /** + * Guess what migrations have been installed based on phpBB version + * + * @param mixed $version + */ + protected function guess_installed_migrations(phpbb_db_driver $db, $table_prefix, $version) + { + $installed = array(); + foreach ($this->version_to_migration as $compare => $migration_list) + { + if (version_compare($version, $compare, '<=')) + { + // The migration should have effectively been installed already + if (!is_array($migration_list)) + { + $migration_list = array($migration_list); + } + + foreach ($migration_list as $migration_name) + { + $sql_ary = array( + 'migration_name' => $migration_name, + 'migration_depends_on' => $migration_name::depends_on(), + 'migration_schema_done' => 1, + 'migration_data_done' => 1, + 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, + ); + $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . + $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + } + } + } + } +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cd43f6065b..74aa072d22 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -147,21 +147,13 @@ header('Content-type: text/html; charset=UTF-8'); // End startup code +// Make sure migrations have been installed. If not, install migrations and guess what migrations have been installed $db_tools = $phpbb_container->get('dbal.tools'); if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) { - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); + $migrations_installer = new phpbb_db_migration_install(); + $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); + unset($migrations_installer); } $migrator = $phpbb_container->get('migrator'); From 8baceacc36f06c2c14d4a4c08cecb3c80b3c76d3 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Thu, 10 Jan 2013 22:45:26 -0600 Subject: [PATCH 110/174] [feature/migrations] Fix migrations installer, schema for schema_data.sql PHPBB3-11318 --- phpBB/includes/db/migration/install.php | 43 ++++++----- phpBB/install/database_update.php | 94 ++++++++++++------------- phpBB/install/schemas/schema_data.sql | 43 +++++++++++ 3 files changed, 116 insertions(+), 64 deletions(-) diff --git a/phpBB/includes/db/migration/install.php b/phpBB/includes/db/migration/install.php index af2ba392b1..95f3a3b994 100644 --- a/phpBB/includes/db/migration/install.php +++ b/phpBB/includes/db/migration/install.php @@ -66,16 +66,16 @@ class phpbb_db_migration_install public function install(phpbb_db_driver $db, phpbb_db_tools $db_tools, $table_prefix, $version) { - $this->create_table($db_tools); + $this->create_table($db_tools, $table_prefix); $this->guess_installed_migrations($db, $table_prefix, $version); } - protected function create_table(phpbb_db_tools $db_tools) + protected function create_table(phpbb_db_tools $db_tools, $table_prefix) { - if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) + if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + $db_tools->sql_create_table($table_prefix . 'migrations', array( 'COLUMNS' => array( 'migration_name' => array('VCHAR', ''), 'migration_depends_on' => array('TEXT', ''), @@ -100,7 +100,7 @@ class phpbb_db_migration_install $installed = array(); foreach ($this->version_to_migration as $compare => $migration_list) { - if (version_compare($version, $compare, '<=')) + if (version_compare($version, $compare, '>=')) { // The migration should have effectively been installed already if (!is_array($migration_list)) @@ -110,18 +110,27 @@ class phpbb_db_migration_install foreach ($migration_list as $migration_name) { - $sql_ary = array( - 'migration_name' => $migration_name, - 'migration_depends_on' => $migration_name::depends_on(), - 'migration_schema_done' => 1, - 'migration_data_done' => 1, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . - $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); + $sql = 'SELECT 1 FROM ' . $table_prefix . "migrations + WHERE migration_name = '" . $db->sql_escape($migration_name) . "'"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $sql_ary = array( + 'migration_name' => $migration_name, + 'migration_depends_on' => serialize($migration_name::depends_on()), + 'migration_schema_done' => 1, + 'migration_data_done' => 1, + 'migration_data_state' => '', + 'migration_start_time' => 0, + 'migration_end_time' => 0, + ); + $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . + $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + } } } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 74aa072d22..f220a1f684 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,6 +21,52 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); +if (!function_exists('phpbb_require_updated')) +{ + function phpbb_require_updated($path, $optional = false) + { + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + require($new_path); + } + else if (!$optional || file_exists($old_path)) + { + require($old_path); + } + } +} + +function phpbb_end_update($cache) +{ + $cache->purge(); + +?> + </p> + </div> + </div> + <span class="corners-bottom"><span></span></span> + </div> + </div> + </div> + + <div id="page-footer"> + Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group + </div> + </div> +</body> +</html> + +<?php + + garbage_collection(); + exit_handler(); +} + phpbb_require_updated('includes/startup.' . $phpEx); include($phpbb_root_path . 'config.' . $phpEx); @@ -149,7 +195,7 @@ header('Content-type: text/html; charset=UTF-8'); // Make sure migrations have been installed. If not, install migrations and guess what migrations have been installed $db_tools = $phpbb_container->get('dbal.tools'); -if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) +if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { $migrations_installer = new phpbb_db_migration_install(); $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); @@ -196,49 +242,3 @@ if ($orig_version != $config['version']) echo $lang['DATABASE_UPDATE_COMPLETE']; phpbb_end_update($cache); - -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - -function phpbb_end_update($cache) -{ - $cache->purge(); - -?> - </p> - </div> - </div> - <span class="corners-bottom"><span></span></span> - </div> - </div> - </div> - - <div id="page-footer"> - Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Group - </div> - </div> -</body> -</html> - -<?php - - garbage_collection(); - exit_handler(); -} diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 7c1a7d40f5..d9e5c46e55 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -611,6 +611,49 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # NEW MEMBERS on the queue INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); +# Migrations +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_1_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1_rc1', 'a:0:{}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_3_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_3_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_4_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_4_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_3";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5', 'a:1:{i:0;s:38:"phpbb_db_migration_data_3_0_5_rc1part2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_4";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5_rc1part2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_5_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc4";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_5";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc3";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_pl1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_7";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_6";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_8', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_8_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_8_rc1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_pl1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc4";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_8";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc3";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_extensions', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p2', 'a:1:{i:0;s:39:"phpbb_db_migration_data_style_update_p1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone_p2', 'a:1:{i:0;s:32:"phpbb_db_migration_data_timezone";}', 1, 1, '', 0, 0); # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); From dd327ac83ead363564d489a5819cb9648dcac2c1 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Fri, 11 Jan 2013 10:48:46 -0600 Subject: [PATCH 111/174] [feature/migrations] Order the migrations schema in schema_data.sql PHPBB3-11318 --- phpBB/install/schemas/schema_data.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index d9e5c46e55..53ff90119e 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -613,14 +613,6 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # Migrations INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_1_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1_rc1', 'a:0:{}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc2";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_1";}', 1, 1, '', 0, 0); @@ -648,12 +640,20 @@ INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_sc INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc1";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc2";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_extensions', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p2', 'a:1:{i:0;s:39:"phpbb_db_migration_data_style_update_p1";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone_p2', 'a:1:{i:0;s:32:"phpbb_db_migration_data_timezone";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); From dfcf9966e95fce074a5ed6eb4036393f5b62de7c Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sat, 12 Jan 2013 19:45:20 -0600 Subject: [PATCH 112/174] [feature/migrations] Comments for the return in the custom functions PHPBB3-11318 --- phpBB/includes/db/migration/data/3_0_11_rc1.php | 1 + phpBB/includes/db/migration/data/3_0_7_rc2.php | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 676e6baa87..43e0156760 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -83,6 +83,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms); $this->sql_query($sql); + // Return false to have the Migrator call this function again return false; } } diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index e986be23bf..c2720b532f 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -62,6 +62,7 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration return; } + // Return the next start, will be sent to $start when this function is called again return $start + $limit; } } From 5e69e1a7612a4dbe24620cc5cad33720cb0c2885 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sun, 13 Jan 2013 13:23:02 -0600 Subject: [PATCH 113/174] [feature/migrations] effectively installed check for migration data PHPBB3-9737 --- phpBB/includes/db/migration/data/3_0_1.php | 5 + phpBB/includes/db/migration/data/3_0_10.php | 5 + .../includes/db/migration/data/3_0_10_rc1.php | 5 + .../includes/db/migration/data/3_0_10_rc2.php | 5 + .../includes/db/migration/data/3_0_10_rc3.php | 5 + phpBB/includes/db/migration/data/3_0_11.php | 5 + .../includes/db/migration/data/3_0_11_rc1.php | 5 + .../includes/db/migration/data/3_0_11_rc2.php | 5 + .../includes/db/migration/data/3_0_12_rc1.php | 5 + .../includes/db/migration/data/3_0_1_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_2.php | 5 + .../includes/db/migration/data/3_0_2_rc1.php | 5 + .../includes/db/migration/data/3_0_2_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_3.php | 5 + .../includes/db/migration/data/3_0_3_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_4.php | 5 + .../includes/db/migration/data/3_0_4_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_5.php | 5 + .../includes/db/migration/data/3_0_5_rc1.php | 5 + .../db/migration/data/3_0_5_rc1part2.php | 5 + phpBB/includes/db/migration/data/3_0_6.php | 5 + .../includes/db/migration/data/3_0_6_rc1.php | 5 + .../includes/db/migration/data/3_0_6_rc2.php | 5 + .../includes/db/migration/data/3_0_6_rc3.php | 5 + .../includes/db/migration/data/3_0_6_rc4.php | 5 + phpBB/includes/db/migration/data/3_0_7.php | 5 + .../includes/db/migration/data/3_0_7_pl1.php | 5 + .../includes/db/migration/data/3_0_7_rc1.php | 5 + .../includes/db/migration/data/3_0_7_rc2.php | 5 + phpBB/includes/db/migration/data/3_0_8.php | 5 + .../includes/db/migration/data/3_0_8_rc1.php | 5 + phpBB/includes/db/migration/data/3_0_9.php | 5 + .../includes/db/migration/data/3_0_9_rc1.php | 5 + .../includes/db/migration/data/3_0_9_rc2.php | 5 + .../includes/db/migration/data/3_0_9_rc3.php | 5 + .../includes/db/migration/data/3_0_9_rc4.php | 5 + .../includes/db/migration/data/3_1_0_dev.php | 5 + .../includes/db/migration/data/extensions.php | 5 + .../db/migration/data/style_update_p1.php | 5 + .../db/migration/data/style_update_p2.php | 5 + phpBB/includes/db/migration/data/timezone.php | 5 + .../db/migration/data/timezone_p2.php | 5 + phpBB/includes/db/migration/install.php | 138 ------------------ phpBB/install/database_update.php | 17 ++- 44 files changed, 223 insertions(+), 142 deletions(-) delete mode 100644 phpBB/includes/db/migration/install.php diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/3_0_1.php index a9eac6f110..8b7c6f0f7c 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/3_0_1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/3_0_10.php index 89afb8a432..b24a876bac 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/3_0_10.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc3'); diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/3_0_10_rc1.php index ca8fadec61..46b7db4e59 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9'); diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/3_0_10_rc2.php index 1f39ea48e0..5e85467202 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/3_0_10_rc3.php index cd82bb573e..6ff81f7776 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_10_rc3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.10-rc3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/3_0_11.php index 9f25f0e489..1a63508593 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/3_0_11.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.11', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/3_0_11_rc1.php index 43e0156760..19703bcc35 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.11-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_10'); diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/3_0_11_rc2.php index e5bb3e44a6..219d44c4e0 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_11_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.11-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/3_0_12_rc1.php index 4fe0828716..c23e8b24b8 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_12_rc1.php @@ -11,6 +11,11 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.12-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/3_0_1_rc1.php index 9f1c04809d..2fc2849d04 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_1_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.1-rc1', '>='); + } + public function update_schema() { return array( diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/3_0_2.php index 8661578281..8aa975f779 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/3_0_2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/3_0_2_rc1.php index 851060c3b5..6081cd682c 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.2-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_1'); diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/3_0_2_rc2.php index c255e55aef..bb76c270d7 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_2_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.2-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/3_0_3.php index 2873c798fd..82039a109b 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/3_0_3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/3_0_3_rc1.php index 49e4170c3f..5e300962b7 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_3_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.3-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_2'); diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/3_0_4.php index 590ae3c69f..34af9fa4ae 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/3_0_4.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.4', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/3_0_4_rc1.php index 8f44baf046..f63bebcf75 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_4_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.4-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_3'); diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/3_0_5.php index 65b292207e..077ed251d2 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/3_0_5.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.5', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1part2'); diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/3_0_5_rc1.php index a0893a0dbb..df85ee4f7d 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.5-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_4'); diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php index 0597fc0ff8..d2fad7a7f8 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/3_0_5_rc1part2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.5-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/3_0_6.php index a7b88e510a..1b0cbb1435 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/3_0_6.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc4'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/3_0_6_rc1.php index 5ebeceeed7..0f85084e65 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_5'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/3_0_6_rc2.php index 7cbda4c616..a9c497b3cd 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/3_0_6_rc3.php index 209057ec70..eca19fc2ff 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/3_0_6_rc4.php index 62f0e91a7d..19611d3c56 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_6_rc4.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.6-rc4', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6_rc3'); diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/3_0_7.php index 3e215ff905..97cdf4e3f1 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/3_0_7.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/3_0_7_pl1.php index ffe0836d02..176854a8a6 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/3_0_7_pl1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7-pl1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7'); diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/3_0_7_rc1.php index b30830c21d..daf52213b9 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_6'); diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/3_0_7_rc2.php index c2720b532f..8167d8fa40 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_7_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.7-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/3_0_8.php index 8043b934b0..25baaf0f07 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/3_0_8.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.8', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/3_0_8_rc1.php index 8214f44f17..13e68a7953 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_8_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.8-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_7_pl1'); diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/3_0_9.php index c562f1f2cf..b35350dbb5 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/3_0_9.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc4'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/3_0_9_rc1.php index 367bb25734..be6ced2566 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc1', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_8'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/3_0_9_rc2.php index c8566d54a5..0bec42a8de 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc2', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc1'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/3_0_9_rc3.php index da977e9666..a339670932 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc3.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc3', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc2'); diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/3_0_9_rc4.php index 0bfe26985c..ab5c302611 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/3_0_9_rc4.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.0.9-rc4', '>='); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_9_rc3'); diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index 14953591d1..ac8882cb3a 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration { + public function effectively_installed() + { + return version_compare($this->config['version'], '3.1.0-dev', '>='); + } + static public function depends_on() { return array( diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/extensions.php index ff54d0d933..f077741883 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/extensions.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration { + public function effectively_installed() + { + return $this->db_tools->sql_table_exists($this->table_prefix . 'ext'); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/style_update_p1.php index 701afc0d78..7506b7c49b 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/style_update_p1.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/style_update_p2.php index 1a8cc9da58..ef13f45d9b 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/style_update_p2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'); + } + static public function depends_on() { return array('phpbb_db_migration_data_style_update_p1'); diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/timezone.php index 3658120629..66085b8872 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/timezone.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); + } + static public function depends_on() { return array('phpbb_db_migration_data_3_0_11'); diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/timezone_p2.php index 15f1a3e414..38347a0c63 100644 --- a/phpBB/includes/db/migration/data/timezone_p2.php +++ b/phpBB/includes/db/migration/data/timezone_p2.php @@ -9,6 +9,11 @@ class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration { + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst'); + } + static public function depends_on() { return array('phpbb_db_migration_data_timezone'); diff --git a/phpBB/includes/db/migration/install.php b/phpBB/includes/db/migration/install.php deleted file mode 100644 index 95f3a3b994..0000000000 --- a/phpBB/includes/db/migration/install.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -/** -* -* @package migration -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 -* -*/ - -class phpbb_db_migration_install -{ - /** - * List of phpBB versions/what migration identifier - * contains the updates that should have been installed already - * - * @var array - */ - protected $version_to_migration = array( - '3.0.1-rc1' => 'phpbb_db_migration_data_3_0_1_rc1', - '3.0.1' => 'phpbb_db_migration_data_3_0_1', - '3.0.2-rc1' => 'phpbb_db_migration_data_3_0_2_rc1', - '3.0.2-rc2' => 'phpbb_db_migration_data_3_0_2_rc2', - '3.0.2' => 'phpbb_db_migration_data_3_0_2', - '3.0.3-rc1' => 'phpbb_db_migration_data_3_0_3_rc1', - '3.0.3' => 'phpbb_db_migration_data_3_0_3', - '3.0.4-rc1' => 'phpbb_db_migration_data_3_0_4_rc1', - '3.0.4' => 'phpbb_db_migration_data_3_0_4', - '3.0.5-rc1' => array( - 'phpbb_db_migration_data_3_0_5_rc1', - 'phpbb_db_migration_data_3_0_5_rc1part2', - ), - '3.0.5' => 'phpbb_db_migration_data_3_0_5', - '3.0.6-rc1' => 'phpbb_db_migration_data_3_0_6_rc1', - '3.0.6-rc2' => 'phpbb_db_migration_data_3_0_6_rc2', - '3.0.6-rc3' => 'phpbb_db_migration_data_3_0_6_rc3', - '3.0.6-rc4' => 'phpbb_db_migration_data_3_0_6_rc4', - '3.0.6' => 'phpbb_db_migration_data_3_0_6', - '3.0.7-rc1' => 'phpbb_db_migration_data_3_0_7_rc1', - '3.0.7-rc2' => 'phpbb_db_migration_data_3_0_7_rc2', - '3.0.7' => 'phpbb_db_migration_data_3_0_7', - '3.0.7-pl1' => 'phpbb_db_migration_data_3_0_7_pl1', - '3.0.8-rc1' => 'phpbb_db_migration_data_3_0_8_rc1', - '3.0.8' => 'phpbb_db_migration_data_3_0_8', - '3.0.9-rc1' => 'phpbb_db_migration_data_3_0_9_rc1', - '3.0.9-rc2' => 'phpbb_db_migration_data_3_0_9_rc2', - '3.0.9-rc3' => 'phpbb_db_migration_data_3_0_9_rc3', - '3.0.9-rc4' => 'phpbb_db_migration_data_3_0_9_rc4', - '3.0.9' => 'phpbb_db_migration_data_3_0_9', - '3.0.10-rc1' => 'phpbb_db_migration_data_3_0_10_rc1', - '3.0.10-rc2' => 'phpbb_db_migration_data_3_0_10_rc2', - '3.0.10-rc3' => 'phpbb_db_migration_data_3_0_10_rc3', - '3.0.10' => 'phpbb_db_migration_data_3_0_10', - '3.0.11-rc1' => 'phpbb_db_migration_data_3_0_11_rc1', - '3.0.11-rc2' => 'phpbb_db_migration_data_3_0_11_rc2', - '3.0.11' => 'phpbb_db_migration_data_3_0_11', - '3.0.12-rc1' => 'phpbb_db_migration_data_3_0_12_rc1', - '3.1.0-dev' => array( - 'phpbb_db_migration_data_style_update_p1', - 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone', - 'phpbb_db_migration_data_timezone_p2', - 'phpbb_db_migration_data_extensions', - 'phpbb_db_migration_data_3_1_0_dev', - ), - ); - - public function install(phpbb_db_driver $db, phpbb_db_tools $db_tools, $table_prefix, $version) - { - $this->create_table($db_tools, $table_prefix); - - $this->guess_installed_migrations($db, $table_prefix, $version); - } - - protected function create_table(phpbb_db_tools $db_tools, $table_prefix) - { - if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) - { - $db_tools->sql_create_table($table_prefix . 'migrations', array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); - } - } - - /** - * Guess what migrations have been installed based on phpBB version - * - * @param mixed $version - */ - protected function guess_installed_migrations(phpbb_db_driver $db, $table_prefix, $version) - { - $installed = array(); - foreach ($this->version_to_migration as $compare => $migration_list) - { - if (version_compare($version, $compare, '>=')) - { - // The migration should have effectively been installed already - if (!is_array($migration_list)) - { - $migration_list = array($migration_list); - } - - foreach ($migration_list as $migration_name) - { - $sql = 'SELECT 1 FROM ' . $table_prefix . "migrations - WHERE migration_name = '" . $db->sql_escape($migration_name) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql_ary = array( - 'migration_name' => $migration_name, - 'migration_depends_on' => serialize($migration_name::depends_on()), - 'migration_schema_done' => 1, - 'migration_data_done' => 1, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - $sql = 'INSERT INTO ' . $table_prefix . 'migrations ' . - $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - } - } - } - } -} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f220a1f684..459839f393 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -193,13 +193,22 @@ header('Content-type: text/html; charset=UTF-8'); // End startup code -// Make sure migrations have been installed. If not, install migrations and guess what migrations have been installed +// Make sure migrations have been installed. $db_tools = $phpbb_container->get('dbal.tools'); if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { - $migrations_installer = new phpbb_db_migration_install(); - $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); - unset($migrations_installer); + $db_tools->sql_create_table($table_prefix . 'migrations', array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); } $migrator = $phpbb_container->get('migrator'); From d30a9cb4971f261e33a4814cc94c8fd218afda91 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Sun, 13 Jan 2013 13:23:42 -0600 Subject: [PATCH 114/174] [feature/migrations] Automatically populate migrations table on install PHPBB3-9737 --- phpBB/install/install_install.php | 7 +++++ phpBB/install/schemas/schema_data.sql | 44 --------------------------- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 1ab9caee0a..e0eb9e4472 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -114,6 +114,7 @@ class install_install extends module $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); $this->disable_avatars_if_unwritable(); + $this->populate_migrations($phpbb_container, $phpbb_root_path); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); @@ -1880,6 +1881,12 @@ class install_install extends module } } + function populate_migrations($container, $phpbb_root_path) + { + $migrator = $container->get('migrator'); + $migrator->populate_migrations_from_directory($phpbb_root_path . 'includes/db/migration/data/'); + } + /** * Generate a list of available mail server authentication methods */ diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 53ff90119e..4e4d70ced3 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -611,50 +611,6 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # NEW MEMBERS on the queue INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); -# Migrations -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_1_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1_rc1', 'a:0:{}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_3_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_3_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_4_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_4_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5', 'a:1:{i:0;s:38:"phpbb_db_migration_data_3_0_5_rc1part2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_4";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5_rc1part2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_5_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc4";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_5";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_pl1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_7";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_6";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_8', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_8_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_8_rc1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_pl1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc4";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_8";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_extensions', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p2', 'a:1:{i:0;s:39:"phpbb_db_migration_data_style_update_p1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone_p2', 'a:1:{i:0;s:32:"phpbb_db_migration_data_timezone";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); - # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); From 747e51491859507ad2f1891df5df4e563c23dd57 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Mon, 14 Jan 2013 12:38:14 -0600 Subject: [PATCH 115/174] [feature/migrations] Reports table schema changes in recent develop PHPBB3-9737 --- .../includes/db/migration/data/3_1_0_dev.php | 1 + .../migration/data/reported_posts_display.php | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 phpBB/includes/db/migration/data/reported_posts_display.php diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/3_1_0_dev.php index ac8882cb3a..8b437104e0 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/3_1_0_dev.php @@ -21,6 +21,7 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration 'phpbb_db_migration_data_extensions', 'phpbb_db_migration_data_style_update_p2', 'phpbb_db_migration_data_timezone_p2', + 'phpbb_db_migration_data_reported_posts_display', ); } diff --git a/phpBB/includes/db/migration/data/reported_posts_display.php b/phpBB/includes/db/migration/data/reported_posts_display.php new file mode 100644 index 0000000000..fa605e28e5 --- /dev/null +++ b/phpBB/includes/db/migration/data/reported_posts_display.php @@ -0,0 +1,42 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_reported_posts_display extends phpbb_db_migration +{ + public function effectively_installed() + { + return $this->db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'reports' => array( + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'reports' => array( + 'reported_post_enable_bbcode', + 'reported_post_enable_smilies', + 'reported_post_enable_magic_url', + ), + ), + ); + } +} From 58507f250bf11dda6a138d5f66057ec413750e03 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Mon, 14 Jan 2013 12:45:01 -0600 Subject: [PATCH 116/174] [feature/migrations] Subdirectories for migration data Organization will set you free PHPBB3-9737 --- phpBB/includes/db/migration/data/{ => 30x}/3_0_1.php | 4 ++-- .../includes/db/migration/data/{ => 30x}/3_0_10.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_10_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_10_rc2.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_10_rc3.php | 4 ++-- .../includes/db/migration/data/{ => 30x}/3_0_11.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_11_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_11_rc2.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_12_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_1_rc1.php | 2 +- phpBB/includes/db/migration/data/{ => 30x}/3_0_2.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_2_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_2_rc2.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_3.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_3_rc1.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_4.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_4_rc1.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_5.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_5_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_5_rc1part2.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_6.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_6_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_6_rc2.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_6_rc3.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_6_rc4.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_7.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_7_pl1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_7_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_7_rc2.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_8.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_8_rc1.php | 4 ++-- phpBB/includes/db/migration/data/{ => 30x}/3_0_9.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_9_rc1.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_9_rc2.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_9_rc3.php | 4 ++-- .../db/migration/data/{ => 30x}/3_0_9_rc4.php | 4 ++-- .../db/migration/data/{3_1_0_dev.php => 310/dev.php} | 12 ++++++------ .../db/migration/data/{ => 310}/extensions.php | 4 ++-- .../data/{ => 310}/reported_posts_display.php | 2 +- .../db/migration/data/{ => 310}/style_update_p1.php | 4 ++-- .../db/migration/data/{ => 310}/style_update_p2.php | 4 ++-- .../db/migration/data/{ => 310}/timezone.php | 4 ++-- .../db/migration/data/{ => 310}/timezone_p2.php | 4 ++-- 43 files changed, 88 insertions(+), 88 deletions(-) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_1.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_10.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_10_rc1.php (79%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_10_rc2.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_10_rc3.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_11.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_11_rc1.php (94%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_11_rc2.php (86%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_12_rc1.php (95%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_1_rc1.php (97%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_2.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_2_rc1.php (84%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_2_rc2.php (92%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_3.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_3_rc1.php (94%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_4.php (89%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_4_rc1.php (96%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_5.php (76%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_5_rc1.php (96%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_5_rc1part2.php (84%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_6.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_6_rc1.php (98%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_6_rc2.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_6_rc3.php (86%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_6_rc4.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_7.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_7_pl1.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_7_rc1.php (93%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_7_rc2.php (92%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_8.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_8_rc1.php (97%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_9.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_9_rc1.php (96%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_9_rc2.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_9_rc3.php (77%) rename phpBB/includes/db/migration/data/{ => 30x}/3_0_9_rc4.php (77%) rename phpBB/includes/db/migration/data/{3_1_0_dev.php => 310/dev.php} (97%) rename phpBB/includes/db/migration/data/{ => 310}/extensions.php (91%) rename phpBB/includes/db/migration/data/{ => 310}/reported_posts_display.php (91%) rename phpBB/includes/db/migration/data/{ => 310}/style_update_p1.php (97%) rename phpBB/includes/db/migration/data/{ => 310}/style_update_p2.php (96%) rename phpBB/includes/db/migration/data/{ => 310}/timezone.php (98%) rename phpBB/includes/db/migration/data/{ => 310}/timezone_p2.php (84%) diff --git a/phpBB/includes/db/migration/data/3_0_1.php b/phpBB/includes/db/migration/data/30x/3_0_1.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_1.php rename to phpBB/includes/db/migration/data/30x/3_0_1.php index 8b7c6f0f7c..c996a0138a 100644 --- a/phpBB/includes/db/migration/data/3_0_1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_1_rc1'); + return array('phpbb_db_migration_data_30x_3_0_1_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_10.php b/phpBB/includes/db/migration/data/30x/3_0_10.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_10.php rename to phpBB/includes/db/migration/data/30x/3_0_10.php index b24a876bac..122f93d6b4 100644 --- a/phpBB/includes/db/migration/data/3_0_10.php +++ b/phpBB/includes/db/migration/data/30x/3_0_10.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_10 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_10_rc3'); + return array('phpbb_db_migration_data_30x_3_0_10_rc3'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_10_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_10_rc1.php similarity index 79% rename from phpBB/includes/db/migration/data/3_0_10_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_10_rc1.php index 46b7db4e59..0ed05812dc 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_10_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_9'); + return array('phpbb_db_migration_data_30x_3_0_9'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_10_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_10_rc2.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_10_rc2.php rename to phpBB/includes/db/migration/data/30x/3_0_10_rc2.php index 5e85467202..b14b3b00aa 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_10_rc2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_10_rc1'); + return array('phpbb_db_migration_data_30x_3_0_10_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_10_rc3.php b/phpBB/includes/db/migration/data/30x/3_0_10_rc3.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_10_rc3.php rename to phpBB/includes/db/migration/data/30x/3_0_10_rc3.php index 6ff81f7776..473057d65d 100644 --- a/phpBB/includes/db/migration/data/3_0_10_rc3.php +++ b/phpBB/includes/db/migration/data/30x/3_0_10_rc3.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_10_rc2'); + return array('phpbb_db_migration_data_30x_3_0_10_rc2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_11.php b/phpBB/includes/db/migration/data/30x/3_0_11.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_11.php rename to phpBB/includes/db/migration/data/30x/3_0_11.php index 1a63508593..e063c699cc 100644 --- a/phpBB/includes/db/migration/data/3_0_11.php +++ b/phpBB/includes/db/migration/data/30x/3_0_11.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_11 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_11_rc2'); + return array('phpbb_db_migration_data_30x_3_0_11_rc2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_11_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_11_rc1.php similarity index 94% rename from phpBB/includes/db/migration/data/3_0_11_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_11_rc1.php index 19703bcc35..dddfc0e0e7 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_11_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_10'); + return array('phpbb_db_migration_data_30x_3_0_10'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_11_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_11_rc2.php similarity index 86% rename from phpBB/includes/db/migration/data/3_0_11_rc2.php rename to phpBB/includes/db/migration/data/30x/3_0_11_rc2.php index 219d44c4e0..fac8523e8c 100644 --- a/phpBB/includes/db/migration/data/3_0_11_rc2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_11_rc2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_11_rc1'); + return array('phpbb_db_migration_data_30x_3_0_11_rc1'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_12_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_12_rc1.php similarity index 95% rename from phpBB/includes/db/migration/data/3_0_12_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_12_rc1.php index c23e8b24b8..6a31a51201 100644 --- a/phpBB/includes/db/migration/data/3_0_12_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_12_rc1.php @@ -9,7 +9,7 @@ /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/ -class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -18,7 +18,7 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_1_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_1_rc1.php similarity index 97% rename from phpBB/includes/db/migration/data/3_0_1_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_1_rc1.php index 2fc2849d04..562ccf077c 100644 --- a/phpBB/includes/db/migration/data/3_0_1_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_1_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration { public function effectively_installed() { diff --git a/phpBB/includes/db/migration/data/3_0_2.php b/phpBB/includes/db/migration/data/30x/3_0_2.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_2.php rename to phpBB/includes/db/migration/data/30x/3_0_2.php index 8aa975f779..eed5acef82 100644 --- a/phpBB/includes/db/migration/data/3_0_2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_2_rc2'); + return array('phpbb_db_migration_data_30x_3_0_2_rc2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_2_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_2_rc1.php similarity index 84% rename from phpBB/includes/db/migration/data/3_0_2_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_2_rc1.php index 6081cd682c..a960e90765 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_2_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_1'); + return array('phpbb_db_migration_data_30x_3_0_1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_2_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_2_rc2.php similarity index 92% rename from phpBB/includes/db/migration/data/3_0_2_rc2.php rename to phpBB/includes/db/migration/data/30x/3_0_2_rc2.php index bb76c270d7..8917dfea77 100644 --- a/phpBB/includes/db/migration/data/3_0_2_rc2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_2_rc2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_2_rc1'); + return array('phpbb_db_migration_data_30x_3_0_2_rc1'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_3.php b/phpBB/includes/db/migration/data/30x/3_0_3.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_3.php rename to phpBB/includes/db/migration/data/30x/3_0_3.php index 82039a109b..8984cf7b76 100644 --- a/phpBB/includes/db/migration/data/3_0_3.php +++ b/phpBB/includes/db/migration/data/30x/3_0_3.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_3 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_3_rc1'); + return array('phpbb_db_migration_data_30x_3_0_3_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_3_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_3_rc1.php similarity index 94% rename from phpBB/includes/db/migration/data/3_0_3_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_3_rc1.php index 5e300962b7..4b102e1a2e 100644 --- a/phpBB/includes/db/migration/data/3_0_3_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_3_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_2'); + return array('phpbb_db_migration_data_30x_3_0_2'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_4.php b/phpBB/includes/db/migration/data/30x/3_0_4.php similarity index 89% rename from phpBB/includes/db/migration/data/3_0_4.php rename to phpBB/includes/db/migration/data/30x/3_0_4.php index 34af9fa4ae..9a0c132e78 100644 --- a/phpBB/includes/db/migration/data/3_0_4.php +++ b/phpBB/includes/db/migration/data/30x/3_0_4.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_4 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_4_rc1'); + return array('phpbb_db_migration_data_30x_3_0_4_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_4_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_4_rc1.php similarity index 96% rename from phpBB/includes/db/migration/data/3_0_4_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_4_rc1.php index f63bebcf75..8ad75a557b 100644 --- a/phpBB/includes/db/migration/data/3_0_4_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_4_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_3'); + return array('phpbb_db_migration_data_30x_3_0_3'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_5.php b/phpBB/includes/db/migration/data/30x/3_0_5.php similarity index 76% rename from phpBB/includes/db/migration/data/3_0_5.php rename to phpBB/includes/db/migration/data/30x/3_0_5.php index 077ed251d2..16d2dee457 100644 --- a/phpBB/includes/db/migration/data/3_0_5.php +++ b/phpBB/includes/db/migration/data/30x/3_0_5.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_5 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_5_rc1part2'); + return array('phpbb_db_migration_data_30x_3_0_5_rc1part2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_5_rc1.php similarity index 96% rename from phpBB/includes/db/migration/data/3_0_5_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_5_rc1.php index df85ee4f7d..ea17cc1e31 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_5_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_5_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_5_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_4'); + return array('phpbb_db_migration_data_30x_3_0_4'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php b/phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php similarity index 84% rename from phpBB/includes/db/migration/data/3_0_5_rc1part2.php rename to phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php index d2fad7a7f8..8538347b1a 100644 --- a/phpBB/includes/db/migration/data/3_0_5_rc1part2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_5_rc1'); + return array('phpbb_db_migration_data_30x_3_0_5_rc1'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_6.php b/phpBB/includes/db/migration/data/30x/3_0_6.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_6.php rename to phpBB/includes/db/migration/data/30x/3_0_6.php index 1b0cbb1435..bb651dc7cd 100644 --- a/phpBB/includes/db/migration/data/3_0_6.php +++ b/phpBB/includes/db/migration/data/30x/3_0_6.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_6 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_6_rc4'); + return array('phpbb_db_migration_data_30x_3_0_6_rc4'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_6_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc1.php similarity index 98% rename from phpBB/includes/db/migration/data/3_0_6_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_6_rc1.php index 0f85084e65..38c282ebf0 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_5'); + return array('phpbb_db_migration_data_30x_3_0_5'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_6_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc2.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_6_rc2.php rename to phpBB/includes/db/migration/data/30x/3_0_6_rc2.php index a9c497b3cd..a939dbd489 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_6_rc1'); + return array('phpbb_db_migration_data_30x_3_0_6_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_6_rc3.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc3.php similarity index 86% rename from phpBB/includes/db/migration/data/3_0_6_rc3.php rename to phpBB/includes/db/migration/data/30x/3_0_6_rc3.php index eca19fc2ff..b3f09d8ab8 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc3.php +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc3.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_6_rc2'); + return array('phpbb_db_migration_data_30x_3_0_6_rc2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_6_rc4.php b/phpBB/includes/db/migration/data/30x/3_0_6_rc4.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_6_rc4.php rename to phpBB/includes/db/migration/data/30x/3_0_6_rc4.php index 19611d3c56..fc2923f99b 100644 --- a/phpBB/includes/db/migration/data/3_0_6_rc4.php +++ b/phpBB/includes/db/migration/data/30x/3_0_6_rc4.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_6_rc3'); + return array('phpbb_db_migration_data_30x_3_0_6_rc3'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_7.php b/phpBB/includes/db/migration/data/30x/3_0_7.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_7.php rename to phpBB/includes/db/migration/data/30x/3_0_7.php index 97cdf4e3f1..9ff2e9e4ab 100644 --- a/phpBB/includes/db/migration/data/3_0_7.php +++ b/phpBB/includes/db/migration/data/30x/3_0_7.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_7 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_7_rc2'); + return array('phpbb_db_migration_data_30x_3_0_7_rc2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_7_pl1.php b/phpBB/includes/db/migration/data/30x/3_0_7_pl1.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_7_pl1.php rename to phpBB/includes/db/migration/data/30x/3_0_7_pl1.php index 176854a8a6..c9cc9d19ac 100644 --- a/phpBB/includes/db/migration/data/3_0_7_pl1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_7_pl1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_7_pl1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_7'); + return array('phpbb_db_migration_data_30x_3_0_7'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_7_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_7_rc1.php similarity index 93% rename from phpBB/includes/db/migration/data/3_0_7_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_7_rc1.php index daf52213b9..ffebf66f2d 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_7_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_6'); + return array('phpbb_db_migration_data_30x_3_0_6'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_7_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_7_rc2.php similarity index 92% rename from phpBB/includes/db/migration/data/3_0_7_rc2.php rename to phpBB/includes/db/migration/data/30x/3_0_7_rc2.php index 8167d8fa40..55bc2bc679 100644 --- a/phpBB/includes/db/migration/data/3_0_7_rc2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_7_rc2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_7_rc1'); + return array('phpbb_db_migration_data_30x_3_0_7_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_8.php b/phpBB/includes/db/migration/data/30x/3_0_8.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_8.php rename to phpBB/includes/db/migration/data/30x/3_0_8.php index 25baaf0f07..8998ef9627 100644 --- a/phpBB/includes/db/migration/data/3_0_8.php +++ b/phpBB/includes/db/migration/data/30x/3_0_8.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_8 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_8_rc1'); + return array('phpbb_db_migration_data_30x_3_0_8_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_8_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_8_rc1.php similarity index 97% rename from phpBB/includes/db/migration/data/3_0_8_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_8_rc1.php index 13e68a7953..aeff35333e 100644 --- a/phpBB/includes/db/migration/data/3_0_8_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_8_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_7_pl1'); + return array('phpbb_db_migration_data_30x_3_0_7_pl1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_9.php b/phpBB/includes/db/migration/data/30x/3_0_9.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_9.php rename to phpBB/includes/db/migration/data/30x/3_0_9.php index b35350dbb5..d5269ea6f0 100644 --- a/phpBB/includes/db/migration/data/3_0_9.php +++ b/phpBB/includes/db/migration/data/30x/3_0_9.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_9 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_9_rc4'); + return array('phpbb_db_migration_data_30x_3_0_9_rc4'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_9_rc1.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc1.php similarity index 96% rename from phpBB/includes/db/migration/data/3_0_9_rc1.php rename to phpBB/includes/db/migration/data/30x/3_0_9_rc1.php index be6ced2566..1f8622798e 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc1.php +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_8'); + return array('phpbb_db_migration_data_30x_3_0_8'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/3_0_9_rc2.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc2.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_9_rc2.php rename to phpBB/includes/db/migration/data/30x/3_0_9_rc2.php index 0bec42a8de..c0e662aa45 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc2.php +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_9_rc1'); + return array('phpbb_db_migration_data_30x_3_0_9_rc1'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_9_rc3.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc3.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_9_rc3.php rename to phpBB/includes/db/migration/data/30x/3_0_9_rc3.php index a339670932..d6d1f14b2e 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc3.php +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc3.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_9_rc2'); + return array('phpbb_db_migration_data_30x_3_0_9_rc2'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_0_9_rc4.php b/phpBB/includes/db/migration/data/30x/3_0_9_rc4.php similarity index 77% rename from phpBB/includes/db/migration/data/3_0_9_rc4.php rename to phpBB/includes/db/migration/data/30x/3_0_9_rc4.php index ab5c302611..e673249343 100644 --- a/phpBB/includes/db/migration/data/3_0_9_rc4.php +++ b/phpBB/includes/db/migration/data/30x/3_0_9_rc4.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration +class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_9_rc3'); + return array('phpbb_db_migration_data_30x_3_0_9_rc3'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/3_1_0_dev.php b/phpBB/includes/db/migration/data/310/dev.php similarity index 97% rename from phpBB/includes/db/migration/data/3_1_0_dev.php rename to phpBB/includes/db/migration/data/310/dev.php index 8b437104e0..f41750e327 100644 --- a/phpBB/includes/db/migration/data/3_1_0_dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration +class phpbb_db_migration_data_310_dev extends phpbb_db_migration { public function effectively_installed() { @@ -17,11 +17,11 @@ class phpbb_db_migration_data_3_1_0_dev extends phpbb_db_migration static public function depends_on() { return array( - 'phpbb_db_migration_data_3_0_11', - 'phpbb_db_migration_data_extensions', - 'phpbb_db_migration_data_style_update_p2', - 'phpbb_db_migration_data_timezone_p2', - 'phpbb_db_migration_data_reported_posts_display', + 'phpbb_db_migration_data_30x_11', + 'phpbb_db_migration_data_310_extensions', + 'phpbb_db_migration_data_310_style_update_p2', + 'phpbb_db_migration_data_310_timezone_p2', + 'phpbb_db_migration_data_310_reported_posts_display', ); } diff --git a/phpBB/includes/db/migration/data/extensions.php b/phpBB/includes/db/migration/data/310/extensions.php similarity index 91% rename from phpBB/includes/db/migration/data/extensions.php rename to phpBB/includes/db/migration/data/310/extensions.php index f077741883..925fa29384 100644 --- a/phpBB/includes/db/migration/data/extensions.php +++ b/phpBB/includes/db/migration/data/310/extensions.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_extensions extends phpbb_db_migration +class phpbb_db_migration_data_310_extensions extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_extensions extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_11'); + return array('phpbb_db_migration_data_30x_11'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/reported_posts_display.php b/phpBB/includes/db/migration/data/310/reported_posts_display.php similarity index 91% rename from phpBB/includes/db/migration/data/reported_posts_display.php rename to phpBB/includes/db/migration/data/310/reported_posts_display.php index fa605e28e5..64f0f1aaec 100644 --- a/phpBB/includes/db/migration/data/reported_posts_display.php +++ b/phpBB/includes/db/migration/data/310/reported_posts_display.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_reported_posts_display extends phpbb_db_migration +class phpbb_db_migration_data_310_reported_posts_display extends phpbb_db_migration { public function effectively_installed() { diff --git a/phpBB/includes/db/migration/data/style_update_p1.php b/phpBB/includes/db/migration/data/310/style_update_p1.php similarity index 97% rename from phpBB/includes/db/migration/data/style_update_p1.php rename to phpBB/includes/db/migration/data/310/style_update_p1.php index 7506b7c49b..d19ccc37cf 100644 --- a/phpBB/includes/db/migration/data/style_update_p1.php +++ b/phpBB/includes/db/migration/data/310/style_update_p1.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration +class phpbb_db_migration_data_310_style_update_p1 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_11'); + return array('phpbb_db_migration_data_30x_11'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/style_update_p2.php b/phpBB/includes/db/migration/data/310/style_update_p2.php similarity index 96% rename from phpBB/includes/db/migration/data/style_update_p2.php rename to phpBB/includes/db/migration/data/310/style_update_p2.php index ef13f45d9b..7b10518a66 100644 --- a/phpBB/includes/db/migration/data/style_update_p2.php +++ b/phpBB/includes/db/migration/data/310/style_update_p2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration +class phpbb_db_migration_data_310_style_update_p2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_style_update_p1'); + return array('phpbb_db_migration_data_310_style_update_p1'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/timezone.php b/phpBB/includes/db/migration/data/310/timezone.php similarity index 98% rename from phpBB/includes/db/migration/data/timezone.php rename to phpBB/includes/db/migration/data/310/timezone.php index 66085b8872..7a6a9bce05 100644 --- a/phpBB/includes/db/migration/data/timezone.php +++ b/phpBB/includes/db/migration/data/310/timezone.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_timezone extends phpbb_db_migration +class phpbb_db_migration_data_310_timezone extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_timezone extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_3_0_11'); + return array('phpbb_db_migration_data_30x_11'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/timezone_p2.php b/phpBB/includes/db/migration/data/310/timezone_p2.php similarity index 84% rename from phpBB/includes/db/migration/data/timezone_p2.php rename to phpBB/includes/db/migration/data/310/timezone_p2.php index 38347a0c63..113b979e4f 100644 --- a/phpBB/includes/db/migration/data/timezone_p2.php +++ b/phpBB/includes/db/migration/data/310/timezone_p2.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration +class phpbb_db_migration_data_310_timezone_p2 extends phpbb_db_migration { public function effectively_installed() { @@ -16,7 +16,7 @@ class phpbb_db_migration_data_timezone_p2 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_timezone'); + return array('phpbb_db_migration_data_310_timezone'); } public function update_schema() From e4afb68dc35131918a6b91ae9874ade97f448475 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Mon, 14 Jan 2013 12:50:13 -0600 Subject: [PATCH 117/174] [feature/migrations] Correct depends_on PHPBB3-9737 --- phpBB/includes/db/migration/data/310/dev.php | 1 - phpBB/includes/db/migration/data/310/extensions.php | 2 +- .../db/migration/data/310/reported_posts_display.php | 5 +++++ phpBB/includes/db/migration/data/310/style_update_p1.php | 2 +- phpBB/includes/db/migration/data/310/timezone.php | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index f41750e327..13b36bbf30 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -17,7 +17,6 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration static public function depends_on() { return array( - 'phpbb_db_migration_data_30x_11', 'phpbb_db_migration_data_310_extensions', 'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_timezone_p2', diff --git a/phpBB/includes/db/migration/data/310/extensions.php b/phpBB/includes/db/migration/data/310/extensions.php index 925fa29384..6a9caa1cfc 100644 --- a/phpBB/includes/db/migration/data/310/extensions.php +++ b/phpBB/includes/db/migration/data/310/extensions.php @@ -16,7 +16,7 @@ class phpbb_db_migration_data_310_extensions extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_30x_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_schema() diff --git a/phpBB/includes/db/migration/data/310/reported_posts_display.php b/phpBB/includes/db/migration/data/310/reported_posts_display.php index 64f0f1aaec..80a0a0e43f 100644 --- a/phpBB/includes/db/migration/data/310/reported_posts_display.php +++ b/phpBB/includes/db/migration/data/310/reported_posts_display.php @@ -14,6 +14,11 @@ class phpbb_db_migration_data_310_reported_posts_display extends phpbb_db_migrat return $this->db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode'); } + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + public function update_schema() { return array( diff --git a/phpBB/includes/db/migration/data/310/style_update_p1.php b/phpBB/includes/db/migration/data/310/style_update_p1.php index d19ccc37cf..e324ce7f24 100644 --- a/phpBB/includes/db/migration/data/310/style_update_p1.php +++ b/phpBB/includes/db/migration/data/310/style_update_p1.php @@ -16,7 +16,7 @@ class phpbb_db_migration_data_310_style_update_p1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_30x_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_data() diff --git a/phpBB/includes/db/migration/data/310/timezone.php b/phpBB/includes/db/migration/data/310/timezone.php index 7a6a9bce05..6e50cbe45f 100644 --- a/phpBB/includes/db/migration/data/310/timezone.php +++ b/phpBB/includes/db/migration/data/310/timezone.php @@ -16,7 +16,7 @@ class phpbb_db_migration_data_310_timezone extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_30x_11'); + return array('phpbb_db_migration_data_30x_3_0_11'); } public function update_schema() From a665ad5c2e44922fbd9790597913091c68311533 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 15 Jan 2013 18:58:19 -0600 Subject: [PATCH 118/174] [feature/migrations] Remove user_msnm migration PHPBB3-9737 --- phpBB/includes/db/migration/data/310/dev.php | 1 + .../db/migration/data/310/remove_msnm.php | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 phpBB/includes/db/migration/data/310/remove_msnm.php diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index 13b36bbf30..34f081bf62 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -21,6 +21,7 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration 'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_timezone_p2', 'phpbb_db_migration_data_310_reported_posts_display', + 'phpbb_db_migration_data_310_remove_msnm', ); } diff --git a/phpBB/includes/db/migration/data/310/remove_msnm.php b/phpBB/includes/db/migration/data/310/remove_msnm.php new file mode 100644 index 0000000000..521161df6b --- /dev/null +++ b/phpBB/includes/db/migration/data/310/remove_msnm.php @@ -0,0 +1,43 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +class phpbb_db_migration_data_310_remove_msnm extends phpbb_db_migration +{ + public function effectively_installed() + { + return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_msnm'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_msnm', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_msnm' => array('VCHAR_UNI', ''), + ), + ), + ); + } +} From daf243026a1c6bcd369381433b556732674c41f6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Wed, 6 Feb 2013 13:08:35 -0600 Subject: [PATCH 119/174] [ticket/11350] Do not pass $db by reference; typehint phpbb_db_driver PHPBB3-11350 --- phpBB/includes/db/db_tools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index a4bf40fcd7..9235317958 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -303,7 +303,7 @@ class phpbb_db_tools * @param phpbb_db_driver $db Database connection * @param bool $return_statements True if only statements should be returned and no SQL being executed */ - function phpbb_db_tools(&$db, $return_statements = false) + function phpbb_db_tools(phpbb_db_driver $db, $return_statements = false) { $this->db = $db; $this->return_statements = $return_statements; From 5705c3d377d097ef8bf7b99863eabc08fe3276e7 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Wed, 6 Feb 2013 13:14:40 -0600 Subject: [PATCH 120/174] [feature/migrations] Fix path to extension migrations PHPBB3-11318 --- phpBB/includes/extension/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 018324d5d6..008bd35376 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -520,7 +520,7 @@ class phpbb_extension_manager protected function handle_migrations($extension_name, $mode) { $migrator = $this->container->get('migrator'); - $migrations_path = $this->get_extension_path($extension_name) . 'migrations'; + $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; if (file_exists($migrations_path) && is_dir($migrations_path)) { $migrator->load_migrations($migrations_path); From a8da6b89e9da1d3b4e16317c21fc88fa1173d0f1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 20:01:40 -0600 Subject: [PATCH 121/174] [feature/migrations] Inject Migrator instead of using the container to fetch PHPBB3-11318 --- phpBB/config/services.yml | 1 + phpBB/includes/extension/manager.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 028ab88229..ef5359129f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -115,6 +115,7 @@ services: - @service_container - @dbal.conn - @config + - @migrator - %tables.ext% - %core.root_path% - .%core.php_ext% diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 008bd35376..926cc015de 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -29,6 +29,7 @@ class phpbb_extension_manager protected $db; protected $config; + protected $migrator; protected $cache; protected $php_ext; protected $extensions; @@ -48,12 +49,13 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; + $this->migrator = $migrator; $this->cache = $cache; $this->php_ext = $php_ext; $this->extension_table = $extension_table; @@ -519,11 +521,10 @@ class phpbb_extension_manager */ protected function handle_migrations($extension_name, $mode) { - $migrator = $this->container->get('migrator'); $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; if (file_exists($migrations_path) && is_dir($migrations_path)) { - $migrator->load_migrations($migrations_path); + $this->migrator->load_migrations($migrations_path); } // What is a safe limit of execution time? Half the max execution time should be safe. @@ -532,9 +533,9 @@ class phpbb_extension_manager if ($mode == 'enable') { - while (!$migrator->finished()) + while (!$this->migrator->finished()) { - $migrator->update(); + $this->migrator->update(); // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $start_time) >= $safe_time_limit) @@ -545,9 +546,9 @@ class phpbb_extension_manager } else if ($mode == 'purge') { - while ($migrator->migration_state() !== false) + while ($this->migrator->migration_state() !== false) { - $migrator->revert(); + $this->migrator->revert(); // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $start_time) >= $safe_time_limit) From fc4d5f74c0b82989370e899939d6f31e9a85723d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 20:05:39 -0600 Subject: [PATCH 122/174] [feature/migrations] Call revert correctly when purging an extension PHPBB3-11318 --- phpBB/includes/extension/manager.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 926cc015de..21a9ec1370 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -522,11 +522,13 @@ class phpbb_extension_manager protected function handle_migrations($extension_name, $mode) { $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; - if (file_exists($migrations_path) && is_dir($migrations_path)) + if (!file_exists($migrations_path) || !is_dir($migrations_path)) { - $this->migrator->load_migrations($migrations_path); + return true; } + $migrations = $this->migrator->load_migrations($migrations_path); + // What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); $start_time = time(); @@ -546,14 +548,17 @@ class phpbb_extension_manager } else if ($mode == 'purge') { - while ($this->migrator->migration_state() !== false) + foreach ($migrations as $migration) { - $this->migrator->revert(); - - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) + while ($this->migrator->migration_state($migration) !== false) { - return false; + $this->migrator->revert($migration); + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + return false; + } } } } From cacaffee6e013e43b75212d49960922f88f9f69a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 20:56:42 -0600 Subject: [PATCH 123/174] [feature/migrations] Add language strings for migrations errors Unfulfillable returns string of the missing dependency name now if the migration is unfulfillable (this is significantly more helpful). PHPBB3-11351 --- phpBB/includes/db/migration/tool/config.php | 2 +- phpBB/includes/db/migration/tool/module.php | 6 +- .../includes/db/migration/tool/permission.php | 6 +- phpBB/includes/db/migrator.php | 16 +++--- phpBB/language/en/migrator.php | 55 +++++++++++++++++++ 5 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 phpBB/language/en/migrator.php diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/includes/db/migration/tool/config.php index d9cc20053e..458a25fb66 100644 --- a/phpBB/includes/db/migration/tool/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -49,7 +49,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac { if (isset($this->config[$config_name])) { - throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name); + throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXIST', $config_name); } $this->config->set($config_name, $config_value, !$is_dynamic); diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index afe1f21ec5..4d7fae2bb0 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -242,14 +242,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if (!$module_id) { - throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent); } $parent = $data['parent_id'] = $module_id; } else if (!$this->exists($class, false, $parent)) { - throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); + throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent); } if ($this->exists($class, $parent, $data['module_langname'])) @@ -477,7 +477,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $result = $acp_modules->delete_module($module_id); if (!empty($result)) { - throw new phpbb_db_migration_exception('CANNOT_REMOVE_MODULE', $module_id); + throw new phpbb_db_migration_exception('MODULE_NOT_REMOVABLE', $module_id, $result); } } diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 001d090f5a..4231fbe1dd 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -107,7 +107,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte { if ($this->exists($auth_option, $global)) { - throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXISTS', $auth_option); + throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXIST', $auth_option); } // We've added permissions, so set to true to notify the user. @@ -252,7 +252,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte if ($role_id) { - throw new phpbb_db_migration_exception('ROLE_ALREADY_EXISTS', $old_role_name); + return; } $sql = 'SELECT MAX(role_order) AS max_role_order @@ -290,7 +290,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte if (!$role_id) { - throw new phpbb_db_migration_exception('ROLE_NOT_EXISTS', $old_role_name); + throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $old_role_name); } $sql = 'UPDATE ' . ACL_ROLES_TABLE . " diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 4456600b0a..3c311e96d7 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -228,9 +228,10 @@ class phpbb_db_migrator { foreach ($this->migrations as $name) { - if ($this->unfulfillable($name)) + $unfulfillable = $this->unfulfillable($name); + if ($unfulfillable !== false) { - throw new phpbb_db_migration_exception('MIGRATION NOT FULFILLABLE', $name); + throw new phpbb_db_migration_exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable); } } } @@ -674,13 +675,13 @@ class phpbb_db_migrator * Checks if a migration's dependencies can even theoretically be satisfied. * * @param string $name The class name of the migration - * @return bool Whether the migration cannot be fulfilled + * @return bool|string False if fulfillable, string of missing migration name if unfulfillable */ public function unfulfillable($name) { if (isset($this->migration_state[$name])) { - return false; + return $name; } if (!class_exists($name)) @@ -693,9 +694,10 @@ class phpbb_db_migrator foreach ($depends as $depend) { - if ($this->unfulfillable($depend)) + $unfulfillable = $this->unfulfillable($depend); + if ($unfulfillable !== false) { - return true; + return $unfulfillable; } } @@ -715,7 +717,7 @@ class phpbb_db_migrator { // skip unfulfillable migrations, but fulfillables mean we // are not finished yet - if ($this->unfulfillable($name)) + if ($this->unfulfillable($name) !== false) { continue; } diff --git a/phpBB/language/en/migrator.php b/phpBB/language/en/migrator.php new file mode 100644 index 0000000000..bc9fbc57af --- /dev/null +++ b/phpBB/language/en/migrator.php @@ -0,0 +1,55 @@ +<?php +/** +* +* migrator [English] +* +* @package language +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* DO NOT CHANGE +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +if (empty($lang) || !is_array($lang)) +{ + $lang = array(); +} + +// DEVELOPERS PLEASE NOTE +// +// All language files should use UTF-8 as their encoding and the files must not contain a BOM. +// +// Placeholders can now contain order information, e.g. instead of +// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows +// translators to re-order the output of data while ensuring it remains correct +// +// You do not need this where single placeholders are used, e.g. 'Message %d' is fine +// equally where a string contains only two placeholders which are used to wrap text +// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine + +$lang = array_merge($lang, array( + 'CONFIG_ALREADY_EXIST' => 'The config setting "%s" unexpectedly already exists.', + 'CONFIG_NOT_EXIST' => 'The config setting "%s" unexpectedly does not exist.', + + 'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.', + + 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', + + 'MODULE_ALREADY_EXIST' => 'The module "%s" unexpectedly already exists.', + 'MODULE_ERROR' => 'An error occured while creating a module: %s', + 'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s', + 'MODULE_NOT_EXIST' => 'A required module does not exist: %s', + 'MODULE_NOT_REMOVABLE' => 'Module %1$s was unable to be removed: %2$s', + + 'PERMISSION_ALREADY_EXIST' => 'The permission setting "%s" unexpectedly already exists.', + 'PERMISSION_NOT_EXIST' => 'The permission setting "%s" unexpectedly does not exist.', + + 'ROLE_NOT_EXIST' => 'The permission role "%s" unexpectedly does not exist.', +)); From f409697137b0b1d01b663bb81d12f6179c3922e3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 21:06:08 -0600 Subject: [PATCH 124/174] [feature/migrations] Add explanatory language string for migration errors This should be used if an exception is thrown to inform the user of what occurred. PHPBB3-11351 --- phpBB/language/en/migrator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/language/en/migrator.php b/phpBB/language/en/migrator.php index bc9fbc57af..84074c391c 100644 --- a/phpBB/language/en/migrator.php +++ b/phpBB/language/en/migrator.php @@ -40,6 +40,7 @@ $lang = array_merge($lang, array( 'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.', + 'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors.', 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', 'MODULE_ALREADY_EXIST' => 'The module "%s" unexpectedly already exists.', From b398fa2050ab720d9a3ae2b809bb3cdf4f153dc6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 21:09:29 -0600 Subject: [PATCH 125/174] [feature/migrations] Catch and display errors from the migrator PHPBB3-11318 --- phpBB/adm/style/acp_ext_enable.html | 8 +++++++- phpBB/adm/style/acp_ext_purge.html | 8 +++++++- phpBB/includes/acp/acp_extensions.php | 28 ++++++++++++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_ext_enable.html b/phpBB/adm/style/acp_ext_enable.html index 3f7be2c847..35585207eb 100644 --- a/phpBB/adm/style/acp_ext_enable.html +++ b/phpBB/adm/style/acp_ext_enable.html @@ -7,7 +7,13 @@ <p>{L_EXTENSIONS_EXPLAIN}</p> <p>{L_ENABLE_EXPLAIN}</p> - <!-- IF PRE --> + <!-- IF MIGRATOR_ERROR --> + <div class="errorbox"> + <p><strong>{L_MIGRATION_EXCEPTION_ERROR}</strong></p> + <p>{MIGRATOR_ERROR}</p> + <p><a href="{U_RETURN}">{L_RETURN}</a></p> + </div> + <!-- ELSEIF PRE --> <div class="errorbox"> <p>{L_ENABLE_CONFIRM}</p> </div> diff --git a/phpBB/adm/style/acp_ext_purge.html b/phpBB/adm/style/acp_ext_purge.html index 00a58721cb..94bef82ca5 100644 --- a/phpBB/adm/style/acp_ext_purge.html +++ b/phpBB/adm/style/acp_ext_purge.html @@ -7,7 +7,13 @@ <p>{L_EXTENSIONS_EXPLAIN}</p> <p>{L_PURGE_EXPLAIN}</p> - <!-- IF PRE --> + <!-- IF MIGRATOR_ERROR --> + <div class="errorbox"> + <p><strong>{L_MIGRATION_EXCEPTION_ERROR}</strong></p> + <p>{MIGRATOR_ERROR}</p> + <p><a href="{U_RETURN}">{L_RETURN}</a></p> + </div> + <!-- ELSEIF PRE --> <div class="errorbox"> <p>{L_PURGE_CONFIRM}</p> </div> diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index a0bcf62ecc..17ab4f3169 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -37,7 +37,7 @@ class acp_extensions $this->template = $template; $this->user = $user; - $user->add_lang(array('install', 'acp/extensions')); + $user->add_lang(array('install', 'acp/extensions', 'migrator')); $this->page_title = 'ACP_EXTENSIONS'; @@ -103,11 +103,18 @@ class acp_extensions trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action)); } - if ($phpbb_extension_manager->enable_step($ext_name)) + try { - $template->assign_var('S_NEXT_STEP', true); + if ($phpbb_extension_manager->enable_step($ext_name)) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + } + } + catch (phpbb_db_migration_exception $e) + { + $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); } $this->tpl_name = 'acp_ext_enable'; @@ -156,11 +163,18 @@ class acp_extensions break; case 'purge': - if ($phpbb_extension_manager->purge_step($ext_name)) + try { - $template->assign_var('S_NEXT_STEP', true); + if ($phpbb_extension_manager->purge_step($ext_name)) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + } + } + catch (phpbb_db_migration_exception $e) + { + $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); } $this->tpl_name = 'acp_ext_purge'; From f18b096df945648aa3ecc2b8b914869871b1823f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 21:10:56 -0600 Subject: [PATCH 126/174] [feature/migrations] getParameters function for migration exception PHPBB3-11351 --- phpBB/includes/db/migration/exception.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php index ffdcd97780..b3abcdb5e5 100644 --- a/phpBB/includes/db/migration/exception.php +++ b/phpBB/includes/db/migration/exception.php @@ -52,4 +52,14 @@ class phpbb_db_migration_exception extends \Exception { return $this->message . ': ' . var_export($this->parameters, true); } + + /** + * Get the parameters + * + * @return array + */ + public function getParameters() + { + return $this->parameters; + } } From f9a1b27a99e30a41db4facd415b39a690614d6c6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 9 Feb 2013 21:16:39 -0600 Subject: [PATCH 127/174] [feature/migrations] Fix unfulfillable function Returned unfulfillable name in the wrong place previously PHPBB3-11351 --- phpBB/includes/db/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 3c311e96d7..41d996b1e3 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -681,12 +681,12 @@ class phpbb_db_migrator { if (isset($this->migration_state[$name])) { - return $name; + return false; } if (!class_exists($name)) { - return true; + return $name; } $migration = $this->get_migration($name); From 3a68bba2fbfe8416884ac5230876cc73c3ba30bd Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Mon, 11 Feb 2013 21:31:34 -0600 Subject: [PATCH 128/174] [feature/migrations] Fix failing tests PHPBB3-11318 --- tests/extension/manager_test.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 5c0b419540..e31e27ef83 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -25,14 +25,22 @@ class phpbb_extension_manager_test extends phpbb_database_test_case { parent::setUp(); + $config = new phpbb_config(array()); + $db = $this->new_dbal(); + $db_tools = new phpbb_db_tools($db); + $phpbb_root_path = __DIR__ . './../../phpBB/'; + $php_ext = 'php'; + $table_prefix = 'phpbb_'; + $this->extension_manager = new phpbb_extension_manager( new phpbb_mock_container_builder(), - $this->new_dbal(), - new phpbb_config(array()), + $db, + $config, + new phpbb_db_migrator($config, $db, $db_tools, 'phpbb_migrations', $phpbb_root_path, $php_ext, $table_prefix, array()), 'phpbb_ext', dirname(__FILE__) . '/', - '.php', - new phpbb_mock_cache + '.' . $php_ext, + new phpbb_mock_cache() ); } From 8ec55b062dbaf40f5ad3aec49bf987a14b34dfe8 Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Mon, 11 Feb 2013 15:29:12 +0530 Subject: [PATCH 129/174] [ticket/11196] Changed 401 response message in session.php. In session.php 401 response message was "Not Authorized". I changed it to "Unauthorized". PHPBB3-11196 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 496c12a0d1..d980f50e05 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -325,7 +325,7 @@ class session // if no session id is set, redirect to index.php if (defined('NEED_SID') && (!isset($_GET['sid']) || $this->session_id !== $_GET['sid'])) { - send_status_line(401, 'Not authorized'); + send_status_line(401, 'Unauthorized'); redirect(append_sid("{$phpbb_root_path}index.$phpEx")); } From 193a3beb8f75e17b09a0e66d2815bc2bf8d4dce4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Wed, 13 Feb 2013 21:12:50 -0600 Subject: [PATCH 130/174] [feature/migrations] Fix failing tests (again) PHPBB3-11318 --- tests/extension/manager_test.php | 48 +++++++++---------- tests/extension/metadata_manager_test.php | 3 ++ .../phpbb_functional_test_case.php | 26 +++++----- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index e31e27ef83..9032afbd73 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -25,23 +25,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case { parent::setUp(); - $config = new phpbb_config(array()); - $db = $this->new_dbal(); - $db_tools = new phpbb_db_tools($db); - $phpbb_root_path = __DIR__ . './../../phpBB/'; - $php_ext = 'php'; - $table_prefix = 'phpbb_'; - - $this->extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $db, - $config, - new phpbb_db_migrator($config, $db, $db_tools, 'phpbb_migrations', $phpbb_root_path, $php_ext, $table_prefix, array()), - 'phpbb_ext', - dirname(__FILE__) . '/', - '.' . $php_ext, - new phpbb_mock_cache() - ); + $this->extension_manager = $this->create_extension_manager(); } public function test_available() @@ -98,16 +82,30 @@ class phpbb_extension_manager_test extends phpbb_database_test_case public function test_enabled_no_cache() { - $extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $this->new_dbal(), - new phpbb_config(array()), - 'phpbb_ext', - dirname(__FILE__) . '/', - '.php' - ); + $extension_manager = $this->create_extension_manager(false); $this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled())); } + protected function create_extension_manager($with_cache = true) + { + + $config = new phpbb_config(array()); + $db = $this->new_dbal(); + $db_tools = new phpbb_db_tools($db); + $phpbb_root_path = __DIR__ . './../../phpBB/'; + $php_ext = 'php'; + $table_prefix = 'phpbb_'; + + return new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $db, + $config, + new phpbb_db_migrator($config, $db, $db_tools, 'phpbb_migrations', $phpbb_root_path, $php_ext, $table_prefix, array()), + 'phpbb_ext', + dirname(__FILE__) . '/', + '.' . $php_ext, + ($with_cache) ? new phpbb_mock_cache() : null + ); + } } diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 7a04229a9c..cdea8d5258 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -34,9 +34,11 @@ class metadata_manager_test extends phpbb_database_test_case 'version' => '3.1.0', )); $this->db = $this->new_dbal(); + $this->db_tools = new phpbb_db_tools($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = '.php'; $this->user = new phpbb_user(); + $this->table_prefix = 'phpbb_'; $this->template = new phpbb_template( $this->phpbb_root_path, @@ -51,6 +53,7 @@ class metadata_manager_test extends phpbb_database_test_case new phpbb_mock_container_builder(), $this->db, $this->config, + new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', $this->phpbb_root_path, $this->php_ext, $this->table_prefix, array()), 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index cb0a475278..b570b464e6 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -134,20 +134,20 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - if (!$this->extension_manager) - { - $this->extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $this->get_db(), - new phpbb_config(array()), - self::$config['table_prefix'] . 'ext', - $phpbb_root_path, - ".$phpEx", - $this->get_cache_driver() - ); - } + $config = new phpbb_config(array()); + $db = $this->get_db(); + $db_tools = new phpbb_db_tools($db); - return $this->extension_manager; + return new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $db, + $config, + new phpbb_db_migrator($config, $db, $db_tools, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, $php_ext, self::$config['table_prefix'], array()), + self::$config['table_prefix'] . 'ext', + dirname(__FILE__) . '/', + '.' . $php_ext, + $this->get_cache_driver() + ); } static protected function install_board() From f6bb14569b0a777d3511b732201af9d1a415f2ed Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Fri, 15 Feb 2013 22:19:24 -0600 Subject: [PATCH 131/174] [feature/migrations] getLocalisedMessage function for migration exception PHPBB3-11351 --- phpBB/includes/db/migration/exception.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/includes/db/migration/exception.php index b3abcdb5e5..e84330dd71 100644 --- a/phpBB/includes/db/migration/exception.php +++ b/phpBB/includes/db/migration/exception.php @@ -62,4 +62,18 @@ class phpbb_db_migration_exception extends \Exception { return $this->parameters; } + + /** + * Get localised message (with $user->lang()) + * + * @param phpbb_user $user + * @return string + */ + public function getLocalisedMessage(phpbb_user $user) + { + $parameters = $this->getParameters(); + array_unshift($parameters, $this->getMessage()); + + return call_user_func_array(array($user, 'lang'), $parameters); + } } From 872773a21897ccad754a53d7c8ad7899bcc05796 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Fri, 15 Feb 2013 22:22:13 -0600 Subject: [PATCH 132/174] [feature/migrations] Use getLocalisedMessage() function to get error message PHPBB3-11318 --- phpBB/includes/acp/acp_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 17ab4f3169..24211196bd 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -114,7 +114,7 @@ class acp_extensions } catch (phpbb_db_migration_exception $e) { - $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); + $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user)); } $this->tpl_name = 'acp_ext_enable'; @@ -174,7 +174,7 @@ class acp_extensions } catch (phpbb_db_migration_exception $e) { - $template->assign_var('MIGRATOR_ERROR', $user->lang($e->getMessage(), $e->getParameters())); + $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user)); } $this->tpl_name = 'acp_ext_purge'; From 5b99f0c113390959f693222055715413addef34e Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Mon, 18 Feb 2013 14:01:46 +0530 Subject: [PATCH 133/174] [ticket/11359] close span PHPBB3-11359 --- phpBB/includes/search/fulltext_sphinx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 4bacf74f93..07bcbdadc1 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -878,7 +878,7 @@ class phpbb_search_fulltext_sphinx <dd><input id="fulltext_sphinx_indexer_mem_limit" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" /> ' . $this->user->lang['MIB'] . '</dd> </dl> <dl> - <dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</dt> + <dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</span></dt> <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd> <dl> '; From 3c6256b3e7489b9aca1e153b3e3bb754f3dd6a7d Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Mon, 18 Feb 2013 14:05:25 +0530 Subject: [PATCH 134/174] [ticket/11359] add id attribute to textarea PHPBB3-11359 --- phpBB/includes/search/fulltext_sphinx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 07bcbdadc1..6c66499d21 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -879,7 +879,7 @@ class phpbb_search_fulltext_sphinx </dl> <dl> <dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</span></dt> - <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd> + <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6" id="sphinx_config_data">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd> <dl> '; From 38360c71f298efee54396118b8afb5c642c79db3 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Mon, 18 Feb 2013 14:13:31 +0530 Subject: [PATCH 135/174] [ticket/11359] html escape sphinx config data PHPBB3-11359 --- phpBB/includes/search/fulltext_sphinx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 6c66499d21..7304e70ff8 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -879,7 +879,7 @@ class phpbb_search_fulltext_sphinx </dl> <dl> <dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</span></dt> - <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6" id="sphinx_config_data">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd> + <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6" id="sphinx_config_data">' . htmlspecialchars($this->config_file_data) . '</textarea>' : $this->config_file_data) . '</dd> <dl> '; From 737b99966de8e12ffa13d762b7065043a39399d7 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 03:39:51 +0530 Subject: [PATCH 136/174] [ticket/11179] add search query in case initial one fails changes the start parameter according to the total search results and executes the search query again to get the results. PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 34 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 324c214e91..acb1a7bde8 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -381,7 +381,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { return $result_count; } - $id_ary = array(); $join_topic = ($type == 'posts') ? false : true; @@ -490,7 +489,38 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if (!sizeof($id_ary)) { - return false; + $sql_count = "SELECT COUNT(*) as result_count + FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p + WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) + $sql_where_options + ORDER BY $sql_sort"; + $result = $this->db->sql_query($sql_count); + $total_match_count = (int) $this->db->sql_fetchfield('result_count'); + + if ($total_match_count) + { + if ($start < 0) + { + $start = 0; + } + else if ($start >= $total_match_count) + { + $start = floor(($total_match_count - 1) / $per_page) * $per_page; + } + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + } + + if (!sizeof($id_ary)) + { + return false; + } } // if the total result count is not cached yet, retrieve it from the db From 00d34617ccb6a53185f0e872a735b4dd2f65009b Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 13:36:14 +0100 Subject: [PATCH 137/174] [ticket/11179] correct the start parameter while retrieving from cache Start parameter if not between 0 and the total result count of the cached search results is changed accordingly PHPBB3-11179 --- phpBB/includes/search/base.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index b364dead9a..11e5535979 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -97,7 +97,6 @@ class phpbb_search_base function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) { global $cache; - if (!($stored_ids = $cache->get('_search_results_' . $search_key))) { // no search results cached for this search_key @@ -109,6 +108,19 @@ class phpbb_search_base $reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false; $complete = true; + // change start parameter in case out of bounds + if ($result_count) + { + if ($start < 0) + { + $start = 0; + } + else if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + } + // change the start to the actual end of the current request if the sort direction differs // from the dirction in the cache and reverse the ids later if ($reverse_ids) From 3e5ef8ab2cc1d8c6e0850e36ddb546489cc5ab12 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 13:39:40 +0100 Subject: [PATCH 138/174] [ticket/11179] pass start parameter by reference start parameter is passed by reference so that in case it is not in bounds the changes made to it are reflected back to the phpBB/search.php file PHPBB3-11179 --- phpBB/includes/search/base.php | 2 +- phpBB/includes/search/fulltext_mysql.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index 11e5535979..2047742367 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -94,7 +94,7 @@ class phpbb_search_base * * @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE */ - function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) + function obtain_ids($search_key, &$result_count, &$id_ary, &$start, $per_page, $sort_dir) { global $cache; if (!($stored_ids = $cache->get('_search_results_' . $search_key))) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index acb1a7bde8..749353b2ee 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -353,7 +353,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts if (!$this->search_query) From 1c9c666ef193942a2d88ec59741ddc49900e92e9 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 14:17:38 +0100 Subject: [PATCH 139/174] [ticket/11179] use FOUND_ROWS query to re-search with changed start param PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 60 +++++++++--------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 749353b2ee..3ecc2cd39d 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -375,6 +375,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base implode(',', $author_ary) ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -487,47 +492,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $id_ary = array_unique($id_ary); - if (!sizeof($id_ary)) - { - $sql_count = "SELECT COUNT(*) as result_count - FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p - WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) - $sql_where_options - ORDER BY $sql_sort"; - $result = $this->db->sql_query($sql_count); - $total_match_count = (int) $this->db->sql_fetchfield('result_count'); - - if ($total_match_count) - { - if ($start < 0) - { - $start = 0; - } - else if ($start >= $total_match_count) - { - $start = floor(($total_match_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - if (!sizeof($id_ary)) - { - return false; - } - } - // if the total result count is not cached yet, retrieve it from the db if (!$result_count) { - $sql = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql); + $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; + $result = $this->db->sql_query($sql_found_rows); $result_count = (int) $this->db->sql_fetchfield('result_count'); $this->db->sql_freeresult($result); @@ -537,6 +506,21 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base } } + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); From 2601411a9cfb79de1c45523005e91f00a8583ad1 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 14:28:29 +0100 Subject: [PATCH 140/174] [ticket/11179] correct start parameter for author search PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 3ecc2cd39d..54e2007da3 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -571,6 +571,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $author_name, ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -676,8 +681,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base // retrieve the total result count if needed if (!$result_count) { - $sql = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql); + $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; + $result = $this->db->sql_query($sql_found_rows); $result_count = (int) $this->db->sql_fetchfield('result_count'); $this->db->sql_freeresult($result); @@ -687,6 +692,20 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base } } + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + if (sizeof($id_ary)) { $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); From 80f8e3abceabab658a5a935e5a6079e73f663698 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 14:29:39 +0100 Subject: [PATCH 141/174] [ticket/11179] pass start param by reference in author search PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 54e2007da3..69f76ba99e 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -547,7 +547,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) @@ -578,7 +578,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base // try reading the results from cache $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) + if ($this->obtain_ids($search_key, $result_count, $id_ary, &$start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) { return $result_count; } From 2cb48f034153038d71d89ab58904cd048b8524d9 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 15:35:05 +0100 Subject: [PATCH 142/174] [ticket/11179] correct start parameter in psql keyword search PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index 1475cc31d0..d968a934f4 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -371,6 +371,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base implode(',', $author_ary) ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -495,11 +500,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $id_ary = array_unique($id_ary); - if (!sizeof($id_ary)) - { - return false; - } - // if the total result count is not cached yet, retrieve it from the db if (!$result_count) { @@ -518,6 +518,21 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $this->db->sql_transaction('commit'); + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); From ef88edbcf69541bd79e220c87c444b33a6751c67 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 15:44:16 +0100 Subject: [PATCH 143/174] [ticket/11179] correct start param in author search of postgres PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index d968a934f4..e8a5353b05 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -583,6 +583,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $author_name, ))); + if ($start < 0) + { + $start = 0; + } + // try reading the results from cache $result_count = 0; if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) @@ -725,6 +730,20 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base $this->db->sql_transaction('commit'); + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + } + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); + if (sizeof($id_ary)) { $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); From bc77ca4d4eb6a5bcf3e47706c6b6fd2b0fe33f82 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sat, 10 Nov 2012 15:45:15 +0100 Subject: [PATCH 144/174] [ticket/11179] pass start param by reference in postgres PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index e8a5353b05..bdc2fa4f19 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -343,7 +343,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts if (!$this->search_query) @@ -559,7 +559,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) From 16bbdf4a52b2cb2fa4aa2cd607ae726ea1c7af67 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sun, 11 Nov 2012 10:11:58 +0100 Subject: [PATCH 145/174] [ticket/11179] minor fixes Amends comments to start with capitals. Reinsert blank lines which were not supposed to be removed PHPBB3-11179 --- phpBB/includes/search/base.php | 3 ++- phpBB/includes/search/fulltext_mysql.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index 2047742367..914cef9167 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -97,6 +97,7 @@ class phpbb_search_base function obtain_ids($search_key, &$result_count, &$id_ary, &$start, $per_page, $sort_dir) { global $cache; + if (!($stored_ids = $cache->get('_search_results_' . $search_key))) { // no search results cached for this search_key @@ -108,7 +109,7 @@ class phpbb_search_base $reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false; $complete = true; - // change start parameter in case out of bounds + // Change start parameter in case out of bounds if ($result_count) { if ($start < 0) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 69f76ba99e..ad5119f67c 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -386,6 +386,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { return $result_count; } + $id_ary = array(); $join_topic = ($type == 'posts') ? false : true; From f0d63594e68fa7a165b8ba90d0fcf35f38e42de9 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sun, 2 Dec 2012 14:15:04 +0530 Subject: [PATCH 146/174] [ticket/11179] fix success query path for mysql Additional query to check start parameter executed only incase of no results. PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index ad5119f67c..4dc62753aa 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -510,18 +510,18 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); @@ -696,16 +696,16 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); - $id_ary = array_unique($id_ary); + $id_ary = array_unique($id_ary); + } if (sizeof($id_ary)) { From 8b7f306897cddcb16cbed50488848ee357c26f39 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Sun, 2 Dec 2012 14:31:12 +0530 Subject: [PATCH 147/174] [ticket/11179] fix success query path for postgres Additional query to check start parameter executed only incase of no results. PHPBB3-11179 --- phpBB/includes/search/fulltext_postgres.php | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index bdc2fa4f19..eeb628b18f 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -521,18 +521,18 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = $row[$field]; + } + $this->db->sql_freeresult($result); + + $id_ary = array_unique($id_ary); } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); @@ -733,16 +733,16 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base if ($start >= $result_count) { $start = floor(($result_count - 1) / $per_page) * $per_page; - } - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); - $id_ary = array_unique($id_ary); + $id_ary = array_unique($id_ary); + } if (sizeof($id_ary)) { From a0ae223ef46e30c9413350ed7c4e52eaab5bb159 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Fri, 21 Dec 2012 19:10:48 +0530 Subject: [PATCH 148/174] [ticket/11179] correct start parameter in native keyword search PHPBB3-11179 --- phpBB/includes/search/fulltext_native.php | 28 +++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 53df8348ae..fccdcd855e 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -516,7 +516,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts. if (empty($this->search_query)) @@ -855,10 +855,6 @@ class phpbb_search_fulltext_native extends phpbb_search_base } $this->db->sql_freeresult($result); - if (!sizeof($id_ary)) - { - return false; - } // if we use mysql and the total result count is not cached yet, retrieve it from the db if (!$total_results && $is_mysql) @@ -867,14 +863,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base $sql_array_copy = $sql_array; $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id '; - $sql = $this->db->sql_build_query('SELECT', $sql_array_copy); + $sql_calc = $this->db->sql_build_query('SELECT', $sql_array_copy); unset($sql_array_copy); - $this->db->sql_query($sql); + $this->db->sql_query($sql_calc); $this->db->sql_freeresult($result); - $sql = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql); + $sql_count = 'SELECT FOUND_ROWS() as total_results'; + $result = $this->db->sql_query($sql_count); $total_results = (int) $this->db->sql_fetchfield('total_results'); $this->db->sql_freeresult($result); @@ -884,6 +880,20 @@ class phpbb_search_fulltext_native extends phpbb_search_base } } + if ($start >= $total_results) + { + $start = floor(($total_results - 1) / $per_page) * $per_page; + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; + } + $this->db->sql_freeresult($result); + + } + // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page $this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir); $id_ary = array_slice($id_ary, 0, (int) $per_page); From 2ff874fe930d458382212cfe5495080231ec76e6 Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Fri, 21 Dec 2012 19:11:20 +0530 Subject: [PATCH 149/174] [ticket/11179] correct start parameter in native author search PHPBB3-11179 --- phpBB/includes/search/fulltext_native.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index fccdcd855e..c9f33054fc 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -920,7 +920,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) @@ -1106,13 +1106,13 @@ class phpbb_search_fulltext_native extends phpbb_search_base if (!$total_results && $is_mysql) { // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. - $sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); + $sql_calc = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); - $this->db->sql_query($sql); + $this->db->sql_query($sql_calc); $this->db->sql_freeresult($result); - $sql = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql); + $sql_count = 'SELECT FOUND_ROWS() as total_results'; + $result = $this->db->sql_query($sql_count); $total_results = (int) $this->db->sql_fetchfield('total_results'); $this->db->sql_freeresult($result); @@ -1122,6 +1122,19 @@ class phpbb_search_fulltext_native extends phpbb_search_base } } + if ($start >= $total_results) + { + $start = floor(($total_results - 1) / $per_page) * $per_page; + + $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); + + while ($row = $this->db->sql_fetchrow($result)) + { + $id_ary[] = (int) $row[$field]; + } + $this->db->sql_freeresult($result); + } + if (sizeof($id_ary)) { $this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir); From 38bb7dca31740f9d4f188b75167f736ee6666c2f Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Fri, 21 Dec 2012 21:54:41 +0530 Subject: [PATCH 150/174] [ticket/11179] correct start parameter in sphinx search PHPBB3-11179 --- phpBB/includes/search/fulltext_sphinx.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 7304e70ff8..48445d0794 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -454,7 +454,7 @@ class phpbb_search_fulltext_sphinx * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts. if (!strlen($this->search_query) && !sizeof($author_ary)) @@ -609,6 +609,25 @@ class phpbb_search_fulltext_sphinx } } + $result_count = $result['total_found']; + + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + + $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES); + $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes); + + // Could be connection to localhost:9312 failed (errno=111, + // msg=Connection refused) during rotate, retry if so + $retries = SPHINX_CONNECT_RETRIES; + while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) + { + usleep(SPHINX_CONNECT_WAIT_TIME); + $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes); + } + } + $id_ary = array(); if (isset($result['matches'])) { @@ -629,8 +648,6 @@ class phpbb_search_fulltext_sphinx return false; } - $result_count = $result['total_found']; - $id_ary = array_slice($id_ary, 0, (int) $per_page); return $result_count; From 1ee4702ec51ecfc7d40c8768ba7927439c73002c Mon Sep 17 00:00:00 2001 From: Dhruv <dhruv.goel92@gmail.com> Date: Fri, 25 Jan 2013 18:15:55 +0530 Subject: [PATCH 151/174] [ticket/11179] remove extra & in function call PHPBB3-11179 --- phpBB/includes/search/fulltext_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 4dc62753aa..adaf025730 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -579,7 +579,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base // try reading the results from cache $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, &$start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) + if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) { return $result_count; } From 37093b6aa522dd15d05659eaf6c541e25e163289 Mon Sep 17 00:00:00 2001 From: Marc Alexander <admin@m-a-styles.de> Date: Tue, 19 Feb 2013 13:04:06 +0100 Subject: [PATCH 152/174] [ticket/11342] Fix "unexpected token" syntax error PHPBB-11342 --- phpBB/styles/prosilver/template/ajax.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index b2a27089f7..0b587ac561 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -54,7 +54,7 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) { * @param update_topic_links bool Wether "Mark topics read" links should be * updated. Defaults to true. */ -phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links = true) { +phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) { var readTitle = res.NO_UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS; var iconsArray = { @@ -68,6 +68,10 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links = tru var classMap = {}; var classNames = []; + if (typeof update_topic_links === 'undefined') { + update_topic_links = true; + } + $.each(iconsArray, function(unreadClass, readClass) { $.each(iconsState, function(key, value) { // Only topics can be hot From ae3a22bd0c06bd6098c229963402d660572a0598 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sat, 23 Feb 2013 11:06:48 +0100 Subject: [PATCH 153/174] [ticket/11361] Make sure that array passed to strtr() has the proper format. The array $date_cache[$format]['lang'] passed to strtr() contains a sub-array which results in an E_NOTICE being thrown for 'Array to string conversion' on PHP 5.4. Ensure that the array passed to strtr() is one-dimensional by filtering out non-string values. PHPBB3-11361 --- phpBB/includes/session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index d980f50e05..b93f2ff65e 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2156,7 +2156,8 @@ class user extends session 'is_short' => strpos($format, '|'), 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1), 'format_long' => str_replace('|', '', $format), - 'lang' => $this->lang['datetime'], + // Filter out values that are not strings (e.g. arrays) for strtr(). + 'lang' => array_filter($this->lang['datetime'], 'is_string'), ); // Short representation of month in format? Some languages use different terms for the long and short format of May From b7a222cdd593edb3e61183d9e28707ac9005aa82 Mon Sep 17 00:00:00 2001 From: David King <imkingdavid@gmail.com> Date: Sat, 23 Feb 2013 14:20:56 -0500 Subject: [PATCH 154/174] [ticket/11298] Fix typo in language key; EXTENSIONS -> EXTENSION PHPBB3-11298 --- phpBB/includes/acp/info/acp_extensions.php | 4 ++-- phpBB/install/install_install.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/info/acp_extensions.php b/phpBB/includes/acp/info/acp_extensions.php index 03d7059165..174b365af0 100644 --- a/phpBB/includes/acp/info/acp_extensions.php +++ b/phpBB/includes/acp/info/acp_extensions.php @@ -16,10 +16,10 @@ class acp_extensions_info { return array( 'filename' => 'acp_extensions', - 'title' => 'ACP_EXTENSIONS_MANAGEMENT', + 'title' => 'ACP_EXTENSION_MANAGEMENT', 'version' => '1.0.0', 'modes' => array( - 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSIONS_MANAGEMENT')), + 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSION_MANAGEMENT')), ), ); } diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index dd90335480..16a527b252 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -2098,7 +2098,7 @@ class install_install extends module ), 'ACP_CAT_CUSTOMISE' => array( 'ACP_STYLE_MANAGEMENT', - 'ACP_EXTENSIONS_MANAGEMENT', + 'ACP_EXTENSION_MANAGEMENT', 'ACP_LANGUAGE', ), 'ACP_CAT_MAINTENANCE' => array( From c31935abda37b1d8f4f7ebbce33012a95e7b4b69 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 23 Feb 2013 15:08:28 -0600 Subject: [PATCH 155/174] [feature/migrations] Revert unrelated change to schema_data.sql PHBB3-9737 --- phpBB/install/schemas/schema_data.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 4e4d70ced3..7c1a7d40f5 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -611,6 +611,7 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # NEW MEMBERS on the queue INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); + # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); From 4bf64b5e38efd194b6ab41fcc5d62ee0cc6fad5a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 23 Feb 2013 15:10:21 -0600 Subject: [PATCH 156/174] [feature/migrations] Fully revert the removal of the user_msnm field PHBB3-9737 --- phpBB/includes/db/migration/data/310/dev.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index 34f081bf62..13b36bbf30 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -21,7 +21,6 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration 'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_timezone_p2', 'phpbb_db_migration_data_310_reported_posts_display', - 'phpbb_db_migration_data_310_remove_msnm', ); } From f6a894f07700627b675c2b16aab4714df5819a23 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Sat, 23 Feb 2013 16:12:24 -0600 Subject: [PATCH 157/174] [feature/migrations] Use the user class for language handling Also localise error messages from the migrator PHBB3-9737 --- phpBB/install/database_update.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 459839f393..4938ef0f87 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -133,9 +133,7 @@ set_config(null, null, null, $config); set_config_count(null, null, null, $config); $orig_version = $config['version']; -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx); +$user->add_lang(array('common', 'acp/common', 'install', 'migrator')); // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) @@ -157,11 +155,11 @@ else header('Content-type: text/html; charset=UTF-8'); ?> <!DOCTYPE html> -<html dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>"> +<html dir="<?php echo $user->lang['DIRECTION']; ?>" lang="<?php echo $user->lang['USER_LANG']; ?>"> <head> <meta charset="utf-8"> -<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title> +<title><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></title> <link href="<?php echo htmlspecialchars($phpbb_admin_path); ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" /> @@ -178,12 +176,12 @@ header('Content-type: text/html; charset=UTF-8'); <div id="content"> <div id="main" class="install-body"> - <h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1> + <h1><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></h1> <br /> - <p><?php echo $lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br /> - <?php echo $lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br /> + <p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br /> + <?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br /> <?php @@ -225,7 +223,7 @@ while (!$migrator->finished()) } catch (phpbb_db_migration_exception $e) { - echo $e; + echo $e->getLocalisedMessage($user); phpbb_end_update($cache); } @@ -236,8 +234,8 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; - echo $lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />'; - echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">' . $lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; + echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; phpbb_end_update($cache); } @@ -248,6 +246,6 @@ if ($orig_version != $config['version']) add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -echo $lang['DATABASE_UPDATE_COMPLETE']; +echo $user->lang['DATABASE_UPDATE_COMPLETE']; phpbb_end_update($cache); From c4f8c64a2334957757683aa2f65f51d25f359292 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sun, 24 Feb 2013 12:37:02 +0100 Subject: [PATCH 158/174] [ticket/11122] Add EXreaction to docs/AUTHORS. PHPBB3-11122 --- phpBB/docs/AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index c623bbb988..28d3548d0b 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -23,6 +23,7 @@ involved in phpBB. phpBB Lead Developer: naderman (Nils Adermann) phpBB Developers: bantu (Andreas Fischer) + EXreaction (Nathan Guse) igorw (Igor Wiedler) imkingdavid (David King) nickvergessen (Joas Schilling) From c69b1c2ef24faa74a6b44ccdc19495419bc15131 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sun, 24 Feb 2013 12:43:31 +0100 Subject: [PATCH 159/174] [ticket/11122] Move rxu to 'Former Contributors' section. PHPBB3-11122 --- phpBB/docs/AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index 28d3548d0b..fcef26daa1 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -28,7 +28,6 @@ phpBB Developers: bantu (Andreas Fischer) imkingdavid (David King) nickvergessen (Joas Schilling) Oleg (Oleg Pudeyev) - rxu (Ruslan Uzdenov) Contributions by: leviatan21 (Gabriel Vazquez) Raimon (Raimon Meuldijk) @@ -54,6 +53,7 @@ phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010] dhn (Dominik Dröscher) [05/2007 - 01/2011] GrahamJE (Graham Eames) [09/2005 - 11/2006] kellanved (Henry Sudhof) [04/2007 - 03/2011] + rxu (Ruslan Uzdenov) [04/2010 - 12/2012] TerraFrost (Jim Wigginton) [04/2009 - 01/2011] ToonArmy (Chris Smith) [06/2008 - 11/2011] Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009] From e8b3e8498d9842296a905fdaad8c0c32e31bceb4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sun, 24 Feb 2013 12:54:05 +0100 Subject: [PATCH 160/174] [ticket/7262] Backport set_config() and set_config_count() docs from develop. PHPBB3-7262 --- phpBB/includes/functions.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 571c863839..04b69f8c69 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -137,7 +137,14 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) } /** -* Set config value. Creates missing config entry. +* Sets a configuration option's value. +* +* @param string $config_name The configuration option's name +* @param string $config_value New configuration value +* @param bool $is_dynamic Whether this variable should be cached or if it +* changes too frequently to be efficiently cached. +* +* @return null */ function set_config($config_name, $config_value, $is_dynamic = false) { @@ -166,7 +173,14 @@ function set_config($config_name, $config_value, $is_dynamic = false) } /** -* Set dynamic config value with arithmetic operation. +* Increments an integer config value directly in the database. +* +* @param string $config_name The configuration option's name +* @param int $increment Amount to increment by +* @param bool $is_dynamic Whether this variable should be cached or if it +* changes too frequently to be efficiently cached. +* +* @return null */ function set_config_count($config_name, $increment, $is_dynamic = false) { From a9037a68c177d396b2ed4b9bfcaad64536a01aaa Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sun, 24 Feb 2013 13:03:48 +0100 Subject: [PATCH 161/174] [ticket/7262] Add $is_dynamic example to set_config() and set_config_count(). The logic is the other way around here in comparison to develop's phpbb_config_db class, so add examples to make things more clear. PHPBB3-7262 --- phpBB/includes/functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 04b69f8c69..2ca7d7f898 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -141,8 +141,9 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) * * @param string $config_name The configuration option's name * @param string $config_value New configuration value -* @param bool $is_dynamic Whether this variable should be cached or if it -* changes too frequently to be efficiently cached. +* @param bool $is_dynamic Whether this variable should be cached (false) or +* if it changes too frequently (true) to be +* efficiently cached. * * @return null */ @@ -177,8 +178,9 @@ function set_config($config_name, $config_value, $is_dynamic = false) * * @param string $config_name The configuration option's name * @param int $increment Amount to increment by -* @param bool $is_dynamic Whether this variable should be cached or if it -* changes too frequently to be efficiently cached. +* @param bool $is_dynamic Whether this variable should be cached (false) or +* if it changes too frequently (true) to be +* efficiently cached. * * @return null */ From 6bf64d5620b1b9f165a65b50042c391a29ef151c Mon Sep 17 00:00:00 2001 From: Andreas Fischer <bantu@phpbb.com> Date: Sun, 24 Feb 2013 13:37:52 +0100 Subject: [PATCH 162/174] [ticket/7262] Add note about set_config() not updating is_dynamic. PHPBB3-7262 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2ca7d7f898..ccd2d3147c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -139,6 +139,9 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) /** * Sets a configuration option's value. * +* Please note that this function does not update the is_dynamic value for +* an already existing config option. +* * @param string $config_name The configuration option's name * @param string $config_value New configuration value * @param bool $is_dynamic Whether this variable should be cached (false) or From d2a15d9afe06509ff3e9fe5b6463800f66813783 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Sun, 24 Feb 2013 17:42:53 +0100 Subject: [PATCH 163/174] [ticket/10896] Add missing email validation lost in develop merge Fix incomplete merge, by adding a piece of code moved to another file in olympus back. PHPBB3-10896 --- phpBB/includes/functions_acp.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 32fd76e74d..d6bd9e35dd 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -443,6 +443,13 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) } break; + case 'email': + if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) + { + $error[] = $user->lang['EMAIL_INVALID_EMAIL']; + } + break; + // Absolute path case 'script_path': if (!$cfg_array[$config_name]) From f8e184c54e85dc55a803b76a6ccefb769ef38e17 Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Mon, 18 Feb 2013 11:04:14 +0530 Subject: [PATCH 164/174] [ticket/11355] Wrong error message when no user is selected. In ACP group membership management, if you select 'remove member from group' without selecting any users and submit,it will display a wrong error after confirmbox. Since no users are selected, this should not go even until confirmbox. Added a new condition to check weather any users are selected when the action is 'deleteusers' in acp_groups.php and disply a correct error. PHPBB3-11355 --- phpBB/includes/acp/acp_groups.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 486616c33d..ec44f4fc0c 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -179,6 +179,10 @@ class acp_groups break; case 'deleteusers': + if (!$name_ary) + { + trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); + } case 'delete': if (!$group_id) { @@ -795,4 +799,4 @@ class acp_groups } } -?> \ No newline at end of file +?> From ab530a999ed64a2e1fcc10252bdae6d9139d7538 Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Thu, 21 Feb 2013 22:47:42 +0530 Subject: [PATCH 165/174] [ticket/11355] Referred proper variable when validating selection. Earlier PR was referring wrong variable $name_ary. Changed it to $mark_ary which actually contains selected user ids. PHPBB3-11355 --- phpBB/includes/acp/acp_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index ec44f4fc0c..bbe85f8038 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -179,7 +179,7 @@ class acp_groups break; case 'deleteusers': - if (!$name_ary) + if (empty($mark_ary)) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } From 373c9a3f4ea92f1bcbe63404a2b3bf356fe5abcb Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Mon, 18 Feb 2013 11:17:27 +0530 Subject: [PATCH 166/174] [ticket/11358] Success message even without selecting a user. In group membership management, if you perform the action 'Make group default for member' without selecting any user, a confirm box will be displayed and will show a success message after confirming. Added a new condition to fix this issue in acp_groups.php. It will check weather any users are selected before performing above action. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index bbe85f8038..dbe692aee0 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,6 +120,10 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } + else if (!$name_ary) + { + trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); + } if (confirm_box(true)) { From 880786d68610aff0c30573dc599af9e5b3ad56cf Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Thu, 21 Feb 2013 22:25:12 +0530 Subject: [PATCH 167/174] [ticket/11358] Removed redundant code and referred proper variable. Error was thrown when no users are selected before executing the code chunk which manually adds all the user to make the group default. Removed this code and referred $mark_ary instead of $name_ary which will not have selected user ids. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 42 ++----------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index dbe692aee0..af25d9d014 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,7 +120,7 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } - else if (!$name_ary) + else if (empty($mark_ary)) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } @@ -128,45 +128,7 @@ class acp_groups if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - - if (!sizeof($mark_ary)) - { - $start = 0; - - do - { - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - ORDER BY user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - $mark_ary = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $mark_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); - - $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - } - else - { - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); - } - + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } else From 538b09ba6115a1f90821a18d045f2056e66b5178 Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Fri, 22 Feb 2013 00:31:55 +0530 Subject: [PATCH 168/174] [ticket/11358] Enabled link making all users default for a group. Detect whether link is clicked or form is posted for making users default for a group. If form is posted and no users are selected, validation happens and displays an error message. When the link is clicked, all the users will be default users for that group. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 42 +++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index af25d9d014..c70327c6f1 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,7 +120,7 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } - else if (empty($mark_ary)) + else if (empty($mark_ary) && $request->is_set_post('default')) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } @@ -128,7 +128,45 @@ class acp_groups if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + + if (!sizeof($mark_ary)) + { + $start = 0; + + do + { + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + ORDER BY user_id"; + $result = $db->sql_query_limit($sql, 200, $start); + + $mark_ary = array(); + if ($row = $db->sql_fetchrow($result)) + { + do + { + $mark_ary[] = $row['user_id']; + } + while ($row = $db->sql_fetchrow($result)); + + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + + $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + } + else + { + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + } + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } else From c0a39537e38c350365c0baa74be31c000b1e9381 Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Fri, 22 Feb 2013 09:53:49 +0530 Subject: [PATCH 169/174] [ticket/11358] Changed the action parameter value to represent the link. Changed the action parameter value to recognize whether 'Make default group for every member' is clicked. If so execute a seperate code block under switch statement for $action and add all the users as default for the group. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 50 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index c70327c6f1..33d5c16ed0 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -120,7 +120,7 @@ class acp_groups { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } - else if (empty($mark_ary) && $request->is_set_post('default')) + else if (empty($mark_ary)) { trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); } @@ -128,9 +128,26 @@ class acp_groups if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - - if (!sizeof($mark_ary)) + group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'mark' => $mark_ary, + 'g' => $group_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action)) + ); + } + + break; + case 'defaultbylink': + if (confirm_box(true)) { + $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; + $start = 0; do @@ -161,27 +178,20 @@ class acp_groups $db->sql_freeresult($result); } while ($start); + + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } else { - group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'mark' => $mark_ary, + 'g' => $group_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action)) + ); } - - trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mark' => $mark_ary, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - break; - case 'deleteusers': if (empty($mark_ary)) { @@ -691,7 +701,7 @@ class acp_groups 'U_ACTION' => $this->u_action . "&g=$group_id", 'U_BACK' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=list&field=usernames'), - 'U_DEFAULT_ALL' => "{$this->u_action}&action=default&g=$group_id", + 'U_DEFAULT_ALL' => "{$this->u_action}&action=defaultbylink&g=$group_id", )); // Grab the members From 1b39d6d65e2af632e6ad2ccba7fa2e61ab36c30c Mon Sep 17 00:00:00 2001 From: erangamapa <erangamapa@gmail.com> Date: Sun, 24 Feb 2013 21:34:29 +0530 Subject: [PATCH 170/174] [ticket/11358] Changed the name of post parameter. Replaced the parameter name 'defaultbylink' to a meaningful name 'set_default_on_all'. Parameter is used for making all users default for selected group in acp_groups.php. PHPBB3-11358 --- phpBB/includes/acp/acp_groups.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 33d5c16ed0..00ca26dfa6 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -143,7 +143,7 @@ class acp_groups } break; - case 'defaultbylink': + case 'set_default_on_all': if (confirm_box(true)) { $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; @@ -701,7 +701,7 @@ class acp_groups 'U_ACTION' => $this->u_action . "&g=$group_id", 'U_BACK' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=list&field=usernames'), - 'U_DEFAULT_ALL' => "{$this->u_action}&action=defaultbylink&g=$group_id", + 'U_DEFAULT_ALL' => "{$this->u_action}&action=set_default_on_all&g=$group_id", )); // Grab the members From 4615698807e17c55d5ab93e872f7efefb1e6acd7 Mon Sep 17 00:00:00 2001 From: Nils Adermann <naderman@naderman.de> Date: Sun, 24 Feb 2013 19:07:24 +0100 Subject: [PATCH 171/174] [ticket/10986] message.id fallback to SERVER_NAME or phpbb.generated Rather than send invalid message ids with a missing domain part we try to read one from $_SERVER and otherwise use phpbb.generated PHPBB3-10986 --- phpBB/includes/functions_messenger.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index e837811c86..db2dea33e8 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -389,6 +389,28 @@ class messenger } } + /** + * Generates a valid message id to be used in emails + * + * @return string message id + */ + function generate_message_id() + { + global $config; + + $domain = 'phpbb.generated'; + if ($config['server_name']) + { + $domain = $config['server_name']; + } + else if (!empty($_SERVER['SERVER_NAME'])) + { + $domain = $_SERVER['SERVER_NAME']; + } + + return md5(unique_id(time())) . '@' . $domain; + } + /** * Return email header */ @@ -415,7 +437,7 @@ class messenger $headers[] = 'Return-Path: <' . $config['board_email'] . '>'; $headers[] = 'Sender: <' . $config['board_email'] . '>'; $headers[] = 'MIME-Version: 1.0'; - $headers[] = 'Message-ID: <' . md5(unique_id(time())) . '@' . $config['server_name'] . '>'; + $headers[] = 'Message-ID: <' . $this->generate_message_id() . '>'; $headers[] = 'Date: ' . date('r', time()); $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit From 7a8ae493009eac3d4f5c97279f0be6e10c588002 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Mon, 25 Feb 2013 13:12:32 -0600 Subject: [PATCH 172/174] [feature/migrations] Inject migrator rather than the container. Some docblocks PHBB3-9737 --- phpBB/install/install_install.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index e0eb9e4472..a99de9bec9 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -114,7 +114,7 @@ class install_install extends module $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); $this->disable_avatars_if_unwritable(); - $this->populate_migrations($phpbb_container, $phpbb_root_path); + $this->populate_migrations($phpbb_container->get('migrator'), $phpbb_root_path); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); @@ -1881,9 +1881,18 @@ class install_install extends module } } - function populate_migrations($container, $phpbb_root_path) + /** + * Populate migrations for the installation + * + * This "installs" all migrations from (root path)/includes/db/migrations/data. + * "installs" means it adds all migrations to the migrations table, but does not + * perform any of the actions in the migrations. + * + * @param phpbb_db_migrator $migrator + * @param string $phpbb_root_path + */ + function populate_migrations($migrator, $phpbb_root_path) { - $migrator = $container->get('migrator'); $migrator->populate_migrations_from_directory($phpbb_root_path . 'includes/db/migration/data/'); } From 6045aa7aa2fb63358e3f736504b17533b1085712 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse <nathaniel.guse@gmail.com> Date: Mon, 25 Feb 2013 19:16:29 -0600 Subject: [PATCH 173/174] [ticket/11367] Migrator throws error if migrations table does not exist Force load_migration_state to not throw errors if the table does not exist. PHPBB3-11367 --- phpBB/includes/db/migrator.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 41d996b1e3..ea5de3372f 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -99,18 +99,26 @@ class phpbb_db_migrator { $this->migration_state = array(); + // prevent errors in case the table does not exist yet + $this->db->sql_return_on_error(true); + $sql = "SELECT * FROM " . $this->migrations_table; $result = $this->db->sql_query($sql); - while ($migration = $this->db->sql_fetchrow($result)) + if (!$this->db->sql_error_triggered) { - $this->migration_state[$migration['migration_name']] = $migration; + while ($migration = $this->db->sql_fetchrow($result)) + { + $this->migration_state[$migration['migration_name']] = $migration; - $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + } + + $this->db->sql_freeresult($result); } - $this->db->sql_freeresult($result); + $this->db->sql_return_on_error(false); } /** From 9a319fefb2ffed58da1d3339d59e53de09521e03 Mon Sep 17 00:00:00 2001 From: Nathan Guse <nathaniel.guse@gmail.com> Date: Tue, 26 Feb 2013 10:22:13 -0600 Subject: [PATCH 174/174] [ticket/11367] Always freeresult PHPBB3-11367 --- phpBB/includes/db/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index ea5de3372f..74f71775f3 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -114,10 +114,10 @@ class phpbb_db_migrator $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); } - - $this->db->sql_freeresult($result); } + $this->db->sql_freeresult($result); + $this->db->sql_return_on_error(false); }