Merge pull request #255 from owncloud/scrutinizer-fixes

Scrutinizer fixes
This commit is contained in:
VicDeo 2014-05-14 18:12:27 +03:00
commit 85bf4bce20
8 changed files with 35 additions and 18 deletions

View File

@ -63,7 +63,7 @@ class DocumentController extends Controller{
public static function rename($args){ public static function rename($args){
$uid = self::preDispatch(); self::preDispatch();
$fileId = intval(Helper::getArrayValueByKey($args, 'file_id', 0)); $fileId = intval(Helper::getArrayValueByKey($args, 'file_id', 0));
$name = Helper::getArrayValueByKey($_POST, 'name'); $name = Helper::getArrayValueByKey($_POST, 'name');

View File

@ -67,6 +67,7 @@ try{
try { try {
$member->updateActivity($memberId); $member->updateActivity($memberId);
} catch (\Exception $e){ } catch (\Exception $e){
//Db error. Not critical
} }
// TODO handle the case ($currentHead == "") && ($seqHead != "") // TODO handle the case ($currentHead == "") && ($seqHead != "")

View File

@ -18,7 +18,7 @@ class SessionController extends Controller{
self::preDispatchGuest(); self::preDispatchGuest();
$uid = Helper::getArrayValueByKey($_POST, 'name'); $uid = Helper::getArrayValueByKey($_POST, 'name');
$guestUid = substr($uid, 0, 16); $uid = substr($uid, 0, 16);
try { try {
$token = Helper::getArrayValueByKey($args, 'token'); $token = Helper::getArrayValueByKey($args, 'token');
@ -74,9 +74,9 @@ class SessionController extends Controller{
$currentMember = new Db_Member(); $currentMember = new Db_Member();
$currentMember->load($memberId); $currentMember->load($memberId);
if (is_null($currentMember->getIsGuest()) || $currentMember->getIsGuest()){ if (is_null($currentMember->getIsGuest()) || $currentMember->getIsGuest()){
$uid = self::preDispatchGuest(); self::preDispatchGuest();
} else { } else {
self::preDispatch(); $uid = self::preDispatch();
} }
//check if member belongs to the session //check if member belongs to the session
@ -84,7 +84,8 @@ class SessionController extends Controller{
throw new \Exception($memberId . ' does not belong to session ' . $esId); throw new \Exception($memberId . ' does not belong to session ' . $esId);
} }
$sessionRevision = @$_SERVER['HTTP_WEBODF_SESSION_REVISION']; // Extra info for future usage
// $sessionRevision = Helper::getArrayValueByKey($_SERVER, 'HTTP_WEBODF_SESSION_REVISION');
$stream = fopen('php://input','r'); $stream = fopen('php://input','r');
if (!$stream){ if (!$stream){
@ -110,10 +111,12 @@ class SessionController extends Controller{
} catch (\Exception $e){ } catch (\Exception $e){
//File was deleted or unshared. We need to save content as new file anyway //File was deleted or unshared. We need to save content as new file anyway
//Sorry, but for guests it would be lost :( //Sorry, but for guests it would be lost :(
$view = new \OC\Files\View('/' . $uid . '/files'); if (isset($uid)){
$view = new \OC\Files\View('/' . $uid . '/files');
$dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', ''); $dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '');
$path = Helper::getNewFileName($view, $dir . 'New Document.odt'); $path = Helper::getNewFileName($view, $dir . 'New Document.odt');
}
} }
$member = new Db_Member(); $member = new Db_Member();

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ class Converter {
public static function checkConnection(){ public static function checkConnection(){
$expected = file_get_contents(__DIR__ . '/response.odt'); $expected = file_get_contents(__DIR__ . '/response.odt');
$converted = self::convertExternal(''); $converted = self::convertExternal('', 'application/vnd.oasis.opendocument.text');
return $converted === $expected; return $converted === $expected;
} }

View File

@ -100,12 +100,12 @@ abstract class Db {
} }
$count = count($value); $count = count($value);
if ($count===0){ if ($count===0){
return 0; return;
} elseif ($count===1){ } elseif ($count===1){
$result = $this->execute('DELETE FROM ' . $this->tableName . ' WHERE `'. $field .'` =?', $value); $this->execute('DELETE FROM ' . $this->tableName . ' WHERE `'. $field .'` =?', $value);
} else { } else {
$stmt = $this->buildInQuery($field, $value); $stmt = $this->buildInQuery($field, $value);
$result = $this->execute('DELETE FROM ' . $this->tableName . ' WHERE ' . $stmt, $value); $this->execute('DELETE FROM ' . $this->tableName . ' WHERE ' . $stmt, $value);
} }
} }

View File

@ -12,6 +12,12 @@
namespace OCA\Documents; namespace OCA\Documents;
/*
* @method boolean getIsGuest()
* @method string getEsId()
* @method string getToken()
*/
class Db_Member extends Db{ class Db_Member extends Db{
const DB_TABLE = '`*PREFIX*documents_member`'; const DB_TABLE = '`*PREFIX*documents_member`';

View File

@ -13,7 +13,14 @@
namespace OCA\Documents; namespace OCA\Documents;
/** /**
* Session management * Session management
*
* @method string getEsId()
* @method int getFileId()
* @method string getGenesisUrl()
* @method string getOwner()
* @method string getGenesisHash()
*
*/ */
class Db_Session extends \OCA\Documents\Db { class Db_Session extends \OCA\Documents\Db {