aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-08-01 18:10:46 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-08-01 18:10:46 +0200
commitc6fd65ef7639cd67487c831db10dd79e4510efa6 (patch)
tree2c825413c26df7d0c5394d01c2599003cab87c0b /app/Models
parent93f7f849874dcdf1263370ff08c72a962f8de56f (diff)
parent17c3e616e8c3b927ee46258a8b8b20371bf59592 (diff)
Resolve git conflict
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/Auth.php18
-rw-r--r--app/Models/ConfigurationSetter.php7
-rw-r--r--app/Models/EntryDAO.php60
3 files changed, 53 insertions, 32 deletions
diff --git a/app/Models/Auth.php b/app/Models/Auth.php
index 4e7a71947..d689f7cdb 100644
--- a/app/Models/Auth.php
+++ b/app/Models/Auth.php
@@ -60,16 +60,6 @@ class FreshRSS_Auth {
Minz_Session::_param('currentUser', $current_user);
}
return $login_ok;
- case 'persona':
- $email = filter_var(Minz_Session::param('mail'), FILTER_VALIDATE_EMAIL);
- $persona_file = DATA_PATH . '/persona/' . $email . '.txt';
- if (($current_user = @file_get_contents($persona_file)) !== false) {
- $current_user = trim($current_user);
- Minz_Session::_param('currentUser', $current_user);
- Minz_Session::_param('mail', $email);
- return true;
- }
- return false;
case 'none':
return true;
default:
@@ -93,9 +83,6 @@ class FreshRSS_Auth {
case 'http_auth':
self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0;
break;
- case 'persona':
- self::$login_ok = strcasecmp(Minz_Session::param('mail'), $user_conf->mail_login) === 0;
- break;
case 'none':
self::$login_ok = true;
break;
@@ -143,9 +130,6 @@ class FreshRSS_Auth {
Minz_Session::_param('passwordHash');
FreshRSS_FormAuth::deleteCookie();
break;
- case 'persona':
- Minz_Session::_param('mail');
- break;
case 'http_auth':
case 'none':
// Nothing to do...
@@ -170,7 +154,7 @@ class FreshRSS_Auth {
public static function accessNeedsAction() {
$conf = Minz_Configuration::get('system');
$auth_type = $conf->auth_type;
- return $auth_type === 'form' || $auth_type === 'persona';
+ return $auth_type === 'form';
}
}
diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php
index 250c14c39..e472b1e7f 100644
--- a/app/Models/ConfigurationSetter.php
+++ b/app/Models/ConfigurationSetter.php
@@ -95,11 +95,6 @@ class FreshRSS_ConfigurationSetter {
$data['language'] = $value;
}
- private function _mail_login(&$data, $value) {
- $value = filter_var($value, FILTER_VALIDATE_EMAIL);
- $data['mail_login'] = $value ? $value : '';
- }
-
private function _old_entries(&$data, $value) {
$value = intval($value);
$data['old_entries'] = $value > 0 ? $value : 3;
@@ -278,7 +273,7 @@ class FreshRSS_ConfigurationSetter {
private function _auth_type(&$data, $value) {
$value = strtolower($value);
- if (!in_array($value, array('form', 'http_auth', 'persona', 'none'))) {
+ if (!in_array($value, array('form', 'http_auth', 'none'))) {
$value = 'none';
}
$data['auth_type'] = $value;
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index f74055835..c9e6f9742 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -11,7 +11,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
}
protected function addColumn($name) {
- Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn: ' . $name);
+ Minz_Log::warning('FreshRSS_EntryDAO::addColumn: ' . $name);
$hasTransaction = false;
try {
$stm = null;
@@ -38,7 +38,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return $stm && $stm->execute();
}
} catch (Exception $e) {
- Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn error: ' . $e->getMessage());
+ Minz_Log::error('FreshRSS_EntryDAO::addColumn error: ' . $e->getMessage());
if ($hasTransaction) {
$this->bd->rollBack();
}
@@ -46,9 +46,44 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return false;
}
- protected function autoAddColumn($errorInfo) {
+ private $triedUpdateToUtf8mb4 = false;
+
+ protected function updateToUtf8mb4() {
+ if ($this->triedUpdateToUtf8mb4) {
+ return false;
+ }
+ $this->triedUpdateToUtf8mb4 = true;
+ $db = FreshRSS_Context::$system_conf->db;
+ if ($db['type'] === 'mysql') {
+ include_once(APP_PATH . '/SQL/install.sql.mysql.php');
+ if (defined('SQL_UPDATE_UTF8MB4')) {
+ Minz_Log::warning('Updating MySQL to UTF8MB4...');
+ $hadTransaction = $this->bd->inTransaction();
+ if ($hadTransaction) {
+ $this->bd->commit();
+ }
+ $ok = false;
+ try {
+ $sql = sprintf(SQL_UPDATE_UTF8MB4, $this->prefix, $db['base']);
+ $stm = $this->bd->prepare($sql);
+ $ok = $stm->execute();
+ } catch (Exception $e) {
+ Minz_Log::error('FreshRSS_EntryDAO::updateToUtf8mb4 error: ' . $e->getMessage());
+ }
+ if ($hadTransaction) {
+ $this->bd->beginTransaction();
+ //NB: Transaction not starting. Why? (tested on PHP 7.0.8-0ubuntu and MySQL 5.7.13-0ubuntu)
+ }
+ return $ok;
+ }
+ }
+ return false;
+ }
+
+ protected function autoUpdateDb($errorInfo) {
if (isset($errorInfo[0])) {
- if ($errorInfo[0] == '42S22') { //ER_BAD_FIELD_ERROR
+ if ($errorInfo[0] === '42S22') { //ER_BAD_FIELD_ERROR
+ //autoAddColumn
foreach (array('lastSeen', 'hash') as $column) {
if (stripos($errorInfo[2], $column) !== false) {
return $this->addColumn($column);
@@ -56,6 +91,11 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
}
}
}
+ if (isset($errorInfo[1])) {
+ if ($errorInfo[1] == '1366') { //ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
+ return $this->updateToUtf8mb4();
+ }
+ }
return false;
}
@@ -94,7 +134,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return $this->bd->lastInsertId();
} else {
$info = $this->addEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->addEntryPrepared->errorInfo();
- if ($this->autoAddColumn($info)) {
+ if ($this->autoUpdateDb($info)) {
return $this->addEntry($valuesTmp);
} elseif ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries
Minz_Log::error('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
@@ -145,7 +185,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return $this->bd->lastInsertId();
} else {
$info = $this->updateEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->updateEntryPrepared->errorInfo();
- if ($this->autoAddColumn($info)) {
+ if ($this->autoUpdateDb($info)) {
return $this->updateEntry($valuesTmp);
}
Minz_Log::error('SQL error updateEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
@@ -615,7 +655,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return $result;
} else {
$info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo();
- if ($this->autoAddColumn($info)) {
+ if ($this->autoUpdateDb($info)) {
return $this->listHashForFeedGuids($id_feed, $guids);
}
Minz_Log::error('SQL error listHashForFeedGuids: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
@@ -636,7 +676,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return $stm->rowCount();
} else {
$info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo();
- if ($this->autoAddColumn($info)) {
+ if ($this->autoUpdateDb($info)) {
return $this->updateLastSeen($id_feed, $guids);
}
Minz_Log::error('SQL error updateLastSeen: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
@@ -692,7 +732,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
public function optimizeTable() {
$sql = 'OPTIMIZE TABLE `' . $this->prefix . 'entry`'; //MySQL
$stm = $this->bd->prepare($sql);
- $stm->execute();
+ if ($stm) {
+ return $stm->execute();
+ }
}
public function size($all = false) {