mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-27 11:22:17 -05:00
Merge pull request #632 from mariroz/dev
logging by import added; error by creation table if exists in postgresql...
This commit is contained in:
commit
389d751e92
@ -77,7 +77,7 @@ class Database {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = '
|
$sql = '
|
||||||
CREATE TABLE tags (
|
CREATE TABLE IF NOT EXISTS tags (
|
||||||
id bigserial primary key,
|
id bigserial primary key,
|
||||||
value varchar(255) NOT NULL
|
value varchar(255) NOT NULL
|
||||||
);
|
);
|
||||||
@ -110,7 +110,7 @@ class Database {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = '
|
$sql = '
|
||||||
CREATE TABLE tags_entries (
|
CREATE TABLE IF NOT EXISTS tags_entries (
|
||||||
id bigserial primary key,
|
id bigserial primary key,
|
||||||
entry_id integer NOT NULL,
|
entry_id integer NOT NULL,
|
||||||
tag_id integer NOT NULL
|
tag_id integer NOT NULL
|
||||||
@ -407,7 +407,7 @@ class Database {
|
|||||||
public function getLastId($column = '') {
|
public function getLastId($column = '') {
|
||||||
return $this->getHandle()->lastInsertId($column);
|
return $this->getHandle()->lastInsertId($column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search($term, $user_id, $limit = '') {
|
public function search($term, $user_id, $limit = '') {
|
||||||
$search = '%'.$term.'%';
|
$search = '%'.$term.'%';
|
||||||
$sql_action = "SELECT * FROM entries WHERE user_id=? AND (content LIKE ? OR title LIKE ? OR url LIKE ?) "; //searches in content, title and URL
|
$sql_action = "SELECT * FROM entries WHERE user_id=? AND (content LIKE ? OR title LIKE ? OR url LIKE ?) "; //searches in content, title and URL
|
||||||
|
@ -832,6 +832,8 @@ class Poche
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($_FILES['file']) ) {
|
if ( isset($_FILES['file']) ) {
|
||||||
|
Tools::logm('Import stated: parsing file');
|
||||||
|
|
||||||
// assume, that file is in json format
|
// assume, that file is in json format
|
||||||
$str_data = file_get_contents($_FILES['file']['tmp_name']);
|
$str_data = file_get_contents($_FILES['file']['tmp_name']);
|
||||||
$data = json_decode($str_data, true);
|
$data = json_decode($str_data, true);
|
||||||
@ -897,6 +899,7 @@ class Poche
|
|||||||
if ( $i > 0 ) {
|
if ( $i > 0 ) {
|
||||||
$this->messages->add('s', _('Articles inserted: ').$i._('. Please note, that some may be marked as "read".'));
|
$this->messages->add('s', _('Articles inserted: ').$i._('. Please note, that some may be marked as "read".'));
|
||||||
}
|
}
|
||||||
|
Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).');
|
||||||
}
|
}
|
||||||
//file parsing finished here
|
//file parsing finished here
|
||||||
|
|
||||||
@ -907,12 +910,14 @@ class Poche
|
|||||||
if ( $recordsDownloadRequired == 0 ) {
|
if ( $recordsDownloadRequired == 0 ) {
|
||||||
//nothing to download
|
//nothing to download
|
||||||
$this->messages->add('s', _('Import finished.'));
|
$this->messages->add('s', _('Import finished.'));
|
||||||
|
Tools::logm('Import finished completely');
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//if just inserted - don't download anything, download will start in next reload
|
//if just inserted - don't download anything, download will start in next reload
|
||||||
if ( !isset($_FILES['file']) ) {
|
if ( !isset($_FILES['file']) ) {
|
||||||
//download next batch
|
//download next batch
|
||||||
|
Tools::logm('Fetching next batch of articles...');
|
||||||
$items = $this->store->retrieveUnfetchedEntries($this->user->getId(), IMPORT_LIMIT);
|
$items = $this->store->retrieveUnfetchedEntries($this->user->getId(), IMPORT_LIMIT);
|
||||||
|
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
@ -921,6 +926,7 @@ class Poche
|
|||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$url = new Url(base64_encode($item['url']));
|
$url = new Url(base64_encode($item['url']));
|
||||||
|
Tools::logm('Fetching article '.$item['id']);
|
||||||
$content = Tools::getPageContent($url);
|
$content = Tools::getPageContent($url);
|
||||||
|
|
||||||
$title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'));
|
$title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'));
|
||||||
@ -931,6 +937,7 @@ class Poche
|
|||||||
$body = $purifier->purify($body);
|
$body = $purifier->purify($body);
|
||||||
|
|
||||||
$this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId());
|
$this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId());
|
||||||
|
Tools::logm('Article '.$item['id'].' updated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user