* @copyright 2009-2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
+defined('GNUSOCIAL') || die();
+
class DBQueueManager extends QueueManager
{
/**
@@ -39,7 +38,7 @@ class DBQueueManager extends QueueManager
{
$qi = new Queue_item();
- $qi->frame = $this->encode($object);
+ $qi->frame = DB_DataObject_Cast::blob($this->encode($object));
$qi->transport = $queue;
$qi->created = common_sql_now();
$result = $qi->insert();
@@ -121,7 +120,8 @@ class DBQueueManager extends QueueManager
// What to do if no handler was found. For example, the OpportunisticQM
// should avoid deleting items just because it can't reach XMPP queues etc.
- protected function noHandlerFound(Queue_item $qi, $rep=null) {
+ protected function noHandlerFound(Queue_item $qi, $rep = null)
+ {
$this->_log(LOG_INFO, "[{$qi->transport}:{$rep}] No handler for queue {$qi->transport}; discarding.");
$this->_done($qi);
}
diff --git a/plugins/OStatus/scripts/update-profile-data.php b/plugins/OStatus/scripts/update-profile-data.php
index 5b3e00e9fc..a6454bca7d 100755
--- a/plugins/OStatus/scripts/update-profile-data.php
+++ b/plugins/OStatus/scripts/update-profile-data.php
@@ -1,21 +1,23 @@
#!/usr/bin/env php
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GNU social is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with GNU social. If not, see .
+
+/**
+ * @copyright 2010 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
@@ -39,7 +41,8 @@ END_OF_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
-function showProfileInfo(Ostatus_profile $oprofile) {
+function showProfileInfo(Ostatus_profile $oprofile)
+{
if ($oprofile->isGroup()) {
echo "group\n";
} else {
@@ -51,7 +54,8 @@ function showProfileInfo(Ostatus_profile $oprofile) {
echo "\n";
}
-function fixProfile(Ostatus_profile $oprofile) {
+function fixProfile(Ostatus_profile $oprofile)
+{
echo "Before:\n";
showProfileInfo($oprofile);
@@ -102,10 +106,10 @@ if (have_option('all')) {
echo "Failed on URI=="._ve($oprofile->uri).": {$e->getMessage()}\n";
}
}
-} else if (have_option('suspicious')) {
+} elseif (have_option('suspicious')) {
$oprofile = new Ostatus_profile();
- $oprofile->joinAdd(array('profile_id', 'profile:id'));
- $oprofile->whereAdd("nickname rlike '^[0-9]$'");
+ $oprofile->joinAdd(['profile_id', 'profile:id']);
+ $oprofile->whereAdd("CHAR_LENGTH(nickname) = 1 AND nickname BETWEEN '0' AND '9'");
$oprofile->find();
echo "Found $oprofile->N matching profiles:\n\n";
while ($oprofile->fetch()) {
@@ -116,7 +120,7 @@ if (have_option('all')) {
echo "Failed on URI=="._ve($oprofile->uri).": {$e->getMessage()}\n";
}
}
-} else if (!empty($args[0]) && $validate->uri($args[0])) {
+} elseif (!empty($args[0]) && $validate->uri($args[0])) {
$uri = $args[0];
$oprofile = Ostatus_profile::getKV('uri', $uri);
diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php
index 964d098030..5237cc81ea 100644
--- a/plugins/OpenID/openid.php
+++ b/plugins/OpenID/openid.php
@@ -1,25 +1,25 @@
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GNU social is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with GNU social. If not, see .
+
+/**
+ * @copyright 2008, 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
require_once('Auth/OpenID.php');
require_once('Auth/OpenID/Consumer.php');
@@ -49,19 +49,19 @@ function oid_store()
}
$db = DB::connect($dsn, $options);
- if (PEAR::isError($db)) {
+ if ((new PEAR)->isError($db)) {
throw new ServerException($db->getMessage());
}
switch (common_config('db', 'type')) {
+ case 'pgsql':
+ $store = new Auth_OpenID_PostgreSQLStore($db);
+ break;
case 'mysql':
$store = new Auth_OpenID_MySQLStore($db);
break;
- case 'postgresql':
- $store = new Auth_OpenID_PostgreSQLStore($db);
- break;
default:
- throw new ServerException(_m('Unknown DB type for OpenID.'));
+ throw new ServerException('Unknown DB type selected.');
}
}
return $store;
@@ -90,9 +90,11 @@ function oid_clear_last()
function oid_set_last($openid_url)
{
- common_set_cookie(OPENID_COOKIE_KEY,
- $openid_url,
- time() + OPENID_COOKIE_EXPIRY);
+ common_set_cookie(
+ OPENID_COOKIE_KEY,
+ $openid_url,
+ time() + OPENID_COOKIE_EXPIRY
+ );
}
function oid_get_last()
@@ -119,7 +121,7 @@ function oid_link_user($id, $canonical, $display)
$oid->created = common_sql_now();
if (!$oid->insert()) {
- $err = &$_PEAR->getStaticProperty('DB_DataObject','lastError');
+ $err = &$_PEAR->getStaticProperty('DB_DataObject', 'lastError');
return false;
}
@@ -149,9 +151,11 @@ function oid_check_immediate($openid_url, $backto=null)
$_SESSION['openid_immediate_backto'] = $backto;
- oid_authenticate($openid_url,
- 'finishimmediate',
- true);
+ oid_authenticate(
+ $openid_url,
+ 'finishimmediate',
+ true
+ );
}
function oid_authenticate($openid_url, $returnto, $immediate=false)
@@ -177,23 +181,27 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
common_log(LOG_ERR, __METHOD__ . ": mystery fail contacting $openid_url");
// TRANS: OpenID plugin message. Given when an OpenID is not valid.
throw new ServerException(_m('Not a valid OpenID.'));
- } else if (Auth_OpenID::isFailure($auth_request)) {
+ } elseif (Auth_OpenID::isFailure($auth_request)) {
common_log(LOG_ERR, __METHOD__ . ": OpenID fail to $openid_url: $auth_request->message");
// TRANS: OpenID plugin server error. Given when the OpenID authentication request fails.
// TRANS: %s is the failure message.
throw new ServerException(sprintf(_m('OpenID failure: %s.'), $auth_request->message));
}
- $sreg_request = Auth_OpenID_SRegRequest::build(// Required
- array(),
- // Optional
- array('nickname',
- 'email',
- 'fullname',
- 'language',
- 'timezone',
- 'postcode',
- 'country'));
+ $sreg_request = Auth_OpenID_SRegRequest::build(
+ // Required
+ [],
+ // Optional
+ [
+ 'nickname',
+ 'email',
+ 'fullname',
+ 'language',
+ 'timezone',
+ 'postcode',
+ 'country',
+ ]
+ );
if ($sreg_request) {
$auth_request->addExtension($sreg_request);
@@ -224,9 +232,11 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
// autosubmitter for now.
//
//if ($auth_request->shouldSendRedirect()) {
- $redirect_url = $auth_request->redirectURL($trust_root,
- $process_url,
- $immediate);
+ $redirect_url = $auth_request->redirectURL(
+ $trust_root,
+ $process_url,
+ $immediate
+ );
if (Auth_OpenID::isFailure($redirect_url)) {
// TRANS: OpenID plugin server error. Given when the OpenID authentication request cannot be redirected.
// TRANS: %s is the failure message.
@@ -266,11 +276,14 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
function _oid_print_instructions()
{
- common_element('div', 'instructions',
- // TRANS: OpenID plugin user instructions.
- _m('This form should automatically submit itself. '.
- 'If not, click the submit button to go to your '.
- 'OpenID provider.'));
+ common_element(
+ 'div',
+ 'instructions',
+ // TRANS: OpenID plugin user instructions.
+ _m('This form should automatically submit itself. '.
+ 'If not, click the submit button to go to your '.
+ 'OpenID provider.')
+ );
}
/**
@@ -382,22 +395,22 @@ function oid_check_teams($response)
class AutosubmitAction extends Action
{
- var $form_html = null;
- var $form_id = null;
+ public $form_html = null;
+ public $form_id = null;
- function handle()
+ public function handle()
{
parent::handle();
$this->showPage();
}
- function title()
+ public function title()
{
// TRANS: Title
return _m('OpenID Login Submission');
}
- function showContent()
+ public function showContent()
{
$this->raw('');
// @todo FIXME: This would be better using standard CSS class, but the present theme's a bit scary.
@@ -414,10 +427,13 @@ class AutosubmitAction extends Action
$this->raw($this->form_html);
}
- function showScripts()
+ public function showScripts()
{
parent::showScripts();
- $this->element('script', null,
- 'document.getElementById(\'' . $this->form_id . '\').submit();');
+ $this->element(
+ 'script',
+ null,
+ 'document.getElementById(\'' . $this->form_id . '\').submit();'
+ );
}
}
diff --git a/plugins/SphinxSearch/README b/plugins/SphinxSearch/README
index 873a8cf692..a8e0d20d8b 100644
--- a/plugins/SphinxSearch/README
+++ b/plugins/SphinxSearch/README
@@ -22,7 +22,7 @@ client side, which itself depends on the sphinx development files.
"pecl install sphinx" should take care of that. Add "extension=sphinx.so"
to your php.ini and reload apache to enable it.
-You can update your MySQL or Postgresql databases to drop their fulltext
+You can update your MariaDB or PostgreSQL databases to drop their fulltext
search indexes, since they're now provided by sphinx.
diff --git a/scripts/upgrade.php b/scripts/upgrade.php
index d60e072781..1178d59769 100755
--- a/scripts/upgrade.php
+++ b/scripts/upgrade.php
@@ -605,14 +605,26 @@ function fixupFileThumbnailUrlhash()
{
printfnq("Setting urlhash for File_thumbnail entries: ");
+ switch (common_config('db', 'type')) {
+ case 'pgsql':
+ $url_sha256 = 'encode(sha256(CAST("url" AS bytea)), \'hex\')';
+ break;
+ case 'mysql':
+ $url_sha256 = 'sha2(`url`, 256)';
+ break;
+ default:
+ throw new Exception('Unknown DB type selected.');
+ }
+
$thumb = new File_thumbnail();
$thumb->query(sprintf(
'UPDATE %1$s ' .
- 'SET urlhash = sha2(url, 256) ' .
+ 'SET urlhash = %2$s ' .
'WHERE url IS NOT NULL ' . // find all entries with a url value
"AND url <> '' " . // precaution against non-null empty strings
'AND urlhash IS NULL', // but don't touch those we've already calculated
- $thumb->escapedTableName()
+ $thumb->escapedTableName(),
+ $url_sha256
));
printfnq("DONE.\n");