From 9c4f0d51df4424f410534686f00bf629d98d53e0 Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Thu, 10 Jan 2013 10:59:20 +0100
Subject: [ticket/11314] Cleanup core.js coding
function errorHandler() was used in returnHandler() before it was defined.
The unused variable alert has been removed from errorHandler(). Overuse of
the var keyword for the variable sign has been removed and the if
statement has been simplified. The definition of the variable i has been
moved outside of the for loop definition. The var keyword shouldn't be
used inside the definition of the for loop.
PHPBB3-11314
---
phpBB/assets/javascript/core.js | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 16ed04746d..9323f4a447 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -252,6 +252,11 @@ phpbb.ajaxify = function(options) {
return;
}
+ function errorHandler() {
+ phpbb.clearLoadingTimeout();
+ phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text'));
+ }
+
/**
* This is a private function used to handle the callbacks, refreshes
* and alert. It calls the callback, refreshes the page if necessary, and
@@ -320,13 +325,6 @@ phpbb.ajaxify = function(options) {
}
}
- function errorHandler() {
- var alert;
-
- phpbb.clearLoadingTimeout();
- alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text'));
- }
-
// If the element is a form, POST must be used and some extra data must
// be taken from the form.
var runFilter = (typeof options.filter === 'function');
@@ -440,12 +438,11 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
// The offset returned here is in minutes and negated.
// http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp
var offset = (new Date()).getTimezoneOffset();
+ var sign = '-';
if (offset < 0) {
- var sign = '+';
+ sign = '+';
offset = -offset;
- } else {
- var sign = '-';
}
var minutes = offset % 60;
@@ -466,8 +463,9 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
var prefix = 'GMT' + sign + hours + ':' + minutes;
var prefixLength = prefix.length;
var selectorOptions = $('#tz_date > option');
+ var i;
- for (var i = 0; i < selectorOptions.length; ++i) {
+ for (i = 0; i < selectorOptions.length; ++i) {
var option = selectorOptions[i];
if (option.value.substring(0, prefixLength) == prefix) {
--
cgit v1.2.1
From 0fc863c68a6832fe6589b14b2ca9107f7b570621 Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Thu, 10 Jan 2013 11:06:05 +0100
Subject: [ticket/11314] Add missing semi-colons
Omitting the semi-colon is not legal behavior for JavaScript.
PHPBB3-11314
---
phpBB/adm/style/ajax.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js
index 294a35b615..8f7c210e00 100644
--- a/phpBB/adm/style/ajax.js
+++ b/phpBB/adm/style/ajax.js
@@ -115,9 +115,9 @@ phpbb.addAjaxCallback('activate_deactivate', function(res) {
el.text(res.text);
if (newHref.indexOf('deactivate') !== -1) {
- newHref = newHref.replace('deactivate', 'activate')
+ newHref = newHref.replace('deactivate', 'activate');
} else {
- newHref = newHref.replace('activate', 'deactivate')
+ newHref = newHref.replace('activate', 'deactivate');
}
el.attr('href', newHref);
--
cgit v1.2.1
From f7af4eb2e98a70cce267d01828437e205527e47f Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Thu, 10 Jan 2013 11:11:30 +0100
Subject: [ticket/11314] Use return variable instead of overusing the return
keyword
Use a return variable and modify it to our needs.
PHPBB3-11314
---
phpBB/styles/prosilver/template/ajax.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index 8583fb565c..771981b3e3 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -173,18 +173,19 @@ phpbb.ajaxify({
refresh: true,
filter: function (data) {
var action = $('#quick-mod-select').val();
+ var ret = false;
if (action === 'make_normal') {
- return $(this).find('select option[value="make_global"]').length > 0;
+ ret = $(this).find('select option[value="make_global"]').length > 0;
} else if (action === 'lock' || action === 'unlock') {
- return true;
+ ret = true;
}
if (action === 'delete_topic' || action === 'make_sticky' || action === 'make_announce' || action === 'make_global') {
- return true;
+ ret = true;
}
- return false;
+ return ret;
}
});
--
cgit v1.2.1
From c31f489cce8fd5d60eb484928221bef0666f3c06 Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Thu, 10 Jan 2013 11:14:07 +0100
Subject: [ticket/11314] Add missing "use strict" to timezone.js files
PHPBB3-11314
---
phpBB/adm/style/timezone.js | 2 ++
phpBB/styles/prosilver/template/timezone.js | 2 ++
phpBB/styles/subsilver2/template/timezone.js | 2 ++
3 files changed, 6 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/adm/style/timezone.js b/phpBB/adm/style/timezone.js
index 419d37c34f..b5e27c907c 100644
--- a/phpBB/adm/style/timezone.js
+++ b/phpBB/adm/style/timezone.js
@@ -1,5 +1,7 @@
(function($) { // Avoid conflicts with other libraries
+"use strict";
+
$('#tz_date').change(function() {
phpbb.timezoneSwitchDate(false);
});
diff --git a/phpBB/styles/prosilver/template/timezone.js b/phpBB/styles/prosilver/template/timezone.js
index af8206d12d..b0e8a38366 100644
--- a/phpBB/styles/prosilver/template/timezone.js
+++ b/phpBB/styles/prosilver/template/timezone.js
@@ -1,5 +1,7 @@
(function($) { // Avoid conflicts with other libraries
+"use strict";
+
$('#tz_date').change(function() {
phpbb.timezoneSwitchDate(false);
});
diff --git a/phpBB/styles/subsilver2/template/timezone.js b/phpBB/styles/subsilver2/template/timezone.js
index af8206d12d..b0e8a38366 100644
--- a/phpBB/styles/subsilver2/template/timezone.js
+++ b/phpBB/styles/subsilver2/template/timezone.js
@@ -1,5 +1,7 @@
(function($) { // Avoid conflicts with other libraries
+"use strict";
+
$('#tz_date').change(function() {
phpbb.timezoneSwitchDate(false);
});
--
cgit v1.2.1
From 49edfa49ab9b475e02997f8a89050acc73bf30c8 Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Sat, 12 Jan 2013 19:08:34 +0100
Subject: [ticket/11314] Fix whitespace issues
PHPBB3-11314
---
phpBB/assets/javascript/core.js | 12 ++++++------
phpBB/styles/subsilver2/template/editor.js | 5 ++---
2 files changed, 8 insertions(+), 9 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 9323f4a447..f38b35d613 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -57,7 +57,7 @@ phpbb.clearLoadingTimeout = function() {
* @param string title Title of the message, eg "Information" (HTML).
* @param string msg Message to display (HTML).
* @param bool fadedark Remove the dark background when done? Defaults
- * to yes.
+ * to yes.
*
* @returns object Returns the div created.
*/
@@ -121,9 +121,9 @@ phpbb.alert = function(title, msg, fadedark) {
*
* @param string msg Message to display (HTML).
* @param function callback Callback. Bool param, whether the user pressed
- * yes or no (or whatever their language is).
+ * yes or no (or whatever their language is).
* @param bool fadedark Remove the dark background when done? Defaults
- * to yes.
+ * to yes.
*
* @returns object Returns the div created.
*/
@@ -232,10 +232,10 @@ phpbb.parseQuerystring = function(string) {
*
* @param object options Options.
* @param bool/function refresh If we are sent back a refresh, should it be
- * acted upon? This can either be true / false / a function.
+ * acted upon? This can either be true / false / a function.
* @param function callback Callback to call on completion of event. Has
- * three parameters: the element that the event was evoked from, the JSON
- * that was returned and (if it is a form) the form action.
+ * three parameters: the element that the event was evoked from, the JSON
+ * that was returned and (if it is a form) the form action.
*/
phpbb.ajaxify = function(options) {
var elements = $(options.selector),
diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js
index 151cf53ff1..0b5b15643a 100644
--- a/phpBB/styles/subsilver2/template/editor.js
+++ b/phpBB/styles/subsilver2/template/editor.js
@@ -179,11 +179,10 @@ function insert_text(text, spaces, popup)
{
textarea.value = textarea.value + text;
}
- if (!popup)
+ if (!popup)
{
textarea.focus();
- }
-
+ }
}
/**
--
cgit v1.2.1
From 2f6b072bb13ce9d7c7784136bedec651b73ae11b Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Sun, 13 Jan 2013 23:00:48 +0100
Subject: [ticket/11314] Add missing radix parameters
PHPBB3-11314
---
phpBB/adm/style/editor.js | 2 +-
phpBB/styles/prosilver/template/editor.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/adm/style/editor.js b/phpBB/adm/style/editor.js
index c9e8afe08e..2b814a10c6 100644
--- a/phpBB/adm/style/editor.js
+++ b/phpBB/adm/style/editor.js
@@ -10,7 +10,7 @@ var theSelection = false;
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
-var clientVer = parseInt(navigator.appVersion); // Get browser version
+var clientVer = parseInt(navigator.appVersion, 10); // Get browser version
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js
index c16b0ef703..c099466005 100644
--- a/phpBB/styles/prosilver/template/editor.js
+++ b/phpBB/styles/prosilver/template/editor.js
@@ -11,7 +11,7 @@ var bbcodeEnabled = true;
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
-var clientVer = parseInt(navigator.appVersion); // Get browser version
+var clientVer = parseInt(navigator.appVersion, 10); // Get browser version
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
--
cgit v1.2.1
From 6704a82bbea45ab53a05c7490c87e46e1c57dd00 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Sat, 9 Mar 2013 09:21:31 -0600
Subject: [ticket/11422] Increment assets when database_update is complete
PHPBB3-11422
---
phpBB/install/database_update.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 2ecddf49d4..867235e607 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -41,10 +41,12 @@ if (!function_exists('phpbb_require_updated'))
}
}
-function phpbb_end_update($cache)
+function phpbb_end_update($cache, $config)
{
$cache->purge();
+ $config->increment('assets_version', 1);
+
?>
@@ -232,7 +234,7 @@ while (!$migrator->finished())
{
echo $e->getLocalisedMessage($user);
- phpbb_end_update($cache);
+ phpbb_end_update($cache, $config);
}
$state = array_merge(array(
@@ -265,7 +267,7 @@ while (!$migrator->finished())
echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . ' ';
echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '';
- phpbb_end_update($cache);
+ phpbb_end_update($cache, $config);
}
}
@@ -276,4 +278,4 @@ if ($orig_version != $config['version'])
echo $user->lang['DATABASE_UPDATE_COMPLETE'];
-phpbb_end_update($cache);
+phpbb_end_update($cache, $config);
--
cgit v1.2.1
From df98de971ca9e8362f1bbf5ce59967db16268531 Mon Sep 17 00:00:00 2001
From: erangamapa
Date: Tue, 12 Mar 2013 10:19:29 +0530
Subject: [ticket/11106] Undefined index EDITED_TIME_TOTAL notice.
When viewing a private message, when message edit count is 1
Undefined index EDITED_TIME_TOTAL php notice appears. Changed
the message formatting method to what is used in viewtopic.php.
PHPBB3-11106
---
phpBB/includes/ucp/ucp_pm_viewmessage.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index c85b05f144..e2b61f1b02 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -94,8 +94,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
// Editing information
if ($message_row['message_edit_count'] && $config['display_last_edited'])
{
- $l_edit_time_total = ($message_row['message_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
- $l_edited_by = '
' . sprintf($l_edit_time_total, (!$message_row['message_edit_user']) ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time'], false, true), $message_row['message_edit_count']);
+ $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $message_row['message_edit_count'], (!$message_row['message_edit_user']) ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time'], false, true));
}
else
{
--
cgit v1.2.1
From 567eefb2bd2bf280391786ea171dad0bdb0b442d Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 12 Mar 2013 22:35:31 +0100
Subject: [ticket/11362] Correctly sanitise the directory path
We need to correctly remove ../ form the path if possible by removing the
previous folder aswell. Otherwise the finder is unable to locate /adm/style
directories in extensions as he is looking for /adm/../adm/style instead.
PHPBB3-11362
---
phpBB/includes/extension/finder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php
index f71e32bc8d..d9aacc38ff 100644
--- a/phpBB/includes/extension/finder.php
+++ b/phpBB/includes/extension/finder.php
@@ -227,7 +227,7 @@ class phpbb_extension_finder
*/
protected function sanitise_directory($directory)
{
- $directory = preg_replace('#(?:^|/)\./#', '/', $directory);
+ $directory = phpbb_clean_path($directory);
$dir_len = strlen($directory);
if ($dir_len > 1 && $directory[$dir_len - 1] === '/')
--
cgit v1.2.1
From a38a92424ddf00383c17a6dffffe522065e25c9f Mon Sep 17 00:00:00 2001
From: Matt Friedman
Date: Thu, 14 Mar 2013 10:45:17 -0700
Subject: [ticket/10155] Update jQuery to 1.8.3
Currently included jQuery is old by now, v1.6.2. We should update to
1.8.3. This allows us to take advantage of the latest form of jQuery
event delegation ($.on). I don't think it wise to update to jQuery
1.9.x yet, as many 3rd party scripts still need to be updated to cope
with its deprecated features ($.browser). Therefor, 1.8.3 is the latest
and most widely compatible stable version right now.
PHPBB3-10155
---
phpBB/assets/javascript/jquery.js | 20 ++------------------
phpBB/includes/db/migration/data/310/dev.php | 2 +-
phpBB/install/schemas/schema_data.sql | 2 +-
3 files changed, 4 insertions(+), 20 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/assets/javascript/jquery.js b/phpBB/assets/javascript/jquery.js
index 48590ecb96..83589daa70 100644
--- a/phpBB/assets/javascript/jquery.js
+++ b/phpBB/assets/javascript/jquery.js
@@ -1,18 +1,2 @@
-/*!
- * jQuery JavaScript Library v1.6.2
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Thu Jun 30 14:16:56 2011 -0400
- */
-(function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z])/ig,x=function(a,b){return b.toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!A){A=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||D.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
--
cgit v1.2.1
From 2387e7eb4122ebc7ecd87bd709d6d661535b2ae2 Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin
Date: Fri, 12 Apr 2013 16:42:36 +0300
Subject: [ticket/11275] Do not use spacer.gif in color picker
PHPBB3-11275
---
phpBB/styles/prosilver/template/editor.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js
index 9e5665de99..0a749347ad 100644
--- a/phpBB/styles/prosilver/template/editor.js
+++ b/phpBB/styles/prosilver/template/editor.js
@@ -326,7 +326,7 @@ function colorPalette(dir, width, height) {
for (b = 0; b < 5; b++) {
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
html += '
';
- html += '';
+ html += '';
html += '
';
}
@@ -346,7 +346,7 @@ function colorPalette(dir, width, height) {
(function($) {
$(document).ready(function() {
$('#color_palette_placeholder').each(function() {
- $(this).html(colorPalette('h', 15, 10));
+ $(this).html(colorPalette('h', 15, 12));
});
});
})(jQuery);
--
cgit v1.2.1
From 88072fd6c2c3ec6cc6d2a880bd76a9c601fd0767 Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin
Date: Tue, 9 Apr 2013 18:38:59 +0300
Subject: [ticket/10741] Function to resize textarea elements
New function to automatically resize textarea elements
as user types text
PHPBB3-10741
---
phpBB/assets/javascript/core.js | 85 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 8bbea8b8c9..6fe71d141a 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -568,4 +568,89 @@ phpbb.addAjaxCallback('toggle_link', function() {
el.parent().attr('class', toggleClass);
});
+/**
+* Automatically resize textarea
+*
+* This function automatically resizes textarea elements when user
+* types text.
+*
+* @param jQuery item jQuery object to resize
+* @param object options Optional parameter that adjusts default
+* configuration. See configuration variable
+*/
+phpbb.resizeTextArea = function(items) {
+ // Configuration
+ var configuration = {
+ minWindowHeight: 500, // Minimum browser window height when textareas are resized
+ minHeight: 200, // Minimum height of textarea
+ maxHeight: 500, // Maximum height of textarea
+ heightDiff: 200, // Minimum difference between window and textarea height
+ // In following callbacks parameter "item" is jQuery object. "this" points to DOM object
+ resizeCallback: function(item) { }, // Function to call after resizing textarea.
+ resetCallback: function(item) { } // Function to call when resize has been canceled
+ }
+
+ if (arguments.length > 1)
+ {
+ configuration = $.extend(configuration, arguments[1]);
+ }
+
+ function resetAutoResize(item)
+ {
+ var $item = $(item);
+ if ($item.hasClass('auto-resized'))
+ {
+ $(item).css('height', '').removeClass('auto-resized');
+ configuration.resetCallback.call(item, $item);
+ }
+ };
+
+ function autoResize(item)
+ {
+ function setHeight(height)
+ {
+ $item.css('height', height + 'px').addClass('auto-resized');
+ configuration.resizeCallback.call(item, $item);
+ }
+
+ var windowHeight = $(window).height();
+
+ if (windowHeight < configuration.minWindowHeight)
+ {
+ resetAutoResize(item);
+ return;
+ }
+
+ var maxHeight = Math.min(Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), configuration.maxHeight),
+ $item = $(item),
+ height = parseInt($item.height()),
+ scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
+
+ if (height > maxHeight)
+ {
+ setHeight(maxHeight);
+ }
+ else if (scrollHeight > (height + 5))
+ {
+ setHeight(Math.min(maxHeight, scrollHeight));
+ }
+ };
+
+ items.bind('focus change keyup', function() {
+ $(this).each(function() {
+ autoResize(this);
+ });
+ }).css('resize', 'none').change();
+
+ $(window).resize(function() {
+ items.each(function() {
+ if ($(this).hasClass('auto-resized'))
+ {
+ autoResize(this);
+ }
+ });
+ });
+};
+
+
})(jQuery); // Avoid conflicts with other libraries
--
cgit v1.2.1
From 316efcbbbb72058bb9986be08af3d11173817386 Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin
Date: Tue, 9 Apr 2013 18:39:47 +0300
Subject: [ticket/10741] Automatically resize textareas in prosilver and ACP
Automatically resize textareas in prosilver and ACP.
PHPBB3-10741
---
phpBB/adm/style/ajax.js | 6 ++++++
phpBB/styles/prosilver/template/ajax.js | 9 +++++++++
2 files changed, 15 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js
index 8f7c210e00..8211bdd014 100644
--- a/phpBB/adm/style/ajax.js
+++ b/phpBB/adm/style/ajax.js
@@ -148,6 +148,12 @@ $('[data-ajax]').each(function() {
}
});
+/**
+* Automatically resize textarea
+*/
+$(document).ready(function() {
+ phpbb.resizeTextArea($('textarea'), {minHeight: 75});
+});
})(jQuery); // Avoid conflicts with other libraries
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index 8dd1f58c97..e7dfe95009 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -225,4 +225,13 @@ $('#member_search').click(function () {
return false;
});
+/**
+* Automatically resize textarea
+*/
+$(document).ready(function() {
+ phpbb.resizeTextArea($('textarea:not(#message-box textarea)'), {minHeight: 75, maxHeight: 250});
+ phpbb.resizeTextArea($('#message-box textarea'));
+});
+
+
})(jQuery); // Avoid conflicts with other libraries
--
cgit v1.2.1
From 67f0e19128415210f0ece4a8cd3df12e4b35eaf6 Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin
Date: Tue, 9 Apr 2013 18:47:08 +0300
Subject: [ticket/10741] Do not resize textarea.no-auto-resize
Do not auto-resize textareas with class .no-auto-resize
PHPBB3-10741
---
phpBB/adm/style/ajax.js | 2 +-
phpBB/styles/prosilver/template/ajax.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js
index 8211bdd014..6f21dfa6ac 100644
--- a/phpBB/adm/style/ajax.js
+++ b/phpBB/adm/style/ajax.js
@@ -152,7 +152,7 @@ $('[data-ajax]').each(function() {
* Automatically resize textarea
*/
$(document).ready(function() {
- phpbb.resizeTextArea($('textarea'), {minHeight: 75});
+ phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
});
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index e7dfe95009..2528b96ece 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -229,7 +229,7 @@ $('#member_search').click(function () {
* Automatically resize textarea
*/
$(document).ready(function() {
- phpbb.resizeTextArea($('textarea:not(#message-box textarea)'), {minHeight: 75, maxHeight: 250});
+ phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250});
phpbb.resizeTextArea($('#message-box textarea'));
});
--
cgit v1.2.1
From cbb9f084fce0fd42ed1481233f417c79e8a0abfa Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin
Date: Wed, 10 Apr 2013 09:08:25 +0300
Subject: [ticket/10741] Fix for browser-specific resizing of textarea
Disable browser-specific resizing only after textarea has been resized
Enable browser-specific resizing after script resizing has been reset
PHPBB3-10741
---
phpBB/assets/javascript/core.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 6fe71d141a..827ed2e34a 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -600,7 +600,7 @@ phpbb.resizeTextArea = function(items) {
var $item = $(item);
if ($item.hasClass('auto-resized'))
{
- $(item).css('height', '').removeClass('auto-resized');
+ $(item).css({height: '', resize: ''}).removeClass('auto-resized');
configuration.resetCallback.call(item, $item);
}
};
@@ -609,7 +609,7 @@ phpbb.resizeTextArea = function(items) {
{
function setHeight(height)
{
- $item.css('height', height + 'px').addClass('auto-resized');
+ $item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized');
configuration.resizeCallback.call(item, $item);
}
@@ -640,7 +640,7 @@ phpbb.resizeTextArea = function(items) {
$(this).each(function() {
autoResize(this);
});
- }).css('resize', 'none').change();
+ }).change();
$(window).resize(function() {
items.each(function() {
--
cgit v1.2.1
From 6a3d77d76e9a6ee17acbd29da8486742f60a2514 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Mon, 1 Apr 2013 10:34:06 +0200
Subject: [ticket/10844] Add phpbb_root_path to
phpbb_style_extension_path_provider
The phpbb_root_path needs to be removed from the style path, before giving
the path to the finder, because the finder prepends it later again and is
therefor unable to find style files when the root path is not ./
PHPBB3-10844
---
phpBB/config/services.yml | 1 +
phpBB/includes/bbcode.php | 2 +-
phpBB/includes/functions_messenger.php | 2 +-
phpBB/includes/style/extension_path_provider.php | 15 ++++++++++++++-
4 files changed, 17 insertions(+), 3 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index b9c71844dc..6b7b3f2f2b 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -242,6 +242,7 @@ services:
arguments:
- @ext.manager
- @style.path_provider
+ - %core.root_path%
style.path_provider:
class: phpbb_style_path_provider
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index e8681420d4..c198abeb54 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -133,7 +133,7 @@ class bbcode
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
$style_resource_locator = new phpbb_style_resource_locator();
- $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
+ $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path);
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template);
$style->set_style();
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 821f0d970d..e580f6b675 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -209,7 +209,7 @@ class messenger
if (!isset($this->tpl_msg[$template_lang . $template_file]))
{
$style_resource_locator = new phpbb_style_resource_locator();
- $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
+ $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path);
$tpl = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl);
diff --git a/phpBB/includes/style/extension_path_provider.php b/phpBB/includes/style/extension_path_provider.php
index 6976a45ed0..e658abcb42 100644
--- a/phpBB/includes/style/extension_path_provider.php
+++ b/phpBB/includes/style/extension_path_provider.php
@@ -40,17 +40,22 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple
*/
protected $base_path_provider;
+ /** @var string */
+ protected $phpbb_root_path;
+
/**
* Constructor stores extension manager
*
* @param phpbb_extension_manager $extension_manager phpBB extension manager
* @param phpbb_style_path_provider $base_path_provider A simple path provider
* to provide paths to be located in extensions
+ * @param string $phpbb_root_path phpBB root path
*/
- public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider)
+ public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider, $phpbb_root_path)
{
parent::__construct($extension_manager);
$this->base_path_provider = $base_path_provider;
+ $this->phpbb_root_path = $phpbb_root_path;
}
/**
@@ -91,6 +96,14 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple
$directories['style'][] = $path;
if ($path && !phpbb_is_absolute($path))
{
+ // Remove phpBB root path from the style path,
+ // so the finder is able to find extension styles,
+ // when the root path is not ./
+ if (strpos($path, $this->phpbb_root_path) === 0)
+ {
+ $path = substr($path, strlen($this->phpbb_root_path));
+ }
+
$result = $finder->directory('/' . $this->ext_dir_prefix . $path)
->get_directories(true, false, true);
foreach ($result as $ext => $ext_path)
--
cgit v1.2.1
From bbaa3411b04c06c519e8dd215a0251c97263eac4 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 12 Apr 2013 21:19:09 +0200
Subject: [ticket/10844] Make sure ext_path has no trailing slash
PHPBB3-10844
---
phpBB/includes/style/extension_path_provider.php | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/style/extension_path_provider.php b/phpBB/includes/style/extension_path_provider.php
index e658abcb42..ec1d85f821 100644
--- a/phpBB/includes/style/extension_path_provider.php
+++ b/phpBB/includes/style/extension_path_provider.php
@@ -108,6 +108,11 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple
->get_directories(true, false, true);
foreach ($result as $ext => $ext_path)
{
+ // Make sure $ext_path has no ending slash
+ if (substr($ext_path, -1) === '/')
+ {
+ $ext_path = substr($ext_path, 0, -1);
+ }
$directories[$ext][] = $ext_path;
}
}
--
cgit v1.2.1
From c1dedabdfb688501dceade55f6f3e96e3495e5dd Mon Sep 17 00:00:00 2001
From: Marc Alexander
Date: Mon, 15 Apr 2013 12:50:21 +0200
Subject: [ticket/11488] Use correct base class in email notification method
In ticket/11451 this was not correctly changed to reflect the new class
phpbb_notifcation_method_messenger_base. Additionally, an undefined
variable error has been fixed in messenger_base.php (change should be
confirmed by bantu though).
PHPBB3-11488
---
phpBB/includes/notification/method/email.php | 2 +-
phpBB/includes/notification/method/messenger_base.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php
index dc505c0d41..44666b1422 100644
--- a/phpBB/includes/notification/method/email.php
+++ b/phpBB/includes/notification/method/email.php
@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
*
* @package notifications
*/
-class phpbb_notification_method_email extends phpbb_notification_method_base
+class phpbb_notification_method_email extends phpbb_notification_method_messenger_base
{
/**
* Get notification method name
diff --git a/phpBB/includes/notification/method/messenger_base.php b/phpBB/includes/notification/method/messenger_base.php
index ce1ecc09ce..2f9073e80b 100644
--- a/phpBB/includes/notification/method/messenger_base.php
+++ b/phpBB/includes/notification/method/messenger_base.php
@@ -78,7 +78,7 @@ abstract class phpbb_notification_method_messenger_base extends phpbb_notificati
continue;
}
- $messenger->template($email_template_base_dir . $notification->get_email_template(), $user['user_lang']);
+ $messenger->template($template_dir_prefix . $notification->get_email_template(), $user['user_lang']);
$messenger->to($user['user_email'], $user['username']);
--
cgit v1.2.1
From a1183a58894967bfec7da01c5004138e4daeb583 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 16 Apr 2013 23:07:48 +0200
Subject: [ticket/11495] Add basic interface with nestedset operations
PHPBB3-11495
---
phpBB/includes/nestedset/interface.php | 131 ++++++++++++++++++++++++++++
phpBB/includes/nestedset/item/interface.php | 61 +++++++++++++
2 files changed, 192 insertions(+)
create mode 100644 phpBB/includes/nestedset/interface.php
create mode 100644 phpBB/includes/nestedset/item/interface.php
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
new file mode 100644
index 0000000000..7ef6ff87bb
--- /dev/null
+++ b/phpBB/includes/nestedset/interface.php
@@ -0,0 +1,131 @@
+ down, > 0 => up
+ * @return bool True if the item was moved
+ */
+ public function move(phpbb_nestedset_item_interface $item, $delta);
+
+ /**
+ * Move an item down by 1
+ *
+ * @param phpbb_nestedset_item_interface $item The item to be moved
+ * @return bool True if the item was moved
+ */
+ public function move_down(phpbb_nestedset_item_interface $item);
+
+ /**
+ * Move an item up by 1
+ *
+ * @param phpbb_nestedset_item_interface $item The item to be moved
+ * @return bool True if the item was moved
+ */
+ public function move_up(phpbb_nestedset_item_interface $item);
+
+ /**
+ * Moves all children of one item to another item
+ *
+ * @param phpbb_nestedset_item_interface $current_parent The current parent item
+ * @param phpbb_nestedset_item_interface $new_parent The new parent item
+ * @return bool True if any items where moved
+ */
+ public function move_children(phpbb_nestedset_item_interface $current_parent, phpbb_nestedset_item_interface $new_parent);
+
+ /**
+ * Set the parent item
+ *
+ * @param phpbb_nestedset_item_interface $item The item to be moved
+ * @param phpbb_nestedset_item_interface $new_parent The new parent item
+ * @return bool True if the parent was set successfully
+ */
+ public function set_parent(phpbb_nestedset_item_interface $item, phpbb_nestedset_item_interface $new_parent);
+
+ /**
+ * Get branch of the item
+ *
+ * This method can return all parents, children or both of the given item
+ *
+ * @param phpbb_nestedset_item_interface $item The item to get the branch from
+ * @param string $type One of all|parent|children
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the given item be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ public function get_branch_data(phpbb_nestedset_item_interface $item, $type, $order_desc, $include_item);
+
+ /**
+ * Get base information of parent items
+ *
+ * @param phpbb_nestedset_item_interface $item The item to get the parents from
+ * @return array Array of items (containing basic columns from the item table)
+ * ID => Item data
+ */
+ public function get_parent_data(phpbb_nestedset_item_interface $item);
+
+ /**
+ * Recalculate Nested Sets
+ *
+ * @param int $new_id First left_id to be used (should start with 1)
+ * @param int $parent_id parent_id of the current set (default = 0)
+ * @param bool $reset_ids Should we reset all left_id/right_id on the first call?
+ * @return int $new_id The next left_id/right_id that should be used
+ */
+ public function recalculate_nested_set($new_id, $parent_id = 0, $reset_ids = false);
+}
diff --git a/phpBB/includes/nestedset/item/interface.php b/phpBB/includes/nestedset/item/interface.php
new file mode 100644
index 0000000000..18206d752e
--- /dev/null
+++ b/phpBB/includes/nestedset/item/interface.php
@@ -0,0 +1,61 @@
+
Date: Tue, 16 Apr 2013 23:08:35 +0200
Subject: [ticket/11495] Add abstract implementation of the interface
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 632 +++++++++++++++++++++++++++++++++
phpBB/includes/nestedset/item/base.php | 82 +++++
2 files changed, 714 insertions(+)
create mode 100644 phpBB/includes/nestedset/base.php
create mode 100644 phpBB/includes/nestedset/item/base.php
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
new file mode 100644
index 0000000000..7f4691b7e0
--- /dev/null
+++ b/phpBB/includes/nestedset/base.php
@@ -0,0 +1,632 @@
+ 'item_id',
+ 'left_id' => 'left_id',
+ 'right_id' => 'right_id',
+ 'parent_id' => 'parent_id',
+ 'item_parents' => 'item_parents',
+ );
+
+ /**
+ * Additional SQL restrictions
+ * Allows to have multiple nested sets in one table
+ * @var String
+ */
+ protected $sql_where = '';
+
+ /**
+ * List of item properties to be cached in $item_parents
+ * @var array
+ */
+ protected $item_basic_data = array('*');
+
+ /**
+ * Delete an item from the nested set (also deletes the rows form the table)
+ *
+ * Also deletes all subitems from the nested set
+ *
+ * @param string $operator SQL operator that needs to be prepended to sql_where,
+ * if it is not empty.
+ * @param string $column_prefix Prefix that needs to be prepended to column names
+ * @return bool True if the item was deleted
+ */
+ public function get_sql_where($operator = 'AND', $column_prefix = '')
+ {
+ return (!$this->sql_where) ? '' : $operator . ' ' . sprintf($this->sql_where, $column_prefix);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function insert(array $additional_data)
+ {
+ $item_data = array_merge($additional_data, array(
+ $this->table_columns['parent_id'] => 0,
+ $this->table_columns['left_id'] => 0,
+ $this->table_columns['right_id'] => 0,
+ $this->table_columns['item_parents'] => '',
+ ));
+
+ unset($item_data[$this->table_columns['item_id']]);
+
+ $sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
+ $this->db->sql_query($sql);
+
+ $item_data[$this->table_columns['item_id']] = (int) $this->db->sql_nextid();
+
+ $item = new $this->item_class($item_data);
+
+ return array_merge($item_data, $this->add($item));
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function add(phpbb_nestedset_item_interface $item)
+ {
+ $sql = 'SELECT MAX(' . $this->table_columns['right_id'] . ') AS ' . $this->table_columns['right_id'] . '
+ FROM ' . $this->table_name . '
+ ' . $this->get_sql_where('WHERE');
+ $result = $this->db->sql_query($sql);
+ $current_max_right_id = (int) $this->db->sql_fetchfield($this->table_columns['right_id']);
+ $this->db->sql_freeresult($result);
+
+ $update_item_data = array(
+ $this->table_columns['parent_id'] => 0,
+ $this->table_columns['left_id'] => $current_max_right_id + 1,
+ $this->table_columns['right_id'] => $current_max_right_id + 2,
+ $this->table_columns['item_parents'] => '',
+ );
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . '
+ WHERE ' . $this->table_columns['item_id'] . ' = ' . $item->get_item_id();
+ $this->db->sql_query($sql);
+
+ return $update_item_data;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function remove(phpbb_nestedset_item_interface $item)
+ {
+ if ($item->has_children())
+ {
+ $items = array_keys($this->get_branch_data($item, 'children'));
+ }
+ else
+ {
+ $items = array($item->get_item_id());
+ }
+
+ $this->remove_subset($items, $item);
+
+ return $items;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function delete(phpbb_nestedset_item_interface $item)
+ {
+ $removed_items = $this->remove($item);
+
+ $sql = 'DELETE FROM ' . $this->table_name . '
+ WHERE ' . $this->db->sql_in_set($this->table_columns['item_id'], $removed_items) . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ return $removed_items;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move(phpbb_nestedset_item_interface $item, $delta)
+ {
+ if ($delta == 0)
+ {
+ return false;
+ }
+
+ $action = ($delta > 0) ? 'move_up' : 'move_down';
+ $delta = abs($delta);
+
+ /**
+ * Fetch all the siblings between the item's current spot
+ * and where we want to move it to. If there are less than $delta
+ * siblings between the current spot and the target then the
+ * item will move as far as possible
+ */
+ $sql = 'SELECT ' . implode(', ', $this->table_columns) . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->table_columns['parent_id'] . ' = ' . $item->get_parent_id() . '
+ ' . $this->get_sql_where() . '
+ AND ';
+
+ if ($action == 'move_up')
+ {
+ $sql .= $this->table_columns['right_id'] . ' < ' . $item->get_right_id() . ' ORDER BY ' . $this->table_columns['right_id'] . ' DESC';
+ }
+ else
+ {
+ $sql .= $this->table_columns['left_id'] . ' > ' . $item->get_left_id() . ' ORDER BY ' . $this->table_columns['left_id'] . ' ASC';
+ }
+
+ $result = $this->db->sql_query_limit($sql, $delta);
+
+ $target = null;
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $target = new $this->item_class($row);
+ }
+ $this->db->sql_freeresult($result);
+
+ if (is_null($target))
+ {
+ // The item is already on top or bottom
+ return false;
+ }
+
+ /**
+ * $left_id and $right_id define the scope of the items that are affected by the move.
+ * $diff_up and $diff_down are the values to substract or add to each item's left_id
+ * and right_id in order to move them up or down.
+ * $move_up_left and $move_up_right define the scope of the items that are moving
+ * up. Other items in the scope of ($left_id, $right_id) are considered to move down.
+ */
+ if ($action == 'move_up')
+ {
+ $left_id = $target->get_left_id();
+ $right_id = $item->get_right_id();
+
+ $diff_up = $item->get_left_id() - $target->get_left_id();
+ $diff_down = $item->get_right_id() + 1 - $item->get_left_id();
+
+ $move_up_left = $item->get_left_id();
+ $move_up_right = $item->get_right_id();
+ }
+ else
+ {
+ $left_id = $item->get_left_id();
+ $right_id = $target->get_right_id();
+
+ $diff_up = $item->get_right_id() + 1 - $item->get_left_id();
+ $diff_down = $target->get_right_id() - $item->get_right_id();
+
+ $move_up_left = $item->get_right_id() + 1;
+ $move_up_right = $target->get_right_id();
+ }
+
+ // Now do the dirty job
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->table_columns['left_id'] . ' = ' . $this->table_columns['left_id'] . ' + CASE
+ WHEN ' . $this->table_columns['left_id'] . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
+ ELSE {$diff_down}
+ END,
+ " . $this->table_columns['right_id'] . ' = ' . $this->table_columns['right_id'] . ' + CASE
+ WHEN ' . $this->table_columns['right_id'] . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
+ ELSE {$diff_down}
+ END,
+ " . $this->table_columns['item_parents'] . " = ''
+ WHERE
+ " . $this->table_columns['left_id'] . " BETWEEN {$left_id} AND {$right_id}
+ AND " . $this->table_columns['right_id'] . " BETWEEN {$left_id} AND {$right_id}
+ " . $this->get_sql_where();
+ $this->db->sql_query($sql);
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_down(phpbb_nestedset_item_interface $item)
+ {
+ return $this->move($item, -1);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_up(phpbb_nestedset_item_interface $item)
+ {
+ return $this->move($item, 1);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_children(phpbb_nestedset_item_interface $current_parent, phpbb_nestedset_item_interface $new_parent)
+ {
+ if (!$current_parent->has_children() || !$current_parent->get_item_id() || $current_parent->get_item_id() == $new_parent->get_item_id())
+ {
+ return false;
+ }
+
+ $move_items = array_keys($this->get_branch_data($current_parent, 'children', true, false));
+
+ if (in_array($new_parent->get_item_id(), $move_items))
+ {
+ throw new phpbb_nestedset_exception('INVALID_PARENT');
+ }
+
+ $diff = sizeof($move_items) * 2;
+ $sql_exclude_moved_items = $this->db->sql_in_set($this->table_columns['item_id'], $move_items, true);
+
+ $this->db->sql_transaction('begin');
+
+ $this->remove_subset($move_items, $current_parent, false);
+
+ if ($new_parent->get_item_id())
+ {
+ // Retrieve new-parent again, it may have been changed...
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->table_columns['item_id'] . ' = ' . $new_parent->get_item_id();
+ $result = $this->db->sql_query($sql);
+ $parent_data = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (!$parent_data)
+ {
+ $this->db->sql_transaction('rollback');
+ throw new phpbb_nestedset_exception('INVALID_PARENT');
+ }
+
+ $new_parent = new $this->item_class($parent_data);
+
+ $new_right_id = $this->prepare_adding_subset($move_items, $new_parent);
+
+ if ($new_right_id > $current_parent->get_right_id())
+ {
+ $diff = ' + ' . ($new_right_id - $current_parent->get_right_id());
+ }
+ else
+ {
+ $diff = ' - ' . abs($new_right_id - $current_parent->get_right_id());
+ }
+ }
+ else
+ {
+ $sql = 'SELECT MAX(' . $this->table_columns['right_id'] . ') AS ' . $this->table_columns['right_id'] . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $sql_exclude_moved_items . '
+ ' . $this->get_sql_where('AND');
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $diff = ' + ' . ($row[$this->table_columns['right_id']] - $current_parent->get_left_id());
+ }
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->table_columns['left_id'] . ' = ' . $this->table_columns['left_id'] . $diff . ',
+ ' . $this->table_columns['right_id'] . ' = ' . $this->table_columns['right_id'] . $diff . ',
+ ' . $this->table_columns['parent_id'] . ' = ' . $this->db->sql_case($this->table_columns['parent_id'] . ' = ' . $current_parent->get_item_id(), $new_parent->get_item_id(), $this->table_columns['parent_id']) . ',
+ ' . $this->table_columns['item_parents'] . " = ''
+ WHERE " . $this->db->sql_in_set($this->table_columns['item_id'], $move_items) . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ $this->db->sql_transaction('commit');
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function set_parent(phpbb_nestedset_item_interface $item, phpbb_nestedset_item_interface $new_parent)
+ {
+ $move_items = array_keys($this->get_branch_data($item, 'children'));
+
+ if (in_array($new_parent->get_item_id(), $move_items))
+ {
+ throw new phpbb_nestedset_exception('INVALID_PARENT');
+ }
+
+ $diff = sizeof($move_items) * 2;
+ $sql_exclude_moved_items = $this->db->sql_in_set($this->table_columns['item_id'], $move_items, true);
+
+ $this->db->sql_transaction('begin');
+
+ $this->remove_subset($move_items, $item, false);
+
+ if ($new_parent->get_item_id())
+ {
+ // Retrieve new-parent again, it may have been changed...
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->table_columns['item_id'] . ' = ' . $new_parent->get_item_id();
+ $result = $this->db->sql_query($sql);
+ $parent_data = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (!$parent_data)
+ {
+ $this->db->sql_transaction('rollback');
+ throw new phpbb_nestedset_exception('INVALID_PARENT');
+ }
+
+ $new_parent = new $this->item_class($parent_data);
+
+ $new_right_id = $this->prepare_adding_subset($move_items, $new_parent);
+
+ if ($new_right_id > $item->get_right_id())
+ {
+ $diff = ' + ' . ($new_right_id - $item->get_right_id() - 1);
+ }
+ else
+ {
+ $diff = ' - ' . abs($new_right_id - $item->get_right_id() - 1);
+ }
+ }
+ else
+ {
+ $sql = 'SELECT MAX(' . $this->table_columns['right_id'] . ') AS ' . $this->table_columns['right_id'] . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $sql_exclude_moved_items . '
+ ' . $this->get_sql_where('AND');
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $diff = ' + ' . ($row[$this->table_columns['right_id']] - $item->get_left_id() + 1);
+ }
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->table_columns['left_id'] . ' = ' . $this->table_columns['left_id'] . $diff . ',
+ ' . $this->table_columns['right_id'] . ' = ' . $this->table_columns['right_id'] . $diff . ',
+ ' . $this->table_columns['parent_id'] . ' = ' . $this->db->sql_case($this->table_columns['item_id'] . ' = ' . $item->get_item_id(), $new_parent->get_item_id(), $this->table_columns['parent_id']) . ',
+ ' . $this->table_columns['item_parents'] . " = ''
+ WHERE " . $this->db->sql_in_set($this->table_columns['item_id'], $move_items) . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ $this->db->sql_transaction('commit');
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_branch_data(phpbb_nestedset_item_interface $item, $type = 'all', $order_desc = true, $include_item = true)
+ {
+ switch ($type)
+ {
+ case 'parents':
+ $condition = 'i1.' . $this->table_columns['left_id'] . ' BETWEEN i2.' . $this->table_columns['left_id'] . ' AND i2.' . $this->table_columns['right_id'] . '';
+ break;
+
+ case 'children':
+ $condition = 'i2.' . $this->table_columns['left_id'] . ' BETWEEN i1.' . $this->table_columns['left_id'] . ' AND i1.' . $this->table_columns['right_id'] . '';
+ break;
+
+ default:
+ $condition = 'i2.' . $this->table_columns['left_id'] . ' BETWEEN i1.' . $this->table_columns['left_id'] . ' AND i1.' . $this->table_columns['right_id'] . '
+ OR i1.' . $this->table_columns['left_id'] . ' BETWEEN i2.' . $this->table_columns['left_id'] . ' AND i2.' . $this->table_columns['right_id'];
+ break;
+ }
+
+ $rows = array();
+
+ $sql = 'SELECT i2.*
+ FROM ' . $this->table_name . ' i1
+ LEFT JOIN ' . $this->table_name . " i2
+ ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
+ WHERE i1.' . $this->table_columns['item_id'] . ' = ' . $item->get_item_id() . '
+ ' . $this->get_sql_where('AND', 'i1.') . '
+ ORDER BY i2.' . $this->table_columns['left_id'] . ' ' . ($order_desc ? 'ASC' : 'DESC');
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (!$include_item && $item->get_item_id() === (int) $row[$this->table_columns['item_id']])
+ {
+ continue;
+ }
+
+ $rows[$row[$this->table_columns['item_id']]] = $row;
+ }
+ $this->db->sql_freeresult($result);
+
+ return $rows;
+ }
+
+ /**
+ * Get base information of parent items
+ *
+ * Data is cached in the item_parents column in the item table
+ *
+ * @inheritdoc
+ */
+ public function get_parent_data(phpbb_nestedset_item_interface $item)
+ {
+ $parents = array();
+ if ($item->get_parent_id())
+ {
+ if (!$item->get_item_parents_data())
+ {
+ $sql = 'SELECT ' . implode(', ', $this->item_basic_data) . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->table_columns['left_id'] . ' < ' . $item->get_left_id() . '
+ AND ' . $this->table_columns['right_id'] . ' > ' . $item->get_right_id() . '
+ ' . $this->get_sql_where('AND') . '
+ ORDER BY ' . $this->table_columns['left_id'] . ' ASC';
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $parents[$row[$this->table_columns['item_id']]] = $row;
+ }
+ $this->db->sql_freeresult($result);
+
+ $item_parents = serialize($parents);
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->table_columns['item_parents'] . " = '" . $this->db->sql_escape($item_parents) . "'
+ WHERE " . $this->table_columns['parent_id'] . ' = ' . $item->get_parent_id();
+ $this->db->sql_query($sql);
+ }
+ else
+ {
+ $parents = unserialize($item->get_item_parents_data());
+ }
+ }
+
+ return $parents;
+ }
+
+ /**
+ * Remove a subset from the nested set
+ *
+ * @param array $subset_items Subset of items to remove
+ * @param phpbb_nestedset_item_interface $bounding_item Item containing the right bound of the subset
+ * @param bool $set_subset_zero Should the parent, left and right id of the item be set to 0, or kept unchanged?
+ * @return null
+ */
+ protected function remove_subset(array $subset_items, phpbb_nestedset_item_interface $bounding_item, $set_subset_zero = true)
+ {
+ $diff = sizeof($subset_items) * 2;
+ $sql_subset_items = $this->db->sql_in_set($this->table_columns['item_id'], $subset_items);
+ $sql_not_subset_items = $this->db->sql_in_set($this->table_columns['item_id'], $subset_items, true);
+
+ $sql_is_parent = $this->table_columns['left_id'] . ' <= ' . $bounding_item->get_right_id() . '
+ AND ' . $this->table_columns['right_id'] . ' >= ' . $bounding_item->get_right_id();
+
+ $sql_is_right = $this->table_columns['left_id'] . ' > ' . $bounding_item->get_right_id();
+
+ $set_left_id = $this->db->sql_case($sql_is_right, $this->table_columns['left_id'] . ' - ' . $diff, $this->table_columns['left_id']);
+ $set_right_id = $this->db->sql_case($sql_is_parent . ' OR ' . $sql_is_right, $this->table_columns['right_id'] . ' - ' . $diff, $this->table_columns['right_id']);
+
+ if ($set_subset_zero)
+ {
+ $set_left_id = $this->db->sql_case($sql_subset_items, 0, $set_left_id);
+ $set_right_id = $this->db->sql_case($sql_subset_items, 0, $set_right_id);
+ }
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->table_columns['left_id'] . ' = ' . $set_left_id . ',
+ ' . $this->table_columns['right_id'] . ' = ' . $set_right_id . ',
+ ' . (($set_subset_zero) ? $this->table_columns['parent_id'] . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->table_columns['parent_id']) . ',' : '') . '
+ ' . $this->table_columns['item_parents'] . " = ''
+ " . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
+ $this->db->sql_query($sql);
+ }
+
+ /**
+ * Add a subset to the nested set
+ *
+ * @param array $subset_items Subset of items to add
+ * @param phpbb_nestedset_item_interface $new_parent Item containing the right bound of the new parent
+ * @return int New right id of the parent item
+ */
+ protected function prepare_adding_subset(array $subset_items, phpbb_nestedset_item_interface $new_parent)
+ {
+ $diff = sizeof($subset_items) * 2;
+ $sql_not_subset_items = $this->db->sql_in_set($this->table_columns['item_id'], $subset_items, true);
+
+ $set_left_id = $this->db->sql_case($this->table_columns['left_id'] . ' > ' . $new_parent->get_right_id(), $this->table_columns['left_id'] . ' + ' . $diff, $this->table_columns['left_id']);
+ $set_right_id = $this->db->sql_case($this->table_columns['right_id'] . ' >= ' . $new_parent->get_right_id(), $this->table_columns['right_id'] . ' + ' . $diff, $this->table_columns['right_id']);
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->table_columns['left_id'] . ' = ' . $set_left_id . ',
+ ' . $this->table_columns['right_id'] . ' = ' . $set_right_id . ',
+ ' . $this->table_columns['item_parents'] . " = ''
+ WHERE " . $sql_not_subset_items . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ return $new_parent->get_right_id() + $diff;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function recalculate_nested_set($new_id, $parent_id = 0, $reset_ids = false)
+ {
+ if ($reset_ids)
+ {
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', array(
+ $this->table_columns['left_id'] => 0,
+ $this->table_columns['right_id'] => 0,
+ $this->table_columns['item_parents'] => '',
+ )) . '
+ ' . $this->get_sql_where('WHERE');
+ $this->db->sql_query($sql);
+ }
+
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->table_columns['parent_id'] . ' = ' . (int) $parent_id . '
+ ' . $this->get_sql_where('AND') . '
+ ORDER BY ' . $this->table_columns['left_id'] . ', ' . $this->table_columns['item_id'] . ' ASC';
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ // First we update the left_id for this module
+ if ($row[$this->table_columns['left_id']] != $new_id)
+ {
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', array(
+ $this->table_columns['left_id'] => $new_id,
+ $this->table_columns['item_parents'] => '',
+ )) . '
+ WHERE ' . $this->table_columns['item_id'] . ' = ' . $row[$this->table_columns['item_id']];
+ $this->db->sql_query($sql);
+ }
+ $new_id++;
+
+ // Then we go through any children and update their left/right id's
+ $new_id = $this->recalculate_nested_set($new_id, $row[$this->table_columns['item_id']]);
+
+ // Then we come back and update the right_id for this module
+ if ($row[$this->table_columns['right_id']] != $new_id)
+ {
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', array($this->table_columns['right_id'] => $new_id)) . '
+ WHERE ' . $this->table_columns['item_id'] . ' = ' . $row[$this->table_columns['item_id']];
+ $this->db->sql_query($sql);
+ }
+ $new_id++;
+ }
+ $this->db->sql_freeresult($result);
+
+ return $new_id;
+ }
+}
diff --git a/phpBB/includes/nestedset/item/base.php b/phpBB/includes/nestedset/item/base.php
new file mode 100644
index 0000000000..c3a7600827
--- /dev/null
+++ b/phpBB/includes/nestedset/item/base.php
@@ -0,0 +1,82 @@
+item_id;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_parent_id()
+ {
+ return (int) $this->parent_id;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_item_parents_data()
+ {
+ return (string) $this->item_parents_data;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_left_id()
+ {
+ return (int) $this->left_id;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_right_id()
+ {
+ return (int) $this->right_id;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function has_children()
+ {
+ return $this->right_id - $this->left_id > 1;
+ }
+}
--
cgit v1.2.1
From 57a05e7cf509f56309591aaf9344226a8f1a9a8e Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 16 Apr 2013 23:09:21 +0200
Subject: [ticket/11495] Add forum implementation of nestedset
PHPBB3-11495
---
phpBB/includes/nestedset/exception.php | 20 ++++++
phpBB/includes/nestedset/forum.php | 121 ++++++++++++++++++++++++++++++++
phpBB/includes/nestedset/item/forum.php | 28 ++++++++
3 files changed, 169 insertions(+)
create mode 100644 phpBB/includes/nestedset/exception.php
create mode 100644 phpBB/includes/nestedset/forum.php
create mode 100644 phpBB/includes/nestedset/item/forum.php
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/exception.php b/phpBB/includes/nestedset/exception.php
new file mode 100644
index 0000000000..10937d0b29
--- /dev/null
+++ b/phpBB/includes/nestedset/exception.php
@@ -0,0 +1,20 @@
+ 'forum_id',
+ 'left_id' => 'left_id',
+ 'right_id' => 'right_id',
+ 'parent_id' => 'parent_id',
+ 'item_parents' => 'forum_parents',
+ );
+
+ /**
+ * Additional SQL restrictions
+ * Allows to have multiple nestedsets in one table
+ * Columns must be prefixed with %1$s
+ * @var String
+ */
+ protected $sql_where = '';
+
+ /**
+ * List of item properties to be cached in $item_parents
+ * @var array
+ */
+ protected $item_basic_data = array('forum_id', 'forum_name', 'forum_type');
+
+ /**
+ * Construct
+ *
+ * @param phpbb_db_driver $db Database connection
+ * @param phpbb_lock_db $lock Lock class used to lock the table when moving forums around
+ * @param string $table_name Table name
+ */
+ public function __construct(phpbb_db_driver $db, phpbb_lock_db $lock, $table_name)
+ {
+ $this->db = $db;
+ $this->lock = $lock;
+ $this->table_name = $table_name;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_children(phpbb_nestedset_item_interface $current_parent, phpbb_nestedset_item_interface $new_parent)
+ {
+ while (!$this->lock->acquire())
+ {
+ // Retry after 0.2 seconds
+ usleep(200 * 1000);
+ }
+
+ try
+ {
+ $return = parent::move_children($current_parent, $new_parent);
+ }
+ catch (phpbb_nestedset_exception $e)
+ {
+ $this->lock->release();
+ throw new phpbb_nestedset_exception('FORUM_NESTEDSET_' . $e->getMessage());
+ }
+ $this->lock->release();
+
+ return $return;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function set_parent(phpbb_nestedset_item_interface $item, phpbb_nestedset_item_interface $new_parent)
+ {
+ while (!$this->lock->acquire())
+ {
+ // Retry after 0.2 seconds
+ usleep(200 * 1000);
+ }
+
+ try
+ {
+ $return = parent::set_parent($item, $new_parent);
+ }
+ catch (phpbb_nestedset_exception $e)
+ {
+ $this->lock->release();
+ throw new phpbb_nestedset_exception('FORUM_NESTEDSET_' . $e->getMessage());
+ }
+ $this->lock->release();
+
+ return $return;
+ }
+}
diff --git a/phpBB/includes/nestedset/item/forum.php b/phpBB/includes/nestedset/item/forum.php
new file mode 100644
index 0000000000..9475517999
--- /dev/null
+++ b/phpBB/includes/nestedset/item/forum.php
@@ -0,0 +1,28 @@
+item_id = (int) $forum_row['forum_id'];
+ $this->parent_id = (int) $forum_row['parent_id'];
+ $this->left_id = (int) $forum_row['left_id'];
+ $this->right_id = (int) $forum_row['right_id'];
+ $this->item_parents_data = (string) $forum_row['forum_parents'];
+ }
+}
--
cgit v1.2.1
From 869e00a23b0400b9ad81c1130227cc4c29d6a38d Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 17:45:49 +0200
Subject: [ticket/11362] Move phpbb_clean_path into a simple filesystem service
PHPBB3-11362
---
phpBB/config/services.yml | 4 ++++
phpBB/includes/filesystem.php | 52 +++++++++++++++++++++++++++++++++++++++++++
phpBB/includes/functions.php | 30 -------------------------
3 files changed, 56 insertions(+), 30 deletions(-)
create mode 100644 phpBB/includes/filesystem.php
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index b9c71844dc..5febe76c49 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -142,9 +142,13 @@ services:
- @ext.manager
- %core.root_path%
- @cache.driver
+ - @filesystem
- .%core.php_ext%
- _ext_finder
+ filesystem:
+ class: phpbb_filesystem
+
groupposition.legend:
class: phpbb_groupposition_legend
arguments:
diff --git a/phpBB/includes/filesystem.php b/phpBB/includes/filesystem.php
new file mode 100644
index 0000000000..27cab48fb0
--- /dev/null
+++ b/phpBB/includes/filesystem.php
@@ -0,0 +1,52 @@
+
Date: Wed, 17 Apr 2013 17:50:44 +0200
Subject: [ticket/11362] Use new filesystem class in finder
PHPBB3-11362
---
phpBB/includes/extension/finder.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php
index d9aacc38ff..02a9ebb8c3 100644
--- a/phpBB/includes/extension/finder.php
+++ b/phpBB/includes/extension/finder.php
@@ -23,6 +23,7 @@ if (!defined('IN_PHPBB'))
class phpbb_extension_finder
{
protected $extension_manager;
+ protected $filesystem;
protected $phpbb_root_path;
protected $cache;
protected $php_ext;
@@ -54,15 +55,17 @@ class phpbb_extension_finder
* @param phpbb_extension_manager $extension_manager An extension manager
* instance that provides the finder with a list of active
* extensions and their locations
+ * @param phpbb_filesystem $filesystem Filesystem instance
* @param string $phpbb_root_path Path to the phpbb root directory
* @param phpbb_cache_driver_interface $cache A cache instance or null
* @param string $php_ext php file extension
* @param string $cache_name The name of the cache variable, defaults to
* _ext_finder
*/
- public function __construct(phpbb_extension_manager $extension_manager, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $php_ext = '.php', $cache_name = '_ext_finder')
+ public function __construct(phpbb_extension_manager $extension_manager, phpbb_filesystem $filesystem, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $php_ext = '.php', $cache_name = '_ext_finder')
{
$this->extension_manager = $extension_manager;
+ $this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
$this->cache = $cache;
$this->php_ext = $php_ext;
@@ -227,7 +230,7 @@ class phpbb_extension_finder
*/
protected function sanitise_directory($directory)
{
- $directory = phpbb_clean_path($directory);
+ $directory = $this->filesystem->clean_path($directory);
$dir_len = strlen($directory);
if ($dir_len > 1 && $directory[$dir_len - 1] === '/')
--
cgit v1.2.1
From d7fb934a2f6fbce86563d692b9689eb5c76e31dd Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 17:52:00 +0200
Subject: [ticket/11362] Replace other calls to phpbb_clean_path
Need to instantiate the object manually here, as the container is not yet
set up.
PHPBB3-11362
---
phpBB/common.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/common.php b/phpBB/common.php
index c33e2cbb1f..6dd65739fc 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -44,8 +44,11 @@ if (!defined('PHPBB_INSTALLED'))
// Replace any number of consecutive backslashes and/or slashes with a single slash
// (could happen on some proxy setups and/or Windows servers)
$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
+
// Eliminate . and .. from the path
- $script_path = phpbb_clean_path($script_path);
+ require($phpbb_root_path . 'includes/filesystem.' . $phpEx);
+ $phpbb_filesystem = new phpbb_filesystem();
+ $script_path = $phpbb_filesystem->clean_path($script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
--
cgit v1.2.1
From 423b310e2acbbc72814a4278a4cccf2900114f85 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 18:43:19 +0200
Subject: [ticket/11362] Extension manager depends on filesystem
PHPBB3-11362
---
phpBB/config/services.yml | 1 +
phpBB/includes/extension/manager.php | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 5febe76c49..fb3e7aa964 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -131,6 +131,7 @@ services:
- @dbal.conn
- @config
- @migrator
+ - @filesystem
- %tables.ext%
- %core.root_path%
- .%core.php_ext%
diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php
index 44a30c6280..de9a3937c3 100644
--- a/phpBB/includes/extension/manager.php
+++ b/phpBB/includes/extension/manager.php
@@ -44,13 +44,14 @@ class phpbb_extension_manager
* @param phpbb_db_driver $db A database connection
* @param phpbb_config $config phpbb_config
* @param phpbb_db_migrator $migrator
+ * @param phpbb_filesystem $filesystem
* @param string $extension_table The name of the table holding extensions
* @param string $phpbb_root_path Path to the phpbb includes directory.
* @param string $php_ext php file extension
* @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, phpbb_db_migrator $migrator, $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, phpbb_filesystem $filesystem, $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;
@@ -58,6 +59,7 @@ class phpbb_extension_manager
$this->config = $config;
$this->migrator = $migrator;
$this->cache = $cache;
+ $this->filesystem = $filesystem;
$this->php_ext = $php_ext;
$this->extension_table = $extension_table;
$this->cache_name = $cache_name;
@@ -510,7 +512,7 @@ class phpbb_extension_manager
*/
public function get_finder()
{
- return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
+ return new phpbb_extension_finder($this, $this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
}
/**
--
cgit v1.2.1
From ffe9f2a93e7bb91378e462b44a786252bddbd0be Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 20:25:30 +0200
Subject: [ticket/11362] Fix service description of finder
PHPBB3-11362
---
phpBB/config/services.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index fb3e7aa964..19dfb3e23b 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -141,9 +141,9 @@ services:
class: phpbb_extension_finder
arguments:
- @ext.manager
+ - @filesystem
- %core.root_path%
- @cache.driver
- - @filesystem
- .%core.php_ext%
- _ext_finder
--
cgit v1.2.1
From e2875a7e170770a92fa02db3a75f1552cc33005a Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 21:23:47 +0200
Subject: [ticket/10966] Introduce MySQL base class
PHPBB3-10966
---
phpBB/includes/db/driver/mysql.php | 124 +--------------------------
phpBB/includes/db/driver/mysql_base.php | 145 ++++++++++++++++++++++++++++++++
phpBB/includes/db/driver/mysqli.php | 125 +--------------------------
3 files changed, 148 insertions(+), 246 deletions(-)
create mode 100644 phpBB/includes/db/driver/mysql_base.php
(limited to 'phpBB')
diff --git a/phpBB/includes/db/driver/mysql.php b/phpBB/includes/db/driver/mysql.php
index 9de7283a42..f3744ac09d 100644
--- a/phpBB/includes/db/driver/mysql.php
+++ b/phpBB/includes/db/driver/mysql.php
@@ -24,7 +24,7 @@ if (!defined('IN_PHPBB'))
* MySQL 5.0+
* @package dbal
*/
-class phpbb_db_driver_mysql extends phpbb_db_driver
+class phpbb_db_driver_mysql extends phpbb_db_driver_mysql_base
{
var $multi_insert = true;
var $connect_error = '';
@@ -135,14 +135,6 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
return ($raw) ? $this->sql_server_version : 'MySQL ' . $this->sql_server_version;
}
- /**
- * {@inheritDoc}
- */
- public function sql_concatenate($expr1, $expr2)
- {
- return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
- }
-
/**
* SQL Transaction
* @access private
@@ -226,25 +218,6 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
return $this->query_result;
}
- /**
- * Build LIMIT query
- */
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
- {
- $this->query_result = false;
-
- // if $total is set to 0 we do not want to limit the number of rows
- if ($total == 0)
- {
- // Having a value of -1 was always a bug
- $total = '18446744073709551615';
- }
-
- $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
-
- return $this->sql_query($query, $cache_ttl);
- }
-
/**
* Return number of affected rows
*/
@@ -341,101 +314,6 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
return @mysql_real_escape_string($msg, $this->db_connect_id);
}
- /**
- * Gets the estimated number of rows in a specified table.
- *
- * @param string $table_name Table name
- *
- * @return string Number of rows in $table_name.
- * Prefixed with ~ if estimated (otherwise exact).
- *
- * @access public
- */
- function get_estimated_row_count($table_name)
- {
- $table_status = $this->get_table_status($table_name);
-
- if (isset($table_status['Engine']))
- {
- if ($table_status['Engine'] === 'MyISAM')
- {
- return $table_status['Rows'];
- }
- else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
- {
- return '~' . $table_status['Rows'];
- }
- }
-
- return parent::get_row_count($table_name);
- }
-
- /**
- * Gets the exact number of rows in a specified table.
- *
- * @param string $table_name Table name
- *
- * @return string Exact number of rows in $table_name.
- *
- * @access public
- */
- function get_row_count($table_name)
- {
- $table_status = $this->get_table_status($table_name);
-
- if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
- {
- return $table_status['Rows'];
- }
-
- return parent::get_row_count($table_name);
- }
-
- /**
- * Gets some information about the specified table.
- *
- * @param string $table_name Table name
- *
- * @return array
- *
- * @access protected
- */
- function get_table_status($table_name)
- {
- $sql = "SHOW TABLE STATUS
- LIKE '" . $this->sql_escape($table_name) . "'";
- $result = $this->sql_query($sql);
- $table_status = $this->sql_fetchrow($result);
- $this->sql_freeresult($result);
-
- return $table_status;
- }
-
- /**
- * Build LIKE expression
- * @access private
- */
- function _sql_like_expression($expression)
- {
- return $expression;
- }
-
- /**
- * Build db-specific query data
- * @access private
- */
- function _sql_custom_build($stage, $data)
- {
- switch ($stage)
- {
- case 'FROM':
- $data = '(' . $data . ')';
- break;
- }
-
- return $data;
- }
-
/**
* return sql error array
* @access private
diff --git a/phpBB/includes/db/driver/mysql_base.php b/phpBB/includes/db/driver/mysql_base.php
new file mode 100644
index 0000000000..ba44ea61aa
--- /dev/null
+++ b/phpBB/includes/db/driver/mysql_base.php
@@ -0,0 +1,145 @@
+query_result = false;
+
+ // if $total is set to 0 we do not want to limit the number of rows
+ if ($total == 0)
+ {
+ // MySQL 4.1+ no longer supports -1 in limit queries
+ $total = '18446744073709551615';
+ }
+
+ $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
+
+ return $this->sql_query($query, $cache_ttl);
+ }
+
+ /**
+ * Gets the estimated number of rows in a specified table.
+ *
+ * @param string $table_name Table name
+ *
+ * @return string Number of rows in $table_name.
+ * Prefixed with ~ if estimated (otherwise exact).
+ *
+ * @access public
+ */
+ function get_estimated_row_count($table_name)
+ {
+ $table_status = $this->get_table_status($table_name);
+
+ if (isset($table_status['Engine']))
+ {
+ if ($table_status['Engine'] === 'MyISAM')
+ {
+ return $table_status['Rows'];
+ }
+ else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
+ {
+ return '~' . $table_status['Rows'];
+ }
+ }
+
+ return parent::get_row_count($table_name);
+ }
+
+ /**
+ * Gets the exact number of rows in a specified table.
+ *
+ * @param string $table_name Table name
+ *
+ * @return string Exact number of rows in $table_name.
+ *
+ * @access public
+ */
+ function get_row_count($table_name)
+ {
+ $table_status = $this->get_table_status($table_name);
+
+ if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
+ {
+ return $table_status['Rows'];
+ }
+
+ return parent::get_row_count($table_name);
+ }
+
+ /**
+ * Gets some information about the specified table.
+ *
+ * @param string $table_name Table name
+ *
+ * @return array
+ *
+ * @access protected
+ */
+ function get_table_status($table_name)
+ {
+ $sql = "SHOW TABLE STATUS
+ LIKE '" . $this->sql_escape($table_name) . "'";
+ $result = $this->sql_query($sql);
+ $table_status = $this->sql_fetchrow($result);
+ $this->sql_freeresult($result);
+
+ return $table_status;
+ }
+
+ /**
+ * Build LIKE expression
+ * @access private
+ */
+ function _sql_like_expression($expression)
+ {
+ return $expression;
+ }
+
+ /**
+ * Build db-specific query data
+ * @access private
+ */
+ function _sql_custom_build($stage, $data)
+ {
+ switch ($stage)
+ {
+ case 'FROM':
+ $data = '(' . $data . ')';
+ break;
+ }
+
+ return $data;
+ }
+}
diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/includes/db/driver/mysqli.php
index 7448bf1670..0f7a73ee6e 100644
--- a/phpBB/includes/db/driver/mysqli.php
+++ b/phpBB/includes/db/driver/mysqli.php
@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
* MySQL 4.1+ or MySQL 5.0+
* @package dbal
*/
-class phpbb_db_driver_mysqli extends phpbb_db_driver
+class phpbb_db_driver_mysqli extends phpbb_db_driver_mysql_base
{
var $multi_insert = true;
var $connect_error = '';
@@ -103,6 +103,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
/**
* Version information about used database
+ * @param bool $raw if true, only return the fetched sql_server_version
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
@@ -127,14 +128,6 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
}
- /**
- * {@inheritDoc}
- */
- public function sql_concatenate($expr1, $expr2)
- {
- return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
- }
-
/**
* SQL Transaction
* @access private
@@ -217,25 +210,6 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
return $this->query_result;
}
- /**
- * Build LIMIT query
- */
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
- {
- $this->query_result = false;
-
- // if $total is set to 0 we do not want to limit the number of rows
- if ($total == 0)
- {
- // MySQL 4.1+ no longer supports -1 in limit queries
- $total = '18446744073709551615';
- }
-
- $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
-
- return $this->sql_query($query, $cache_ttl);
- }
-
/**
* Return number of affected rows
*/
@@ -327,101 +301,6 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
return @mysqli_real_escape_string($this->db_connect_id, $msg);
}
- /**
- * Gets the estimated number of rows in a specified table.
- *
- * @param string $table_name Table name
- *
- * @return string Number of rows in $table_name.
- * Prefixed with ~ if estimated (otherwise exact).
- *
- * @access public
- */
- function get_estimated_row_count($table_name)
- {
- $table_status = $this->get_table_status($table_name);
-
- if (isset($table_status['Engine']))
- {
- if ($table_status['Engine'] === 'MyISAM')
- {
- return $table_status['Rows'];
- }
- else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
- {
- return '~' . $table_status['Rows'];
- }
- }
-
- return parent::get_row_count($table_name);
- }
-
- /**
- * Gets the exact number of rows in a specified table.
- *
- * @param string $table_name Table name
- *
- * @return string Exact number of rows in $table_name.
- *
- * @access public
- */
- function get_row_count($table_name)
- {
- $table_status = $this->get_table_status($table_name);
-
- if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
- {
- return $table_status['Rows'];
- }
-
- return parent::get_row_count($table_name);
- }
-
- /**
- * Gets some information about the specified table.
- *
- * @param string $table_name Table name
- *
- * @return array
- *
- * @access protected
- */
- function get_table_status($table_name)
- {
- $sql = "SHOW TABLE STATUS
- LIKE '" . $this->sql_escape($table_name) . "'";
- $result = $this->sql_query($sql);
- $table_status = $this->sql_fetchrow($result);
- $this->sql_freeresult($result);
-
- return $table_status;
- }
-
- /**
- * Build LIKE expression
- * @access private
- */
- function _sql_like_expression($expression)
- {
- return $expression;
- }
-
- /**
- * Build db-specific query data
- * @access private
- */
- function _sql_custom_build($stage, $data)
- {
- switch ($stage)
- {
- case 'FROM':
- $data = '(' . $data . ')';
- break;
- }
-
- return $data;
- }
-
/**
* return sql error array
* @access private
--
cgit v1.2.1
From f831e3c66efe79841a0bcc01cf0b2d37e6d4e65c Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 22:52:17 +0200
Subject: [ticket/11495] Use unique properties for the column names
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 186 ++++++++++++++++++-------------------
phpBB/includes/nestedset/forum.php | 11 +--
2 files changed, 95 insertions(+), 102 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 7f4691b7e0..4dfe3e6203 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -28,15 +28,13 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* Column names in the table
- * @var array
+ * @var String
*/
- protected $table_columns = array(
- 'item_id' => 'item_id',
- 'left_id' => 'left_id',
- 'right_id' => 'right_id',
- 'parent_id' => 'parent_id',
- 'item_parents' => 'item_parents',
- );
+ protected $columns_item_id = 'item_id';
+ protected $columns_left_id = 'left_id';
+ protected $columns_right_id = 'right_id';
+ protected $columns_parent_id = 'parent_id';
+ protected $columns_item_parents = 'item_parents';
/**
* Additional SQL restrictions
@@ -72,18 +70,18 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
public function insert(array $additional_data)
{
$item_data = array_merge($additional_data, array(
- $this->table_columns['parent_id'] => 0,
- $this->table_columns['left_id'] => 0,
- $this->table_columns['right_id'] => 0,
- $this->table_columns['item_parents'] => '',
+ $this->column_parent_id => 0,
+ $this->column_left_id => 0,
+ $this->column_right_id => 0,
+ $this->column_item_parents => '',
));
- unset($item_data[$this->table_columns['item_id']]);
+ unset($item_data[$this->column_item_id]);
$sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
$this->db->sql_query($sql);
- $item_data[$this->table_columns['item_id']] = (int) $this->db->sql_nextid();
+ $item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
$item = new $this->item_class($item_data);
@@ -95,23 +93,23 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
public function add(phpbb_nestedset_item_interface $item)
{
- $sql = 'SELECT MAX(' . $this->table_columns['right_id'] . ') AS ' . $this->table_columns['right_id'] . '
+ $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
' . $this->get_sql_where('WHERE');
$result = $this->db->sql_query($sql);
- $current_max_right_id = (int) $this->db->sql_fetchfield($this->table_columns['right_id']);
+ $current_max_right_id = (int) $this->db->sql_fetchfield($this->column_right_id);
$this->db->sql_freeresult($result);
$update_item_data = array(
- $this->table_columns['parent_id'] => 0,
- $this->table_columns['left_id'] => $current_max_right_id + 1,
- $this->table_columns['right_id'] => $current_max_right_id + 2,
- $this->table_columns['item_parents'] => '',
+ $this->column_parent_id => 0,
+ $this->column_left_id => $current_max_right_id + 1,
+ $this->column_right_id => $current_max_right_id + 2,
+ $this->column_item_parents => '',
);
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . '
- WHERE ' . $this->table_columns['item_id'] . ' = ' . $item->get_item_id();
+ WHERE ' . $this->column_item_id . ' = ' . $item->get_item_id();
$this->db->sql_query($sql);
return $update_item_data;
@@ -144,7 +142,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$removed_items = $this->remove($item);
$sql = 'DELETE FROM ' . $this->table_name . '
- WHERE ' . $this->db->sql_in_set($this->table_columns['item_id'], $removed_items) . '
+ WHERE ' . $this->db->sql_in_set($this->column_item_id, $removed_items) . '
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
@@ -172,17 +170,17 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
$sql = 'SELECT ' . implode(', ', $this->table_columns) . '
FROM ' . $this->table_name . '
- WHERE ' . $this->table_columns['parent_id'] . ' = ' . $item->get_parent_id() . '
+ WHERE ' . $this->column_parent_id . ' = ' . $item->get_parent_id() . '
' . $this->get_sql_where() . '
AND ';
if ($action == 'move_up')
{
- $sql .= $this->table_columns['right_id'] . ' < ' . $item->get_right_id() . ' ORDER BY ' . $this->table_columns['right_id'] . ' DESC';
+ $sql .= $this->column_right_id . ' < ' . $item->get_right_id() . ' ORDER BY ' . $this->column_right_id . ' DESC';
}
else
{
- $sql .= $this->table_columns['left_id'] . ' > ' . $item->get_left_id() . ' ORDER BY ' . $this->table_columns['left_id'] . ' ASC';
+ $sql .= $this->column_left_id . ' > ' . $item->get_left_id() . ' ORDER BY ' . $this->column_left_id . ' ASC';
}
$result = $this->db->sql_query_limit($sql, $delta);
@@ -232,18 +230,18 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
// Now do the dirty job
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->table_columns['left_id'] . ' = ' . $this->table_columns['left_id'] . ' + CASE
- WHEN ' . $this->table_columns['left_id'] . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
+ SET ' . $this->column_left_id . ' = ' . $this->column_left_id . ' + CASE
+ WHEN ' . $this->column_left_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
ELSE {$diff_down}
END,
- " . $this->table_columns['right_id'] . ' = ' . $this->table_columns['right_id'] . ' + CASE
- WHEN ' . $this->table_columns['right_id'] . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
+ " . $this->column_right_id . ' = ' . $this->column_right_id . ' + CASE
+ WHEN ' . $this->column_right_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
ELSE {$diff_down}
END,
- " . $this->table_columns['item_parents'] . " = ''
+ " . $this->column_item_parents . " = ''
WHERE
- " . $this->table_columns['left_id'] . " BETWEEN {$left_id} AND {$right_id}
- AND " . $this->table_columns['right_id'] . " BETWEEN {$left_id} AND {$right_id}
+ " . $this->column_left_id . " BETWEEN {$left_id} AND {$right_id}
+ AND " . $this->column_right_id . " BETWEEN {$left_id} AND {$right_id}
" . $this->get_sql_where();
$this->db->sql_query($sql);
@@ -284,7 +282,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
}
$diff = sizeof($move_items) * 2;
- $sql_exclude_moved_items = $this->db->sql_in_set($this->table_columns['item_id'], $move_items, true);
+ $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true);
$this->db->sql_transaction('begin');
@@ -295,7 +293,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
// Retrieve new-parent again, it may have been changed...
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->table_columns['item_id'] . ' = ' . $new_parent->get_item_id();
+ WHERE ' . $this->column_item_id . ' = ' . $new_parent->get_item_id();
$result = $this->db->sql_query($sql);
$parent_data = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
@@ -321,7 +319,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
}
else
{
- $sql = 'SELECT MAX(' . $this->table_columns['right_id'] . ') AS ' . $this->table_columns['right_id'] . '
+ $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
WHERE ' . $sql_exclude_moved_items . '
' . $this->get_sql_where('AND');
@@ -329,15 +327,15 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $diff = ' + ' . ($row[$this->table_columns['right_id']] - $current_parent->get_left_id());
+ $diff = ' + ' . ($row[$this->column_right_id] - $current_parent->get_left_id());
}
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->table_columns['left_id'] . ' = ' . $this->table_columns['left_id'] . $diff . ',
- ' . $this->table_columns['right_id'] . ' = ' . $this->table_columns['right_id'] . $diff . ',
- ' . $this->table_columns['parent_id'] . ' = ' . $this->db->sql_case($this->table_columns['parent_id'] . ' = ' . $current_parent->get_item_id(), $new_parent->get_item_id(), $this->table_columns['parent_id']) . ',
- ' . $this->table_columns['item_parents'] . " = ''
- WHERE " . $this->db->sql_in_set($this->table_columns['item_id'], $move_items) . '
+ SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
+ ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent->get_item_id(), $new_parent->get_item_id(), $this->column_parent_id) . ',
+ ' . $this->column_item_parents . " = ''
+ WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
@@ -359,7 +357,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
}
$diff = sizeof($move_items) * 2;
- $sql_exclude_moved_items = $this->db->sql_in_set($this->table_columns['item_id'], $move_items, true);
+ $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true);
$this->db->sql_transaction('begin');
@@ -370,7 +368,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
// Retrieve new-parent again, it may have been changed...
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->table_columns['item_id'] . ' = ' . $new_parent->get_item_id();
+ WHERE ' . $this->column_item_id . ' = ' . $new_parent->get_item_id();
$result = $this->db->sql_query($sql);
$parent_data = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
@@ -396,7 +394,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
}
else
{
- $sql = 'SELECT MAX(' . $this->table_columns['right_id'] . ') AS ' . $this->table_columns['right_id'] . '
+ $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
WHERE ' . $sql_exclude_moved_items . '
' . $this->get_sql_where('AND');
@@ -404,15 +402,15 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $diff = ' + ' . ($row[$this->table_columns['right_id']] - $item->get_left_id() + 1);
+ $diff = ' + ' . ($row[$this->column_right_id] - $item->get_left_id() + 1);
}
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->table_columns['left_id'] . ' = ' . $this->table_columns['left_id'] . $diff . ',
- ' . $this->table_columns['right_id'] . ' = ' . $this->table_columns['right_id'] . $diff . ',
- ' . $this->table_columns['parent_id'] . ' = ' . $this->db->sql_case($this->table_columns['item_id'] . ' = ' . $item->get_item_id(), $new_parent->get_item_id(), $this->table_columns['parent_id']) . ',
- ' . $this->table_columns['item_parents'] . " = ''
- WHERE " . $this->db->sql_in_set($this->table_columns['item_id'], $move_items) . '
+ SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
+ ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item->get_item_id(), $new_parent->get_item_id(), $this->column_parent_id) . ',
+ ' . $this->column_item_parents . " = ''
+ WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
@@ -429,16 +427,16 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
switch ($type)
{
case 'parents':
- $condition = 'i1.' . $this->table_columns['left_id'] . ' BETWEEN i2.' . $this->table_columns['left_id'] . ' AND i2.' . $this->table_columns['right_id'] . '';
+ $condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
break;
case 'children':
- $condition = 'i2.' . $this->table_columns['left_id'] . ' BETWEEN i1.' . $this->table_columns['left_id'] . ' AND i1.' . $this->table_columns['right_id'] . '';
+ $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
break;
default:
- $condition = 'i2.' . $this->table_columns['left_id'] . ' BETWEEN i1.' . $this->table_columns['left_id'] . ' AND i1.' . $this->table_columns['right_id'] . '
- OR i1.' . $this->table_columns['left_id'] . ' BETWEEN i2.' . $this->table_columns['left_id'] . ' AND i2.' . $this->table_columns['right_id'];
+ $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
+ OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
break;
}
@@ -448,19 +446,19 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
FROM ' . $this->table_name . ' i1
LEFT JOIN ' . $this->table_name . " i2
ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
- WHERE i1.' . $this->table_columns['item_id'] . ' = ' . $item->get_item_id() . '
+ WHERE i1.' . $this->column_item_id . ' = ' . $item->get_item_id() . '
' . $this->get_sql_where('AND', 'i1.') . '
- ORDER BY i2.' . $this->table_columns['left_id'] . ' ' . ($order_desc ? 'ASC' : 'DESC');
+ ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (!$include_item && $item->get_item_id() === (int) $row[$this->table_columns['item_id']])
+ if (!$include_item && $item->get_item_id() === (int) $row[$this->column_item_id])
{
continue;
}
- $rows[$row[$this->table_columns['item_id']]] = $row;
+ $rows[$row[$this->column_item_id]] = $row;
}
$this->db->sql_freeresult($result);
@@ -483,23 +481,23 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
$sql = 'SELECT ' . implode(', ', $this->item_basic_data) . '
FROM ' . $this->table_name . '
- WHERE ' . $this->table_columns['left_id'] . ' < ' . $item->get_left_id() . '
- AND ' . $this->table_columns['right_id'] . ' > ' . $item->get_right_id() . '
+ WHERE ' . $this->column_left_id . ' < ' . $item->get_left_id() . '
+ AND ' . $this->column_right_id . ' > ' . $item->get_right_id() . '
' . $this->get_sql_where('AND') . '
- ORDER BY ' . $this->table_columns['left_id'] . ' ASC';
+ ORDER BY ' . $this->column_left_id . ' ASC';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- $parents[$row[$this->table_columns['item_id']]] = $row;
+ $parents[$row[$this->column_item_id]] = $row;
}
$this->db->sql_freeresult($result);
$item_parents = serialize($parents);
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->table_columns['item_parents'] . " = '" . $this->db->sql_escape($item_parents) . "'
- WHERE " . $this->table_columns['parent_id'] . ' = ' . $item->get_parent_id();
+ SET ' . $this->column_item_parents . " = '" . $this->db->sql_escape($item_parents) . "'
+ WHERE " . $this->column_parent_id . ' = ' . $item->get_parent_id();
$this->db->sql_query($sql);
}
else
@@ -522,16 +520,16 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
protected function remove_subset(array $subset_items, phpbb_nestedset_item_interface $bounding_item, $set_subset_zero = true)
{
$diff = sizeof($subset_items) * 2;
- $sql_subset_items = $this->db->sql_in_set($this->table_columns['item_id'], $subset_items);
- $sql_not_subset_items = $this->db->sql_in_set($this->table_columns['item_id'], $subset_items, true);
+ $sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
+ $sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
- $sql_is_parent = $this->table_columns['left_id'] . ' <= ' . $bounding_item->get_right_id() . '
- AND ' . $this->table_columns['right_id'] . ' >= ' . $bounding_item->get_right_id();
+ $sql_is_parent = $this->column_left_id . ' <= ' . $bounding_item->get_right_id() . '
+ AND ' . $this->column_right_id . ' >= ' . $bounding_item->get_right_id();
- $sql_is_right = $this->table_columns['left_id'] . ' > ' . $bounding_item->get_right_id();
+ $sql_is_right = $this->column_left_id . ' > ' . $bounding_item->get_right_id();
- $set_left_id = $this->db->sql_case($sql_is_right, $this->table_columns['left_id'] . ' - ' . $diff, $this->table_columns['left_id']);
- $set_right_id = $this->db->sql_case($sql_is_parent . ' OR ' . $sql_is_right, $this->table_columns['right_id'] . ' - ' . $diff, $this->table_columns['right_id']);
+ $set_left_id = $this->db->sql_case($sql_is_right, $this->column_left_id . ' - ' . $diff, $this->column_left_id);
+ $set_right_id = $this->db->sql_case($sql_is_parent . ' OR ' . $sql_is_right, $this->column_right_id . ' - ' . $diff, $this->column_right_id);
if ($set_subset_zero)
{
@@ -540,10 +538,10 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
}
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->table_columns['left_id'] . ' = ' . $set_left_id . ',
- ' . $this->table_columns['right_id'] . ' = ' . $set_right_id . ',
- ' . (($set_subset_zero) ? $this->table_columns['parent_id'] . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->table_columns['parent_id']) . ',' : '') . '
- ' . $this->table_columns['item_parents'] . " = ''
+ SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
+ ' . $this->column_right_id . ' = ' . $set_right_id . ',
+ ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->column_parent_id) . ',' : '') . '
+ ' . $this->column_item_parents . " = ''
" . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
$this->db->sql_query($sql);
}
@@ -558,15 +556,15 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
protected function prepare_adding_subset(array $subset_items, phpbb_nestedset_item_interface $new_parent)
{
$diff = sizeof($subset_items) * 2;
- $sql_not_subset_items = $this->db->sql_in_set($this->table_columns['item_id'], $subset_items, true);
+ $sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
- $set_left_id = $this->db->sql_case($this->table_columns['left_id'] . ' > ' . $new_parent->get_right_id(), $this->table_columns['left_id'] . ' + ' . $diff, $this->table_columns['left_id']);
- $set_right_id = $this->db->sql_case($this->table_columns['right_id'] . ' >= ' . $new_parent->get_right_id(), $this->table_columns['right_id'] . ' + ' . $diff, $this->table_columns['right_id']);
+ $set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . $new_parent->get_right_id(), $this->column_left_id . ' + ' . $diff, $this->column_left_id);
+ $set_right_id = $this->db->sql_case($this->column_right_id . ' >= ' . $new_parent->get_right_id(), $this->column_right_id . ' + ' . $diff, $this->column_right_id);
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->table_columns['left_id'] . ' = ' . $set_left_id . ',
- ' . $this->table_columns['right_id'] . ' = ' . $set_right_id . ',
- ' . $this->table_columns['item_parents'] . " = ''
+ SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
+ ' . $this->column_right_id . ' = ' . $set_right_id . ',
+ ' . $this->column_item_parents . " = ''
WHERE " . $sql_not_subset_items . '
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
@@ -583,9 +581,9 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', array(
- $this->table_columns['left_id'] => 0,
- $this->table_columns['right_id'] => 0,
- $this->table_columns['item_parents'] => '',
+ $this->column_left_id => 0,
+ $this->column_right_id => 0,
+ $this->column_item_parents => '',
)) . '
' . $this->get_sql_where('WHERE');
$this->db->sql_query($sql);
@@ -593,34 +591,34 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->table_columns['parent_id'] . ' = ' . (int) $parent_id . '
+ WHERE ' . $this->column_parent_id . ' = ' . (int) $parent_id . '
' . $this->get_sql_where('AND') . '
- ORDER BY ' . $this->table_columns['left_id'] . ', ' . $this->table_columns['item_id'] . ' ASC';
+ ORDER BY ' . $this->column_left_id . ', ' . $this->column_item_id . ' ASC';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
// First we update the left_id for this module
- if ($row[$this->table_columns['left_id']] != $new_id)
+ if ($row[$this->column_left_id] != $new_id)
{
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', array(
- $this->table_columns['left_id'] => $new_id,
- $this->table_columns['item_parents'] => '',
+ $this->column_left_id => $new_id,
+ $this->column_item_parents => '',
)) . '
- WHERE ' . $this->table_columns['item_id'] . ' = ' . $row[$this->table_columns['item_id']];
+ WHERE ' . $this->column_item_id . ' = ' . $row[$this->column_item_id];
$this->db->sql_query($sql);
}
$new_id++;
// Then we go through any children and update their left/right id's
- $new_id = $this->recalculate_nested_set($new_id, $row[$this->table_columns['item_id']]);
+ $new_id = $this->recalculate_nested_set($new_id, $row[$this->column_item_id]);
// Then we come back and update the right_id for this module
- if ($row[$this->table_columns['right_id']] != $new_id)
+ if ($row[$this->column_right_id] != $new_id)
{
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->db->sql_build_array('UPDATE', array($this->table_columns['right_id'] => $new_id)) . '
- WHERE ' . $this->table_columns['item_id'] . ' = ' . $row[$this->table_columns['item_id']];
+ SET ' . $this->db->sql_build_array('UPDATE', array($this->column_right_id => $new_id)) . '
+ WHERE ' . $this->column_item_id . ' = ' . $row[$this->column_item_id];
$this->db->sql_query($sql);
}
$new_id++;
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
index 7ad4d2c85e..b1df3c7e45 100644
--- a/phpBB/includes/nestedset/forum.php
+++ b/phpBB/includes/nestedset/forum.php
@@ -31,15 +31,10 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
/**
* Column names in the table
- * @var array
+ * @var String
*/
- protected $table_columns = array(
- 'item_id' => 'forum_id',
- 'left_id' => 'left_id',
- 'right_id' => 'right_id',
- 'parent_id' => 'parent_id',
- 'item_parents' => 'forum_parents',
- );
+ protected $columns_item_id = 'forum_id';
+ protected $columns_item_parents = 'forum_parents';
/**
* Additional SQL restrictions
--
cgit v1.2.1
From 5c379db085bab4ff0f807a9e7dfe6edb52ef25ab Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Wed, 17 Apr 2013 22:56:12 +0200
Subject: [ticket/11495] Fix description of get_sql_where
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 4dfe3e6203..ae6a77dc8d 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -50,9 +50,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
protected $item_basic_data = array('*');
/**
- * Delete an item from the nested set (also deletes the rows form the table)
- *
- * Also deletes all subitems from the nested set
+ * Returns additional sql where restrictions
*
* @param string $operator SQL operator that needs to be prepended to sql_where,
* if it is not empty.
--
cgit v1.2.1
From 8c3443ba996c57a0420e4559022c97c2547404c0 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 00:13:19 +0200
Subject: [ticket/11495] Use array directly instead of
phpbb_nestedset_item_interface
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 150 ++++++++++++++++-----------------
phpBB/includes/nestedset/forum.php | 4 +-
phpBB/includes/nestedset/interface.php | 46 +++++-----
3 files changed, 97 insertions(+), 103 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index ae6a77dc8d..56422f52a5 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -81,15 +81,13 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
- $item = new $this->item_class($item_data);
-
- return array_merge($item_data, $this->add($item));
+ return array_merge($item_data, $this->add($item_data));
}
/**
* @inheritdoc
*/
- public function add(phpbb_nestedset_item_interface $item)
+ public function add(array $item)
{
$sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
@@ -107,7 +105,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . '
- WHERE ' . $this->column_item_id . ' = ' . $item->get_item_id();
+ WHERE ' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id];
$this->db->sql_query($sql);
return $update_item_data;
@@ -116,15 +114,15 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function remove(phpbb_nestedset_item_interface $item)
+ public function remove(array $item)
{
- if ($item->has_children())
+ if ($item[$this->column_right_id] - $item[$this->column_left_id] > 1)
{
$items = array_keys($this->get_branch_data($item, 'children'));
}
else
{
- $items = array($item->get_item_id());
+ $items = array((int) $item[$this->column_item_id]);
}
$this->remove_subset($items, $item);
@@ -135,7 +133,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function delete(phpbb_nestedset_item_interface $item)
+ public function delete(array $item)
{
$removed_items = $this->remove($item);
@@ -150,7 +148,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function move(phpbb_nestedset_item_interface $item, $delta)
+ public function move(array $item, $delta)
{
if ($delta == 0)
{
@@ -168,17 +166,17 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
$sql = 'SELECT ' . implode(', ', $this->table_columns) . '
FROM ' . $this->table_name . '
- WHERE ' . $this->column_parent_id . ' = ' . $item->get_parent_id() . '
+ WHERE ' . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id] . '
' . $this->get_sql_where() . '
AND ';
if ($action == 'move_up')
{
- $sql .= $this->column_right_id . ' < ' . $item->get_right_id() . ' ORDER BY ' . $this->column_right_id . ' DESC';
+ $sql .= $this->column_right_id . ' < ' . (int) $item[$this->column_right_id] . ' ORDER BY ' . $this->column_right_id . ' DESC';
}
else
{
- $sql .= $this->column_left_id . ' > ' . $item->get_left_id() . ' ORDER BY ' . $this->column_left_id . ' ASC';
+ $sql .= $this->column_left_id . ' > ' . (int) $item[$this->column_left_id] . ' ORDER BY ' . $this->column_left_id . ' ASC';
}
$result = $this->db->sql_query_limit($sql, $delta);
@@ -186,7 +184,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$target = null;
while ($row = $this->db->sql_fetchrow($result))
{
- $target = new $this->item_class($row);
+ $target = $row;
}
$this->db->sql_freeresult($result);
@@ -205,25 +203,25 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
if ($action == 'move_up')
{
- $left_id = $target->get_left_id();
- $right_id = $item->get_right_id();
+ $left_id = $target[$this->column_left_id];
+ $right_id = (int) $item[$this->column_right_id];
- $diff_up = $item->get_left_id() - $target->get_left_id();
- $diff_down = $item->get_right_id() + 1 - $item->get_left_id();
+ $diff_up = (int) $item[$this->column_left_id] - $target[$this->column_left_id];
+ $diff_down = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
- $move_up_left = $item->get_left_id();
- $move_up_right = $item->get_right_id();
+ $move_up_left = (int) $item[$this->column_left_id];
+ $move_up_right = (int) $item[$this->column_right_id];
}
else
{
- $left_id = $item->get_left_id();
- $right_id = $target->get_right_id();
+ $left_id = (int) $item[$this->column_left_id];
+ $right_id = $target[$this->column_right_id];
- $diff_up = $item->get_right_id() + 1 - $item->get_left_id();
- $diff_down = $target->get_right_id() - $item->get_right_id();
+ $diff_up = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
+ $diff_down = $target[$this->column_right_id] - (int) $item[$this->column_right_id];
- $move_up_left = $item->get_right_id() + 1;
- $move_up_right = $target->get_right_id();
+ $move_up_left = (int) $item[$this->column_right_id] + 1;
+ $move_up_right = $target[$this->column_right_id];
}
// Now do the dirty job
@@ -249,7 +247,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function move_down(phpbb_nestedset_item_interface $item)
+ public function move_down(array $item)
{
return $this->move($item, -1);
}
@@ -257,7 +255,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function move_up(phpbb_nestedset_item_interface $item)
+ public function move_up(array $item)
{
return $this->move($item, 1);
}
@@ -265,16 +263,16 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function move_children(phpbb_nestedset_item_interface $current_parent, phpbb_nestedset_item_interface $new_parent)
+ public function move_children(array $current_parent, array $new_parent)
{
- if (!$current_parent->has_children() || !$current_parent->get_item_id() || $current_parent->get_item_id() == $new_parent->get_item_id())
+ if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1 || !$current_parent[$this->column_item_id] || $current_parent[$this->column_item_id] == $new_parent[$this->column_item_id])
{
return false;
}
$move_items = array_keys($this->get_branch_data($current_parent, 'children', true, false));
- if (in_array($new_parent->get_item_id(), $move_items))
+ if (in_array($new_parent[$this->column_item_id], $move_items))
{
throw new phpbb_nestedset_exception('INVALID_PARENT');
}
@@ -286,33 +284,31 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->remove_subset($move_items, $current_parent, false);
- if ($new_parent->get_item_id())
+ if ($new_parent[$this->column_item_id])
{
// Retrieve new-parent again, it may have been changed...
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . $new_parent->get_item_id();
+ WHERE ' . $this->column_item_id . ' = ' . (int) $new_parent[$this->column_item_id];
$result = $this->db->sql_query($sql);
- $parent_data = $this->db->sql_fetchrow($result);
+ $new_parent = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- if (!$parent_data)
+ if (!$new_parent)
{
$this->db->sql_transaction('rollback');
throw new phpbb_nestedset_exception('INVALID_PARENT');
}
- $new_parent = new $this->item_class($parent_data);
-
$new_right_id = $this->prepare_adding_subset($move_items, $new_parent);
- if ($new_right_id > $current_parent->get_right_id())
+ if ($new_right_id > $current_parent[$this->column_right_id])
{
- $diff = ' + ' . ($new_right_id - $current_parent->get_right_id());
+ $diff = ' + ' . ($new_right_id - $current_parent[$this->column_right_id]);
}
else
{
- $diff = ' - ' . abs($new_right_id - $current_parent->get_right_id());
+ $diff = ' - ' . abs($new_right_id - $current_parent[$this->column_right_id]);
}
}
else
@@ -325,13 +321,13 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $diff = ' + ' . ($row[$this->column_right_id] - $current_parent->get_left_id());
+ $diff = ' + ' . ($row[$this->column_right_id] - $current_parent[$this->column_left_id]);
}
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
- ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent->get_item_id(), $new_parent->get_item_id(), $this->column_parent_id) . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . (int) $current_parent[$this->column_item_id], (int) $new_parent[$this->column_item_id], $this->column_parent_id) . ',
' . $this->column_item_parents . " = ''
WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND');
@@ -345,11 +341,11 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function set_parent(phpbb_nestedset_item_interface $item, phpbb_nestedset_item_interface $new_parent)
+ public function set_parent(array $item, array $new_parent)
{
$move_items = array_keys($this->get_branch_data($item, 'children'));
- if (in_array($new_parent->get_item_id(), $move_items))
+ if (in_array($new_parent[$this->column_item_id], $move_items))
{
throw new phpbb_nestedset_exception('INVALID_PARENT');
}
@@ -361,33 +357,31 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->remove_subset($move_items, $item, false);
- if ($new_parent->get_item_id())
+ if ($new_parent[$this->column_item_id])
{
// Retrieve new-parent again, it may have been changed...
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . $new_parent->get_item_id();
+ WHERE ' . $this->column_item_id . ' = ' . (int) $new_parent[$this->column_item_id];
$result = $this->db->sql_query($sql);
- $parent_data = $this->db->sql_fetchrow($result);
+ $new_parent = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- if (!$parent_data)
+ if (!$new_parent)
{
$this->db->sql_transaction('rollback');
throw new phpbb_nestedset_exception('INVALID_PARENT');
}
- $new_parent = new $this->item_class($parent_data);
-
$new_right_id = $this->prepare_adding_subset($move_items, $new_parent);
- if ($new_right_id > $item->get_right_id())
+ if ($new_right_id > (int) $item[$this->column_right_id])
{
- $diff = ' + ' . ($new_right_id - $item->get_right_id() - 1);
+ $diff = ' + ' . ($new_right_id - (int) $item[$this->column_right_id] - 1);
}
else
{
- $diff = ' - ' . abs($new_right_id - $item->get_right_id() - 1);
+ $diff = ' - ' . abs($new_right_id - (int) $item[$this->column_right_id] - 1);
}
}
else
@@ -400,13 +394,13 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $diff = ' + ' . ($row[$this->column_right_id] - $item->get_left_id() + 1);
+ $diff = ' + ' . ($row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
}
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
- ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item->get_item_id(), $new_parent->get_item_id(), $this->column_parent_id) . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . (int) $item[$this->column_item_id], $new_parent[$this->column_item_id], $this->column_parent_id) . ',
' . $this->column_item_parents . " = ''
WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND');
@@ -420,7 +414,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function get_branch_data(phpbb_nestedset_item_interface $item, $type = 'all', $order_desc = true, $include_item = true)
+ public function get_branch_data(array $item, $type = 'all', $order_desc = true, $include_item = true)
{
switch ($type)
{
@@ -444,19 +438,19 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
FROM ' . $this->table_name . ' i1
LEFT JOIN ' . $this->table_name . " i2
ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
- WHERE i1.' . $this->column_item_id . ' = ' . $item->get_item_id() . '
+ WHERE i1.' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id] . '
' . $this->get_sql_where('AND', 'i1.') . '
ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (!$include_item && $item->get_item_id() === (int) $row[$this->column_item_id])
+ if (!$include_item && $item[$this->column_item_id] == $row[$this->column_item_id])
{
continue;
}
- $rows[$row[$this->column_item_id]] = $row;
+ $rows[(int) $row[$this->column_item_id]] = $row;
}
$this->db->sql_freeresult($result);
@@ -470,17 +464,17 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*
* @inheritdoc
*/
- public function get_parent_data(phpbb_nestedset_item_interface $item)
+ public function get_parent_data(array $item)
{
$parents = array();
- if ($item->get_parent_id())
+ if ((int) $item[$this->column_parent_id])
{
- if (!$item->get_item_parents_data())
+ if (!$item[$this->column_item_parents])
{
$sql = 'SELECT ' . implode(', ', $this->item_basic_data) . '
FROM ' . $this->table_name . '
- WHERE ' . $this->column_left_id . ' < ' . $item->get_left_id() . '
- AND ' . $this->column_right_id . ' > ' . $item->get_right_id() . '
+ WHERE ' . $this->column_left_id . ' < ' . (int) $item[$this->column_left_id] . '
+ AND ' . $this->column_right_id . ' > ' . (int) $item[$this->column_right_id] . '
' . $this->get_sql_where('AND') . '
ORDER BY ' . $this->column_left_id . ' ASC';
$result = $this->db->sql_query($sql);
@@ -495,12 +489,12 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_item_parents . " = '" . $this->db->sql_escape($item_parents) . "'
- WHERE " . $this->column_parent_id . ' = ' . $item->get_parent_id();
+ WHERE " . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id];
$this->db->sql_query($sql);
}
else
{
- $parents = unserialize($item->get_item_parents_data());
+ $parents = unserialize($item[$this->column_item_parents]);
}
}
@@ -511,20 +505,20 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* Remove a subset from the nested set
*
* @param array $subset_items Subset of items to remove
- * @param phpbb_nestedset_item_interface $bounding_item Item containing the right bound of the subset
+ * @param array $bounding_item Item containing the right bound of the subset
* @param bool $set_subset_zero Should the parent, left and right id of the item be set to 0, or kept unchanged?
* @return null
*/
- protected function remove_subset(array $subset_items, phpbb_nestedset_item_interface $bounding_item, $set_subset_zero = true)
+ protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true)
{
$diff = sizeof($subset_items) * 2;
$sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
$sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
- $sql_is_parent = $this->column_left_id . ' <= ' . $bounding_item->get_right_id() . '
- AND ' . $this->column_right_id . ' >= ' . $bounding_item->get_right_id();
+ $sql_is_parent = $this->column_left_id . ' <= ' . (int) $bounding_item[$this->column_right_id] . '
+ AND ' . $this->column_right_id . ' >= ' . (int) $bounding_item[$this->column_right_id];
- $sql_is_right = $this->column_left_id . ' > ' . $bounding_item->get_right_id();
+ $sql_is_right = $this->column_left_id . ' > ' . (int) $bounding_item[$this->column_right_id];
$set_left_id = $this->db->sql_case($sql_is_right, $this->column_left_id . ' - ' . $diff, $this->column_left_id);
$set_right_id = $this->db->sql_case($sql_is_parent . ' OR ' . $sql_is_right, $this->column_right_id . ' - ' . $diff, $this->column_right_id);
@@ -548,16 +542,16 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* Add a subset to the nested set
*
* @param array $subset_items Subset of items to add
- * @param phpbb_nestedset_item_interface $new_parent Item containing the right bound of the new parent
+ * @param array $new_parent Item containing the right bound of the new parent
* @return int New right id of the parent item
*/
- protected function prepare_adding_subset(array $subset_items, phpbb_nestedset_item_interface $new_parent)
+ protected function prepare_adding_subset(array $subset_items, array $new_parent)
{
$diff = sizeof($subset_items) * 2;
$sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
- $set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . $new_parent->get_right_id(), $this->column_left_id . ' + ' . $diff, $this->column_left_id);
- $set_right_id = $this->db->sql_case($this->column_right_id . ' >= ' . $new_parent->get_right_id(), $this->column_right_id . ' + ' . $diff, $this->column_right_id);
+ $set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . (int) $new_parent[$this->column_right_id], $this->column_left_id . ' + ' . $diff, $this->column_left_id);
+ $set_right_id = $this->db->sql_case($this->column_right_id . ' >= ' . (int) $new_parent[$this->column_right_id], $this->column_right_id . ' + ' . $diff, $this->column_right_id);
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
@@ -567,7 +561,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
- return $new_parent->get_right_id() + $diff;
+ return $new_parent[$this->column_right_id] + $diff;
}
/**
@@ -603,7 +597,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->column_left_id => $new_id,
$this->column_item_parents => '',
)) . '
- WHERE ' . $this->column_item_id . ' = ' . $row[$this->column_item_id];
+ WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
$this->db->sql_query($sql);
}
$new_id++;
@@ -616,7 +610,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', array($this->column_right_id => $new_id)) . '
- WHERE ' . $this->column_item_id . ' = ' . $row[$this->column_item_id];
+ WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
$this->db->sql_query($sql);
}
$new_id++;
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
index b1df3c7e45..e00754eb68 100644
--- a/phpBB/includes/nestedset/forum.php
+++ b/phpBB/includes/nestedset/forum.php
@@ -67,7 +67,7 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
/**
* @inheritdoc
*/
- public function move_children(phpbb_nestedset_item_interface $current_parent, phpbb_nestedset_item_interface $new_parent)
+ public function move_children(array $current_parent, array $new_parent)
{
while (!$this->lock->acquire())
{
@@ -92,7 +92,7 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
/**
* @inheritdoc
*/
- public function set_parent(phpbb_nestedset_item_interface $item, phpbb_nestedset_item_interface $new_parent)
+ public function set_parent(array $item, array $new_parent)
{
while (!$this->lock->acquire())
{
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index 7ef6ff87bb..2d353544dd 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -20,7 +20,7 @@ interface phpbb_nestedset_interface
/**
* Insert an item into the nested set (also insert the rows into the table)
*
- * @param phpbb_nestedset_item_interface $item The item to be added
+ * @param array $item The item to be added
* @return array Array with item data as set in the database
*/
public function insert(array $additional_data);
@@ -28,96 +28,96 @@ interface phpbb_nestedset_interface
/**
* Add an item at the end of the nested set
*
- * @param phpbb_nestedset_item_interface $item The item to be added
+ * @param array $item The item to be added
* @return bool True if the item was added
*/
- public function add(phpbb_nestedset_item_interface $item);
+ public function add(array $item);
/**
* Remove an item from the nested set
*
* Also removes all subitems from the nested set
*
- * @param phpbb_nestedset_item_interface $item The item to be removed
+ * @param array $item The item to be removed
* @return array Items that have been removed
*/
- public function remove(phpbb_nestedset_item_interface $item);
+ public function remove(array $item);
/**
* Delete an item from the nested set (also deletes the rows form the table)
*
* Also deletes all subitems from the nested set
*
- * @param phpbb_nestedset_item_interface $item The item to be deleted
+ * @param array $item The item to be deleted
* @return array Items that have been deleted
*/
- public function delete(phpbb_nestedset_item_interface $item);
+ public function delete(array $item);
/**
* Move an item by a given delta
*
- * @param phpbb_nestedset_item_interface $item The item to be moved
+ * @param array $item The item to be moved
* @param int $delta Number of steps to move this item, < 0 => down, > 0 => up
* @return bool True if the item was moved
*/
- public function move(phpbb_nestedset_item_interface $item, $delta);
+ public function move(array $item, $delta);
/**
* Move an item down by 1
*
- * @param phpbb_nestedset_item_interface $item The item to be moved
+ * @param array $item The item to be moved
* @return bool True if the item was moved
*/
- public function move_down(phpbb_nestedset_item_interface $item);
+ public function move_down(array $item);
/**
* Move an item up by 1
*
- * @param phpbb_nestedset_item_interface $item The item to be moved
+ * @param array $item The item to be moved
* @return bool True if the item was moved
*/
- public function move_up(phpbb_nestedset_item_interface $item);
+ public function move_up(array $item);
/**
* Moves all children of one item to another item
*
- * @param phpbb_nestedset_item_interface $current_parent The current parent item
- * @param phpbb_nestedset_item_interface $new_parent The new parent item
+ * @param array $current_parent The current parent item
+ * @param array $new_parent The new parent item
* @return bool True if any items where moved
*/
- public function move_children(phpbb_nestedset_item_interface $current_parent, phpbb_nestedset_item_interface $new_parent);
+ public function move_children(array $current_parent, array $new_parent);
/**
* Set the parent item
*
- * @param phpbb_nestedset_item_interface $item The item to be moved
- * @param phpbb_nestedset_item_interface $new_parent The new parent item
+ * @param array $item The item to be moved
+ * @param array $new_parent The new parent item
* @return bool True if the parent was set successfully
*/
- public function set_parent(phpbb_nestedset_item_interface $item, phpbb_nestedset_item_interface $new_parent);
+ public function set_parent(array $item, array $new_parent);
/**
* Get branch of the item
*
* This method can return all parents, children or both of the given item
*
- * @param phpbb_nestedset_item_interface $item The item to get the branch from
+ * @param array $item The item to get the branch from
* @param string $type One of all|parent|children
* @param bool $order_desc Order the items descending (most outer parent first)
* @param bool $include_item Should the given item be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_branch_data(phpbb_nestedset_item_interface $item, $type, $order_desc, $include_item);
+ public function get_branch_data(array $item, $type, $order_desc, $include_item);
/**
* Get base information of parent items
*
- * @param phpbb_nestedset_item_interface $item The item to get the parents from
+ * @param array $item The item to get the parents from
* @return array Array of items (containing basic columns from the item table)
* ID => Item data
*/
- public function get_parent_data(phpbb_nestedset_item_interface $item);
+ public function get_parent_data(array $item);
/**
* Recalculate Nested Sets
--
cgit v1.2.1
From 86937e03ec4af92b6467427d9ee69467139f8119 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 00:15:02 +0200
Subject: [ticket/11495] Remove item classes
PHPBB3-11495
---
phpBB/includes/nestedset/item/base.php | 82 -----------------------------
phpBB/includes/nestedset/item/forum.php | 28 ----------
phpBB/includes/nestedset/item/interface.php | 61 ---------------------
3 files changed, 171 deletions(-)
delete mode 100644 phpBB/includes/nestedset/item/base.php
delete mode 100644 phpBB/includes/nestedset/item/forum.php
delete mode 100644 phpBB/includes/nestedset/item/interface.php
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/item/base.php b/phpBB/includes/nestedset/item/base.php
deleted file mode 100644
index c3a7600827..0000000000
--- a/phpBB/includes/nestedset/item/base.php
+++ /dev/null
@@ -1,82 +0,0 @@
-item_id;
- }
-
- /**
- * @inheritdoc
- */
- public function get_parent_id()
- {
- return (int) $this->parent_id;
- }
-
- /**
- * @inheritdoc
- */
- public function get_item_parents_data()
- {
- return (string) $this->item_parents_data;
- }
-
- /**
- * @inheritdoc
- */
- public function get_left_id()
- {
- return (int) $this->left_id;
- }
-
- /**
- * @inheritdoc
- */
- public function get_right_id()
- {
- return (int) $this->right_id;
- }
-
- /**
- * @inheritdoc
- */
- public function has_children()
- {
- return $this->right_id - $this->left_id > 1;
- }
-}
diff --git a/phpBB/includes/nestedset/item/forum.php b/phpBB/includes/nestedset/item/forum.php
deleted file mode 100644
index 9475517999..0000000000
--- a/phpBB/includes/nestedset/item/forum.php
+++ /dev/null
@@ -1,28 +0,0 @@
-item_id = (int) $forum_row['forum_id'];
- $this->parent_id = (int) $forum_row['parent_id'];
- $this->left_id = (int) $forum_row['left_id'];
- $this->right_id = (int) $forum_row['right_id'];
- $this->item_parents_data = (string) $forum_row['forum_parents'];
- }
-}
diff --git a/phpBB/includes/nestedset/item/interface.php b/phpBB/includes/nestedset/item/interface.php
deleted file mode 100644
index 18206d752e..0000000000
--- a/phpBB/includes/nestedset/item/interface.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
Date: Thu, 18 Apr 2013 00:34:09 +0200
Subject: [ticket/11495] Fix column variable names
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 10 +++++-----
phpBB/includes/nestedset/forum.php | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 56422f52a5..630512d713 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -30,11 +30,11 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* Column names in the table
* @var String
*/
- protected $columns_item_id = 'item_id';
- protected $columns_left_id = 'left_id';
- protected $columns_right_id = 'right_id';
- protected $columns_parent_id = 'parent_id';
- protected $columns_item_parents = 'item_parents';
+ protected $column_item_id = 'item_id';
+ protected $column_left_id = 'left_id';
+ protected $column_right_id = 'right_id';
+ protected $column_parent_id = 'parent_id';
+ protected $column_item_parents = 'item_parents';
/**
* Additional SQL restrictions
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
index e00754eb68..18936c1c55 100644
--- a/phpBB/includes/nestedset/forum.php
+++ b/phpBB/includes/nestedset/forum.php
@@ -33,8 +33,8 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
* Column names in the table
* @var String
*/
- protected $columns_item_id = 'forum_id';
- protected $columns_item_parents = 'forum_parents';
+ protected $column_item_id = 'forum_id';
+ protected $column_item_parents = 'forum_parents';
/**
* Additional SQL restrictions
--
cgit v1.2.1
From 514bcb2fac1a11a53e20c789ea95be6207c38e80 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 00:50:30 +0200
Subject: [ticket/11495] Move nestedset default values to new method
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 630512d713..5673a913fc 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -67,14 +67,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
public function insert(array $additional_data)
{
- $item_data = array_merge($additional_data, array(
- $this->column_parent_id => 0,
- $this->column_left_id => 0,
- $this->column_right_id => 0,
- $this->column_item_parents => '',
- ));
-
- unset($item_data[$this->column_item_id]);
+ $item_data = $this->reset_nestedset_values($additional_data);
$sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
$this->db->sql_query($sql);
@@ -564,6 +557,26 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
return $new_parent[$this->column_right_id] + $diff;
}
+ /**
+ * Resets values required for the nested set system
+ *
+ * @param array $item Original item data
+ * @return array Original item data + nested set defaults
+ */
+ protected function reset_nestedset_values(array $item)
+ {
+ $item_data = array_merge($item, array(
+ $this->column_parent_id => 0,
+ $this->column_left_id => 0,
+ $this->column_right_id => 0,
+ $this->column_item_parents => '',
+ ));
+
+ unset($item_data[$this->column_item_id]);
+
+ return $item_data;
+ }
+
/**
* @inheritdoc
*/
--
cgit v1.2.1
From a183fc1118b5ec3b1654ab4fda9c56fa1144e4ce Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 00:54:26 +0200
Subject: [ticket/11495] Manually specify the table columns
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 5673a913fc..7c1e7f631e 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -157,8 +157,8 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* siblings between the current spot and the target then the
* item will move as far as possible
*/
- $sql = 'SELECT ' . implode(', ', $this->table_columns) . '
- FROM ' . $this->table_name . '
+ $sql = "SELECT {$this->column_item_id}, {$this->column_parent_id}, {$this->column_left_id}, {$this->column_right_id}, {$this->column_item_parents}
+ FROM " . $this->table_name . '
WHERE ' . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id] . '
' . $this->get_sql_where() . '
AND ';
--
cgit v1.2.1
From ccd4a725da5269189cdb73a3d7048359a5d2cd4d Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 09:53:02 +0200
Subject: [ticket/11362] Add compatibility function phpbb_clean_path() again
The function first depends on the container, but also works without it and
without autoload. The reason for this is, it might be used before that
stuff is set up, like it has been in our common.php
PHPBB3-11362
---
phpBB/includes/functions.php | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 39a8dbc880..998c52b7c6 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1046,6 +1046,38 @@ else
}
}
+/**
+* Eliminates useless . and .. components from specified path.
+*
+* Deprecated, use filesystem class instead
+*
+* @param string $path Path to clean
+* @return string Cleaned path
+*
+* @deprecated
+*/
+function phpbb_clean_path($path)
+{
+ global $phpbb_container;
+
+ if ($phpbb_container)
+ {
+ $phpbb_filesystem = new phpbb_filesystem();
+ }
+ else
+ {
+ // The container is not yet loaded, use a new instance
+ if (!class_exists('phpbb_filesystem'))
+ {
+ global $phpbb_root_path, $phpEx;
+ require($phpbb_root_path . 'includes/filesystem.' . $phpEx);
+ }
+ $phpbb_filesystem = new phpbb_filesystem();
+ }
+
+ return $phpbb_filesystem->clean_path($path);
+}
+
// functions used for building option fields
/**
--
cgit v1.2.1
From 153b29c6c9dad621e03bf2296a93306c30ea23f0 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 19:31:08 +0200
Subject: [ticket/11495] Remove item class as its no longer required
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 3 ---
phpBB/includes/nestedset/forum.php | 3 ---
2 files changed, 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 7c1e7f631e..d16e33a6db 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -23,9 +23,6 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/** @var String */
protected $table_name;
- /** @var String */
- protected $item_class = 'phpbb_nestedset_item_base';
-
/**
* Column names in the table
* @var String
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
index 18936c1c55..e723e3bf18 100644
--- a/phpBB/includes/nestedset/forum.php
+++ b/phpBB/includes/nestedset/forum.php
@@ -26,9 +26,6 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
/** @var String */
protected $table_name;
- /** @var String */
- protected $item_class = 'phpbb_nestedset_item_forum';
-
/**
* Column names in the table
* @var String
--
cgit v1.2.1
From b28180be1d911364e5c00e3e97e8dac9be6f3d6f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 22:16:14 +0200
Subject: [ticket/11495] Acquire locks for operations that manipulate the tree
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 75 ++++++++++++++++++++++++++++++++++-----
1 file changed, 66 insertions(+), 9 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index d16e33a6db..e36f45e689 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -20,9 +20,18 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/** @var phpbb_db_driver*/
protected $db;
+ /** @var phpbb_lock_db */
+ protected $lock;
+
/** @var String */
protected $table_name;
+ /**
+ * Prefix for the language keys returned by exceptions
+ * @var String
+ */
+ protected $message_prefix = '';
+
/**
* Column names in the table
* @var String
@@ -145,6 +154,11 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
return false;
}
+ if (!$this->lock->acquire())
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
$action = ($delta > 0) ? 'move_up' : 'move_down';
$delta = abs($delta);
@@ -180,6 +194,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (is_null($target))
{
+ $this->lock->release();
// The item is already on top or bottom
return false;
}
@@ -231,6 +246,8 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
" . $this->get_sql_where();
$this->db->sql_query($sql);
+ $this->lock->release();
+
return true;
}
@@ -260,11 +277,17 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
return false;
}
+ if (!$this->lock->acquire())
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
$move_items = array_keys($this->get_branch_data($current_parent, 'children', true, false));
if (in_array($new_parent[$this->column_item_id], $move_items))
{
- throw new phpbb_nestedset_exception('INVALID_PARENT');
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
}
$diff = sizeof($move_items) * 2;
@@ -272,7 +295,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->db->sql_transaction('begin');
- $this->remove_subset($move_items, $current_parent, false);
+ $this->remove_subset($move_items, $current_parent, false, true);
if ($new_parent[$this->column_item_id])
{
@@ -287,10 +310,11 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (!$new_parent)
{
$this->db->sql_transaction('rollback');
- throw new phpbb_nestedset_exception('INVALID_PARENT');
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
}
- $new_right_id = $this->prepare_adding_subset($move_items, $new_parent);
+ $new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
if ($new_right_id > $current_parent[$this->column_right_id])
{
@@ -324,6 +348,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->db->sql_query($sql);
$this->db->sql_transaction('commit');
+ $this->lock->release();
return true;
}
@@ -333,11 +358,17 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
public function set_parent(array $item, array $new_parent)
{
+ if (!$this->lock->acquire())
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
$move_items = array_keys($this->get_branch_data($item, 'children'));
if (in_array($new_parent[$this->column_item_id], $move_items))
{
- throw new phpbb_nestedset_exception('INVALID_PARENT');
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
}
$diff = sizeof($move_items) * 2;
@@ -345,7 +376,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->db->sql_transaction('begin');
- $this->remove_subset($move_items, $item, false);
+ $this->remove_subset($move_items, $item, false, true);
if ($new_parent[$this->column_item_id])
{
@@ -360,10 +391,11 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (!$new_parent)
{
$this->db->sql_transaction('rollback');
- throw new phpbb_nestedset_exception('INVALID_PARENT');
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
}
- $new_right_id = $this->prepare_adding_subset($move_items, $new_parent);
+ $new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
if ($new_right_id > (int) $item[$this->column_right_id])
{
@@ -397,6 +429,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->db->sql_query($sql);
$this->db->sql_transaction('commit');
+ $this->lock->release();
return true;
}
@@ -497,10 +530,16 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* @param array $subset_items Subset of items to remove
* @param array $bounding_item Item containing the right bound of the subset
* @param bool $set_subset_zero Should the parent, left and right id of the item be set to 0, or kept unchanged?
+ * @param bool $table_already_locked Is the table already locked, or should we acquire a new lock?
* @return null
*/
- protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true)
+ protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true, $table_already_locked = false)
{
+ if (!$table_already_locked && !$this->lock->acquire())
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
$diff = sizeof($subset_items) * 2;
$sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
$sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
@@ -526,6 +565,11 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
' . $this->column_item_parents . " = ''
" . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
$this->db->sql_query($sql);
+
+ if (!$table_already_locked)
+ {
+ $this->lock->release();
+ }
}
/**
@@ -581,6 +625,12 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
if ($reset_ids)
{
+ if (!$this->lock->acquire())
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+ $this->db->sql_transaction('begin');
+
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', array(
$this->column_left_id => 0,
@@ -627,6 +677,13 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
}
$this->db->sql_freeresult($result);
+
+ if ($reset_ids)
+ {
+ $this->db->sql_transaction('commit');
+ $this->lock->release();
+ }
+
return $new_id;
}
}
--
cgit v1.2.1
From 5cb7342dd3b7abd2366abbdb7c0ba11d3d27f922 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 18 Apr 2013 22:17:05 +0200
Subject: [ticket/11495] Remove acquire locks from forum implementation
PHPBB3-11495
---
phpBB/includes/nestedset/forum.php | 65 ++------------------------------------
1 file changed, 2 insertions(+), 63 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
index e723e3bf18..54a26772d5 100644
--- a/phpBB/includes/nestedset/forum.php
+++ b/phpBB/includes/nestedset/forum.php
@@ -17,15 +17,6 @@ if (!defined('IN_PHPBB'))
class phpbb_nestedset_forum extends phpbb_nestedset_base
{
- /** @var phpbb_db_driver */
- protected $db;
-
- /** @var phpbb_lock_db */
- protected $lock;
-
- /** @var String */
- protected $table_name;
-
/**
* Column names in the table
* @var String
@@ -34,12 +25,10 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
protected $column_item_parents = 'forum_parents';
/**
- * Additional SQL restrictions
- * Allows to have multiple nestedsets in one table
- * Columns must be prefixed with %1$s
+ * Prefix for the language keys returned by exceptions
* @var String
*/
- protected $sql_where = '';
+ protected $message_prefix = 'FORUM_NESTEDSET_';
/**
* List of item properties to be cached in $item_parents
@@ -60,54 +49,4 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
$this->lock = $lock;
$this->table_name = $table_name;
}
-
- /**
- * @inheritdoc
- */
- public function move_children(array $current_parent, array $new_parent)
- {
- while (!$this->lock->acquire())
- {
- // Retry after 0.2 seconds
- usleep(200 * 1000);
- }
-
- try
- {
- $return = parent::move_children($current_parent, $new_parent);
- }
- catch (phpbb_nestedset_exception $e)
- {
- $this->lock->release();
- throw new phpbb_nestedset_exception('FORUM_NESTEDSET_' . $e->getMessage());
- }
- $this->lock->release();
-
- return $return;
- }
-
- /**
- * @inheritdoc
- */
- public function set_parent(array $item, array $new_parent)
- {
- while (!$this->lock->acquire())
- {
- // Retry after 0.2 seconds
- usleep(200 * 1000);
- }
-
- try
- {
- $return = parent::set_parent($item, $new_parent);
- }
- catch (phpbb_nestedset_exception $e)
- {
- $this->lock->release();
- throw new phpbb_nestedset_exception('FORUM_NESTEDSET_' . $e->getMessage());
- }
- $this->lock->release();
-
- return $return;
- }
}
--
cgit v1.2.1
From f3ff8b36be01bf6414268d9dca0500b6c7d4f47f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 19 Apr 2013 01:14:38 +0200
Subject: [ticket/11495] Fix Spacing and lowercase on docs
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 10 +++++-----
phpBB/includes/nestedset/forum.php | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index e36f45e689..3383fd90c4 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -17,24 +17,24 @@ if (!defined('IN_PHPBB'))
abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
- /** @var phpbb_db_driver*/
+ /** @var phpbb_db_driver */
protected $db;
/** @var phpbb_lock_db */
protected $lock;
- /** @var String */
+ /** @var string */
protected $table_name;
/**
* Prefix for the language keys returned by exceptions
- * @var String
+ * @var string
*/
protected $message_prefix = '';
/**
* Column names in the table
- * @var String
+ * @var string
*/
protected $column_item_id = 'item_id';
protected $column_left_id = 'left_id';
@@ -45,7 +45,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* Additional SQL restrictions
* Allows to have multiple nested sets in one table
- * @var String
+ * @var string
*/
protected $sql_where = '';
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
index 54a26772d5..dbf0e70202 100644
--- a/phpBB/includes/nestedset/forum.php
+++ b/phpBB/includes/nestedset/forum.php
@@ -19,14 +19,14 @@ class phpbb_nestedset_forum extends phpbb_nestedset_base
{
/**
* Column names in the table
- * @var String
+ * @var string
*/
protected $column_item_id = 'forum_id';
protected $column_item_parents = 'forum_parents';
/**
* Prefix for the language keys returned by exceptions
- * @var String
+ * @var string
*/
protected $message_prefix = 'FORUM_NESTEDSET_';
--
cgit v1.2.1
From d24ff2329fe145864712cb37ec19183bd4e21a42 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 19 Apr 2013 16:18:03 +0200
Subject: [ticket/11495] Use item_id only as parameter for get_branch_data()
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 19 ++++++-------------
phpBB/includes/nestedset/interface.php | 6 +++---
2 files changed, 9 insertions(+), 16 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 3383fd90c4..a3c878a47e 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -115,14 +115,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
public function remove(array $item)
{
- if ($item[$this->column_right_id] - $item[$this->column_left_id] > 1)
- {
- $items = array_keys($this->get_branch_data($item, 'children'));
- }
- else
- {
- $items = array((int) $item[$this->column_item_id]);
- }
+ $items = array_keys($this->get_branch_data($item[$this->column_item_id], 'children'));
$this->remove_subset($items, $item);
@@ -282,7 +275,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $move_items = array_keys($this->get_branch_data($current_parent, 'children', true, false));
+ $move_items = array_keys($this->get_branch_data((int) $current_parent[$this->column_item_id], 'children', true, false));
if (in_array($new_parent[$this->column_item_id], $move_items))
{
@@ -363,7 +356,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $move_items = array_keys($this->get_branch_data($item, 'children'));
+ $move_items = array_keys($this->get_branch_data((int) $item[$this->column_item_id], 'children'));
if (in_array($new_parent[$this->column_item_id], $move_items))
{
@@ -437,7 +430,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function get_branch_data(array $item, $type = 'all', $order_desc = true, $include_item = true)
+ public function get_branch_data($item_id, $type = 'all', $order_desc = true, $include_item = true)
{
switch ($type)
{
@@ -461,14 +454,14 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
FROM ' . $this->table_name . ' i1
LEFT JOIN ' . $this->table_name . " i2
ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
- WHERE i1.' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id] . '
+ WHERE i1.' . $this->column_item_id . ' = ' . (int) $item_id . '
' . $this->get_sql_where('AND', 'i1.') . '
ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (!$include_item && $item[$this->column_item_id] == $row[$this->column_item_id])
+ if (!$include_item && $item_id == $row[$this->column_item_id])
{
continue;
}
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index 2d353544dd..c632c09dbf 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -101,19 +101,19 @@ interface phpbb_nestedset_interface
*
* This method can return all parents, children or both of the given item
*
- * @param array $item The item to get the branch from
+ * @param int $item_id The item id to get the parents from
* @param string $type One of all|parent|children
* @param bool $order_desc Order the items descending (most outer parent first)
* @param bool $include_item Should the given item be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_branch_data(array $item, $type, $order_desc, $include_item);
+ public function get_branch_data($item_id, $type, $order_desc, $include_item);
/**
* Get base information of parent items
*
- * @param array $item The item to get the parents from
+ * @param array $item The item to get the branch from
* @return array Array of items (containing basic columns from the item table)
* ID => Item data
*/
--
cgit v1.2.1
From 3d54a81ed9394f13aff4c40d524ed7cff0546604 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 19 Apr 2013 16:19:01 +0200
Subject: [ticket/11495] Use item_id only as parameter for delete() and
remove()
The data is acquired again anyway
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 13 +++++++------
phpBB/includes/nestedset/interface.php | 12 ++++++------
2 files changed, 13 insertions(+), 12 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index a3c878a47e..c1feb48534 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -113,21 +113,22 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function remove(array $item)
+ public function remove($item_id)
{
- $items = array_keys($this->get_branch_data($item[$this->column_item_id], 'children'));
+ $items = $this->get_branch_data($item_id, 'children');
+ $item_ids = array_keys($items);
- $this->remove_subset($items, $item);
+ $this->remove_subset($item_ids, $items[$item_id]);
- return $items;
+ return $item_ids;
}
/**
* @inheritdoc
*/
- public function delete(array $item)
+ public function delete($item_id)
{
- $removed_items = $this->remove($item);
+ $removed_items = $this->remove($item_id);
$sql = 'DELETE FROM ' . $this->table_name . '
WHERE ' . $this->db->sql_in_set($this->column_item_id, $removed_items) . '
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index c632c09dbf..1a6b09f975 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -38,20 +38,20 @@ interface phpbb_nestedset_interface
*
* Also removes all subitems from the nested set
*
- * @param array $item The item to be removed
- * @return array Items that have been removed
+ * @param int $item_id The item to be deleted
+ * @return array Item ids that have been removed
*/
- public function remove(array $item);
+ public function remove($item);
/**
* Delete an item from the nested set (also deletes the rows form the table)
*
* Also deletes all subitems from the nested set
*
- * @param array $item The item to be deleted
- * @return array Items that have been deleted
+ * @param int $item_id The item to be deleted
+ * @return array Item ids that have been deleted
*/
- public function delete(array $item);
+ public function delete($item);
/**
* Move an item by a given delta
--
cgit v1.2.1
From f66b5323a75db084686d9a16c7090b15c5c13e54 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 19 Apr 2013 19:09:22 +0200
Subject: [ticket/11495] Cast some values to int
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index c1feb48534..bb7acca0fb 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -202,10 +202,10 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
if ($action == 'move_up')
{
- $left_id = $target[$this->column_left_id];
+ $left_id = (int) $target[$this->column_left_id];
$right_id = (int) $item[$this->column_right_id];
- $diff_up = (int) $item[$this->column_left_id] - $target[$this->column_left_id];
+ $diff_up = (int) $item[$this->column_left_id] - (int) $target[$this->column_left_id];
$diff_down = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
$move_up_left = (int) $item[$this->column_left_id];
@@ -214,13 +214,13 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
else
{
$left_id = (int) $item[$this->column_left_id];
- $right_id = $target[$this->column_right_id];
+ $right_id = (int) $target[$this->column_right_id];
$diff_up = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
- $diff_down = $target[$this->column_right_id] - (int) $item[$this->column_right_id];
+ $diff_down = (int) $target[$this->column_right_id] - (int) $item[$this->column_right_id];
$move_up_left = (int) $item[$this->column_right_id] + 1;
- $move_up_right = $target[$this->column_right_id];
+ $move_up_right = (int) $target[$this->column_right_id];
}
// Now do the dirty job
--
cgit v1.2.1
From db5df5b6ac025f360cdc97182678536d88c0dccb Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 19 Apr 2013 10:15:03 +0200
Subject: [ticket/10966] Introduce MSSQL base class for native and ODBC
PHPBB3-10966
---
phpBB/includes/db/driver/mssql_base.php | 65 ++++++++++++++++++++++++++++++++
phpBB/includes/db/driver/mssql_odbc.php | 44 +--------------------
phpBB/includes/db/driver/mssqlnative.php | 44 +--------------------
3 files changed, 67 insertions(+), 86 deletions(-)
create mode 100644 phpBB/includes/db/driver/mssql_base.php
(limited to 'phpBB')
diff --git a/phpBB/includes/db/driver/mssql_base.php b/phpBB/includes/db/driver/mssql_base.php
new file mode 100644
index 0000000000..56c111c871
--- /dev/null
+++ b/phpBB/includes/db/driver/mssql_base.php
@@ -0,0 +1,65 @@
+sql_server_version) ? 'MSSQL (ODBC) ' . $this->sql_server_version : 'MSSQL (ODBC)';
}
- /**
- * {@inheritDoc}
- */
- public function sql_concatenate($expr1, $expr2)
- {
- return $expr1 . ' + ' . $expr2;
- }
-
/**
* SQL Transaction
* @access private
@@ -325,40 +317,6 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
return false;
}
- /**
- * Escape string used in sql query
- */
- function sql_escape($msg)
- {
- return str_replace(array("'", "\0"), array("''", ''), $msg);
- }
-
- /**
- * {@inheritDoc}
- */
- function sql_lower_text($column_name)
- {
- return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))";
- }
-
- /**
- * Build LIKE expression
- * @access private
- */
- function _sql_like_expression($expression)
- {
- return $expression . " ESCAPE '\\'";
- }
-
- /**
- * Build db-specific query data
- * @access private
- */
- function _sql_custom_build($stage, $data)
- {
- return $data;
- }
-
/**
* return sql error array
* @access private
diff --git a/phpBB/includes/db/driver/mssqlnative.php b/phpBB/includes/db/driver/mssqlnative.php
index 656cbd2437..6f433e10cf 100644
--- a/phpBB/includes/db/driver/mssqlnative.php
+++ b/phpBB/includes/db/driver/mssqlnative.php
@@ -191,7 +191,7 @@ class result_mssqlnative
/**
* @package dbal
*/
-class phpbb_db_driver_mssqlnative extends phpbb_db_driver
+class phpbb_db_driver_mssqlnative extends phpbb_db_driver_mssql_base
{
var $m_insert_id = NULL;
var $last_query_text = '';
@@ -256,14 +256,6 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
return ($this->sql_server_version) ? 'MSSQL ' . $this->sql_server_version : 'MSSQL';
}
- /**
- * {@inheritDoc}
- */
- public function sql_concatenate($expr1, $expr2)
- {
- return $expr1 . ' + ' . $expr2;
- }
-
/**
* {@inheritDoc}
*/
@@ -490,31 +482,6 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
return false;
}
- /**
- * Escape string used in sql query
- */
- function sql_escape($msg)
- {
- return str_replace(array("'", "\0"), array("''", ''), $msg);
- }
-
- /**
- * {@inheritDoc}
- */
- function sql_lower_text($column_name)
- {
- return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))";
- }
-
- /**
- * Build LIKE expression
- * @access private
- */
- function _sql_like_expression($expression)
- {
- return $expression . " ESCAPE '\\'";
- }
-
/**
* return sql error array
* @access private
@@ -560,15 +527,6 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
return $error;
}
- /**
- * Build db-specific query data
- * @access private
- */
- function _sql_custom_build($stage, $data)
- {
- return $data;
- }
-
/**
* Close sql connection
* @access private
--
cgit v1.2.1
From 87dc3b1e55bcfcade98eedfaa07e77c454dd7d4f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 19 Apr 2013 21:07:42 +0200
Subject: [ticket/11495] Use item ids instead of requiring all data
The data is grabbed again in most cases anyway, so it just makes the system
easier to use.
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 95 +++++++++++++++++++++++++++-------
phpBB/includes/nestedset/interface.php | 26 +++++-----
2 files changed, 90 insertions(+), 31 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index bb7acca0fb..f3bdfe1c7d 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -141,7 +141,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function move(array $item, $delta)
+ public function move($item_id, $delta)
{
if ($delta == 0)
{
@@ -156,6 +156,21 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$action = ($delta > 0) ? 'move_up' : 'move_down';
$delta = abs($delta);
+ // Keep $this->get_sql_where() here, to ensure we are in the right tree.
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->column_item_id . ' = ' . (int) $item_id . '
+ ' . $this->get_sql_where();
+ $result = $this->db->sql_query_limit($sql, $delta);
+ $item = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (!$item)
+ {
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ }
+
/**
* Fetch all the siblings between the item's current spot
* and where we want to move it to. If there are less than $delta
@@ -248,37 +263,60 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function move_down(array $item)
+ public function move_down($item_id)
{
- return $this->move($item, -1);
+ return $this->move($item_id, -1);
}
/**
* @inheritdoc
*/
- public function move_up(array $item)
+ public function move_up($item_id)
{
- return $this->move($item, 1);
+ return $this->move($item_id, 1);
}
/**
* @inheritdoc
*/
- public function move_children(array $current_parent, array $new_parent)
+ public function move_children($current_parent_id, $new_parent_id)
{
- if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1 || !$current_parent[$this->column_item_id] || $current_parent[$this->column_item_id] == $new_parent[$this->column_item_id])
+ $current_parent_id = (int) $current_parent_id;
+ $new_parent_id = (int) $new_parent_id;
+
+ if ($current_parent_id == $new_parent_id)
{
return false;
}
+ if (!$current_parent_id)
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ }
+
if (!$this->lock->acquire())
{
throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $move_items = array_keys($this->get_branch_data((int) $current_parent[$this->column_item_id], 'children', true, false));
+ $item_data = $this->get_branch_data($current_parent_id, 'children');
+ if (!isset($item_data[$current_parent_id]))
+ {
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ $current_parent = $item_data[$current_parent_id];
+ unset($item_data[$current_parent_id]);
+ $move_items = array_keys($item_data);
- if (in_array($new_parent[$this->column_item_id], $move_items))
+ if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1)
+ {
+ $this->lock->release();
+ return false;
+ }
+
+ if (in_array($new_parent_id, $move_items))
{
$this->lock->release();
throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
@@ -291,12 +329,12 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->remove_subset($move_items, $current_parent, false, true);
- if ($new_parent[$this->column_item_id])
+ if ($new_parent_id)
{
// Retrieve new-parent again, it may have been changed...
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $new_parent[$this->column_item_id];
+ WHERE ' . $this->column_item_id . ' = ' . $new_parent_id;
$result = $this->db->sql_query($sql);
$new_parent = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
@@ -335,7 +373,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
- ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . (int) $current_parent[$this->column_item_id], (int) $new_parent[$this->column_item_id], $this->column_parent_id) . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent_id, $new_parent_id, $this->column_parent_id) . ',
' . $this->column_item_parents . " = ''
WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND');
@@ -350,16 +388,37 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function set_parent(array $item, array $new_parent)
+ public function set_parent($item_id, $new_parent_id)
{
+ $item_id = (int) $item_id;
+ $new_parent_id = (int) $new_parent_id;
+
+ if ($item_id == $new_parent_id)
+ {
+ return false;
+ }
+
+ if (!$item_id)
+ {
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ }
+
if (!$this->lock->acquire())
{
throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $move_items = array_keys($this->get_branch_data((int) $item[$this->column_item_id], 'children'));
+ $item_data = $this->get_branch_data($item_id, 'children');
+ if (!isset($item_data[$item_id]))
+ {
+ $this->lock->release();
+ throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ $item = $item_data[$item_id];
+ $move_items = array_keys($item_data);
- if (in_array($new_parent[$this->column_item_id], $move_items))
+ if (in_array($new_parent_id, $move_items))
{
$this->lock->release();
throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
@@ -372,12 +431,12 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$this->remove_subset($move_items, $item, false, true);
- if ($new_parent[$this->column_item_id])
+ if ($new_parent_id)
{
// Retrieve new-parent again, it may have been changed...
$sql = 'SELECT *
FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $new_parent[$this->column_item_id];
+ WHERE ' . $this->column_item_id . ' = ' . $new_parent_id;
$result = $this->db->sql_query($sql);
$new_parent = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
@@ -416,7 +475,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
- ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . (int) $item[$this->column_item_id], $new_parent[$this->column_item_id], $this->column_parent_id) . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item_id, $new_parent_id, $this->column_parent_id) . ',
' . $this->column_item_parents . " = ''
WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND');
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index 1a6b09f975..aedd57821a 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -56,45 +56,45 @@ interface phpbb_nestedset_interface
/**
* Move an item by a given delta
*
- * @param array $item The item to be moved
- * @param int $delta Number of steps to move this item, < 0 => down, > 0 => up
+ * @param int $item_id The item to be moved
+ * @param int $delta Number of steps to move this item, < 0 => down, > 0 => up
* @return bool True if the item was moved
*/
- public function move(array $item, $delta);
+ public function move($item_id, $delta);
/**
* Move an item down by 1
*
- * @param array $item The item to be moved
+ * @param int $item_id The item to be moved
* @return bool True if the item was moved
*/
- public function move_down(array $item);
+ public function move_down($item_id);
/**
* Move an item up by 1
*
- * @param array $item The item to be moved
+ * @param int $item_id The item to be moved
* @return bool True if the item was moved
*/
- public function move_up(array $item);
+ public function move_up($item_id);
/**
* Moves all children of one item to another item
*
- * @param array $current_parent The current parent item
- * @param array $new_parent The new parent item
+ * @param int $current_parent_id The current parent item
+ * @param int $new_parent_id The new parent item
* @return bool True if any items where moved
*/
- public function move_children(array $current_parent, array $new_parent);
+ public function move_children($current_parent_id, $new_parent_id);
/**
* Set the parent item
*
- * @param array $item The item to be moved
- * @param array $new_parent The new parent item
+ * @param int $item_id The item to be moved
+ * @param int $new_parent_id The new parent item
* @return bool True if the parent was set successfully
*/
- public function set_parent(array $item, array $new_parent);
+ public function set_parent($item, $new_parent_id);
/**
* Get branch of the item
--
cgit v1.2.1
From 802fbbb444a580698b130fa54754d26c12321c00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Muller?=
Date: Sun, 21 Apr 2013 16:14:33 +0200
Subject: [ticket/9975] Translate missing style error message
The error message about missing style data was not
translated
PHPBB3-9975
---
phpBB/includes/session.php | 2 +-
phpBB/language/en/common.php | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index b93f2ff65e..fe5357f32e 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -1661,7 +1661,7 @@ class user extends session
if (!$this->theme)
{
- trigger_error('Could not get style data', E_USER_ERROR);
+ trigger_error('NO_STYLE_DATA', E_USER_ERROR);
}
// Now parse the cfg file and cache it
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 6dd390ed24..baf398b146 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -391,6 +391,7 @@ $lang = array_merge($lang, array(
'NO_POSTS_TIME_FRAME' => 'No posts exist inside this topic for the selected time frame.',
'NO_FEED_ENABLED' => 'Feeds are not available on this board.',
'NO_FEED' => 'The requested feed is not available.',
+ 'NO_STYLE_DATA' => 'Could not get style data',
'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages.
'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.',
'NO_SUPPORTED_AUTH_METHODS' => 'No supported authentication methods.',
--
cgit v1.2.1
From 16e70fa08610227d96e149eba2019803ad37c85f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Mon, 22 Apr 2013 00:49:41 +0200
Subject: [ticket/11362] Use container when available instead of creating a new
instance
PHPBB3-11362
---
phpBB/includes/functions.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 998c52b7c6..231825525f 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1062,7 +1062,7 @@ function phpbb_clean_path($path)
if ($phpbb_container)
{
- $phpbb_filesystem = new phpbb_filesystem();
+ $phpbb_filesystem = $phpbb_container->get('filesystem');
}
else
{
--
cgit v1.2.1
From 9f545a7f6ba7ddd54fae083563b5b582e05f5c1c Mon Sep 17 00:00:00 2001
From: asperous
Date: Tue, 23 Apr 2013 09:55:36 -0700
Subject: [ticket/9975] Moved a few E_USER_ERROR errors to /language
There were a few error messages that a user could experience that would, previously, be without any the ability to be localized. There are some more E_USER_ERRORs that I did not change to a constant, for example the error message that is displayed if there aren't any folders in /language.
PHPBB3-9975
---
phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php | 2 +-
phpBB/includes/functions.php | 6 +++---
phpBB/includes/user.php | 2 +-
phpBB/language/en/captcha_recaptcha.php | 1 +
phpBB/language/en/common.php | 2 ++
phpBB/language/en/mcp.php | 2 ++
phpBB/mcp.php | 2 +-
7 files changed, 11 insertions(+), 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
index 83d40bbba7..cb21b04ec5 100644
--- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
@@ -270,7 +270,7 @@ class phpbb_recaptcha extends phpbb_default_captcha
$response = '';
if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10)))
{
- trigger_error('Could not open socket', E_USER_ERROR);
+ trigger_error('RECAPTCHA_SOCKET_ERROR', E_USER_ERROR);
}
fwrite($fs, $http_request);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 58d2ad4760..6b5d7bd1df 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2731,7 +2731,7 @@ function redirect($url, $return = false, $disable_cd_check = false)
// Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2
if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false || strpos($url, ';') !== false)
{
- trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
}
// Now, also check the protocol and for a valid url the last time...
@@ -2740,7 +2740,7 @@ function redirect($url, $return = false, $disable_cd_check = false)
if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols))
{
- trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR);
+ trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
}
if ($return)
@@ -4182,7 +4182,7 @@ function phpbb_checkdnsrr($host, $type = 'MX')
// Handler, header and footer
/**
-* Error and message handler, call with trigger_error if reqd
+* Error and message handler, call with trigger_error if read
*/
function msg_handler($errno, $msg_text, $errfile, $errline)
{
diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php
index 9ddd806b27..4477c98097 100644
--- a/phpBB/includes/user.php
+++ b/phpBB/includes/user.php
@@ -215,7 +215,7 @@ class phpbb_user extends phpbb_session
if (!$this->style)
{
- trigger_error('Could not get style data', E_USER_ERROR);
+ trigger_error('STYLE_NOT_FOUND', E_USER_ERROR);
}
// Now parse the cfg file and cache it
diff --git a/phpBB/language/en/captcha_recaptcha.php b/phpBB/language/en/captcha_recaptcha.php
index c72957ca16..3d91a9d110 100644
--- a/phpBB/language/en/captcha_recaptcha.php
+++ b/phpBB/language/en/captcha_recaptcha.php
@@ -46,4 +46,5 @@ $lang = array_merge($lang, array(
'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your private reCaptcha key. Keys can be obtained on www.google.com/recaptcha.',
'RECAPTCHA_EXPLAIN' => 'In an effort to prevent automatic submissions, we require that you enter both of the words displayed into the text field underneath.',
+ 'RECAPTCHA_SOCKET_ERROR' => 'There was a problem connecting to the RECAPTCHA service: could not open socket. Try again later.',
));
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 5d6fe03b5f..c2db496437 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -313,6 +313,7 @@ $lang = array_merge($lang, array(
'IN' => 'in',
'INDEX' => 'Index page',
'INFORMATION' => 'Information',
+ 'INSECURE_REDIRECT' => 'Tried to redirect to potentially insecure url.',
'INTERESTS' => 'Interests',
'INVALID_DIGEST_CHALLENGE' => 'Invalid digest challenge.',
'INVALID_EMAIL_LOG' => '%s possibly an invalid email address?',
@@ -638,6 +639,7 @@ $lang = array_merge($lang, array(
'STATISTICS' => 'Statistics',
'START_WATCHING_FORUM' => 'Subscribe forum',
'START_WATCHING_TOPIC' => 'Subscribe topic',
+ 'STYLE_NOT_FOUND' => 'Could not get style data',
'STOP_WATCHING_FORUM' => 'Unsubscribe forum',
'STOP_WATCHING_TOPIC' => 'Unsubscribe topic',
'SUBFORUM' => 'Subforum',
diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php
index eaa2d7e3a5..29f418183f 100644
--- a/phpBB/language/en/mcp.php
+++ b/phpBB/language/en/mcp.php
@@ -250,6 +250,8 @@ $lang = array_merge($lang, array(
'ONLY_TOPIC' => 'Only topic “%s”',
'OTHER_USERS' => 'Other users posting from this IP',
+ 'QUICKMOD_ACTION_NOT_ALLOWED' => "%s not allowed as quickmod",
+
'PM_REPORT_CLOSED_SUCCESS' => 'The selected PM report has been closed successfully.',
'PM_REPORT_DELETED_SUCCESS' => 'The selected PM report has been deleted successfully.',
'PM_REPORTED_SUCCESS' => 'This private message has been successfully reported.',
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index d04a297cf9..c36faad74b 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -182,7 +182,7 @@ if ($quickmod)
break;
default:
- trigger_error("$action not allowed as quickmod", E_USER_ERROR);
+ trigger_error($user->lang('QUICKMOD_ACTION_NOT_ALLOWED', $action), E_USER_ERROR);
break;
}
}
--
cgit v1.2.1
From 51a869b13abbe3a93d91e5cc7e14a71bbede1b0e Mon Sep 17 00:00:00 2001
From: asperous
Date: Tue, 23 Apr 2013 11:27:36 -0700
Subject: [ticket/11129] Added headers to empty subscription state
"You are not subscribed to any forums".
While correct, could lead to confusion. What's missing is a header right above the message that says "Watched Topics" to match the "Watched Forums" header above. This will assert the idea that there are two separate watchable sections.
As is, it looks like that message is talking about the "Watched Forums" section, since it's listed under that header.
PHPBB3-11129
---
.../styles/prosilver/template/ucp_main_subscribed.html | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/styles/prosilver/template/ucp_main_subscribed.html b/phpBB/styles/prosilver/template/ucp_main_subscribed.html
index 11957aa90d..84d1d897d4 100644
--- a/phpBB/styles/prosilver/template/ucp_main_subscribed.html
+++ b/phpBB/styles/prosilver/template/ucp_main_subscribed.html
@@ -34,6 +34,13 @@
+
+
+
+
{L_WATCHED_FORUMS}
+
+
+
{L_NO_WATCHED_FORUMS}
@@ -83,14 +90,21 @@
{TOTAL_TOPICS} •
-
+
-
+
{PAGE_NUMBER}
+
+
+
+
{L_WATCHED_TOPICS}
+
+
+
{L_NO_WATCHED_TOPICS}
--
cgit v1.2.1
From 0f41cc34dd83228429824547005e488f0076d0de Mon Sep 17 00:00:00 2001
From: asperous
Date: Tue, 23 Apr 2013 15:00:27 -0700
Subject: [ticket/11129] Added headers to empty subscription state
Added a newline to better seperate the two headers.
PHPBB3-11129
---
phpBB/styles/prosilver/template/ucp_main_subscribed.html | 1 +
1 file changed, 1 insertion(+)
mode change 100644 => 100755 phpBB/styles/prosilver/template/ucp_main_subscribed.html
(limited to 'phpBB')
diff --git a/phpBB/styles/prosilver/template/ucp_main_subscribed.html b/phpBB/styles/prosilver/template/ucp_main_subscribed.html
old mode 100644
new mode 100755
index 84d1d897d4..d5097a2191
--- a/phpBB/styles/prosilver/template/ucp_main_subscribed.html
+++ b/phpBB/styles/prosilver/template/ucp_main_subscribed.html
@@ -43,6 +43,7 @@
{L_NO_WATCHED_FORUMS}
+
--
cgit v1.2.1
From 212971a3a6c7d2b336408f6432218ced55ac36a0 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Wed, 24 Apr 2013 10:37:53 -0500
Subject: [ticket/11454] Correct jabber global available check
Copied from msg_jabber()
PBPBB3-11454
---
phpBB/includes/notification/method/jabber.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/notification/method/jabber.php b/phpBB/includes/notification/method/jabber.php
index debffa8ce5..d3b756d020 100644
--- a/phpBB/includes/notification/method/jabber.php
+++ b/phpBB/includes/notification/method/jabber.php
@@ -48,7 +48,13 @@ class phpbb_notification_method_jabber extends phpbb_notification_method_messeng
*/
public function global_available()
{
- return ($this->config['jab_enable'] && @extension_loaded('xml'));
+ return !(
+ empty($this->config['jab_enable']) ||
+ empty($this->config['jab_host']) ||
+ empty($this->config['jab_username']) ||
+ empty($this->config['jab_password']) ||
+ !@extension_loaded('xml')
+ );
}
public function notify()
--
cgit v1.2.1
From cc902ddee09c3d516a27c26fbf19af8f772814e6 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Wed, 24 Apr 2013 11:26:13 -0500
Subject: [ticket/11479] Fix install/update (rebuild container)
Code copied from fix in 11305
PHPBB3-11479
---
phpBB/install/install_update.php | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index bfceed6b17..cf800aefd4 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -72,7 +72,24 @@ class install_update extends module
function main($mode, $sub)
{
global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language;
- global $request, $phpbb_admin_path, $phpbb_adm_relative_path;
+ global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container;
+
+ // Create a normal container now
+ $phpbb_container = phpbb_create_dumped_container_unless_debug(
+ 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
+ );
+
+ // Writes into global $cache
+ $cache = $phpbb_container->get('cache');
$this->tpl_name = 'install_update';
$this->page_title = 'UPDATE_INSTALLATION';
--
cgit v1.2.1
From 1f6f2435d0d4c18bd0b7586a32534f030710c929 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Muller?=
Date: Mon, 22 Apr 2013 20:57:19 +0200
Subject: [ticket/11471] Unrelated text in e-mail templates
Some e-mail templates contain text unrelated
with the subject of the e-mail
PHPBB3-11471
---
phpBB/language/en/email/post_approved.txt | 1 -
phpBB/language/en/email/post_disapproved.txt | 1 -
phpBB/language/en/email/post_in_queue.txt | 6 +-----
phpBB/language/en/email/report_closed.txt | 3 +--
phpBB/language/en/email/report_deleted.txt | 3 +--
phpBB/language/en/email/report_pm.txt | 6 +-----
phpBB/language/en/email/report_post.txt | 6 +-----
phpBB/language/en/email/short/post_approved.txt | 1 -
phpBB/language/en/email/short/post_disapproved.txt | 1 -
phpBB/language/en/email/short/post_in_queue.txt | 6 +-----
phpBB/language/en/email/short/report_pm.txt | 6 +-----
phpBB/language/en/email/short/report_post.txt | 6 +-----
phpBB/language/en/email/short/topic_approved.txt | 1 -
phpBB/language/en/email/short/topic_disapproved.txt | 1 -
phpBB/language/en/email/short/topic_in_queue.txt | 6 +-----
phpBB/language/en/email/topic_approved.txt | 1 -
phpBB/language/en/email/topic_disapproved.txt | 1 -
phpBB/language/en/email/topic_in_queue.txt | 6 +-----
phpBB/language/en/email/user_reactivate_account.txt | 1 -
phpBB/language/en/email/user_resend_inactive.txt | 1 -
20 files changed, 10 insertions(+), 54 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/language/en/email/post_approved.txt b/phpBB/language/en/email/post_approved.txt
index e715b54026..a02dba142a 100644
--- a/phpBB/language/en/email/post_approved.txt
+++ b/phpBB/language/en/email/post_approved.txt
@@ -10,5 +10,4 @@ If you want to view the post, click the following link:
If you want to view the topic, click the following link:
{U_VIEW_TOPIC}
-
{EMAIL_SIG}
\ No newline at end of file
diff --git a/phpBB/language/en/email/post_disapproved.txt b/phpBB/language/en/email/post_disapproved.txt
index 2f8a8381cb..9b2ee643ff 100644
--- a/phpBB/language/en/email/post_disapproved.txt
+++ b/phpBB/language/en/email/post_disapproved.txt
@@ -8,5 +8,4 @@ The following reason was given for the disapproval:
{REASON}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/post_in_queue.txt b/phpBB/language/en/email/post_in_queue.txt
index 8d56ce6c4d..941f070d37 100644
--- a/phpBB/language/en/email/post_in_queue.txt
+++ b/phpBB/language/en/email/post_in_queue.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Post moderation notification - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -10,8 +10,4 @@ If you want to view the post, click the following link:
If you want to view the topic, click the following link:
{U_TOPIC}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/report_closed.txt b/phpBB/language/en/email/report_closed.txt
index eb7ef22b5e..f248018f9a 100644
--- a/phpBB/language/en/email/report_closed.txt
+++ b/phpBB/language/en/email/report_closed.txt
@@ -4,5 +4,4 @@ Hello {USERNAME},
You are receiving this notification because the report you filed on the post "{POST_SUBJECT}" in "{TOPIC_TITLE}" at "{SITENAME}" was handled by a moderator or by an administrator. The report was afterwards closed. If you have further questions contact {CLOSER_NAME} with a personal message.
-
-{EMAIL_SIG}
\ No newline at end of file
+{EMAIL_SIG}
diff --git a/phpBB/language/en/email/report_deleted.txt b/phpBB/language/en/email/report_deleted.txt
index 4292ca2239..9a30ea2ddd 100644
--- a/phpBB/language/en/email/report_deleted.txt
+++ b/phpBB/language/en/email/report_deleted.txt
@@ -4,5 +4,4 @@ Hello {USERNAME},
You are receiving this notification because the report you filed on the post "{POST_SUBJECT}" in "{TOPIC_TITLE}" at "{SITENAME}" was deleted by a moderator or by an administrator.
-
-{EMAIL_SIG}
\ No newline at end of file
+{EMAIL_SIG}
diff --git a/phpBB/language/en/email/report_pm.txt b/phpBB/language/en/email/report_pm.txt
index 66ae82d074..a101a014ff 100644
--- a/phpBB/language/en/email/report_pm.txt
+++ b/phpBB/language/en/email/report_pm.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Private Message report - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -7,8 +7,4 @@ You are receiving this notification because a Private Message titled "{SUBJECT}"
If you want to view the report, click the following link:
{U_VIEW_REPORT}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/report_post.txt b/phpBB/language/en/email/report_post.txt
index 46983be1ed..8eb24ec6af 100644
--- a/phpBB/language/en/email/report_post.txt
+++ b/phpBB/language/en/email/report_post.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Post report - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -10,8 +10,4 @@ If you want to view the report, click the following link:
If you want to view the post, click the following link:
{U_VIEW_POST}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/post_approved.txt b/phpBB/language/en/email/short/post_approved.txt
index e715b54026..a02dba142a 100644
--- a/phpBB/language/en/email/short/post_approved.txt
+++ b/phpBB/language/en/email/short/post_approved.txt
@@ -10,5 +10,4 @@ If you want to view the post, click the following link:
If you want to view the topic, click the following link:
{U_VIEW_TOPIC}
-
{EMAIL_SIG}
\ No newline at end of file
diff --git a/phpBB/language/en/email/short/post_disapproved.txt b/phpBB/language/en/email/short/post_disapproved.txt
index 2f8a8381cb..9b2ee643ff 100644
--- a/phpBB/language/en/email/short/post_disapproved.txt
+++ b/phpBB/language/en/email/short/post_disapproved.txt
@@ -8,5 +8,4 @@ The following reason was given for the disapproval:
{REASON}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/post_in_queue.txt b/phpBB/language/en/email/short/post_in_queue.txt
index 8d56ce6c4d..941f070d37 100644
--- a/phpBB/language/en/email/short/post_in_queue.txt
+++ b/phpBB/language/en/email/short/post_in_queue.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Post moderation notification - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -10,8 +10,4 @@ If you want to view the post, click the following link:
If you want to view the topic, click the following link:
{U_TOPIC}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/report_pm.txt b/phpBB/language/en/email/short/report_pm.txt
index 66ae82d074..a101a014ff 100644
--- a/phpBB/language/en/email/short/report_pm.txt
+++ b/phpBB/language/en/email/short/report_pm.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Private Message report - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -7,8 +7,4 @@ You are receiving this notification because a Private Message titled "{SUBJECT}"
If you want to view the report, click the following link:
{U_VIEW_REPORT}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/report_post.txt b/phpBB/language/en/email/short/report_post.txt
index 46983be1ed..8eb24ec6af 100644
--- a/phpBB/language/en/email/short/report_post.txt
+++ b/phpBB/language/en/email/short/report_post.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Post report - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -10,8 +10,4 @@ If you want to view the report, click the following link:
If you want to view the post, click the following link:
{U_VIEW_POST}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/topic_approved.txt b/phpBB/language/en/email/short/topic_approved.txt
index 0b09918b89..60c7ef4c09 100644
--- a/phpBB/language/en/email/short/topic_approved.txt
+++ b/phpBB/language/en/email/short/topic_approved.txt
@@ -7,5 +7,4 @@ You are receiving this notification because your topic "{TOPIC_TITLE}" at "{SITE
If you want to view the topic, click the following link:
{U_VIEW_TOPIC}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/topic_disapproved.txt b/phpBB/language/en/email/short/topic_disapproved.txt
index a4bd9c151e..9c821e2bba 100644
--- a/phpBB/language/en/email/short/topic_disapproved.txt
+++ b/phpBB/language/en/email/short/topic_disapproved.txt
@@ -8,5 +8,4 @@ The following reason was given for the disapproval:
{REASON}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/short/topic_in_queue.txt b/phpBB/language/en/email/short/topic_in_queue.txt
index ae8f9e2484..706dddf64f 100644
--- a/phpBB/language/en/email/short/topic_in_queue.txt
+++ b/phpBB/language/en/email/short/topic_in_queue.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Topic moderation notification - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -10,8 +10,4 @@ If you want to view the topic, click the following link:
If you want to view the forum, click the following link:
{U_FORUM}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/topic_approved.txt b/phpBB/language/en/email/topic_approved.txt
index 0b09918b89..60c7ef4c09 100644
--- a/phpBB/language/en/email/topic_approved.txt
+++ b/phpBB/language/en/email/topic_approved.txt
@@ -7,5 +7,4 @@ You are receiving this notification because your topic "{TOPIC_TITLE}" at "{SITE
If you want to view the topic, click the following link:
{U_VIEW_TOPIC}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/topic_disapproved.txt b/phpBB/language/en/email/topic_disapproved.txt
index a4bd9c151e..9c821e2bba 100644
--- a/phpBB/language/en/email/topic_disapproved.txt
+++ b/phpBB/language/en/email/topic_disapproved.txt
@@ -8,5 +8,4 @@ The following reason was given for the disapproval:
{REASON}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/topic_in_queue.txt b/phpBB/language/en/email/topic_in_queue.txt
index ae8f9e2484..706dddf64f 100644
--- a/phpBB/language/en/email/topic_in_queue.txt
+++ b/phpBB/language/en/email/topic_in_queue.txt
@@ -1,4 +1,4 @@
-Subject: Topic reply notification - "{TOPIC_TITLE}"
+Subject: Topic moderation notification - "{TOPIC_TITLE}"
Hello {USERNAME},
@@ -10,8 +10,4 @@ If you want to view the topic, click the following link:
If you want to view the forum, click the following link:
{U_FORUM}
-If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
-
-{U_NOTIFICATION_SETTINGS}
-
{EMAIL_SIG}
diff --git a/phpBB/language/en/email/user_reactivate_account.txt b/phpBB/language/en/email/user_reactivate_account.txt
index 7e25018f4d..385c09f4c5 100644
--- a/phpBB/language/en/email/user_reactivate_account.txt
+++ b/phpBB/language/en/email/user_reactivate_account.txt
@@ -15,5 +15,4 @@ Please visit the following link to reactivate your account:
{U_ACTIVATE}
-
{EMAIL_SIG}
\ No newline at end of file
diff --git a/phpBB/language/en/email/user_resend_inactive.txt b/phpBB/language/en/email/user_resend_inactive.txt
index 7879b914b9..b9b95ce9e5 100644
--- a/phpBB/language/en/email/user_resend_inactive.txt
+++ b/phpBB/language/en/email/user_resend_inactive.txt
@@ -14,7 +14,6 @@ Please visit the following link in order to activate your account:
{U_ACTIVATE}
-
Thank you for registering.
{EMAIL_SIG}
\ No newline at end of file
--
cgit v1.2.1
From 4becf85f5274bbe861da05917ab466eb072ea600 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 14:58:27 -0500
Subject: [ticket/11479] Use phpbb_create_default_container
PHPBB3-11479
---
phpBB/install/install_update.php | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index cf800aefd4..aa1bd0fa35 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -75,18 +75,7 @@ class install_update extends module
global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container;
// Create a normal container now
- $phpbb_container = phpbb_create_dumped_container_unless_debug(
- 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 = phpbb_create_default_container($phpbb_root_path, $phpEx);
// Writes into global $cache
$cache = $phpbb_container->get('cache');
--
cgit v1.2.1
From ebb5169a463db9a2e7c552abf87eaf1ac8d086a2 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Wed, 24 Apr 2013 10:38:57 -0500
Subject: [ticket/11454] Add messenger function set_addresses
Automatically fills to/im from a user row
Send messenger the Jabber address if using Jabber notifications
PHPBB3-11454
---
phpBB/includes/functions_messenger.php | 18 ++++++++++++++++++
phpBB/includes/notification/method/messenger_base.php | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 821f0d970d..5c0c182f4f 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -55,6 +55,24 @@ class messenger
$this->vars = $this->msg = $this->replyto = $this->from = '';
$this->mail_priority = MAIL_NORMAL_PRIORITY;
}
+
+ /**
+ * Set addresses for to/im as available
+ *
+ * @param array $user User row
+ */
+ function set_addresses($user)
+ {
+ if ($user['user_email'])
+ {
+ $this->to($user['user_email'], ($user['username']) ?: '');
+ }
+
+ if ($user['user_jabber'])
+ {
+ $this->im($user['user_jabber'], ($user['username']) ?: '');
+ }
+ }
/**
* Sets an email address to send to
diff --git a/phpBB/includes/notification/method/messenger_base.php b/phpBB/includes/notification/method/messenger_base.php
index 2f9073e80b..4966aa94bc 100644
--- a/phpBB/includes/notification/method/messenger_base.php
+++ b/phpBB/includes/notification/method/messenger_base.php
@@ -80,7 +80,7 @@ abstract class phpbb_notification_method_messenger_base extends phpbb_notificati
$messenger->template($template_dir_prefix . $notification->get_email_template(), $user['user_lang']);
- $messenger->to($user['user_email'], $user['username']);
+ $messenger->set_addresses($user);
$messenger->assign_vars(array_merge(array(
'USERNAME' => $user['username'],
--
cgit v1.2.1
From fcdfe748b89426ed9d29c9e589fc5b98ed53a797 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 15:34:12 -0500
Subject: [ticket/11454] Use set_addresses in other applicable areas
This should fix some other bugs that may not have yet been recognized--some
areas only set to(), but sent according to user_notify_type, which is not
necessarily email.
PHPBB3-11454
---
phpBB/includes/acp/acp_inactive.php | 5 ++---
phpBB/includes/acp/acp_users.php | 4 ++--
phpBB/includes/functions_user.php | 3 +--
phpBB/includes/ucp/ucp_activate.php | 2 +-
phpBB/includes/ucp/ucp_groups.php | 3 +--
phpBB/includes/ucp/ucp_profile.php | 3 +--
phpBB/includes/ucp/ucp_register.php | 3 +--
phpBB/includes/ucp/ucp_remind.php | 3 +--
phpBB/includes/ucp/ucp_resend.php | 5 ++---
phpBB/memberlist.php | 2 +-
10 files changed, 13 insertions(+), 20 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php
index e61115f681..de4679b58d 100644
--- a/phpBB/includes/acp/acp_inactive.php
+++ b/phpBB/includes/acp/acp_inactive.php
@@ -115,7 +115,7 @@ class acp_inactive
{
$messenger->template('admin_welcome_activated', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->anti_abuse_headers($config, $user);
@@ -203,8 +203,7 @@ class acp_inactive
{
$messenger->template('user_remind_inactive', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->anti_abuse_headers($config, $user);
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 8f4a22b61f..c8542ddbe7 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -347,7 +347,7 @@ class acp_users
$messenger->template($email_template, $user_row['user_lang']);
- $messenger->to($user_row['user_email'], $user_row['username']);
+ $messenger->set_addresses($user_row);
$messenger->anti_abuse_headers($config, $user);
@@ -402,7 +402,7 @@ class acp_users
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
- $messenger->to($user_row['user_email'], $user_row['username']);
+ $messenger->set_addresses($user_row);
$messenger->anti_abuse_headers($config, $user);
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index bc636acabb..599cb24f75 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -2924,8 +2924,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
{
$messenger->template('group_approved', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($row['username']),
diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php
index 577761dfde..898dacd831 100644
--- a/phpBB/includes/ucp/ucp_activate.php
+++ b/phpBB/includes/ucp/ucp_activate.php
@@ -114,7 +114,7 @@ class ucp_activate
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
- $messenger->to($user_row['user_email'], $user_row['username']);
+ $messenger->set_addresses($user_row);
$messenger->anti_abuse_headers($config, $user);
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index 8516682633..50d13e00b1 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -212,8 +212,7 @@ class ucp_groups
{
$messenger->template('group_request', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($row['username']),
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index d2507e5dbd..55df5f610c 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -175,8 +175,7 @@ class ucp_profile
while ($row = $db->sql_fetchrow($result))
{
$messenger->template('admin_activate', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($data['username']),
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 1de38fddb7..70fbfe46fb 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -384,8 +384,7 @@ class ucp_register
while ($row = $db->sql_fetchrow($result))
{
$messenger->template('admin_activate', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($data['username']),
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index 4f65ed1866..8a7ba5d0ca 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -94,8 +94,7 @@ class ucp_remind
$messenger->template('user_activate_passwd', $user_row['user_lang']);
- $messenger->to($user_row['user_email'], $user_row['username']);
- $messenger->im($user_row['user_jabber'], $user_row['username']);
+ $messenger->set_addresses($user_row);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($user_row['username']),
diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php
index 5f1e3a92c3..ab396cdec9 100644
--- a/phpBB/includes/ucp/ucp_resend.php
+++ b/phpBB/includes/ucp/ucp_resend.php
@@ -91,7 +91,7 @@ class ucp_resend
if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
{
$messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
- $messenger->to($user_row['user_email'], $user_row['username']);
+ $messenger->set_addresses($user_row);
$messenger->anti_abuse_headers($config, $user);
@@ -126,8 +126,7 @@ class ucp_resend
while ($row = $db->sql_fetchrow($result))
{
$messenger->template('admin_activate', $row['user_lang']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->anti_abuse_headers($config, $user);
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index e6045b151a..7ecf332720 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -376,7 +376,7 @@ switch ($mode)
$messenger->subject(htmlspecialchars_decode($subject));
$messenger->replyto($user->data['user_email']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $messenger->set_addresses($row);
$messenger->assign_vars(array(
'BOARD_CONTACT' => $config['board_contact'],
--
cgit v1.2.1
From e870c04067772d227c4254533826f01252608f26 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:07:30 -0500
Subject: [ticket/11335] (class loader) Make php_ext 'php' not '.php'
PHPBB3-11335
---
phpBB/config/services.yml | 4 ++--
phpBB/includes/class_loader.php | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 3b60f0e83e..502a3c418f 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -36,7 +36,7 @@ services:
arguments:
- phpbb_
- %core.root_path%includes/
- - .%core.php_ext%
+ - %core.php_ext%
calls:
- [register, []]
- [set_cache, [@cache.driver]]
@@ -46,7 +46,7 @@ services:
arguments:
- phpbb_ext_
- %core.root_path%ext/
- - .%core.php_ext%
+ - %core.php_ext%
calls:
- [register, []]
- [set_cache, [@cache.driver]]
diff --git a/phpBB/includes/class_loader.php b/phpBB/includes/class_loader.php
index 6082800908..02a2d584dc 100644
--- a/phpBB/includes/class_loader.php
+++ b/phpBB/includes/class_loader.php
@@ -52,7 +52,7 @@ class phpbb_class_loader
* @param string $php_ext The file extension for PHP files
* @param phpbb_cache_driver_interface $cache An implementation of the phpBB cache interface.
*/
- public function __construct($prefix, $path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null)
+ public function __construct($prefix, $path, $php_ext = 'php', phpbb_cache_driver_interface $cache = null)
{
$this->prefix = $prefix;
$this->path = $path;
@@ -111,7 +111,7 @@ class phpbb_class_loader
{
if (isset($this->cached_paths[$class]))
{
- return $this->path . $this->cached_paths[$class] . $this->php_ext;
+ return $this->path . $this->cached_paths[$class] . '.' . $this->php_ext;
}
if (!preg_match('/^' . $this->prefix . '[a-zA-Z0-9_]+$/', $class))
@@ -136,7 +136,7 @@ class phpbb_class_loader
$relative_path = $dirs . implode(array_slice($parts, $i, sizeof($parts) - $i), '_');
- if (!file_exists($this->path . $relative_path . $this->php_ext))
+ if (!file_exists($this->path . $relative_path . '.' . $this->php_ext))
{
return false;
}
@@ -147,7 +147,7 @@ class phpbb_class_loader
$this->cache->put('class_loader_' . $this->prefix, $this->cached_paths);
}
- return $this->path . $relative_path . $this->php_ext;
+ return $this->path . $relative_path . '.' . $this->php_ext;
}
/**
--
cgit v1.2.1
From 6ef363547abf98445d20db61ffa5bac66b260603 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:10:17 -0500
Subject: [ticket/11335] (controller/helper.php) Make php_ext 'php' not '.php'
PHPBB3-11335
---
phpBB/config/services.yml | 2 +-
phpBB/includes/controller/helper.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 502a3c418f..949f89b946 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -70,7 +70,7 @@ services:
- @template
- @user
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
controller.resolver:
class: phpbb_controller_resolver
diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php
index 46c6307cb4..74410ddfd1 100644
--- a/phpBB/includes/controller/helper.php
+++ b/phpBB/includes/controller/helper.php
@@ -117,7 +117,7 @@ class phpbb_controller_helper
$params = array('controller' => $route);
}
- return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id);
+ return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id);
}
/**
--
cgit v1.2.1
From ce230f8dea4afb585e7aca5a1763c547b2c39e81 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:15:28 -0500
Subject: [ticket/11335] (extension manager/finder) Make php_ext 'php' not
'.php'
PHPBB3-11335
---
phpBB/config/services.yml | 4 ++--
phpBB/includes/extension/finder.php | 8 ++++----
phpBB/includes/extension/manager.php | 4 ++--
phpBB/includes/extension/metadata_manager.php | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 949f89b946..8f58d23fd9 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -134,7 +134,7 @@ services:
- @filesystem
- %tables.ext%
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
- @cache.driver
ext.finder:
@@ -144,7 +144,7 @@ services:
- @filesystem
- %core.root_path%
- @cache.driver
- - .%core.php_ext%
+ - %core.php_ext%
- _ext_finder
filesystem:
diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php
index 02a9ebb8c3..766b9e9b63 100644
--- a/phpBB/includes/extension/finder.php
+++ b/phpBB/includes/extension/finder.php
@@ -62,7 +62,7 @@ class phpbb_extension_finder
* @param string $cache_name The name of the cache variable, defaults to
* _ext_finder
*/
- public function __construct(phpbb_extension_manager $extension_manager, phpbb_filesystem $filesystem, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $php_ext = '.php', $cache_name = '_ext_finder')
+ public function __construct(phpbb_extension_manager $extension_manager, phpbb_filesystem $filesystem, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
{
$this->extension_manager = $extension_manager;
$this->filesystem = $filesystem;
@@ -256,8 +256,8 @@ class phpbb_extension_finder
*/
public function get_classes($cache = true, $use_all_available = false)
{
- $this->query['extension_suffix'] .= $this->php_ext;
- $this->query['core_suffix'] .= $this->php_ext;
+ $this->query['extension_suffix'] .= '.' . $this->php_ext;
+ $this->query['core_suffix'] .= '.' . $this->php_ext;
$files = $this->find($cache, false, $use_all_available);
@@ -277,7 +277,7 @@ class phpbb_extension_finder
{
$file = preg_replace('#^includes/#', '', $file);
- $classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen($this->php_ext)));
+ $classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen('.' . $this->php_ext)));
}
return $classes;
}
diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php
index de9a3937c3..a1022762b8 100644
--- a/phpBB/includes/extension/manager.php
+++ b/phpBB/includes/extension/manager.php
@@ -51,7 +51,7 @@ 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, phpbb_db_migrator $migrator, phpbb_filesystem $filesystem, $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, phpbb_filesystem $filesystem, $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;
@@ -412,7 +412,7 @@ class phpbb_extension_manager
RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file_info)
{
- if ($file_info->isFile() && $file_info->getFilename() == 'ext' . $this->php_ext)
+ if ($file_info->isFile() && $file_info->getFilename() == 'ext.' . $this->php_ext)
{
$ext_name = $iterator->getInnerIterator()->getSubPath();
diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php
index 36b0f8b184..1637abd340 100644
--- a/phpBB/includes/extension/metadata_manager.php
+++ b/phpBB/includes/extension/metadata_manager.php
@@ -39,7 +39,7 @@ class phpbb_extension_metadata_manager
* @param string $phpbb_root_path Path to the phpbb includes directory.
* @param string $phpEx php file extension
*/
- public function __construct($ext_name, phpbb_db_driver $db, phpbb_extension_manager $extension_manager, $phpbb_root_path, $phpEx = '.php', phpbb_template $template, phpbb_config $config)
+ public function __construct($ext_name, phpbb_db_driver $db, phpbb_extension_manager $extension_manager, $phpbb_root_path, $phpEx = 'php', phpbb_template $template, phpbb_config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->db = $db;
--
cgit v1.2.1
From fe89e566869e91a582129b1174c1831b8ee2f865 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:17:53 -0500
Subject: [ticket/11335] (hook finder) Make php_ext 'php' not '.php'
PHPBB3-11335
---
phpBB/config/services.yml | 2 +-
phpBB/includes/hook/finder.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 8f58d23fd9..dc293c83a2 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -173,7 +173,7 @@ services:
class: phpbb_hook_finder
arguments:
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
- @cache.driver
kernel_request_subscriber:
diff --git a/phpBB/includes/hook/finder.php b/phpBB/includes/hook/finder.php
index 065e685514..7b0412f733 100644
--- a/phpBB/includes/hook/finder.php
+++ b/phpBB/includes/hook/finder.php
@@ -66,7 +66,7 @@ class phpbb_hook_finder
{
while (($file = readdir($dh)) !== false)
{
- if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($this->php_ext) + 1)) === '.' . $this->php_ext)
+ if (strpos($file, 'hook_') === 0 && substr($file, -strlen('.' . $this->php_ext)) === '.' . $this->php_ext)
{
$hook_files[] = substr($file, 0, -(strlen($this->php_ext) + 1));
}
--
cgit v1.2.1
From df70b6ebe6590f3b8de32f6f4c6dbdcce1e2db34 Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:19:48 -0500
Subject: [ticket/11335] (kernel request subscriber) Make php_ext 'php' not
'.php'
PHPBB3-11335
---
phpBB/config/services.yml | 2 +-
phpBB/includes/functions_url_matcher.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index dc293c83a2..7923c94a3f 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -181,7 +181,7 @@ services:
arguments:
- @ext.finder
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
tags:
- { name: kernel.event_subscriber }
diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php
index 7280cb74eb..a89ab7b126 100644
--- a/phpBB/includes/functions_url_matcher.php
+++ b/phpBB/includes/functions_url_matcher.php
@@ -60,7 +60,7 @@ function phpbb_create_dumped_url_matcher(phpbb_extension_finder $finder, $root_p
'class' => 'phpbb_url_matcher',
));
- file_put_contents($root_path . 'cache/url_matcher' . $php_ext, $cached_url_matcher_dump);
+ file_put_contents($root_path . 'cache/url_matcher.' . $php_ext, $cached_url_matcher_dump);
}
/**
@@ -87,7 +87,7 @@ function phpbb_create_url_matcher(phpbb_extension_finder $finder, RequestContext
*/
function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext)
{
- require($root_path . 'cache/url_matcher' . $php_ext);
+ require($root_path . 'cache/url_matcher.' . $php_ext);
return new phpbb_url_matcher($context);
}
@@ -102,5 +102,5 @@ function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext)
*/
function phpbb_url_matcher_dumped($root_path, $php_ext)
{
- return file_exists($root_path . 'cache/url_matcher' . $php_ext);
+ return file_exists($root_path . 'cache/url_matcher.' . $php_ext);
}
--
cgit v1.2.1
From 14f1340903ce76fd4d72dfaf041a0e03b4272f1a Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:22:58 -0500
Subject: [ticket/11335] (avatars) Make php_ext 'php' not '.php'
PHPBB3-11335
---
phpBB/config/avatars.yml | 8 ++++----
phpBB/includes/avatar/driver/gravatar.php | 2 +-
phpBB/includes/avatar/driver/remote.php | 4 ++--
phpBB/includes/avatar/driver/upload.php | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/config/avatars.yml b/phpBB/config/avatars.yml
index fa0f07372a..0aad08bac9 100644
--- a/phpBB/config/avatars.yml
+++ b/phpBB/config/avatars.yml
@@ -4,7 +4,7 @@ services:
arguments:
- @config
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.gravatar]]
@@ -16,7 +16,7 @@ services:
arguments:
- @config
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.local]]
@@ -28,7 +28,7 @@ services:
arguments:
- @config
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.remote]]
@@ -40,7 +40,7 @@ services:
arguments:
- @config
- %core.root_path%
- - .%core.php_ext%
+ - %core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.upload]]
diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php
index 2e2ae2071f..d559da1c0d 100644
--- a/phpBB/includes/avatar/driver/gravatar.php
+++ b/phpBB/includes/avatar/driver/gravatar.php
@@ -74,7 +74,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
if (!function_exists('validate_data'))
{
- require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext);
+ require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}
$validate_array = validate_data(
diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php
index 3661e16160..7da58107a1 100644
--- a/phpBB/includes/avatar/driver/remote.php
+++ b/phpBB/includes/avatar/driver/remote.php
@@ -63,7 +63,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
if (!function_exists('validate_data'))
{
- require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext);
+ require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}
$validate_array = validate_data(
@@ -117,7 +117,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
if (!class_exists('fileupload'))
{
- include($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext);
+ include($this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext);
}
$types = fileupload::image_types();
diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php
index f91d170d7c..19737693fd 100644
--- a/phpBB/includes/avatar/driver/upload.php
+++ b/phpBB/includes/avatar/driver/upload.php
@@ -27,7 +27,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
public function get_data($row, $ignore_config = false)
{
return array(
- 'src' => $this->phpbb_root_path . 'download/file' . $this->php_ext . '?avatar=' . $row['avatar'],
+ 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
@@ -63,7 +63,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
if (!class_exists('fileupload'))
{
- include($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext);
+ include($this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext);
}
$upload = new fileupload('AVATAR_', $this->allowed_extensions, $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false));
--
cgit v1.2.1
From e5d032ca2112ba2c6156718b3fe42128e444a6fd Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:37:05 -0500
Subject: [ticket/11335] (more class loader) Make php_ext 'php' not '.php'
PHPBB3-11335
---
phpBB/common.php | 4 ++--
phpBB/download/file.php | 4 ++--
phpBB/install/database_update.php | 2 +-
phpBB/install/index.php | 4 ++--
4 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/common.php b/phpBB/common.php
index 6dd65739fc..3708b63bf9 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -85,9 +85,9 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
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 = 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 = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", "$phpEx");
$phpbb_class_loader_ext->register();
// Set up container
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index 91c05586a5..ac37737184 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -50,9 +50,9 @@ if (isset($_GET['avatar']))
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Setup class loader first
- $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx");
+ $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 = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", "$phpEx");
$phpbb_class_loader_ext->register();
// Set up container
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 867235e607..c2b31b4ecd 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
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 = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", "$phpEx");
$phpbb_class_loader->register();
// Set up container (must be done here because extensions table may not exist)
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index a03fda6395..4009db4794 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -90,9 +90,9 @@ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
// Setup class loader first
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx");
+$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 = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", "$phpEx");
$phpbb_class_loader_ext->register();
// Set up container
--
cgit v1.2.1
From f49993766e2bcf4efe346e29972f3721b1b1438a Mon Sep 17 00:00:00 2001
From: Nathan Guse
Date: Wed, 24 Apr 2013 17:41:27 -0500
Subject: [ticket/11335] (more) Make php_ext 'php' not '.php'
PHPBB3-11335
---
phpBB/includes/acp/acp_extensions.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index e4f8059b45..9b5a8da3aa 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -54,7 +54,7 @@ class acp_extensions
// If they've specified an extension, let's load the metadata manager and validate it.
if ($ext_name)
{
- $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, ".$phpEx", $template, $config);
+ $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, "$phpEx", $template, $config);
try
{
--
cgit v1.2.1
From 0d2d72e8ee5cca9e6bc9048cfa1c3ad81ef51949 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Wed, 24 Apr 2013 20:28:35 -0500
Subject: [ticket/11454] Check if the fields are set
PHPBB3-11454
---
phpBB/includes/functions_messenger.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 5c0c182f4f..f24a4c1eac 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -63,14 +63,14 @@ class messenger
*/
function set_addresses($user)
{
- if ($user['user_email'])
+ if (isset($user['user_email']) && $user['user_email'])
{
- $this->to($user['user_email'], ($user['username']) ?: '');
+ $this->to($user['user_email'], (isset($user['username']) ? $user['username'] : ''));
}
- if ($user['user_jabber'])
+ if (isset($user['user_jabber']) && $user['user_jabber'])
{
- $this->im($user['user_jabber'], ($user['username']) ?: '');
+ $this->im($user['user_jabber'], (isset($user['username']) ? $user['username'] : ''));
}
}
--
cgit v1.2.1
From 9c4553c41f0e0f2c28fb95b5e56886f77cb759ba Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Wed, 24 Apr 2013 20:39:24 -0500
Subject: [ticket/11335] Replace "$phpEx" with $phpEx
PHPBB3-11335
---
phpBB/common.php | 4 ++--
phpBB/download/file.php | 4 ++--
phpBB/includes/acp/acp_extensions.php | 2 +-
phpBB/install/database_update.php | 2 +-
phpBB/install/index.php | 4 ++--
5 files changed, 8 insertions(+), 8 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/common.php b/phpBB/common.php
index 3708b63bf9..f6f109c3de 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -85,9 +85,9 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
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 = 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 = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
// Set up container
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index ac37737184..eee2090da0 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -50,9 +50,9 @@ if (isset($_GET['avatar']))
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Setup class loader first
- $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", "$phpEx");
+ $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 = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
// Set up container
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 9b5a8da3aa..e4defa0400 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -54,7 +54,7 @@ class acp_extensions
// If they've specified an extension, let's load the metadata manager and validate it.
if ($ext_name)
{
- $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, "$phpEx", $template, $config);
+ $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, $phpEx, $template, $config);
try
{
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index c2b31b4ecd..5ea950bfad 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
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 = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx);
$phpbb_class_loader->register();
// Set up container (must be done here because extensions table may not exist)
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 4009db4794..57bcdaffc1 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -90,9 +90,9 @@ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
// Setup class loader first
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", "$phpEx");
+$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 = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
// Set up container
--
cgit v1.2.1
From e8b192fa32a4e7bba6d772075eb430424d0c4750 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 12:57:21 +0200
Subject: [ticket/11495] Do not compare to null anymore (left over from item
class)
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index f3bdfe1c7d..9f83bd757c 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -194,14 +194,14 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$result = $this->db->sql_query_limit($sql, $delta);
- $target = null;
+ $target = false;
while ($row = $this->db->sql_fetchrow($result))
{
$target = $row;
}
$this->db->sql_freeresult($result);
- if (is_null($target))
+ if (!$target)
{
$this->lock->release();
// The item is already on top or bottom
--
cgit v1.2.1
From 61e72d3a1000c48146466305c6693595324f5282 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 13:09:00 +0200
Subject: [ticket/11495] Explain move() more
An item is only moved up/down within the same parent. If the delta is larger
then the number of children, the item is moved to the top/bottom of the list
of children within this parent.
PHPBB3-11495
---
phpBB/includes/nestedset/interface.php | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index aedd57821a..b8a2e4b239 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -56,6 +56,10 @@ interface phpbb_nestedset_interface
/**
* Move an item by a given delta
*
+ * An item is only moved up/down within the same parent. If the delta is
+ * larger then the number of children, the item is moved to the top/bottom
+ * of the list of children within this parent.
+ *
* @param int $item_id The item to be moved
* @param int $delta Number of steps to move this item, < 0 => down, > 0 => up
* @return bool True if the item was moved
--
cgit v1.2.1
From 4bff28a0eeaf44eae9e99725ead6ff2cf770b857 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 13:40:25 +0200
Subject: [ticket/11495] Rename fix function to regenerate_left_right_ids()
This method regenerates the left/right ids for the nested set based on the
parent/child relations. This function executes three queries per item, so
it should only be called, when the set has one of the following problems:
- The set has a duplicated value inside the left/right id chain
- The set has a missing value inside the left/right id chain
- The set has items that do not have a left/right is set
When regenerating the items, the items are sorted by parent id and their
current left id, so the current child/parent relationships are kept and
running the function on a working set will not change any orders.
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 4 ++--
phpBB/includes/nestedset/interface.php | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 9f83bd757c..1a6b578e79 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -674,7 +674,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function recalculate_nested_set($new_id, $parent_id = 0, $reset_ids = false)
+ public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false)
{
if ($reset_ids)
{
@@ -716,7 +716,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
$new_id++;
// Then we go through any children and update their left/right id's
- $new_id = $this->recalculate_nested_set($new_id, $row[$this->column_item_id]);
+ $new_id = $this->regenerate_left_right_ids($new_id, $row[$this->column_item_id]);
// Then we come back and update the right_id for this module
if ($row[$this->column_right_id] != $new_id)
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index b8a2e4b239..9948ccf019 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -124,12 +124,24 @@ interface phpbb_nestedset_interface
public function get_parent_data(array $item);
/**
- * Recalculate Nested Sets
+ * Regenerate left/right ids from parent/child relationship
+ *
+ * This method regenerates the left/right ids for the nested set based on
+ * the parent/child relations. This function executes three queries per
+ * item, so it should only be called, when the set has one of the following
+ * problems:
+ * - The set has a duplicated value inside the left/right id chain
+ * - The set has a missing value inside the left/right id chain
+ * - The set has items that do not have a left/right is set
+ *
+ * When regenerating the items, the items are sorted by parent id and their
+ * current left id, so the current child/parent relationships are kept
+ * and running the function on a working set will not change any orders.
*
* @param int $new_id First left_id to be used (should start with 1)
* @param int $parent_id parent_id of the current set (default = 0)
* @param bool $reset_ids Should we reset all left_id/right_id on the first call?
* @return int $new_id The next left_id/right_id that should be used
*/
- public function recalculate_nested_set($new_id, $parent_id = 0, $reset_ids = false);
+ public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false);
}
--
cgit v1.2.1
From 3efae6d8af6dfe22c0790d3004fdbf20eb16a292 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 13:44:52 +0200
Subject: [ticket/11495] Explain whether move_children
prepends/appends/overwrittes
PHPBB3-11495
---
phpBB/includes/nestedset/interface.php | 3 +++
1 file changed, 3 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index 9948ccf019..9a8f9c4eea 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -85,6 +85,9 @@ interface phpbb_nestedset_interface
/**
* Moves all children of one item to another item
*
+ * If the new parent already has children, the new children are appended
+ * to the list.
+ *
* @param int $current_parent_id The current parent item
* @param int $new_parent_id The new parent item
* @return bool True if any items where moved
--
cgit v1.2.1
From ab7054445fbf397ae5bf4c13eb44a2019d71cc2d Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 13:48:19 +0200
Subject: [ticket/11495] Rename set_parent to change_parent()
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 2 +-
phpBB/includes/nestedset/interface.php | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 1a6b578e79..3817a6d217 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -388,7 +388,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function set_parent($item_id, $new_parent_id)
+ public function change_parent($item_id, $new_parent_id)
{
$item_id = (int) $item_id;
$new_parent_id = (int) $new_parent_id;
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index 9a8f9c4eea..a2dbc55c7d 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -95,13 +95,15 @@ interface phpbb_nestedset_interface
public function move_children($current_parent_id, $new_parent_id);
/**
- * Set the parent item
+ * Change parent item
+ *
+ * Moves the item to the bottom of the new parent's list of children
*
* @param int $item_id The item to be moved
* @param int $new_parent_id The new parent item
* @return bool True if the parent was set successfully
*/
- public function set_parent($item, $new_parent_id);
+ public function change_parent($item, $new_parent_id);
/**
* Get branch of the item
--
cgit v1.2.1
From fe97915fc91e4fbfb211e3eb6038dd1b482553dd Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 14:05:41 +0200
Subject: [ticket/11495] Split get_branch_data into multiple methods
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 56 +++++++++++++++++++++++-----------
phpBB/includes/nestedset/interface.php | 27 +++++++++++++---
2 files changed, 62 insertions(+), 21 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 3817a6d217..fe6318304d 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -115,7 +115,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
*/
public function remove($item_id)
{
- $items = $this->get_branch_data($item_id, 'children');
+ $items = $this->get_children_branch_data($item_id);
$item_ids = array_keys($items);
$this->remove_subset($item_ids, $items[$item_id]);
@@ -299,7 +299,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $item_data = $this->get_branch_data($current_parent_id, 'children');
+ $item_data = $this->get_children_branch_data($current_parent_id);
if (!isset($item_data[$current_parent_id]))
{
$this->lock->release();
@@ -408,7 +408,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $item_data = $this->get_branch_data($item_id, 'children');
+ $item_data = $this->get_children_branch_data($item_id);
if (!isset($item_data[$item_id]))
{
$this->lock->release();
@@ -490,24 +490,46 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
/**
* @inheritdoc
*/
- public function get_branch_data($item_id, $type = 'all', $order_desc = true, $include_item = true)
+ public function get_full_branch_data($item_id, $order_desc = true, $include_item = true)
{
- switch ($type)
- {
- case 'parents':
- $condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
- break;
+ $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
+ OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
- case 'children':
- $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
- break;
+ return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ }
- default:
- $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
- OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
- break;
- }
+ /**
+ * @inheritdoc
+ */
+ public function get_parent_branch_data($item_id, $order_desc = true, $include_item = true)
+ {
+ $condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
+
+ return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_children_branch_data($item_id, $order_desc = true, $include_item = true)
+ {
+ $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
+
+ return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ }
+ /**
+ * Get children and parent branch of the item
+ *
+ * @param int $item_id The item id to get the parents/children from
+ * @param string $condition Query string restricting the item list
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the given item be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ protected function get_branch_data($item_id, $condition, $order_desc = true, $include_item = true)
+ {
$rows = array();
$sql = 'SELECT i2.*
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index a2dbc55c7d..ee78016425 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -106,18 +106,37 @@ interface phpbb_nestedset_interface
public function change_parent($item, $new_parent_id);
/**
- * Get branch of the item
+ * Get children and parent branch of the item
*
- * This method can return all parents, children or both of the given item
+ * @param int $item_id The item id to get the parents/children from
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the given item be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ public function get_full_branch_data($item_id, $order_desc, $include_item);
+
+ /**
+ * Get parent branch of the item
*
* @param int $item_id The item id to get the parents from
- * @param string $type One of all|parent|children
* @param bool $order_desc Order the items descending (most outer parent first)
* @param bool $include_item Should the given item be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_branch_data($item_id, $type, $order_desc, $include_item);
+ public function get_parent_branch_data($item_id, $order_desc, $include_item);
+
+ /**
+ * Get children branch of the item
+ *
+ * @param int $item_id The item id to get the children from
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the given item be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ public function get_children_branch_data($item_id, $order_desc, $include_item);
/**
* Get base information of parent items
--
cgit v1.2.1
From 9d7d962c0db3425e9448eb07649c6709664a56bd Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 14:08:06 +0200
Subject: [ticket/11495] Explain what "given item" means
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 2 +-
phpBB/includes/nestedset/interface.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index fe6318304d..328621a68d 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -524,7 +524,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* @param int $item_id The item id to get the parents/children from
* @param string $condition Query string restricting the item list
* @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the given item be included in the list aswell
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
index ee78016425..eadc9083b1 100644
--- a/phpBB/includes/nestedset/interface.php
+++ b/phpBB/includes/nestedset/interface.php
@@ -110,7 +110,7 @@ interface phpbb_nestedset_interface
*
* @param int $item_id The item id to get the parents/children from
* @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the given item be included in the list aswell
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
@@ -121,7 +121,7 @@ interface phpbb_nestedset_interface
*
* @param int $item_id The item id to get the parents from
* @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the given item be included in the list aswell
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
@@ -132,7 +132,7 @@ interface phpbb_nestedset_interface
*
* @param int $item_id The item id to get the children from
* @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the given item be included in the list aswell
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
--
cgit v1.2.1
From 804f139be0534691fc1c8f6ddaf7ebc68a7d0a1c Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 16:17:58 +0200
Subject: [ticket/11495] Use default exceptions
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 28 ++++++++++++++--------------
phpBB/includes/nestedset/exception.php | 20 --------------------
2 files changed, 14 insertions(+), 34 deletions(-)
delete mode 100644 phpBB/includes/nestedset/exception.php
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index 328621a68d..da6c056313 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -150,7 +150,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (!$this->lock->acquire())
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
$action = ($delta > 0) ? 'move_up' : 'move_down';
@@ -168,7 +168,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (!$item)
{
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
/**
@@ -291,19 +291,19 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (!$current_parent_id)
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
if (!$this->lock->acquire())
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
$item_data = $this->get_children_branch_data($current_parent_id);
if (!isset($item_data[$current_parent_id]))
{
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
$current_parent = $item_data[$current_parent_id];
@@ -319,7 +319,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (in_array($new_parent_id, $move_items))
{
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
$diff = sizeof($move_items) * 2;
@@ -343,7 +343,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
$this->db->sql_transaction('rollback');
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
$new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
@@ -400,19 +400,19 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (!$item_id)
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
if (!$this->lock->acquire())
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
$item_data = $this->get_children_branch_data($item_id);
if (!isset($item_data[$item_id]))
{
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_ITEM');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
$item = $item_data[$item_id];
@@ -421,7 +421,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
if (in_array($new_parent_id, $move_items))
{
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
$diff = sizeof($move_items) * 2;
@@ -445,7 +445,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
$this->db->sql_transaction('rollback');
$this->lock->release();
- throw new phpbb_nestedset_exception($this->message_prefix . 'INVALID_PARENT');
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
$new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
@@ -612,7 +612,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
if (!$table_already_locked && !$this->lock->acquire())
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
$diff = sizeof($subset_items) * 2;
@@ -702,7 +702,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
{
if (!$this->lock->acquire())
{
- throw new phpbb_nestedset_exception($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
$this->db->sql_transaction('begin');
diff --git a/phpBB/includes/nestedset/exception.php b/phpBB/includes/nestedset/exception.php
deleted file mode 100644
index 10937d0b29..0000000000
--- a/phpBB/includes/nestedset/exception.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
Date: Thu, 25 Apr 2013 16:23:47 +0200
Subject: [ticket/11495] Explain use of set_subset_zero on remove_subset()
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
index da6c056313..cb06a0dabe 100644
--- a/phpBB/includes/nestedset/base.php
+++ b/phpBB/includes/nestedset/base.php
@@ -603,8 +603,10 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface
* Remove a subset from the nested set
*
* @param array $subset_items Subset of items to remove
- * @param array $bounding_item Item containing the right bound of the subset
- * @param bool $set_subset_zero Should the parent, left and right id of the item be set to 0, or kept unchanged?
+ * @param array $bounding_item Item containing the right bound of the subset
+ * @param bool $set_subset_zero Should the parent, left and right id of the items be set to 0, or kept unchanged?
+ * In case of removing an item from the tree, we should the values to 0
+ * In case of moving an item, we shouldkeep the original values, in order to allow "+ diff" later
* @param bool $table_already_locked Is the table already locked, or should we acquire a new lock?
* @return null
*/
--
cgit v1.2.1
From b334a2ce0fe3ae196da9686028667c430eb411d1 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 17:04:37 +0200
Subject: [ticket/11495] Move classes to tree/ as they all implement a tree
PHPBB3-11495
---
phpBB/includes/nestedset/base.php | 766 --------------------------------
phpBB/includes/nestedset/forum.php | 52 ---
phpBB/includes/nestedset/interface.php | 171 -------
phpBB/includes/tree/interface.php | 171 +++++++
phpBB/includes/tree/nestedset.php | 766 ++++++++++++++++++++++++++++++++
phpBB/includes/tree/nestedset_forum.php | 52 +++
6 files changed, 989 insertions(+), 989 deletions(-)
delete mode 100644 phpBB/includes/nestedset/base.php
delete mode 100644 phpBB/includes/nestedset/forum.php
delete mode 100644 phpBB/includes/nestedset/interface.php
create mode 100644 phpBB/includes/tree/interface.php
create mode 100644 phpBB/includes/tree/nestedset.php
create mode 100644 phpBB/includes/tree/nestedset_forum.php
(limited to 'phpBB')
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php
deleted file mode 100644
index cb06a0dabe..0000000000
--- a/phpBB/includes/nestedset/base.php
+++ /dev/null
@@ -1,766 +0,0 @@
-sql_where) ? '' : $operator . ' ' . sprintf($this->sql_where, $column_prefix);
- }
-
- /**
- * @inheritdoc
- */
- public function insert(array $additional_data)
- {
- $item_data = $this->reset_nestedset_values($additional_data);
-
- $sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
- $this->db->sql_query($sql);
-
- $item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
-
- return array_merge($item_data, $this->add($item_data));
- }
-
- /**
- * @inheritdoc
- */
- public function add(array $item)
- {
- $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
- FROM ' . $this->table_name . '
- ' . $this->get_sql_where('WHERE');
- $result = $this->db->sql_query($sql);
- $current_max_right_id = (int) $this->db->sql_fetchfield($this->column_right_id);
- $this->db->sql_freeresult($result);
-
- $update_item_data = array(
- $this->column_parent_id => 0,
- $this->column_left_id => $current_max_right_id + 1,
- $this->column_right_id => $current_max_right_id + 2,
- $this->column_item_parents => '',
- );
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id];
- $this->db->sql_query($sql);
-
- return $update_item_data;
- }
-
- /**
- * @inheritdoc
- */
- public function remove($item_id)
- {
- $items = $this->get_children_branch_data($item_id);
- $item_ids = array_keys($items);
-
- $this->remove_subset($item_ids, $items[$item_id]);
-
- return $item_ids;
- }
-
- /**
- * @inheritdoc
- */
- public function delete($item_id)
- {
- $removed_items = $this->remove($item_id);
-
- $sql = 'DELETE FROM ' . $this->table_name . '
- WHERE ' . $this->db->sql_in_set($this->column_item_id, $removed_items) . '
- ' . $this->get_sql_where('AND');
- $this->db->sql_query($sql);
-
- return $removed_items;
- }
-
- /**
- * @inheritdoc
- */
- public function move($item_id, $delta)
- {
- if ($delta == 0)
- {
- return false;
- }
-
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
-
- $action = ($delta > 0) ? 'move_up' : 'move_down';
- $delta = abs($delta);
-
- // Keep $this->get_sql_where() here, to ensure we are in the right tree.
- $sql = 'SELECT *
- FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $item_id . '
- ' . $this->get_sql_where();
- $result = $this->db->sql_query_limit($sql, $delta);
- $item = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- if (!$item)
- {
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
- }
-
- /**
- * Fetch all the siblings between the item's current spot
- * and where we want to move it to. If there are less than $delta
- * siblings between the current spot and the target then the
- * item will move as far as possible
- */
- $sql = "SELECT {$this->column_item_id}, {$this->column_parent_id}, {$this->column_left_id}, {$this->column_right_id}, {$this->column_item_parents}
- FROM " . $this->table_name . '
- WHERE ' . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id] . '
- ' . $this->get_sql_where() . '
- AND ';
-
- if ($action == 'move_up')
- {
- $sql .= $this->column_right_id . ' < ' . (int) $item[$this->column_right_id] . ' ORDER BY ' . $this->column_right_id . ' DESC';
- }
- else
- {
- $sql .= $this->column_left_id . ' > ' . (int) $item[$this->column_left_id] . ' ORDER BY ' . $this->column_left_id . ' ASC';
- }
-
- $result = $this->db->sql_query_limit($sql, $delta);
-
- $target = false;
- while ($row = $this->db->sql_fetchrow($result))
- {
- $target = $row;
- }
- $this->db->sql_freeresult($result);
-
- if (!$target)
- {
- $this->lock->release();
- // The item is already on top or bottom
- return false;
- }
-
- /**
- * $left_id and $right_id define the scope of the items that are affected by the move.
- * $diff_up and $diff_down are the values to substract or add to each item's left_id
- * and right_id in order to move them up or down.
- * $move_up_left and $move_up_right define the scope of the items that are moving
- * up. Other items in the scope of ($left_id, $right_id) are considered to move down.
- */
- if ($action == 'move_up')
- {
- $left_id = (int) $target[$this->column_left_id];
- $right_id = (int) $item[$this->column_right_id];
-
- $diff_up = (int) $item[$this->column_left_id] - (int) $target[$this->column_left_id];
- $diff_down = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
-
- $move_up_left = (int) $item[$this->column_left_id];
- $move_up_right = (int) $item[$this->column_right_id];
- }
- else
- {
- $left_id = (int) $item[$this->column_left_id];
- $right_id = (int) $target[$this->column_right_id];
-
- $diff_up = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
- $diff_down = (int) $target[$this->column_right_id] - (int) $item[$this->column_right_id];
-
- $move_up_left = (int) $item[$this->column_right_id] + 1;
- $move_up_right = (int) $target[$this->column_right_id];
- }
-
- // Now do the dirty job
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_left_id . ' = ' . $this->column_left_id . ' + CASE
- WHEN ' . $this->column_left_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
- ELSE {$diff_down}
- END,
- " . $this->column_right_id . ' = ' . $this->column_right_id . ' + CASE
- WHEN ' . $this->column_right_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
- ELSE {$diff_down}
- END,
- " . $this->column_item_parents . " = ''
- WHERE
- " . $this->column_left_id . " BETWEEN {$left_id} AND {$right_id}
- AND " . $this->column_right_id . " BETWEEN {$left_id} AND {$right_id}
- " . $this->get_sql_where();
- $this->db->sql_query($sql);
-
- $this->lock->release();
-
- return true;
- }
-
- /**
- * @inheritdoc
- */
- public function move_down($item_id)
- {
- return $this->move($item_id, -1);
- }
-
- /**
- * @inheritdoc
- */
- public function move_up($item_id)
- {
- return $this->move($item_id, 1);
- }
-
- /**
- * @inheritdoc
- */
- public function move_children($current_parent_id, $new_parent_id)
- {
- $current_parent_id = (int) $current_parent_id;
- $new_parent_id = (int) $new_parent_id;
-
- if ($current_parent_id == $new_parent_id)
- {
- return false;
- }
-
- if (!$current_parent_id)
- {
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
- }
-
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
-
- $item_data = $this->get_children_branch_data($current_parent_id);
- if (!isset($item_data[$current_parent_id]))
- {
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
- }
-
- $current_parent = $item_data[$current_parent_id];
- unset($item_data[$current_parent_id]);
- $move_items = array_keys($item_data);
-
- if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1)
- {
- $this->lock->release();
- return false;
- }
-
- if (in_array($new_parent_id, $move_items))
- {
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
- }
-
- $diff = sizeof($move_items) * 2;
- $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true);
-
- $this->db->sql_transaction('begin');
-
- $this->remove_subset($move_items, $current_parent, false, true);
-
- if ($new_parent_id)
- {
- // Retrieve new-parent again, it may have been changed...
- $sql = 'SELECT *
- FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . $new_parent_id;
- $result = $this->db->sql_query($sql);
- $new_parent = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- if (!$new_parent)
- {
- $this->db->sql_transaction('rollback');
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
- }
-
- $new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
-
- if ($new_right_id > $current_parent[$this->column_right_id])
- {
- $diff = ' + ' . ($new_right_id - $current_parent[$this->column_right_id]);
- }
- else
- {
- $diff = ' - ' . abs($new_right_id - $current_parent[$this->column_right_id]);
- }
- }
- else
- {
- $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
- FROM ' . $this->table_name . '
- WHERE ' . $sql_exclude_moved_items . '
- ' . $this->get_sql_where('AND');
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $diff = ' + ' . ($row[$this->column_right_id] - $current_parent[$this->column_left_id]);
- }
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
- ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
- ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent_id, $new_parent_id, $this->column_parent_id) . ',
- ' . $this->column_item_parents . " = ''
- WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
- ' . $this->get_sql_where('AND');
- $this->db->sql_query($sql);
-
- $this->db->sql_transaction('commit');
- $this->lock->release();
-
- return true;
- }
-
- /**
- * @inheritdoc
- */
- public function change_parent($item_id, $new_parent_id)
- {
- $item_id = (int) $item_id;
- $new_parent_id = (int) $new_parent_id;
-
- if ($item_id == $new_parent_id)
- {
- return false;
- }
-
- if (!$item_id)
- {
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
- }
-
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
-
- $item_data = $this->get_children_branch_data($item_id);
- if (!isset($item_data[$item_id]))
- {
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
- }
-
- $item = $item_data[$item_id];
- $move_items = array_keys($item_data);
-
- if (in_array($new_parent_id, $move_items))
- {
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
- }
-
- $diff = sizeof($move_items) * 2;
- $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true);
-
- $this->db->sql_transaction('begin');
-
- $this->remove_subset($move_items, $item, false, true);
-
- if ($new_parent_id)
- {
- // Retrieve new-parent again, it may have been changed...
- $sql = 'SELECT *
- FROM ' . $this->table_name . '
- WHERE ' . $this->column_item_id . ' = ' . $new_parent_id;
- $result = $this->db->sql_query($sql);
- $new_parent = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- if (!$new_parent)
- {
- $this->db->sql_transaction('rollback');
- $this->lock->release();
- throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
- }
-
- $new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
-
- if ($new_right_id > (int) $item[$this->column_right_id])
- {
- $diff = ' + ' . ($new_right_id - (int) $item[$this->column_right_id] - 1);
- }
- else
- {
- $diff = ' - ' . abs($new_right_id - (int) $item[$this->column_right_id] - 1);
- }
- }
- else
- {
- $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
- FROM ' . $this->table_name . '
- WHERE ' . $sql_exclude_moved_items . '
- ' . $this->get_sql_where('AND');
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $diff = ' + ' . ($row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
- }
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
- ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
- ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item_id, $new_parent_id, $this->column_parent_id) . ',
- ' . $this->column_item_parents . " = ''
- WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
- ' . $this->get_sql_where('AND');
- $this->db->sql_query($sql);
-
- $this->db->sql_transaction('commit');
- $this->lock->release();
-
- return true;
- }
-
- /**
- * @inheritdoc
- */
- public function get_full_branch_data($item_id, $order_desc = true, $include_item = true)
- {
- $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
- OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
-
- return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
- }
-
- /**
- * @inheritdoc
- */
- public function get_parent_branch_data($item_id, $order_desc = true, $include_item = true)
- {
- $condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
-
- return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
- }
-
- /**
- * @inheritdoc
- */
- public function get_children_branch_data($item_id, $order_desc = true, $include_item = true)
- {
- $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
-
- return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
- }
-
- /**
- * Get children and parent branch of the item
- *
- * @param int $item_id The item id to get the parents/children from
- * @param string $condition Query string restricting the item list
- * @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
- * @return array Array of items (containing all columns from the item table)
- * ID => Item data
- */
- protected function get_branch_data($item_id, $condition, $order_desc = true, $include_item = true)
- {
- $rows = array();
-
- $sql = 'SELECT i2.*
- FROM ' . $this->table_name . ' i1
- LEFT JOIN ' . $this->table_name . " i2
- ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
- WHERE i1.' . $this->column_item_id . ' = ' . (int) $item_id . '
- ' . $this->get_sql_where('AND', 'i1.') . '
- ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
- $result = $this->db->sql_query($sql);
-
- while ($row = $this->db->sql_fetchrow($result))
- {
- if (!$include_item && $item_id == $row[$this->column_item_id])
- {
- continue;
- }
-
- $rows[(int) $row[$this->column_item_id]] = $row;
- }
- $this->db->sql_freeresult($result);
-
- return $rows;
- }
-
- /**
- * Get base information of parent items
- *
- * Data is cached in the item_parents column in the item table
- *
- * @inheritdoc
- */
- public function get_parent_data(array $item)
- {
- $parents = array();
- if ((int) $item[$this->column_parent_id])
- {
- if (!$item[$this->column_item_parents])
- {
- $sql = 'SELECT ' . implode(', ', $this->item_basic_data) . '
- FROM ' . $this->table_name . '
- WHERE ' . $this->column_left_id . ' < ' . (int) $item[$this->column_left_id] . '
- AND ' . $this->column_right_id . ' > ' . (int) $item[$this->column_right_id] . '
- ' . $this->get_sql_where('AND') . '
- ORDER BY ' . $this->column_left_id . ' ASC';
- $result = $this->db->sql_query($sql);
-
- while ($row = $this->db->sql_fetchrow($result))
- {
- $parents[$row[$this->column_item_id]] = $row;
- }
- $this->db->sql_freeresult($result);
-
- $item_parents = serialize($parents);
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_item_parents . " = '" . $this->db->sql_escape($item_parents) . "'
- WHERE " . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id];
- $this->db->sql_query($sql);
- }
- else
- {
- $parents = unserialize($item[$this->column_item_parents]);
- }
- }
-
- return $parents;
- }
-
- /**
- * Remove a subset from the nested set
- *
- * @param array $subset_items Subset of items to remove
- * @param array $bounding_item Item containing the right bound of the subset
- * @param bool $set_subset_zero Should the parent, left and right id of the items be set to 0, or kept unchanged?
- * In case of removing an item from the tree, we should the values to 0
- * In case of moving an item, we shouldkeep the original values, in order to allow "+ diff" later
- * @param bool $table_already_locked Is the table already locked, or should we acquire a new lock?
- * @return null
- */
- protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true, $table_already_locked = false)
- {
- if (!$table_already_locked && !$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
-
- $diff = sizeof($subset_items) * 2;
- $sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
- $sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
-
- $sql_is_parent = $this->column_left_id . ' <= ' . (int) $bounding_item[$this->column_right_id] . '
- AND ' . $this->column_right_id . ' >= ' . (int) $bounding_item[$this->column_right_id];
-
- $sql_is_right = $this->column_left_id . ' > ' . (int) $bounding_item[$this->column_right_id];
-
- $set_left_id = $this->db->sql_case($sql_is_right, $this->column_left_id . ' - ' . $diff, $this->column_left_id);
- $set_right_id = $this->db->sql_case($sql_is_parent . ' OR ' . $sql_is_right, $this->column_right_id . ' - ' . $diff, $this->column_right_id);
-
- if ($set_subset_zero)
- {
- $set_left_id = $this->db->sql_case($sql_subset_items, 0, $set_left_id);
- $set_right_id = $this->db->sql_case($sql_subset_items, 0, $set_right_id);
- }
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
- ' . $this->column_right_id . ' = ' . $set_right_id . ',
- ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->column_parent_id) . ',' : '') . '
- ' . $this->column_item_parents . " = ''
- " . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
- $this->db->sql_query($sql);
-
- if (!$table_already_locked)
- {
- $this->lock->release();
- }
- }
-
- /**
- * Add a subset to the nested set
- *
- * @param array $subset_items Subset of items to add
- * @param array $new_parent Item containing the right bound of the new parent
- * @return int New right id of the parent item
- */
- protected function prepare_adding_subset(array $subset_items, array $new_parent)
- {
- $diff = sizeof($subset_items) * 2;
- $sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
-
- $set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . (int) $new_parent[$this->column_right_id], $this->column_left_id . ' + ' . $diff, $this->column_left_id);
- $set_right_id = $this->db->sql_case($this->column_right_id . ' >= ' . (int) $new_parent[$this->column_right_id], $this->column_right_id . ' + ' . $diff, $this->column_right_id);
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
- ' . $this->column_right_id . ' = ' . $set_right_id . ',
- ' . $this->column_item_parents . " = ''
- WHERE " . $sql_not_subset_items . '
- ' . $this->get_sql_where('AND');
- $this->db->sql_query($sql);
-
- return $new_parent[$this->column_right_id] + $diff;
- }
-
- /**
- * Resets values required for the nested set system
- *
- * @param array $item Original item data
- * @return array Original item data + nested set defaults
- */
- protected function reset_nestedset_values(array $item)
- {
- $item_data = array_merge($item, array(
- $this->column_parent_id => 0,
- $this->column_left_id => 0,
- $this->column_right_id => 0,
- $this->column_item_parents => '',
- ));
-
- unset($item_data[$this->column_item_id]);
-
- return $item_data;
- }
-
- /**
- * @inheritdoc
- */
- public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false)
- {
- if ($reset_ids)
- {
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
- $this->db->sql_transaction('begin');
-
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->db->sql_build_array('UPDATE', array(
- $this->column_left_id => 0,
- $this->column_right_id => 0,
- $this->column_item_parents => '',
- )) . '
- ' . $this->get_sql_where('WHERE');
- $this->db->sql_query($sql);
- }
-
- $sql = 'SELECT *
- FROM ' . $this->table_name . '
- WHERE ' . $this->column_parent_id . ' = ' . (int) $parent_id . '
- ' . $this->get_sql_where('AND') . '
- ORDER BY ' . $this->column_left_id . ', ' . $this->column_item_id . ' ASC';
- $result = $this->db->sql_query($sql);
- while ($row = $this->db->sql_fetchrow($result))
- {
- // First we update the left_id for this module
- if ($row[$this->column_left_id] != $new_id)
- {
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->db->sql_build_array('UPDATE', array(
- $this->column_left_id => $new_id,
- $this->column_item_parents => '',
- )) . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
- $this->db->sql_query($sql);
- }
- $new_id++;
-
- // Then we go through any children and update their left/right id's
- $new_id = $this->regenerate_left_right_ids($new_id, $row[$this->column_item_id]);
-
- // Then we come back and update the right_id for this module
- if ($row[$this->column_right_id] != $new_id)
- {
- $sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->db->sql_build_array('UPDATE', array($this->column_right_id => $new_id)) . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
- $this->db->sql_query($sql);
- }
- $new_id++;
- }
- $this->db->sql_freeresult($result);
-
-
- if ($reset_ids)
- {
- $this->db->sql_transaction('commit');
- $this->lock->release();
- }
-
- return $new_id;
- }
-}
diff --git a/phpBB/includes/nestedset/forum.php b/phpBB/includes/nestedset/forum.php
deleted file mode 100644
index dbf0e70202..0000000000
--- a/phpBB/includes/nestedset/forum.php
+++ /dev/null
@@ -1,52 +0,0 @@
-db = $db;
- $this->lock = $lock;
- $this->table_name = $table_name;
- }
-}
diff --git a/phpBB/includes/nestedset/interface.php b/phpBB/includes/nestedset/interface.php
deleted file mode 100644
index eadc9083b1..0000000000
--- a/phpBB/includes/nestedset/interface.php
+++ /dev/null
@@ -1,171 +0,0 @@
- down, > 0 => up
- * @return bool True if the item was moved
- */
- public function move($item_id, $delta);
-
- /**
- * Move an item down by 1
- *
- * @param int $item_id The item to be moved
- * @return bool True if the item was moved
- */
- public function move_down($item_id);
-
- /**
- * Move an item up by 1
- *
- * @param int $item_id The item to be moved
- * @return bool True if the item was moved
- */
- public function move_up($item_id);
-
- /**
- * Moves all children of one item to another item
- *
- * If the new parent already has children, the new children are appended
- * to the list.
- *
- * @param int $current_parent_id The current parent item
- * @param int $new_parent_id The new parent item
- * @return bool True if any items where moved
- */
- public function move_children($current_parent_id, $new_parent_id);
-
- /**
- * Change parent item
- *
- * Moves the item to the bottom of the new parent's list of children
- *
- * @param int $item_id The item to be moved
- * @param int $new_parent_id The new parent item
- * @return bool True if the parent was set successfully
- */
- public function change_parent($item, $new_parent_id);
-
- /**
- * Get children and parent branch of the item
- *
- * @param int $item_id The item id to get the parents/children from
- * @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
- * @return array Array of items (containing all columns from the item table)
- * ID => Item data
- */
- public function get_full_branch_data($item_id, $order_desc, $include_item);
-
- /**
- * Get parent branch of the item
- *
- * @param int $item_id The item id to get the parents from
- * @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
- * @return array Array of items (containing all columns from the item table)
- * ID => Item data
- */
- public function get_parent_branch_data($item_id, $order_desc, $include_item);
-
- /**
- * Get children branch of the item
- *
- * @param int $item_id The item id to get the children from
- * @param bool $order_desc Order the items descending (most outer parent first)
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
- * @return array Array of items (containing all columns from the item table)
- * ID => Item data
- */
- public function get_children_branch_data($item_id, $order_desc, $include_item);
-
- /**
- * Get base information of parent items
- *
- * @param array $item The item to get the branch from
- * @return array Array of items (containing basic columns from the item table)
- * ID => Item data
- */
- public function get_parent_data(array $item);
-
- /**
- * Regenerate left/right ids from parent/child relationship
- *
- * This method regenerates the left/right ids for the nested set based on
- * the parent/child relations. This function executes three queries per
- * item, so it should only be called, when the set has one of the following
- * problems:
- * - The set has a duplicated value inside the left/right id chain
- * - The set has a missing value inside the left/right id chain
- * - The set has items that do not have a left/right is set
- *
- * When regenerating the items, the items are sorted by parent id and their
- * current left id, so the current child/parent relationships are kept
- * and running the function on a working set will not change any orders.
- *
- * @param int $new_id First left_id to be used (should start with 1)
- * @param int $parent_id parent_id of the current set (default = 0)
- * @param bool $reset_ids Should we reset all left_id/right_id on the first call?
- * @return int $new_id The next left_id/right_id that should be used
- */
- public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false);
-}
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
new file mode 100644
index 0000000000..fd10bd357f
--- /dev/null
+++ b/phpBB/includes/tree/interface.php
@@ -0,0 +1,171 @@
+ down, > 0 => up
+ * @return bool True if the item was moved
+ */
+ public function move($item_id, $delta);
+
+ /**
+ * Move an item down by 1
+ *
+ * @param int $item_id The item to be moved
+ * @return bool True if the item was moved
+ */
+ public function move_down($item_id);
+
+ /**
+ * Move an item up by 1
+ *
+ * @param int $item_id The item to be moved
+ * @return bool True if the item was moved
+ */
+ public function move_up($item_id);
+
+ /**
+ * Moves all children of one item to another item
+ *
+ * If the new parent already has children, the new children are appended
+ * to the list.
+ *
+ * @param int $current_parent_id The current parent item
+ * @param int $new_parent_id The new parent item
+ * @return bool True if any items where moved
+ */
+ public function move_children($current_parent_id, $new_parent_id);
+
+ /**
+ * Change parent item
+ *
+ * Moves the item to the bottom of the new parent's list of children
+ *
+ * @param int $item_id The item to be moved
+ * @param int $new_parent_id The new parent item
+ * @return bool True if the parent was set successfully
+ */
+ public function change_parent($item, $new_parent_id);
+
+ /**
+ * Get children and parent branch of the item
+ *
+ * @param int $item_id The item id to get the parents/children from
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ public function get_full_branch_data($item_id, $order_desc, $include_item);
+
+ /**
+ * Get parent branch of the item
+ *
+ * @param int $item_id The item id to get the parents from
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ public function get_parent_branch_data($item_id, $order_desc, $include_item);
+
+ /**
+ * Get children branch of the item
+ *
+ * @param int $item_id The item id to get the children from
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ public function get_children_branch_data($item_id, $order_desc, $include_item);
+
+ /**
+ * Get base information of parent items
+ *
+ * @param array $item The item to get the branch from
+ * @return array Array of items (containing basic columns from the item table)
+ * ID => Item data
+ */
+ public function get_parent_data(array $item);
+
+ /**
+ * Regenerate left/right ids from parent/child relationship
+ *
+ * This method regenerates the left/right ids for the nested set based on
+ * the parent/child relations. This function executes three queries per
+ * item, so it should only be called, when the set has one of the following
+ * problems:
+ * - The set has a duplicated value inside the left/right id chain
+ * - The set has a missing value inside the left/right id chain
+ * - The set has items that do not have a left/right is set
+ *
+ * When regenerating the items, the items are sorted by parent id and their
+ * current left id, so the current child/parent relationships are kept
+ * and running the function on a working set will not change any orders.
+ *
+ * @param int $new_id First left_id to be used (should start with 1)
+ * @param int $parent_id parent_id of the current set (default = 0)
+ * @param bool $reset_ids Should we reset all left_id/right_id on the first call?
+ * @return int $new_id The next left_id/right_id that should be used
+ */
+ public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false);
+}
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
new file mode 100644
index 0000000000..2110e1a6d2
--- /dev/null
+++ b/phpBB/includes/tree/nestedset.php
@@ -0,0 +1,766 @@
+sql_where) ? '' : $operator . ' ' . sprintf($this->sql_where, $column_prefix);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function insert(array $additional_data)
+ {
+ $item_data = $this->reset_nestedset_values($additional_data);
+
+ $sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
+ $this->db->sql_query($sql);
+
+ $item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
+
+ return array_merge($item_data, $this->add($item_data));
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function add(array $item)
+ {
+ $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
+ FROM ' . $this->table_name . '
+ ' . $this->get_sql_where('WHERE');
+ $result = $this->db->sql_query($sql);
+ $current_max_right_id = (int) $this->db->sql_fetchfield($this->column_right_id);
+ $this->db->sql_freeresult($result);
+
+ $update_item_data = array(
+ $this->column_parent_id => 0,
+ $this->column_left_id => $current_max_right_id + 1,
+ $this->column_right_id => $current_max_right_id + 2,
+ $this->column_item_parents => '',
+ );
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . '
+ WHERE ' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id];
+ $this->db->sql_query($sql);
+
+ return $update_item_data;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function remove($item_id)
+ {
+ $items = $this->get_children_branch_data($item_id);
+ $item_ids = array_keys($items);
+
+ $this->remove_subset($item_ids, $items[$item_id]);
+
+ return $item_ids;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function delete($item_id)
+ {
+ $removed_items = $this->remove($item_id);
+
+ $sql = 'DELETE FROM ' . $this->table_name . '
+ WHERE ' . $this->db->sql_in_set($this->column_item_id, $removed_items) . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ return $removed_items;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move($item_id, $delta)
+ {
+ if ($delta == 0)
+ {
+ return false;
+ }
+
+ if (!$this->lock->acquire())
+ {
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
+ $action = ($delta > 0) ? 'move_up' : 'move_down';
+ $delta = abs($delta);
+
+ // Keep $this->get_sql_where() here, to ensure we are in the right tree.
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->column_item_id . ' = ' . (int) $item_id . '
+ ' . $this->get_sql_where();
+ $result = $this->db->sql_query_limit($sql, $delta);
+ $item = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (!$item)
+ {
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ /**
+ * Fetch all the siblings between the item's current spot
+ * and where we want to move it to. If there are less than $delta
+ * siblings between the current spot and the target then the
+ * item will move as far as possible
+ */
+ $sql = "SELECT {$this->column_item_id}, {$this->column_parent_id}, {$this->column_left_id}, {$this->column_right_id}, {$this->column_item_parents}
+ FROM " . $this->table_name . '
+ WHERE ' . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id] . '
+ ' . $this->get_sql_where() . '
+ AND ';
+
+ if ($action == 'move_up')
+ {
+ $sql .= $this->column_right_id . ' < ' . (int) $item[$this->column_right_id] . ' ORDER BY ' . $this->column_right_id . ' DESC';
+ }
+ else
+ {
+ $sql .= $this->column_left_id . ' > ' . (int) $item[$this->column_left_id] . ' ORDER BY ' . $this->column_left_id . ' ASC';
+ }
+
+ $result = $this->db->sql_query_limit($sql, $delta);
+
+ $target = false;
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $target = $row;
+ }
+ $this->db->sql_freeresult($result);
+
+ if (!$target)
+ {
+ $this->lock->release();
+ // The item is already on top or bottom
+ return false;
+ }
+
+ /**
+ * $left_id and $right_id define the scope of the items that are affected by the move.
+ * $diff_up and $diff_down are the values to substract or add to each item's left_id
+ * and right_id in order to move them up or down.
+ * $move_up_left and $move_up_right define the scope of the items that are moving
+ * up. Other items in the scope of ($left_id, $right_id) are considered to move down.
+ */
+ if ($action == 'move_up')
+ {
+ $left_id = (int) $target[$this->column_left_id];
+ $right_id = (int) $item[$this->column_right_id];
+
+ $diff_up = (int) $item[$this->column_left_id] - (int) $target[$this->column_left_id];
+ $diff_down = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
+
+ $move_up_left = (int) $item[$this->column_left_id];
+ $move_up_right = (int) $item[$this->column_right_id];
+ }
+ else
+ {
+ $left_id = (int) $item[$this->column_left_id];
+ $right_id = (int) $target[$this->column_right_id];
+
+ $diff_up = (int) $item[$this->column_right_id] + 1 - (int) $item[$this->column_left_id];
+ $diff_down = (int) $target[$this->column_right_id] - (int) $item[$this->column_right_id];
+
+ $move_up_left = (int) $item[$this->column_right_id] + 1;
+ $move_up_right = (int) $target[$this->column_right_id];
+ }
+
+ // Now do the dirty job
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_left_id . ' = ' . $this->column_left_id . ' + CASE
+ WHEN ' . $this->column_left_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
+ ELSE {$diff_down}
+ END,
+ " . $this->column_right_id . ' = ' . $this->column_right_id . ' + CASE
+ WHEN ' . $this->column_right_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
+ ELSE {$diff_down}
+ END,
+ " . $this->column_item_parents . " = ''
+ WHERE
+ " . $this->column_left_id . " BETWEEN {$left_id} AND {$right_id}
+ AND " . $this->column_right_id . " BETWEEN {$left_id} AND {$right_id}
+ " . $this->get_sql_where();
+ $this->db->sql_query($sql);
+
+ $this->lock->release();
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_down($item_id)
+ {
+ return $this->move($item_id, -1);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_up($item_id)
+ {
+ return $this->move($item_id, 1);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function move_children($current_parent_id, $new_parent_id)
+ {
+ $current_parent_id = (int) $current_parent_id;
+ $new_parent_id = (int) $new_parent_id;
+
+ if ($current_parent_id == $new_parent_id)
+ {
+ return false;
+ }
+
+ if (!$current_parent_id)
+ {
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ if (!$this->lock->acquire())
+ {
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
+ $item_data = $this->get_children_branch_data($current_parent_id);
+ if (!isset($item_data[$current_parent_id]))
+ {
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ $current_parent = $item_data[$current_parent_id];
+ unset($item_data[$current_parent_id]);
+ $move_items = array_keys($item_data);
+
+ if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1)
+ {
+ $this->lock->release();
+ return false;
+ }
+
+ if (in_array($new_parent_id, $move_items))
+ {
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
+ }
+
+ $diff = sizeof($move_items) * 2;
+ $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true);
+
+ $this->db->sql_transaction('begin');
+
+ $this->remove_subset($move_items, $current_parent, false, true);
+
+ if ($new_parent_id)
+ {
+ // Retrieve new-parent again, it may have been changed...
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->column_item_id . ' = ' . $new_parent_id;
+ $result = $this->db->sql_query($sql);
+ $new_parent = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (!$new_parent)
+ {
+ $this->db->sql_transaction('rollback');
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
+ }
+
+ $new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
+
+ if ($new_right_id > $current_parent[$this->column_right_id])
+ {
+ $diff = ' + ' . ($new_right_id - $current_parent[$this->column_right_id]);
+ }
+ else
+ {
+ $diff = ' - ' . abs($new_right_id - $current_parent[$this->column_right_id]);
+ }
+ }
+ else
+ {
+ $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $sql_exclude_moved_items . '
+ ' . $this->get_sql_where('AND');
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $diff = ' + ' . ($row[$this->column_right_id] - $current_parent[$this->column_left_id]);
+ }
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
+ ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent_id, $new_parent_id, $this->column_parent_id) . ',
+ ' . $this->column_item_parents . " = ''
+ WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ $this->db->sql_transaction('commit');
+ $this->lock->release();
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function change_parent($item_id, $new_parent_id)
+ {
+ $item_id = (int) $item_id;
+ $new_parent_id = (int) $new_parent_id;
+
+ if ($item_id == $new_parent_id)
+ {
+ return false;
+ }
+
+ if (!$item_id)
+ {
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ if (!$this->lock->acquire())
+ {
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
+ $item_data = $this->get_children_branch_data($item_id);
+ if (!isset($item_data[$item_id]))
+ {
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
+ $item = $item_data[$item_id];
+ $move_items = array_keys($item_data);
+
+ if (in_array($new_parent_id, $move_items))
+ {
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
+ }
+
+ $diff = sizeof($move_items) * 2;
+ $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true);
+
+ $this->db->sql_transaction('begin');
+
+ $this->remove_subset($move_items, $item, false, true);
+
+ if ($new_parent_id)
+ {
+ // Retrieve new-parent again, it may have been changed...
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->column_item_id . ' = ' . $new_parent_id;
+ $result = $this->db->sql_query($sql);
+ $new_parent = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if (!$new_parent)
+ {
+ $this->db->sql_transaction('rollback');
+ $this->lock->release();
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
+ }
+
+ $new_right_id = $this->prepare_adding_subset($move_items, $new_parent, true);
+
+ if ($new_right_id > (int) $item[$this->column_right_id])
+ {
+ $diff = ' + ' . ($new_right_id - (int) $item[$this->column_right_id] - 1);
+ }
+ else
+ {
+ $diff = ' - ' . abs($new_right_id - (int) $item[$this->column_right_id] - 1);
+ }
+ }
+ else
+ {
+ $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $sql_exclude_moved_items . '
+ ' . $this->get_sql_where('AND');
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $diff = ' + ' . ($row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
+ }
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
+ ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
+ ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item_id, $new_parent_id, $this->column_parent_id) . ',
+ ' . $this->column_item_parents . " = ''
+ WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ $this->db->sql_transaction('commit');
+ $this->lock->release();
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_full_branch_data($item_id, $order_desc = true, $include_item = true)
+ {
+ $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
+ OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
+
+ return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_parent_branch_data($item_id, $order_desc = true, $include_item = true)
+ {
+ $condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
+
+ return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_children_branch_data($item_id, $order_desc = true, $include_item = true)
+ {
+ $condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
+
+ return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ }
+
+ /**
+ * Get children and parent branch of the item
+ *
+ * @param int $item_id The item id to get the parents/children from
+ * @param string $condition Query string restricting the item list
+ * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @return array Array of items (containing all columns from the item table)
+ * ID => Item data
+ */
+ protected function get_branch_data($item_id, $condition, $order_desc = true, $include_item = true)
+ {
+ $rows = array();
+
+ $sql = 'SELECT i2.*
+ FROM ' . $this->table_name . ' i1
+ LEFT JOIN ' . $this->table_name . " i2
+ ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
+ WHERE i1.' . $this->column_item_id . ' = ' . (int) $item_id . '
+ ' . $this->get_sql_where('AND', 'i1.') . '
+ ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (!$include_item && $item_id == $row[$this->column_item_id])
+ {
+ continue;
+ }
+
+ $rows[(int) $row[$this->column_item_id]] = $row;
+ }
+ $this->db->sql_freeresult($result);
+
+ return $rows;
+ }
+
+ /**
+ * Get base information of parent items
+ *
+ * Data is cached in the item_parents column in the item table
+ *
+ * @inheritdoc
+ */
+ public function get_parent_data(array $item)
+ {
+ $parents = array();
+ if ((int) $item[$this->column_parent_id])
+ {
+ if (!$item[$this->column_item_parents])
+ {
+ $sql = 'SELECT ' . implode(', ', $this->item_basic_data) . '
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->column_left_id . ' < ' . (int) $item[$this->column_left_id] . '
+ AND ' . $this->column_right_id . ' > ' . (int) $item[$this->column_right_id] . '
+ ' . $this->get_sql_where('AND') . '
+ ORDER BY ' . $this->column_left_id . ' ASC';
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $parents[$row[$this->column_item_id]] = $row;
+ }
+ $this->db->sql_freeresult($result);
+
+ $item_parents = serialize($parents);
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_item_parents . " = '" . $this->db->sql_escape($item_parents) . "'
+ WHERE " . $this->column_parent_id . ' = ' . (int) $item[$this->column_parent_id];
+ $this->db->sql_query($sql);
+ }
+ else
+ {
+ $parents = unserialize($item[$this->column_item_parents]);
+ }
+ }
+
+ return $parents;
+ }
+
+ /**
+ * Remove a subset from the nested set
+ *
+ * @param array $subset_items Subset of items to remove
+ * @param array $bounding_item Item containing the right bound of the subset
+ * @param bool $set_subset_zero Should the parent, left and right id of the items be set to 0, or kept unchanged?
+ * In case of removing an item from the tree, we should the values to 0
+ * In case of moving an item, we shouldkeep the original values, in order to allow "+ diff" later
+ * @param bool $table_already_locked Is the table already locked, or should we acquire a new lock?
+ * @return null
+ */
+ protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true, $table_already_locked = false)
+ {
+ if (!$table_already_locked && !$this->lock->acquire())
+ {
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
+ $diff = sizeof($subset_items) * 2;
+ $sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
+ $sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
+
+ $sql_is_parent = $this->column_left_id . ' <= ' . (int) $bounding_item[$this->column_right_id] . '
+ AND ' . $this->column_right_id . ' >= ' . (int) $bounding_item[$this->column_right_id];
+
+ $sql_is_right = $this->column_left_id . ' > ' . (int) $bounding_item[$this->column_right_id];
+
+ $set_left_id = $this->db->sql_case($sql_is_right, $this->column_left_id . ' - ' . $diff, $this->column_left_id);
+ $set_right_id = $this->db->sql_case($sql_is_parent . ' OR ' . $sql_is_right, $this->column_right_id . ' - ' . $diff, $this->column_right_id);
+
+ if ($set_subset_zero)
+ {
+ $set_left_id = $this->db->sql_case($sql_subset_items, 0, $set_left_id);
+ $set_right_id = $this->db->sql_case($sql_subset_items, 0, $set_right_id);
+ }
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
+ ' . $this->column_right_id . ' = ' . $set_right_id . ',
+ ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->column_parent_id) . ',' : '') . '
+ ' . $this->column_item_parents . " = ''
+ " . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
+ $this->db->sql_query($sql);
+
+ if (!$table_already_locked)
+ {
+ $this->lock->release();
+ }
+ }
+
+ /**
+ * Add a subset to the nested set
+ *
+ * @param array $subset_items Subset of items to add
+ * @param array $new_parent Item containing the right bound of the new parent
+ * @return int New right id of the parent item
+ */
+ protected function prepare_adding_subset(array $subset_items, array $new_parent)
+ {
+ $diff = sizeof($subset_items) * 2;
+ $sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
+
+ $set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . (int) $new_parent[$this->column_right_id], $this->column_left_id . ' + ' . $diff, $this->column_left_id);
+ $set_right_id = $this->db->sql_case($this->column_right_id . ' >= ' . (int) $new_parent[$this->column_right_id], $this->column_right_id . ' + ' . $diff, $this->column_right_id);
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
+ ' . $this->column_right_id . ' = ' . $set_right_id . ',
+ ' . $this->column_item_parents . " = ''
+ WHERE " . $sql_not_subset_items . '
+ ' . $this->get_sql_where('AND');
+ $this->db->sql_query($sql);
+
+ return $new_parent[$this->column_right_id] + $diff;
+ }
+
+ /**
+ * Resets values required for the nested set system
+ *
+ * @param array $item Original item data
+ * @return array Original item data + nested set defaults
+ */
+ protected function reset_nestedset_values(array $item)
+ {
+ $item_data = array_merge($item, array(
+ $this->column_parent_id => 0,
+ $this->column_left_id => 0,
+ $this->column_right_id => 0,
+ $this->column_item_parents => '',
+ ));
+
+ unset($item_data[$this->column_item_id]);
+
+ return $item_data;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false)
+ {
+ if ($reset_ids)
+ {
+ if (!$this->lock->acquire())
+ {
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+ $this->db->sql_transaction('begin');
+
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', array(
+ $this->column_left_id => 0,
+ $this->column_right_id => 0,
+ $this->column_item_parents => '',
+ )) . '
+ ' . $this->get_sql_where('WHERE');
+ $this->db->sql_query($sql);
+ }
+
+ $sql = 'SELECT *
+ FROM ' . $this->table_name . '
+ WHERE ' . $this->column_parent_id . ' = ' . (int) $parent_id . '
+ ' . $this->get_sql_where('AND') . '
+ ORDER BY ' . $this->column_left_id . ', ' . $this->column_item_id . ' ASC';
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ // First we update the left_id for this module
+ if ($row[$this->column_left_id] != $new_id)
+ {
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', array(
+ $this->column_left_id => $new_id,
+ $this->column_item_parents => '',
+ )) . '
+ WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
+ $this->db->sql_query($sql);
+ }
+ $new_id++;
+
+ // Then we go through any children and update their left/right id's
+ $new_id = $this->regenerate_left_right_ids($new_id, $row[$this->column_item_id]);
+
+ // Then we come back and update the right_id for this module
+ if ($row[$this->column_right_id] != $new_id)
+ {
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->db->sql_build_array('UPDATE', array($this->column_right_id => $new_id)) . '
+ WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
+ $this->db->sql_query($sql);
+ }
+ $new_id++;
+ }
+ $this->db->sql_freeresult($result);
+
+
+ if ($reset_ids)
+ {
+ $this->db->sql_transaction('commit');
+ $this->lock->release();
+ }
+
+ return $new_id;
+ }
+}
diff --git a/phpBB/includes/tree/nestedset_forum.php b/phpBB/includes/tree/nestedset_forum.php
new file mode 100644
index 0000000000..0a66e68915
--- /dev/null
+++ b/phpBB/includes/tree/nestedset_forum.php
@@ -0,0 +1,52 @@
+db = $db;
+ $this->lock = $lock;
+ $this->table_name = $table_name;
+ }
+}
--
cgit v1.2.1
From 5de14b940e71941853d3bb279779631ae75b9b6f Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sat, 26 Jan 2013 00:22:56 +0530
Subject: [ticket/10325] add allow forgot password option in acp
PHPBB3-10325
---
phpBB/includes/acp/acp_board.php | 1 +
phpBB/language/en/acp/board.php | 2 ++
2 files changed, 3 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index bacf0d6e57..1956ade31a 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -398,6 +398,7 @@ class acp_board
'vars' => array(
'legend1' => 'ACP_SECURITY_SETTINGS',
'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'allow_forgot_password' => array('lang' => 'ALLOW_FORGOT_PASSWORD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index f387158a0b..4b2020b894 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -454,6 +454,8 @@ $lang = array_merge($lang, array(
'ALL' => 'All',
'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins',
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.',
+ 'ALLOW_FORGOT_PASSWORD' => 'Allow "forgot password"',
+ 'ALLOW_FORGOT_PASSWORD_EXPLAIN' => 'Determines whether users can use the "forgot password" option to recover their account',
'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)',
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.',
'BROWSER_VALID' => 'Validate browser',
--
cgit v1.2.1
From c6e9bd13a75441e9b35a1bfa5d2a08cc38ff1fa5 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sat, 26 Jan 2013 01:01:57 +0530
Subject: [ticket/10325] trigger error if forgot password option disabled
PHPBB3-10325
---
phpBB/includes/ucp/ucp_remind.php | 5 +++++
phpBB/language/en/ucp.php | 1 +
2 files changed, 6 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index 8a7ba5d0ca..dd95c29def 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -29,6 +29,11 @@ class ucp_remind
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
+ if (!$config['allow_forgot_password'])
+ {
+ trigger_error('UCP_FORGOT_PASSWORD_DISABLE');
+ }
+
$username = request_var('username', '', true);
$email = strtolower(request_var('email', ''));
$submit = (isset($_POST['submit'])) ? true : false;
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 3e090a8aec..a98dc6f11e 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -521,6 +521,7 @@ $lang = array_merge($lang, array(
'UCP_USERGROUPS_MEMBER' => 'Edit memberships',
'UCP_USERGROUPS_MANAGE' => 'Manage groups',
+ 'UCP_FORGOT_PASSWORD_DISABLE' => 'Function has been disabled.',
'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.',
'UCP_REMIND' => 'Send password',
'UCP_RESEND' => 'Send activation email',
--
cgit v1.2.1
From 73d873548400f18b02167ef49195a50a11970c24 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 17:19:52 +0200
Subject: [ticket/11495] Remove fixing function from tree interface
The fixing function is implementation dependent.
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 34 ++++++----------------------------
phpBB/includes/tree/nestedset.php | 19 ++++++++++++++++++-
2 files changed, 24 insertions(+), 29 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index fd10bd357f..babd0ad03d 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -18,7 +18,7 @@ if (!defined('IN_PHPBB'))
interface phpbb_tree_interface
{
/**
- * Insert an item into the nested set (also insert the rows into the table)
+ * Insert an item into the tree (also insert the rows into the table)
*
* @param array $item The item to be added
* @return array Array with item data as set in the database
@@ -26,7 +26,7 @@ interface phpbb_tree_interface
public function insert(array $additional_data);
/**
- * Add an item at the end of the nested set
+ * Add an item at the end of the tree
*
* @param array $item The item to be added
* @return bool True if the item was added
@@ -34,9 +34,9 @@ interface phpbb_tree_interface
public function add(array $item);
/**
- * Remove an item from the nested set
+ * Remove an item from the tree
*
- * Also removes all subitems from the nested set
+ * Also removes all subitems from the tree
*
* @param int $item_id The item to be deleted
* @return array Item ids that have been removed
@@ -44,9 +44,9 @@ interface phpbb_tree_interface
public function remove($item);
/**
- * Delete an item from the nested set (also deletes the rows form the table)
+ * Delete an item from the tree
*
- * Also deletes all subitems from the nested set
+ * Also deletes all subitems from the tree
*
* @param int $item_id The item to be deleted
* @return array Item ids that have been deleted
@@ -146,26 +146,4 @@ interface phpbb_tree_interface
* ID => Item data
*/
public function get_parent_data(array $item);
-
- /**
- * Regenerate left/right ids from parent/child relationship
- *
- * This method regenerates the left/right ids for the nested set based on
- * the parent/child relations. This function executes three queries per
- * item, so it should only be called, when the set has one of the following
- * problems:
- * - The set has a duplicated value inside the left/right id chain
- * - The set has a missing value inside the left/right id chain
- * - The set has items that do not have a left/right is set
- *
- * When regenerating the items, the items are sorted by parent id and their
- * current left id, so the current child/parent relationships are kept
- * and running the function on a working set will not change any orders.
- *
- * @param int $new_id First left_id to be used (should start with 1)
- * @param int $parent_id parent_id of the current set (default = 0)
- * @param bool $reset_ids Should we reset all left_id/right_id on the first call?
- * @return int $new_id The next left_id/right_id that should be used
- */
- public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false);
}
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 2110e1a6d2..72e3aa4d71 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -696,7 +696,24 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * @inheritdoc
+ * Regenerate left/right ids from parent/child relationship
+ *
+ * This method regenerates the left/right ids for the tree based on
+ * the parent/child relations. This function executes three queries per
+ * item, so it should only be called, when the set has one of the following
+ * problems:
+ * - The set has a duplicated value inside the left/right id chain
+ * - The set has a missing value inside the left/right id chain
+ * - The set has items that do not have a left/right is set
+ *
+ * When regenerating the items, the items are sorted by parent id and their
+ * current left id, so the current child/parent relationships are kept
+ * and running the function on a working set will not change any orders.
+ *
+ * @param int $new_id First left_id to be used (should start with 1)
+ * @param int $parent_id parent_id of the current set (default = 0)
+ * @param bool $reset_ids Should we reset all left_id/right_id on the first call?
+ * @return int $new_id The next left_id/right_id that should be used
*/
public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false)
{
--
cgit v1.2.1
From abfb7bc51fa254edd6274e39625eb8a4edec32be Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 17:24:18 +0200
Subject: [ticket/11495] Remove add/remove from the interface
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 20 +-------------------
phpBB/includes/tree/nestedset.php | 16 ++++++++++++----
2 files changed, 13 insertions(+), 23 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index babd0ad03d..3f03363151 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -18,31 +18,13 @@ if (!defined('IN_PHPBB'))
interface phpbb_tree_interface
{
/**
- * Insert an item into the tree (also insert the rows into the table)
+ * Insert an item into the tree
*
* @param array $item The item to be added
* @return array Array with item data as set in the database
*/
public function insert(array $additional_data);
- /**
- * Add an item at the end of the tree
- *
- * @param array $item The item to be added
- * @return bool True if the item was added
- */
- public function add(array $item);
-
- /**
- * Remove an item from the tree
- *
- * Also removes all subitems from the tree
- *
- * @param int $item_id The item to be deleted
- * @return array Item ids that have been removed
- */
- public function remove($item);
-
/**
* Delete an item from the tree
*
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 72e3aa4d71..8f73b9181e 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -84,9 +84,12 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * @inheritdoc
+ * Add an existing item at the end of the tree
+ *
+ * @param array $item The item to be added
+ * @return bool True if the item was added
*/
- public function add(array $item)
+ protected function add(array $item)
{
$sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
@@ -111,9 +114,14 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * @inheritdoc
+ * Remove an item from the tree WITHOUT removing the items from the table
+ *
+ * Also removes all subitems from the tree
+ *
+ * @param int $item_id The item to be deleted
+ * @return array Item ids that have been removed
*/
- public function remove($item_id)
+ protected function remove($item_id)
{
$items = $this->get_children_branch_data($item_id);
$item_ids = array_keys($items);
--
cgit v1.2.1
From 2dbe3b3c975d61b84310f7da27b8d525a22d1723 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sat, 26 Jan 2013 01:09:30 +0530
Subject: [ticket/10325] add new config value to database
PHPBB3-10325
---
phpBB/includes/db/migration/data/310/dev.php | 2 ++
phpBB/install/schemas/schema_data.sql | 1 +
2 files changed, 3 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php
index 13b36bbf30..d3f3a341b2 100644
--- a/phpBB/includes/db/migration/data/310/dev.php
+++ b/phpBB/includes/db/migration/data/310/dev.php
@@ -84,6 +84,8 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration
return array(
array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])),
+ array('config.add', array('allow_forgot_password', 1)),
+
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)),
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 8a8740a220..d9ba09ff4d 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -18,6 +18,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1'
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bookmarks', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_emailreuse', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forgot_password', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forum_notify', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_mass_pm', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_name_chars', 'USERNAME_CHARS_ANY');
--
cgit v1.2.1
From f8012cc239d8b442e78bbbb8a5cc5856d2a714a0 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sat, 26 Jan 2013 11:10:17 +0530
Subject: [ticket/10325] fix language
PHPBB3-10325
---
phpBB/includes/ucp/ucp_remind.php | 2 +-
phpBB/language/en/ucp.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index dd95c29def..a25d7da91a 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -31,7 +31,7 @@ class ucp_remind
if (!$config['allow_forgot_password'])
{
- trigger_error('UCP_FORGOT_PASSWORD_DISABLE');
+ trigger_error($user->lang('UCP_FORGOT_PASSWORD_DISABLE', '', ''));
}
$username = request_var('username', '', true);
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index a98dc6f11e..ce93c7bcf8 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -521,7 +521,7 @@ $lang = array_merge($lang, array(
'UCP_USERGROUPS_MEMBER' => 'Edit memberships',
'UCP_USERGROUPS_MANAGE' => 'Manage groups',
- 'UCP_FORGOT_PASSWORD_DISABLE' => 'Function has been disabled.',
+ 'UCP_FORGOT_PASSWORD_DISABLE' => 'The administrator has disabled the password reset ability. If you need help accessing your account, please contact the %sBoard Administrator%s',
'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.',
'UCP_REMIND' => 'Send password',
'UCP_RESEND' => 'Send activation email',
--
cgit v1.2.1
From 1a51abcca293b0e2bd836af0dcb9d77054c1d401 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sun, 27 Jan 2013 03:07:52 +0530
Subject: [ticket/10325] change language var
PHPBB3-10325
---
phpBB/includes/acp/acp_board.php | 2 +-
phpBB/includes/db/migration/data/310/dev.php | 2 +-
phpBB/includes/ucp/ucp_remind.php | 2 +-
phpBB/install/schemas/schema_data.sql | 2 +-
phpBB/language/en/acp/board.php | 4 ++--
5 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 1956ade31a..ab44920f0a 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -398,7 +398,7 @@ class acp_board
'vars' => array(
'legend1' => 'ACP_SECURITY_SETTINGS',
'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'allow_forgot_password' => array('lang' => 'ALLOW_FORGOT_PASSWORD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'allow_password_reset' => array('lang' => 'ALLOW_PASSWORD_RESET', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php
index d3f3a341b2..0794567f1b 100644
--- a/phpBB/includes/db/migration/data/310/dev.php
+++ b/phpBB/includes/db/migration/data/310/dev.php
@@ -84,7 +84,7 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration
return array(
array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])),
- array('config.add', array('allow_forgot_password', 1)),
+ array('config.add', array('allow_password_reset', 1)),
array('config.add', array('fulltext_postgres_ts_name', 'simple')),
array('config.add', array('fulltext_postgres_min_word_len', 4)),
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index a25d7da91a..4a2d06e99a 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -29,7 +29,7 @@ class ucp_remind
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
- if (!$config['allow_forgot_password'])
+ if (!$config['allow_password_reset'])
{
trigger_error($user->lang('UCP_FORGOT_PASSWORD_DISABLE', '', ''));
}
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index d9ba09ff4d..9690ec14b8 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -18,7 +18,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1'
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bookmarks', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_emailreuse', '0');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forgot_password', '1');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_password_reset', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forum_notify', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_mass_pm', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_name_chars', 'USERNAME_CHARS_ANY');
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 4b2020b894..c0f6153788 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -454,8 +454,8 @@ $lang = array_merge($lang, array(
'ALL' => 'All',
'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins',
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.',
- 'ALLOW_FORGOT_PASSWORD' => 'Allow "forgot password"',
- 'ALLOW_FORGOT_PASSWORD_EXPLAIN' => 'Determines whether users can use the "forgot password" option to recover their account',
+ 'ALLOW_PASSWORD_RESET' => 'Allow "forgot password"',
+ 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether users can use the "forgot password" option to recover their account',
'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)',
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.',
'BROWSER_VALID' => 'Validate browser',
--
cgit v1.2.1
From f1e615c4297a509325b764e1966118fe171ebbb5 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sun, 27 Jan 2013 03:09:52 +0530
Subject: [ticket/10325] fix language variable
PHPBB3-10325
---
phpBB/includes/ucp/ucp_remind.php | 2 +-
phpBB/language/en/ucp.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index 4a2d06e99a..cd4d13c8a7 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -31,7 +31,7 @@ class ucp_remind
if (!$config['allow_password_reset'])
{
- trigger_error($user->lang('UCP_FORGOT_PASSWORD_DISABLE', '', ''));
+ trigger_error($user->lang('UCP_FORGOT_PASSWORD_DISABLED', '', ''));
}
$username = request_var('username', '', true);
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index ce93c7bcf8..3864414af0 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -521,7 +521,7 @@ $lang = array_merge($lang, array(
'UCP_USERGROUPS_MEMBER' => 'Edit memberships',
'UCP_USERGROUPS_MANAGE' => 'Manage groups',
- 'UCP_FORGOT_PASSWORD_DISABLE' => 'The administrator has disabled the password reset ability. If you need help accessing your account, please contact the %sBoard Administrator%s',
+ 'UCP_FORGOT_PASSWORD_DISABLED' => 'The administrator has disabled the password reset ability. If you need help accessing your account, please contact the %sBoard Administrator%s',
'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.',
'UCP_REMIND' => 'Send password',
'UCP_RESEND' => 'Send activation email',
--
cgit v1.2.1
From c048067bbd45b51595cc243cc4edde1d84eda405 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sun, 27 Jan 2013 11:27:28 +0530
Subject: [ticket/10325] fix language key
PHPBB3-10325
---
phpBB/includes/ucp/ucp_remind.php | 2 +-
phpBB/language/en/ucp.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index cd4d13c8a7..ff7ab53736 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -31,7 +31,7 @@ class ucp_remind
if (!$config['allow_password_reset'])
{
- trigger_error($user->lang('UCP_FORGOT_PASSWORD_DISABLED', '', ''));
+ trigger_error($user->lang('UCP_PASSWORD_RESET_DISABLED', '', ''));
}
$username = request_var('username', '', true);
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 3864414af0..920dfaf176 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -521,7 +521,7 @@ $lang = array_merge($lang, array(
'UCP_USERGROUPS_MEMBER' => 'Edit memberships',
'UCP_USERGROUPS_MANAGE' => 'Manage groups',
- 'UCP_FORGOT_PASSWORD_DISABLED' => 'The administrator has disabled the password reset ability. If you need help accessing your account, please contact the %sBoard Administrator%s',
+ 'UCP_PASSWORD_RESET_DISABLED' => 'The administrator has disabled the password reset ability. If you need help accessing your account, please contact the %sBoard Administrator%s',
'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.',
'UCP_REMIND' => 'Send password',
'UCP_RESEND' => 'Send activation email',
--
cgit v1.2.1
From 419aaa402f025d16e8b823586e32917d1d036599 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Mon, 28 Jan 2013 01:05:04 +0530
Subject: [ticket/10325] improve acp option language
PHPBB3-10325
---
phpBB/language/en/acp/board.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index c0f6153788..c084779a26 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -455,7 +455,7 @@ $lang = array_merge($lang, array(
'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins',
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.',
'ALLOW_PASSWORD_RESET' => 'Allow "forgot password"',
- 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether users can use the "forgot password" option to recover their account',
+ 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. This feature can be disabled when using an external authentication plugin.',
'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)',
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.',
'BROWSER_VALID' => 'Validate browser',
--
cgit v1.2.1
From d242b7a1a5c9b6ecc8bc21027a33bc344501a0ce Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Thu, 25 Apr 2013 21:05:02 +0530
Subject: [ticket/10325] fix language in acp and ucp
PHPBB3-10325
---
phpBB/language/en/acp/board.php | 2 +-
phpBB/language/en/ucp.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index c084779a26..39ad5b78bb 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -455,7 +455,7 @@ $lang = array_merge($lang, array(
'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins',
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.',
'ALLOW_PASSWORD_RESET' => 'Allow "forgot password"',
- 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. This feature can be disabled when using an external authentication plugin.',
+ 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. If you use an external authentication mechanism you may wish to disable this feature.',
'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)',
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.',
'BROWSER_VALID' => 'Validate browser',
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 920dfaf176..372e44a94d 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -521,7 +521,7 @@ $lang = array_merge($lang, array(
'UCP_USERGROUPS_MEMBER' => 'Edit memberships',
'UCP_USERGROUPS_MANAGE' => 'Manage groups',
- 'UCP_PASSWORD_RESET_DISABLED' => 'The administrator has disabled the password reset ability. If you need help accessing your account, please contact the %sBoard Administrator%s',
+ 'UCP_PASSWORD_RESET_DISABLED' => 'The administrator has disabled the password reset functionality. If you need help accessing your account, please contact the %sBoard Administrator%s',
'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.',
'UCP_REMIND' => 'Send password',
'UCP_RESEND' => 'Send activation email',
--
cgit v1.2.1
From 42cfb7264dec3a1e8f141ff40b17b841e5c998cc Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Thu, 25 Apr 2013 10:58:48 -0500
Subject: [ticket/11237] Fix PHP error in acp_prune.php
Also making the code a bit more efficient (removing one SQL query)
PHPBB3-11237
---
phpBB/includes/acp/acp_prune.php | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php
index a5dc02849a..54ffe24594 100644
--- a/phpBB/includes/acp/acp_prune.php
+++ b/phpBB/includes/acp/acp_prune.php
@@ -491,11 +491,12 @@ class acp_prune
if ($group_id)
{
- $sql = 'SELECT user_id
- FROM ' . USER_GROUP_TABLE . '
- WHERE group_id = ' . (int) $group_id . '
- AND user_pending = 0
- AND ' . $db->sql_in_set('user_id', $user_ids, false, true);
+ $sql = 'SELECT u.user_id, u.username
+ FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
+ WHERE ug.group_id = ' . (int) $group_id . '
+ AND ug.user_pending = 0
+ AND ' . $db->sql_in_set('ug.user_id', $user_ids, false, true) . '
+ AND u.user_id = ug.user_id';
$result = $db->sql_query($sql);
// we're performing an intersection operation, so all the relevant users
@@ -504,24 +505,19 @@ class acp_prune
$user_ids = $usernames = array();
while ($row = $db->sql_fetchrow($result))
{
- $user_ids[] = $row['poster_id'];
+ $user_ids[] = $row['user_id'];
+ $usernames[$row['user_id']] = $row['username'];
}
$db->sql_freeresult($result);
-
- // only get usernames if they are needed (not part of some later query)
- if (!$posts_on_queue)
- {
- // this is an additional query aginst the users table
- user_get_id_name($user_ids, $usernames);
- }
}
if ($posts_on_queue)
{
- $sql = 'SELECT poster_id, COUNT(post_id) AS queue_posts
- FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('poster_id', $user_ids, false, true) . '
- GROUP BY poster_id
+ $sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts
+ FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
+ WHERE ' . $db->sql_in_set('p.poster_id', $user_ids, false, true) . '
+ AND u.user_id = p.poster_id
+ GROUP BY p.poster_id
HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue;
$result = $db->sql_query($result);
@@ -529,12 +525,10 @@ class acp_prune
$user_ids = $usernames = array();
while ($row = $db->sql_fetchrow($result))
{
- $user_ids[] = $row['poster_id'];
+ $user_ids[] = $row['user_id'];
+ $usernames[$row['user_id']] = $row['username'];
}
$db->sql_freeresult($result);
-
- // do an additional query to get the correct set of usernames
- user_get_id_name($user_ids, $usernames);
}
}
}
--
cgit v1.2.1
From 0def8b7d9cb06cd2abf462f18f1404fc119861bd Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 18:09:21 +0200
Subject: [ticket/11495] Use constructor arguments over properties in
implementation
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 31 +++++++++++++++++++++++++++
phpBB/includes/tree/nestedset_forum.php | 38 ++++++++++++++-------------------
2 files changed, 47 insertions(+), 22 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 8f73b9181e..245a8165ef 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -55,6 +55,37 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
protected $item_basic_data = array('*');
+ /**
+ * Construct
+ *
+ * @param phpbb_db_driver $db Database connection
+ * @param phpbb_lock_db $lock Lock class used to lock the table when moving forums around
+ * @param string $table_name Table name
+ * @param string $message_prefix Prefix for the messages thrown by exceptions
+ * @param string $sql_where Additional SQL restrictions for the queries
+ * @param array $item_basic_data Array with basic item data that is stored in item_parents
+ * @param array $columns Array with column names to overwrite
+ */
+ public function __construct(phpbb_db_driver $db, phpbb_lock_db $lock, $table_name, $message_prefix = '', $sql_where = '', $item_basic_data = array(), $columns = array())
+ {
+ $this->db = $db;
+ $this->lock = $lock;
+
+ $this->table_name = $table_name;
+ $this->message_prefix = $message_prefix;
+ $this->sql_where = $sql_where;
+ $this->item_basic_data = (!empty($item_basic_data)) ? $item_basic_data : array('*');
+
+ if (!empty($columns))
+ {
+ foreach ($columns as $column => $name)
+ {
+ $column_name = 'column_' . $column;
+ $this->$column_name = $name;
+ }
+ }
+ }
+
/**
* Returns additional sql where restrictions
*
diff --git a/phpBB/includes/tree/nestedset_forum.php b/phpBB/includes/tree/nestedset_forum.php
index 0a66e68915..7dcb12331c 100644
--- a/phpBB/includes/tree/nestedset_forum.php
+++ b/phpBB/includes/tree/nestedset_forum.php
@@ -17,25 +17,6 @@ if (!defined('IN_PHPBB'))
class phpbb_tree_nestedset_forum extends phpbb_tree_nestedset
{
- /**
- * Column names in the table
- * @var string
- */
- protected $column_item_id = 'forum_id';
- protected $column_item_parents = 'forum_parents';
-
- /**
- * Prefix for the language keys returned by exceptions
- * @var string
- */
- protected $message_prefix = 'FORUM_NESTEDSET_';
-
- /**
- * List of item properties to be cached in $item_parents
- * @var array
- */
- protected $item_basic_data = array('forum_id', 'forum_name', 'forum_type');
-
/**
* Construct
*
@@ -45,8 +26,21 @@ class phpbb_tree_nestedset_forum extends phpbb_tree_nestedset
*/
public function __construct(phpbb_db_driver $db, phpbb_lock_db $lock, $table_name)
{
- $this->db = $db;
- $this->lock = $lock;
- $this->table_name = $table_name;
+ parent::__construct(
+ $db,
+ $lock,
+ $table_name,
+ 'FORUM_NESTEDSET_',
+ '',
+ array(
+ 'forum_id',
+ 'forum_name',
+ 'forum_type',
+ ),
+ array(
+ 'item_id' => 'forum_id',
+ 'item_parents' => 'forum_parents',
+ )
+ );
}
}
--
cgit v1.2.1
From ee457e584c66938cc521eecf0ec303a81c536896 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Thu, 25 Apr 2013 11:16:00 -0500
Subject: [ticket/11236] Correct HTML
PHPBB3-11236
---
phpBB/includes/acp/acp_prune.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php
index a5dc02849a..e43f1558b1 100644
--- a/phpBB/includes/acp/acp_prune.php
+++ b/phpBB/includes/acp/acp_prune.php
@@ -340,7 +340,7 @@ class acp_prune
while ($row = $db->sql_fetchrow($result))
{
- $s_group_list .= '';
}
$db->sql_freeresult($result);
--
cgit v1.2.1
From 1a16ee4cb270f81ebeb8697e4bffaaa305010116 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Thu, 25 Apr 2013 11:20:13 -0500
Subject: [ticket/11236] Do not require group selection in prune users
PHPBB3-11236
---
phpBB/includes/acp/acp_prune.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php
index e43f1558b1..dc0f9a345f 100644
--- a/phpBB/includes/acp/acp_prune.php
+++ b/phpBB/includes/acp/acp_prune.php
@@ -331,7 +331,7 @@ class acp_prune
$s_find_active_time .= '';
}
- $s_group_list = '';
+ $s_group_list = '';
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
WHERE group_type <> ' . GROUP_SPECIAL . '
--
cgit v1.2.1
From e7cb0f687df93120b003ad205fc6cb3315379c80 Mon Sep 17 00:00:00 2001
From: Nathaniel Guse
Date: Thu, 25 Apr 2013 11:23:09 -0500
Subject: [ticket/11236] Change PRUNE_USERS_GROUP_EXPLAIN language
PHPBB3-11236
---
phpBB/language/en/acp/prune.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/language/en/acp/prune.php b/phpBB/language/en/acp/prune.php
index fcc085205b..3e890182c0 100644
--- a/phpBB/language/en/acp/prune.php
+++ b/phpBB/language/en/acp/prune.php
@@ -51,7 +51,7 @@ $lang = array_merge($lang, array(
'LAST_ACTIVE_EXPLAIN' => 'Enter a date in YYYY-MM-DD format. Enter 0000-00-00 to prune users who never logged in, Before and After conditions will be ignored.',
'POSTS_ON_QUEUE' => 'Posts Awaiting Approval',
- 'PRUNE_USERS_GROUP_EXPLAIN' => 'Selects all members of the group for pruning.',
+ 'PRUNE_USERS_GROUP_EXPLAIN' => 'Limit to users within the selected group.',
'PRUNE_USERS_LIST' => 'Users to be pruned',
'PRUNE_USERS_LIST_DELETE' => 'With the selected critera for pruning users the following accounts will be removed. You can remove individual users from the deletion list by unchecking the box next to their username.',
'PRUNE_USERS_LIST_DEACTIVATE' => 'With the selected critera for pruning users the following accounts will be deactivated. You can remove individual users from the deactivation list by unchecking the box next to their username.',
--
cgit v1.2.1
From baff4287e5a7142b7af41e56c29b064bb56fd7fb Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Thu, 25 Apr 2013 22:39:24 +0200
Subject: [ticket/11495] Fix comments and package docs
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 6 +++---
phpBB/includes/tree/nestedset.php | 2 +-
phpBB/includes/tree/nestedset_forum.php | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 3f03363151..4e22e322f3 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -1,7 +1,7 @@
Date: Fri, 26 Apr 2013 00:04:58 +0200
Subject: [ticket/11495] Make method names for add/remove more descriptive
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index ffe8687e54..ab6a9d6bb4 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -111,7 +111,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
- return array_merge($item_data, $this->add($item_data));
+ return array_merge($item_data, $this->add_item_to_nestedset($item_data));
}
/**
@@ -120,7 +120,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
* @param array $item The item to be added
* @return bool True if the item was added
*/
- protected function add(array $item)
+ protected function add_item_to_nestedset(array $item)
{
$sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
@@ -152,7 +152,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
* @param int $item_id The item to be deleted
* @return array Item ids that have been removed
*/
- protected function remove($item_id)
+ protected function remove_item_from_nestedset($item_id)
{
$items = $this->get_children_branch_data($item_id);
$item_ids = array_keys($items);
@@ -167,7 +167,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
public function delete($item_id)
{
- $removed_items = $this->remove($item_id);
+ $removed_items = $this->remove_item_from_nestedset($item_id);
$sql = 'DELETE FROM ' . $this->table_name . '
WHERE ' . $this->db->sql_in_set($this->column_item_id, $removed_items) . '
--
cgit v1.2.1
From 2afa6730232cc2e92ae6543852d031a29c8a361f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Fri, 26 Apr 2013 08:42:44 +0200
Subject: [ticket/11495] Fix doc blocks once more
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 6 +++---
phpBB/includes/tree/nestedset.php | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 4e22e322f3..ed0ccca3f1 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -18,7 +18,7 @@ if (!defined('IN_PHPBB'))
interface phpbb_tree_interface
{
/**
- * Insert an item into the tree (also insert the rows into the table)
+ * Inserts an item into the database table and into the tree.
*
* @param array $item The item to be added
* @return array Array with item data as set in the database
@@ -26,9 +26,9 @@ interface phpbb_tree_interface
public function insert(array $additional_data);
/**
- * Delete an item from the tree (also deletes the rows form the table)
+ * Delete an item from the tree and from the database table
*
- * Also deletes all subitems from the tree
+ * Also deletes all subitems from the tree and from the database table
*
* @param int $item_id The item to be deleted
* @return array Item ids that have been deleted
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index ab6a9d6bb4..9655a08aa5 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -115,7 +115,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * Add an existing item at the end of the tree
+ * Add an item which already has a database row at the end of the tree
*
* @param array $item The item to be added
* @return bool True if the item was added
@@ -145,9 +145,9 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * Remove an item from the tree WITHOUT removing the items from the table
+ * Remove an item from the tree without deleting it from the database
*
- * Also removes all subitems from the tree
+ * Also removes all subitems from the tree without deleting them from the database either
*
* @param int $item_id The item to be deleted
* @return array Item ids that have been removed
--
cgit v1.2.1
From cb13add269b78e1a9ac84a80c78557bb7695df09 Mon Sep 17 00:00:00 2001
From: marc1706
Date: Sun, 28 Apr 2013 22:54:48 +0200
Subject: [ticket/11442] Use correct button class for ajaxified confirm_box
In commit 001572f the HTML code for the ajaxified confirm_box was moved
from overall_footer.html to confirm_body.html. While copying, the CSS
class of the "Yes" button was changed from button1 to button2. Due to the
fact that the phpbb.confirm() method uses the class button1 to check if
"Yes" was clicked, this broke the ajaxified confirm box in the ACP. With
this small patch the confirm boxes in the ACP should work properly again.
PHPBB3-11442
---
phpBB/adm/style/confirm_body.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/adm/style/confirm_body.html b/phpBB/adm/style/confirm_body.html
index d0360d1b3a..fa3f1e6c64 100644
--- a/phpBB/adm/style/confirm_body.html
+++ b/phpBB/adm/style/confirm_body.html
@@ -4,7 +4,7 @@
{MESSAGE_TEXT}
--
cgit v1.2.1
From 947550df8f5e2ba624adc26ddd22c7fe74e4f602 Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin
Date: Tue, 30 Apr 2013 11:27:43 +0300
Subject: [ticket/10741] Docblock for phpbb.resizeTextArea
Better description of phpBB.resizeTextArea with detailed
explanation of all optional parameters.
Removed unnecessary semicolons
PHPBB3-10741
---
phpBB/assets/javascript/core.js | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 827ed2e34a..bb1fef253e 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -571,28 +571,39 @@ phpbb.addAjaxCallback('toggle_link', function() {
/**
* Automatically resize textarea
*
-* This function automatically resizes textarea elements when user
+* This function automatically resizes textarea elements when user
* types text.
*
-* @param jQuery item jQuery object to resize
-* @param object options Optional parameter that adjusts default
+* @param {jQuery} items jQuery object(s) to resize
+* @param {object} options Optional parameter that adjusts default
* configuration. See configuration variable
+*
+* Optional parameters:
+* minWindowHeight {number} Minimum browser window height when textareas are resized. Default = 500
+* minHeight {number} Minimum height of textarea. Default = 200
+* maxHeight {number} Maximum height of textarea. Default = 500
+* heightDiff {number} Minimum difference between window and textarea height. Default = 200
+* resizeCallback {function} Function to call after resizing textarea
+* resetCallback {function} Function to call when resize has been canceled
+
+* Callback function format: function(item) {}
+* this points to DOM object
+* item is a jQuery object, same as this
*/
-phpbb.resizeTextArea = function(items) {
+phpbb.resizeTextArea = function(items, options) {
// Configuration
var configuration = {
- minWindowHeight: 500, // Minimum browser window height when textareas are resized
- minHeight: 200, // Minimum height of textarea
- maxHeight: 500, // Maximum height of textarea
- heightDiff: 200, // Minimum difference between window and textarea height
- // In following callbacks parameter "item" is jQuery object. "this" points to DOM object
- resizeCallback: function(item) { }, // Function to call after resizing textarea.
- resetCallback: function(item) { } // Function to call when resize has been canceled
- }
+ minWindowHeight: 500,
+ minHeight: 200,
+ maxHeight: 500,
+ heightDiff: 200,
+ resizeCallback: function(item) { },
+ resetCallback: function(item) { }
+ };
if (arguments.length > 1)
{
- configuration = $.extend(configuration, arguments[1]);
+ configuration = $.extend(configuration, options);
}
function resetAutoResize(item)
@@ -603,7 +614,7 @@ phpbb.resizeTextArea = function(items) {
$(item).css({height: '', resize: ''}).removeClass('auto-resized');
configuration.resetCallback.call(item, $item);
}
- };
+ }
function autoResize(item)
{
@@ -634,7 +645,7 @@ phpbb.resizeTextArea = function(items) {
{
setHeight(Math.min(maxHeight, scrollHeight));
}
- };
+ }
items.bind('focus change keyup', function() {
$(this).each(function() {
--
cgit v1.2.1
From 8a4260703fa76bb92f144b527b3d55289568db74 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 10:32:01 +0200
Subject: [ticket/11495] Fix some docs and replace branch with other terms
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 20 ++++++++++----------
phpBB/includes/tree/nestedset.php | 24 ++++++++++++------------
2 files changed, 22 insertions(+), 22 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index ed0ccca3f1..1b462768a0 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -28,12 +28,12 @@ interface phpbb_tree_interface
/**
* Delete an item from the tree and from the database table
*
- * Also deletes all subitems from the tree and from the database table
+ * Also deletes the subtree from the tree and from the database table
*
* @param int $item_id The item to be deleted
* @return array Item ids that have been deleted
*/
- public function delete($item);
+ public function delete($item_id);
/**
* Move an item by a given delta
@@ -79,16 +79,16 @@ interface phpbb_tree_interface
/**
* Change parent item
*
- * Moves the item to the bottom of the new parent's list of children
+ * Moves the item to the bottom of the new parent's subtree
*
* @param int $item_id The item to be moved
* @param int $new_parent_id The new parent item
* @return bool True if the parent was set successfully
*/
- public function change_parent($item, $new_parent_id);
+ public function change_parent($item_id, $new_parent_id);
/**
- * Get children and parent branch of the item
+ * Get all items that are either a parent or part of the subtree of the item
*
* @param int $item_id The item id to get the parents/children from
* @param bool $order_desc Order the items descending (most outer parent first)
@@ -96,10 +96,10 @@ interface phpbb_tree_interface
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_full_branch_data($item_id, $order_desc, $include_item);
+ public function get_path_and_subtree_data($item_id, $order_desc, $include_item);
/**
- * Get parent branch of the item
+ * Get all parent items of the item
*
* @param int $item_id The item id to get the parents from
* @param bool $order_desc Order the items descending (most outer parent first)
@@ -107,10 +107,10 @@ interface phpbb_tree_interface
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_parent_branch_data($item_id, $order_desc, $include_item);
+ public function get_path_data($item_id, $order_desc, $include_item);
/**
- * Get children branch of the item
+ * Get all items of the item's subtree
*
* @param int $item_id The item id to get the children from
* @param bool $order_desc Order the items descending (most outer parent first)
@@ -118,7 +118,7 @@ interface phpbb_tree_interface
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_children_branch_data($item_id, $order_desc, $include_item);
+ public function get_subtree_data($item_id, $order_desc, $include_item);
/**
* Get base information of parent items
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 9655a08aa5..10ab6a86e3 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -154,7 +154,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
protected function remove_item_from_nestedset($item_id)
{
- $items = $this->get_children_branch_data($item_id);
+ $items = $this->get_subtree_data($item_id);
$item_ids = array_keys($items);
$this->remove_subset($item_ids, $items[$item_id]);
@@ -338,7 +338,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $item_data = $this->get_children_branch_data($current_parent_id);
+ $item_data = $this->get_subtree_data($current_parent_id);
if (!isset($item_data[$current_parent_id]))
{
$this->lock->release();
@@ -447,7 +447,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $item_data = $this->get_children_branch_data($item_id);
+ $item_data = $this->get_subtree_data($item_id);
if (!isset($item_data[$item_id]))
{
$this->lock->release();
@@ -529,45 +529,45 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
/**
* @inheritdoc
*/
- public function get_full_branch_data($item_id, $order_desc = true, $include_item = true)
+ public function get_path_and_subtree_data($item_id, $order_desc = true, $include_item = true)
{
$condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
- return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
}
/**
* @inheritdoc
*/
- public function get_parent_branch_data($item_id, $order_desc = true, $include_item = true)
+ public function get_path_data($item_id, $order_desc = true, $include_item = true)
{
$condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
- return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
}
/**
* @inheritdoc
*/
- public function get_children_branch_data($item_id, $order_desc = true, $include_item = true)
+ public function get_subtree_data($item_id, $order_desc = true, $include_item = true)
{
$condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
- return $this->get_branch_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
}
/**
- * Get children and parent branch of the item
+ * Get items that are related to the given item by the condition
*
- * @param int $item_id The item id to get the parents/children from
+ * @param int $item_id The item id to get the node set from
* @param string $condition Query string restricting the item list
* @param bool $order_desc Order the items descending (most outer parent first)
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- protected function get_branch_data($item_id, $condition, $order_desc = true, $include_item = true)
+ protected function get_set_of_nodes_data($item_id, $condition, $order_desc = true, $include_item = true)
{
$rows = array();
--
cgit v1.2.1
From 4810c61fd7b912ea2914b99f7db502b6f503068f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 10:37:59 +0200
Subject: [ticket/11495] Remove get_parent_data from interface and rename it
The method is implementation specific and has no use, apart from cache, that is
not covered by get_path_data().
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 9 ---------
phpBB/includes/tree/nestedset.php | 9 ++++++---
2 files changed, 6 insertions(+), 12 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 1b462768a0..bd8181beb2 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -119,13 +119,4 @@ interface phpbb_tree_interface
* ID => Item data
*/
public function get_subtree_data($item_id, $order_desc, $include_item);
-
- /**
- * Get base information of parent items
- *
- * @param array $item The item to get the branch from
- * @return array Array of items (containing basic columns from the item table)
- * ID => Item data
- */
- public function get_parent_data(array $item);
}
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 10ab6a86e3..89a91ccb16 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -595,13 +595,16 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * Get base information of parent items
+ * Get basic data of all parent items
*
+ * Basic data is defined in the $item_basic_data property.
* Data is cached in the item_parents column in the item table
*
- * @inheritdoc
+ * @param array $item The item to get the path from
+ * @return array Array of items (containing basic columns from the item table)
+ * ID => Item data
*/
- public function get_parent_data(array $item)
+ public function get_path_basic_data(array $item)
{
$parents = array();
if ((int) $item[$this->column_parent_id])
--
cgit v1.2.1
From 67f2edae170576104e619ffb38672cabf44e20fa Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 13:54:50 +0200
Subject: [ticket/11495] Use descendants and ancestors instead of
parents/children
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 28 ++++++++++++++--------------
phpBB/includes/tree/nestedset.php | 18 +++++++++---------
2 files changed, 23 insertions(+), 23 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index bd8181beb2..e09fcea4fa 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -65,9 +65,9 @@ interface phpbb_tree_interface
public function move_up($item_id);
/**
- * Moves all children of one item to another item
+ * Moves all descendants of one item to another item
*
- * If the new parent already has children, the new children are appended
+ * If the new parent already has descendants, the new descendants are appended
* to the list.
*
* @param int $current_parent_id The current parent item
@@ -88,35 +88,35 @@ interface phpbb_tree_interface
public function change_parent($item_id, $new_parent_id);
/**
- * Get all items that are either a parent or part of the subtree of the item
+ * Get all items that are either an ancestors or descendants of the item
*
- * @param int $item_id The item id to get the parents/children from
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param int $item_id The item to get the ancestors/descendants from
+ * @param bool $order_asc Order the items ascending (most outer ancestor first)
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_path_and_subtree_data($item_id, $order_desc, $include_item);
+ public function get_path_and_subtree_data($item_id, $order_asc, $include_item);
/**
- * Get all parent items of the item
+ * Get all ancestors items of the item
*
- * @param int $item_id The item id to get the parents from
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param int $item_id The item id to get the ancestors from
+ * @param bool $order_asc Order the items ascending (most outer ancestor first)
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_path_data($item_id, $order_desc, $include_item);
+ public function get_path_data($item_id, $order_asc, $include_item);
/**
- * Get all items of the item's subtree
+ * Get all descendants of the item
*
- * @param int $item_id The item id to get the children from
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param int $item_id The item id to get the descendants from
+ * @param bool $order_asc Order the items ascending
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_subtree_data($item_id, $order_desc, $include_item);
+ public function get_subtree_data($item_id, $order_asc, $include_item);
}
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 89a91ccb16..7710895a25 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -529,32 +529,32 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
/**
* @inheritdoc
*/
- public function get_path_and_subtree_data($item_id, $order_desc = true, $include_item = true)
+ public function get_path_and_subtree_data($item_id, $order_asc = true, $include_item = true)
{
$condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
- return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_asc, $include_item);
}
/**
* @inheritdoc
*/
- public function get_path_data($item_id, $order_desc = true, $include_item = true)
+ public function get_path_data($item_id, $order_asc = true, $include_item = true)
{
$condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
- return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_asc, $include_item);
}
/**
* @inheritdoc
*/
- public function get_subtree_data($item_id, $order_desc = true, $include_item = true)
+ public function get_subtree_data($item_id, $order_asc = true, $include_item = true)
{
$condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
- return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_asc, $include_item);
}
/**
@@ -562,12 +562,12 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*
* @param int $item_id The item id to get the node set from
* @param string $condition Query string restricting the item list
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $order_asc Order the items ascending by their left_id
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- protected function get_set_of_nodes_data($item_id, $condition, $order_desc = true, $include_item = true)
+ protected function get_set_of_nodes_data($item_id, $condition, $order_asc = true, $include_item = true)
{
$rows = array();
@@ -577,7 +577,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
WHERE i1.' . $this->column_item_id . ' = ' . (int) $item_id . '
' . $this->get_sql_where('AND', 'i1.') . '
- ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
+ ORDER BY i2.' . $this->column_left_id . ' ' . ($order_asc ? 'ASC' : 'DESC');
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
--
cgit v1.2.1
From 87e8e60d3c09c96a4495dda748673fb8b9078a3e Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 14:12:45 +0200
Subject: [ticket/11495] Correctly distinguish between children and descendants
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index e09fcea4fa..5e43478e22 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -65,9 +65,9 @@ interface phpbb_tree_interface
public function move_up($item_id);
/**
- * Moves all descendants of one item to another item
+ * Moves all children of one item to another item
*
- * If the new parent already has descendants, the new descendants are appended
+ * If the new parent already has children, the new children are appended
* to the list.
*
* @param int $current_parent_id The current parent item
@@ -79,7 +79,7 @@ interface phpbb_tree_interface
/**
* Change parent item
*
- * Moves the item to the bottom of the new parent's subtree
+ * Moves the item to the bottom of the new parent's list of children
*
* @param int $item_id The item to be moved
* @param int $new_parent_id The new parent item
@@ -88,7 +88,7 @@ interface phpbb_tree_interface
public function change_parent($item_id, $new_parent_id);
/**
- * Get all items that are either an ancestors or descendants of the item
+ * Get all items that are either ancestors or descendants of the item
*
* @param int $item_id The item to get the ancestors/descendants from
* @param bool $order_asc Order the items ascending (most outer ancestor first)
--
cgit v1.2.1
From 863d0c7687cc926dfda0ddd20b34e7942748fb2e Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 14:36:26 +0200
Subject: [ticket/11495] Fix some more comments and the package tag
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 2 +-
phpBB/includes/tree/nestedset.php | 8 ++++----
phpBB/includes/tree/nestedset_forum.php | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 5e43478e22..9bd633a5eb 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -99,7 +99,7 @@ interface phpbb_tree_interface
public function get_path_and_subtree_data($item_id, $order_asc, $include_item);
/**
- * Get all ancestors items of the item
+ * Get all ancestors of the item
*
* @param int $item_id The item id to get the ancestors from
* @param bool $order_asc Order the items ascending (most outer ancestor first)
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 7710895a25..ae9805aa45 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -1,7 +1,7 @@
Date: Tue, 30 Apr 2013 14:45:22 +0200
Subject: [ticket/11495] Fix docs of add_item_to_nestedset() and take id as
argument
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index ae9805aa45..934eb933e0 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -111,16 +111,17 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
- return array_merge($item_data, $this->add_item_to_nestedset($item_data));
+ return array_merge($item_data, $this->add_item_to_nestedset($item_data[$this->column_item_id]));
}
/**
* Add an item which already has a database row at the end of the tree
*
- * @param array $item The item to be added
- * @return bool True if the item was added
+ * @param int $item_id The item to be added
+ * @return array Array with updated data, if the item was added successfully
+ * Empty array otherwise
*/
- protected function add_item_to_nestedset(array $item)
+ protected function add_item_to_nestedset($item_id)
{
$sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . '
FROM ' . $this->table_name . '
@@ -138,10 +139,13 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . '
- WHERE ' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id];
+ WHERE ' . $this->column_item_id . ' = ' . (int) $item_id . '
+ AND ' . $this->column_parent_id . ' = 0
+ AND ' . $this->column_left_id . ' = 0
+ AND ' . $this->column_right_id . ' = 0';
$this->db->sql_query($sql);
- return $update_item_data;
+ return ($this->db->sql_affectedrows() == 1) ? $update_item_data : array();
}
/**
--
cgit v1.2.1
From 529e4c00fbb78ba513afbbacfb3d5465efbd82ef Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 15:07:56 +0200
Subject: [ticket/11495] Move lock code into two methods to allow easier
handling
This also allows to simply remove the lock handling by overwriting the two
methods acquire_lock() and release_lock().
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 111 ++++++++++++++++++++++++--------------
1 file changed, 71 insertions(+), 40 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 934eb933e0..85e04cd1cf 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -55,6 +55,12 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
protected $item_basic_data = array('*');
+ /**
+ * Does the class currently have a lock on the item table?
+ * @var bool
+ */
+ protected $lock_acquired = false;
+
/**
* Construct
*
@@ -99,6 +105,46 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
return (!$this->sql_where) ? '' : $operator . ' ' . sprintf($this->sql_where, $column_prefix);
}
+ /**
+ * Acquires a lock on the item table
+ *
+ * @return bool True if the lock was acquired, false if it has been acquired previously
+ *
+ * @throws RuntimeException If the lock could not be acquired
+ */
+ protected function acquire_lock()
+ {
+ if ($this->lock_acquired)
+ {
+ return false;
+ }
+
+ if (!$this->lock->acquire())
+ {
+ throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
+ }
+
+ $this->lock_acquired = true;
+ return true;
+ }
+
+ /**
+ * Releases the lock on the item table
+ *
+ * @return bool False, if there was no lock to release, true otherwise
+ */
+ protected function release_lock()
+ {
+ if (!$this->lock_acquired)
+ {
+ return false;
+ }
+
+ $this->lock->release();
+ $this->lock_acquired = false;
+ return true;
+ }
+
/**
* @inheritdoc
*/
@@ -191,10 +237,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
return false;
}
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
+ $this->acquire_lock();
$action = ($delta > 0) ? 'move_up' : 'move_down';
$delta = abs($delta);
@@ -210,7 +253,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$item)
{
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
@@ -246,7 +289,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$target)
{
- $this->lock->release();
+ $this->release_lock();
// The item is already on top or bottom
return false;
}
@@ -298,7 +341,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
" . $this->get_sql_where();
$this->db->sql_query($sql);
- $this->lock->release();
+ $this->release_lock();
return true;
}
@@ -337,15 +380,12 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
+ $this->acquire_lock();
$item_data = $this->get_subtree_data($current_parent_id);
if (!isset($item_data[$current_parent_id]))
{
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
@@ -355,13 +395,13 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1)
{
- $this->lock->release();
+ $this->release_lock();
return false;
}
if (in_array($new_parent_id, $move_items))
{
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -385,7 +425,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$new_parent)
{
$this->db->sql_transaction('rollback');
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -423,7 +463,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$this->db->sql_query($sql);
$this->db->sql_transaction('commit');
- $this->lock->release();
+ $this->release_lock();
return true;
}
@@ -446,15 +486,12 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
+ $this->acquire_lock();
$item_data = $this->get_subtree_data($item_id);
if (!isset($item_data[$item_id]))
{
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
@@ -463,7 +500,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (in_array($new_parent_id, $move_items))
{
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -487,7 +524,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$new_parent)
{
$this->db->sql_transaction('rollback');
- $this->lock->release();
+ $this->release_lock();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -525,7 +562,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$this->db->sql_query($sql);
$this->db->sql_transaction('commit');
- $this->lock->release();
+ $this->release_lock();
return true;
}
@@ -653,15 +690,11 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
* @param bool $set_subset_zero Should the parent, left and right id of the items be set to 0, or kept unchanged?
* In case of removing an item from the tree, we should the values to 0
* In case of moving an item, we shouldkeep the original values, in order to allow "+ diff" later
- * @param bool $table_already_locked Is the table already locked, or should we acquire a new lock?
* @return null
*/
- protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true, $table_already_locked = false)
+ protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true)
{
- if (!$table_already_locked && !$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
+ $acquired_new_lock = $this->acquire_lock();
$diff = sizeof($subset_items) * 2;
$sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
@@ -689,9 +722,9 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
" . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
$this->db->sql_query($sql);
- if (!$table_already_locked)
+ if ($acquired_new_lock)
{
- $this->lock->release();
+ $this->release_lock();
}
}
@@ -763,14 +796,13 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
public function regenerate_left_right_ids($new_id, $parent_id = 0, $reset_ids = false)
{
- if ($reset_ids)
+ if ($acquired_new_lock = $this->acquire_lock())
{
- if (!$this->lock->acquire())
- {
- throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
- }
$this->db->sql_transaction('begin');
+ }
+ if ($reset_ids)
+ {
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->db->sql_build_array('UPDATE', array(
$this->column_left_id => 0,
@@ -817,11 +849,10 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
$this->db->sql_freeresult($result);
-
- if ($reset_ids)
+ if ($acquired_new_lock)
{
$this->db->sql_transaction('commit');
- $this->lock->release();
+ $this->release_lock();
}
return $new_id;
--
cgit v1.2.1
From 055ee41065fb0b7c08c66daff196eb2d3460b0cc Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 15:16:41 +0200
Subject: [ticket/11495] Remove useless cast
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 85e04cd1cf..6819f9791b 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -648,7 +648,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
public function get_path_basic_data(array $item)
{
$parents = array();
- if ((int) $item[$this->column_parent_id])
+ if ($item[$this->column_parent_id])
{
if (!$item[$this->column_item_parents])
{
--
cgit v1.2.1
From 714092ab4e52dc039536a05846b50f4d4d488799 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 15:48:29 +0200
Subject: [ticket/11495] Add owns_lock() method to lock classes
PHPBB3-11495
---
phpBB/includes/lock/db.php | 11 +++++++++++
phpBB/includes/lock/flock.php | 11 +++++++++++
2 files changed, 22 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php
index ccdaed0b28..5cc0821aa0 100644
--- a/phpBB/includes/lock/db.php
+++ b/phpBB/includes/lock/db.php
@@ -116,6 +116,17 @@ class phpbb_lock_db
return $this->locked;
}
+ /**
+ * Does this process own the lock?
+ *
+ * @return bool true if lock is owned
+ * false otherwise
+ */
+ public function owns_lock()
+ {
+ return (bool) $this->locked;
+ }
+
/**
* Releases the lock.
*
diff --git a/phpBB/includes/lock/flock.php b/phpBB/includes/lock/flock.php
index 97bc7dd2b9..17de0847c0 100644
--- a/phpBB/includes/lock/flock.php
+++ b/phpBB/includes/lock/flock.php
@@ -110,6 +110,17 @@ class phpbb_lock_flock
return (bool) $this->lock_fp;
}
+ /**
+ * Does this process own the lock?
+ *
+ * @return bool true if lock is owned
+ * false otherwise
+ */
+ public function owns_lock()
+ {
+ return (bool) $this->lock_fp;
+ }
+
/**
* Releases the lock.
*
--
cgit v1.2.1
From 78b0d3e723ab57c2e32b95a66159861fe461d77f Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 15:50:14 +0200
Subject: [ticket/11495] Use $lock->owns_lock() instead of own property
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 6819f9791b..26152e6c10 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -55,12 +55,6 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
protected $item_basic_data = array('*');
- /**
- * Does the class currently have a lock on the item table?
- * @var bool
- */
- protected $lock_acquired = false;
-
/**
* Construct
*
@@ -114,7 +108,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
protected function acquire_lock()
{
- if ($this->lock_acquired)
+ if ($this->lock->owns_lock())
{
return false;
}
@@ -124,25 +118,17 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
throw new RuntimeException($this->message_prefix . 'LOCK_FAILED_ACQUIRE');
}
- $this->lock_acquired = true;
return true;
}
/**
* Releases the lock on the item table
*
- * @return bool False, if there was no lock to release, true otherwise
+ * @return null
*/
protected function release_lock()
{
- if (!$this->lock_acquired)
- {
- return false;
- }
-
$this->lock->release();
- $this->lock_acquired = false;
- return true;
}
/**
--
cgit v1.2.1
From 6055a3cc7ed76cfe458ea524bfad66f475f35ce8 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 16:19:25 +0200
Subject: [ticket/11495] Remove useless release_lock() method
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 38 ++++++++++++++------------------------
1 file changed, 14 insertions(+), 24 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 26152e6c10..f92606a4c4 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -121,16 +121,6 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
return true;
}
- /**
- * Releases the lock on the item table
- *
- * @return null
- */
- protected function release_lock()
- {
- $this->lock->release();
- }
-
/**
* @inheritdoc
*/
@@ -239,7 +229,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$item)
{
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
@@ -275,7 +265,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$target)
{
- $this->release_lock();
+ $this->lock->release();
// The item is already on top or bottom
return false;
}
@@ -327,7 +317,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
" . $this->get_sql_where();
$this->db->sql_query($sql);
- $this->release_lock();
+ $this->lock->release();
return true;
}
@@ -371,7 +361,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$item_data = $this->get_subtree_data($current_parent_id);
if (!isset($item_data[$current_parent_id]))
{
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
@@ -381,13 +371,13 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (($current_parent[$this->column_right_id] - $current_parent[$this->column_left_id]) <= 1)
{
- $this->release_lock();
+ $this->lock->release();
return false;
}
if (in_array($new_parent_id, $move_items))
{
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -411,7 +401,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$new_parent)
{
$this->db->sql_transaction('rollback');
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -449,7 +439,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$this->db->sql_query($sql);
$this->db->sql_transaction('commit');
- $this->release_lock();
+ $this->lock->release();
return true;
}
@@ -477,7 +467,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$item_data = $this->get_subtree_data($item_id);
if (!isset($item_data[$item_id]))
{
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
}
@@ -486,7 +476,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (in_array($new_parent_id, $move_items))
{
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -510,7 +500,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if (!$new_parent)
{
$this->db->sql_transaction('rollback');
- $this->release_lock();
+ $this->lock->release();
throw new OutOfBoundsException($this->message_prefix . 'INVALID_PARENT');
}
@@ -548,7 +538,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$this->db->sql_query($sql);
$this->db->sql_transaction('commit');
- $this->release_lock();
+ $this->lock->release();
return true;
}
@@ -710,7 +700,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if ($acquired_new_lock)
{
- $this->release_lock();
+ $this->lock->release();
}
}
@@ -838,7 +828,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if ($acquired_new_lock)
{
$this->db->sql_transaction('commit');
- $this->release_lock();
+ $this->lock->release();
}
return $new_id;
--
cgit v1.2.1
From f3f7be4cd1a0495cf44787c713480d5aceb1bae1 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 17:11:55 +0200
Subject: [ticket/11495] Fix @return doc of get_sql_where()
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index f92606a4c4..5a12afdfe9 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -92,7 +92,8 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
* @param string $operator SQL operator that needs to be prepended to sql_where,
* if it is not empty.
* @param string $column_prefix Prefix that needs to be prepended to column names
- * @return bool True if the item was deleted
+ * @return string Returns additional where statements to narrow down the tree,
+ * prefixed with operator and prepended column_prefix to column names
*/
public function get_sql_where($operator = 'AND', $column_prefix = '')
{
--
cgit v1.2.1
From 5c4d69581afb9fd9b00d6b7b13cec257a97e875c Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 18:06:29 +0200
Subject: [ticket/11495] Do not reset item_parent if not required
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 5a12afdfe9..1f414164df 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -310,8 +310,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
" . $this->column_right_id . ' = ' . $this->column_right_id . ' + CASE
WHEN ' . $this->column_right_id . " BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
ELSE {$diff_down}
- END,
- " . $this->column_item_parents . " = ''
+ END
WHERE
" . $this->column_left_id . " BETWEEN {$left_id} AND {$right_id}
AND " . $this->column_right_id . " BETWEEN {$left_id} AND {$right_id}
@@ -692,11 +691,10 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
- ' . $this->column_right_id . ' = ' . $set_right_id . ',
- ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->column_parent_id) . ',' : '') . '
- ' . $this->column_item_parents . " = ''
- " . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
+ SET ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->column_parent_id) . ',' : '') . '
+ ' . $this->column_left_id . ' = ' . $set_left_id . ',
+ ' . $this->column_right_id . ' = ' . $set_right_id . '
+ ' . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));
$this->db->sql_query($sql);
if ($acquired_new_lock)
@@ -706,7 +704,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
}
/**
- * Add a subset to the nested set
+ * Prepare adding a subset to the nested set
*
* @param array $subset_items Subset of items to add
* @param array $new_parent Item containing the right bound of the new parent
@@ -722,9 +720,8 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
$sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $set_left_id . ',
- ' . $this->column_right_id . ' = ' . $set_right_id . ',
- ' . $this->column_item_parents . " = ''
- WHERE " . $sql_not_subset_items . '
+ ' . $this->column_right_id . ' = ' . $set_right_id . '
+ WHERE ' . $sql_not_subset_items . '
' . $this->get_sql_where('AND');
$this->db->sql_query($sql);
@@ -776,6 +773,14 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if ($acquired_new_lock = $this->acquire_lock())
{
$this->db->sql_transaction('begin');
+
+ if (!$reset_ids)
+ {
+ $sql = 'UPDATE ' . $this->table_name . '
+ SET ' . $this->column_item_parents . " = ''
+ " . $this->get_sql_where('WHERE');
+ $this->db->sql_query($sql);
+ }
}
if ($reset_ids)
@@ -802,10 +807,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
if ($row[$this->column_left_id] != $new_id)
{
$sql = 'UPDATE ' . $this->table_name . '
- SET ' . $this->db->sql_build_array('UPDATE', array(
- $this->column_left_id => $new_id,
- $this->column_item_parents => '',
- )) . '
+ SET ' . $this->db->sql_build_array('UPDATE', array($this->column_left_id => $new_id)) . '
WHERE ' . $this->column_item_id . ' = ' . (int) $row[$this->column_item_id];
$this->db->sql_query($sql);
}
--
cgit v1.2.1
From 98e6207c35910bf9761433e62ca5fe5af3459873 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 18:13:32 +0200
Subject: [ticket/11495] Fix "as well" typo and remove brackets
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 6 +++---
phpBB/includes/tree/nestedset.php | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 9bd633a5eb..546e00ed06 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -92,7 +92,7 @@ interface phpbb_tree_interface
*
* @param int $item_id The item to get the ancestors/descendants from
* @param bool $order_asc Order the items ascending (most outer ancestor first)
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
@@ -103,7 +103,7 @@ interface phpbb_tree_interface
*
* @param int $item_id The item id to get the ancestors from
* @param bool $order_asc Order the items ascending (most outer ancestor first)
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
@@ -114,7 +114,7 @@ interface phpbb_tree_interface
*
* @param int $item_id The item id to get the descendants from
* @param bool $order_asc Order the items ascending
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 1f414164df..2a639d8907 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -580,7 +580,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
* @param int $item_id The item id to get the node set from
* @param string $condition Query string restricting the item list
* @param bool $order_asc Order the items ascending by their left_id
- * @param bool $include_item Should the item (matching the given item id) be included in the list aswell
+ * @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
--
cgit v1.2.1
From 2f54a63b0fb998c84730e21a3af4150281c22cab Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 18:24:54 +0200
Subject: [ticket/11495] Fix more grammar issues in doc blocks
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 546e00ed06..2eb40b066c 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -90,8 +90,8 @@ interface phpbb_tree_interface
/**
* Get all items that are either ancestors or descendants of the item
*
- * @param int $item_id The item to get the ancestors/descendants from
- * @param bool $order_asc Order the items ascending (most outer ancestor first)
+ * @param int $item_id The item id the ancestors/descendants should be retrieved from
+ * @param bool $order_asc Order the items ascendingly (most outer ancestor first)
* @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
@@ -99,10 +99,10 @@ interface phpbb_tree_interface
public function get_path_and_subtree_data($item_id, $order_asc, $include_item);
/**
- * Get all ancestors of the item
+ * Get all of the item's ancestors
*
- * @param int $item_id The item id to get the ancestors from
- * @param bool $order_asc Order the items ascending (most outer ancestor first)
+ * @param int $item_id The item id the ancestors should be retrieved from
+ * @param bool $order_asc Order the items ascendingly (most outer ancestor first)
* @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
@@ -110,10 +110,10 @@ interface phpbb_tree_interface
public function get_path_data($item_id, $order_asc, $include_item);
/**
- * Get all descendants of the item
+ * Get all of the item's descendants
*
- * @param int $item_id The item id to get the descendants from
- * @param bool $order_asc Order the items ascending
+ * @param int $item_id The item id the descendants should be retrieved from
+ * @param bool $order_asc Order the items ascendingly
* @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
* ID => Item data
--
cgit v1.2.1
From 6a7378ecbdeea1ad356cbde8a085aa7510c61788 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 18:39:22 +0200
Subject: [ticket/11495] Some more doc changes
PHPBB3-11495
---
phpBB/includes/tree/interface.php | 6 +++---
phpBB/includes/tree/nestedset.php | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index 2eb40b066c..cc8aab2115 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -90,7 +90,7 @@ interface phpbb_tree_interface
/**
* Get all items that are either ancestors or descendants of the item
*
- * @param int $item_id The item id the ancestors/descendants should be retrieved from
+ * @param int $item_id Id of the item to retrieve the ancestors/descendants from
* @param bool $order_asc Order the items ascendingly (most outer ancestor first)
* @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
@@ -101,7 +101,7 @@ interface phpbb_tree_interface
/**
* Get all of the item's ancestors
*
- * @param int $item_id The item id the ancestors should be retrieved from
+ * @param int $item_id Id of the item to retrieve the ancestors from
* @param bool $order_asc Order the items ascendingly (most outer ancestor first)
* @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
@@ -112,7 +112,7 @@ interface phpbb_tree_interface
/**
* Get all of the item's descendants
*
- * @param int $item_id The item id the descendants should be retrieved from
+ * @param int $item_id Id of the item to retrieve the descendants from
* @param bool $order_asc Order the items ascendingly
* @param bool $include_item Should the item matching the given item id be included in the list as well
* @return array Array of items (containing all columns from the item table)
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 2a639d8907..2f17ebab02 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -577,7 +577,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
/**
* Get items that are related to the given item by the condition
*
- * @param int $item_id The item id to get the node set from
+ * @param int $item_id Id of the item to retrieve the node set from
* @param string $condition Query string restricting the item list
* @param bool $order_asc Order the items ascending by their left_id
* @param bool $include_item Should the item matching the given item id be included in the list as well
--
cgit v1.2.1
From a90a0b087ca3b1e29561a08019ca8ba2fa21c19d Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Tue, 30 Apr 2013 22:59:32 +0530
Subject: [ticket/10325] fix language in acp and ucp
PHPBB3-10325
---
phpBB/language/en/acp/board.php | 2 +-
phpBB/language/en/ucp.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 39ad5b78bb..1bc8d1cf46 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -454,7 +454,7 @@ $lang = array_merge($lang, array(
'ALL' => 'All',
'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins',
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.',
- 'ALLOW_PASSWORD_RESET' => 'Allow "forgot password"',
+ 'ALLOW_PASSWORD_RESET' => 'Allow "Forgot Password"',
'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. If you use an external authentication mechanism you may wish to disable this feature.',
'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)',
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.',
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 372e44a94d..a91b6b84d5 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -521,7 +521,7 @@ $lang = array_merge($lang, array(
'UCP_USERGROUPS_MEMBER' => 'Edit memberships',
'UCP_USERGROUPS_MANAGE' => 'Manage groups',
- 'UCP_PASSWORD_RESET_DISABLED' => 'The administrator has disabled the password reset functionality. If you need help accessing your account, please contact the %sBoard Administrator%s',
+ 'UCP_PASSWORD_RESET_DISABLED' => 'The password reset functionality has been disabled. If you need help accessing your account, please contact the %sBoard Administrator%s',
'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.',
'UCP_REMIND' => 'Send password',
'UCP_RESEND' => 'Send activation email',
--
cgit v1.2.1
From d7787682df0474b7bb78434339f8edde3727c580 Mon Sep 17 00:00:00 2001
From: Joas Schilling
Date: Tue, 30 Apr 2013 22:19:35 +0200
Subject: [ticket/11495] Throw exception when item that should be deleted does
not exist
PHPBB3-11495
---
phpBB/includes/tree/nestedset.php | 11 +++++++++++
1 file changed, 11 insertions(+)
(limited to 'phpBB')
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 2f17ebab02..4d851a87a8 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -181,9 +181,20 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*/
protected function remove_item_from_nestedset($item_id)
{
+ $item_id = (int) $item_id;
+ if (!$item_id)
+ {
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
$items = $this->get_subtree_data($item_id);
$item_ids = array_keys($items);
+ if (empty($items) || !isset($items[$item_id]))
+ {
+ throw new OutOfBoundsException($this->message_prefix . 'INVALID_ITEM');
+ }
+
$this->remove_subset($item_ids, $items[$item_id]);
return $item_ids;
--
cgit v1.2.1
From 32f247ed603a2b57ba0b30f4ce0d2429df33ab7e Mon Sep 17 00:00:00 2001
From: Oleg Pudeyev
Date: Wed, 1 May 2013 17:14:36 -0400
Subject: [ticket/11435] Fit comment into 80 columns and link to php manual.
PHPBB3-11435
---
phpBB/includes/template/filter.php | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index 9e8ad2fef0..c2c100e93e 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -224,28 +224,34 @@ class phpbb_template_filter extends php_user_filter
}
/*
- Preserve whitespace.
- PHP removes a newline after the closing tag (if it's there). This is by design.
+ Preserve whitespace.
+ PHP removes a newline after the closing tag (if it's there).
+ This is by design:
- Consider the following template:
+ http://www.php.net/manual/en/language.basic-syntax.phpmode.php
+ http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php
-
- some content
-
- If we were to simply preserve all whitespace, we could simply replace all "?>" tags
- with "?>\n".
- Doing that, would add additional newlines to the compiled tempalte in place of the
- IF and ENDIF statements. These newlines are unwanted (and one is conditional).
- The IF and ENDIF are usually on their own line for ease of reading.
+ Consider the following template:
- This replacement preserves newlines only for statements that aren't the only statement on a line.
- It will NOT preserve newlines at the end of statements in the above examle.
- It will preserve newlines in situations like:
+
+ some content
+
- inline content
+ If we were to simply preserve all whitespace, we could simply
+ replace all "?>" tags with "?>\n".
+ Doing that, would add additional newlines to the compiled
+ template in place of the IF and ENDIF statements. These
+ newlines are unwanted (and one is conditional). The IF and
+ ENDIF are usually on their own line for ease of reading.
+ This replacement preserves newlines only for statements that
+ are not the only statement on a line. It will NOT preserve
+ newlines at the end of statements in the above example.
+ It will preserve newlines in situations like:
+
+ inline content
*/
--
cgit v1.2.1
From 6d4a75b3cb9a403d37fe3ac7b3eda5e9c65ad9e0 Mon Sep 17 00:00:00 2001
From: hjpotter92
Date: Thu, 2 May 2013 06:29:32 +0530
Subject: [ticket/11517] Fix list numbering
PHPBB3-11517
---
phpBB/docs/coding-guidelines.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index cd113a7226..54b8526cdf 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -2314,7 +2314,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
-
8. Copyright and disclaimer
+
7. Copyright and disclaimer
--
cgit v1.2.1
From 00d5cde04eb56b53179385c3ada075b1c207c3a3 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sat, 4 May 2013 14:44:33 +0530
Subject: [ticket/10325] fix acp language
PHPBB3-10325
---
phpBB/language/en/acp/board.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 1bc8d1cf46..ce15dfefb4 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -454,7 +454,7 @@ $lang = array_merge($lang, array(
'ALL' => 'All',
'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins',
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.',
- 'ALLOW_PASSWORD_RESET' => 'Allow "Forgot Password"',
+ 'ALLOW_PASSWORD_RESET' => 'Allow password reset ("Forgot Password")',
'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. If you use an external authentication mechanism you may wish to disable this feature.',
'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)',
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.',
--
cgit v1.2.1
From bfdc6e19300da8fa62d8661fcbd92548a2d2cf97 Mon Sep 17 00:00:00 2001
From: Dhruv
Date: Sat, 4 May 2013 18:56:52 +0530
Subject: [ticket/11288] fix regex in postgres
Postgres search backend now uses updated regex being used by
mysql search backend.
PHPBB3-11288
---
phpBB/includes/search/fulltext_postgres.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index eeb628b18f..5080587681 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -214,7 +214,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
{
if ($terms == 'all')
{
- $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#\+#', '#-#', '#\|#');
+ $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#');
$replace = array(' +', ' |', ' -', ' +', ' -', ' |');
$keywords = preg_replace($match, $replace, $keywords);
--
cgit v1.2.1
From 153be855ca8fdee9549be9f51f940a385a0b4e03 Mon Sep 17 00:00:00 2001
From: Matt Friedman
Date: Mon, 6 May 2013 09:49:37 -0700
Subject: [ticket/10155] Update copyright in new migration file to 2013
PHPBB3-10155
---
phpBB/includes/db/migration/data/310/jquery_update.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'phpBB')
diff --git a/phpBB/includes/db/migration/data/310/jquery_update.php b/phpBB/includes/db/migration/data/310/jquery_update.php
index bb0c48550a..dc49f74fcb 100644
--- a/phpBB/includes/db/migration/data/310/jquery_update.php
+++ b/phpBB/includes/db/migration/data/310/jquery_update.php
@@ -2,7 +2,7 @@
/**
*
* @package migration
-* @copyright (c) 2012 phpBB Group
+* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
--
cgit v1.2.1
From 828d3b6b68acad606fe150cff7993c216ebc4474 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Muller?=
Date: Sun, 21 Apr 2013 14:22:45 +0200
Subject: [ticket/11144] Add missing {FORUM_NAME} variable
The template variable {FORUM_NAME} was missing from
the login page of a password protected forum
PHPBB3-11144
---
phpBB/docs/coding-guidelines.html | 2 +
phpBB/download/file.php | 2 +-
phpBB/includes/functions.php | 1 +
phpBB/includes/ucp/ucp_pm_compose.php | 11 ++----
phpBB/posting.php | 1 +
phpBB/styles/prosilver/template/login_forum.html | 45 +++++++++++++----------
phpBB/styles/subsilver2/template/login_forum.html | 8 ++++
7 files changed, 42 insertions(+), 28 deletions(-)
(limited to 'phpBB')
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index cd113a7226..38f11534d2 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -956,6 +956,8 @@ $action_ary = request_var('action', array('' => 0));
Login checks/redirection:
To show a forum login box use login_forum_box($forum_data), else use the login_box() function.
+
$forum_data should contain at least the forum_id and forum_password fields. If the field forum_name is available, then it is displayed on the forum login page.
+
The login_box() function can have a redirect as the first parameter. As a thumb of rule, specify an empty string if you want to redirect to the users current location, else do not add the $SID to the redirect string (for example within the ucp/login we redirect to the board index because else the user would be redirected to the login screen).