Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Commit 51a55e3

Browse files
author
Stefan
committed
SQLite cache fix
1 parent d0146fa commit 51a55e3

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

libs/UrlCache/PHPCrawlerSQLiteURLCache.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ protected function openConnection($create_tables = false): void
242242

243243
$this->PDO->exec('PRAGMA journal_mode = OFF');
244244

245-
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
245+
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
246246
$this->PDO->setAttribute(PDO::ATTR_TIMEOUT, 100);
247247

248248
if ($create_tables == true) {
249249
// Create url-table (if not exists)
250-
$this->PDO->exec('CREATE TABLE IF NOT EXISTS urls (id integer PRIMARY KEY AUTOINCREMENT,
250+
$created = $this->PDO->exec('CREATE TABLE IF NOT EXISTS urls (id integer PRIMARY KEY AUTOINCREMENT,
251251
in_process bool DEFAULT 0,
252252
processed bool DEFAULT 0,
253253
priority_level integer,
@@ -277,18 +277,19 @@ protected function openConnection($create_tables = false): void
277277
*/
278278
protected function createPreparedInsertStatement(): void
279279
{
280-
if (isset($this->PreparedInsertStatement) && $this->PreparedInsertStatement == null) {
281-
// Prepared statement for URL-inserts
282-
$this->PreparedInsertStatement = $this->PDO->prepare('INSERT OR IGNORE INTO urls (priority_level, distinct_hash, link_raw, linkcode, linktext, refering_url, url_rebuild, is_redirect_url, url_link_depth)
283-
VALUES(:priority_level,
284-
:distinct_hash,
285-
:link_raw,
286-
:linkcode,
287-
:linktext,
288-
:refering_url,
289-
:url_rebuild,
290-
:is_redirect_url,
291-
:url_link_depth);');
280+
if(!isset($this->PreparedInsertStatement) || $this->PreparedInsertStatement == null) {
281+
$this->PreparedInsertStatement = $this->PDO->prepare(
282+
'INSERT OR IGNORE INTO urls (priority_level, distinct_hash, link_raw, linkcode, linktext, refering_url, url_rebuild, is_redirect_url, url_link_depth)
283+
VALUES(:priority_level,
284+
:distinct_hash,
285+
:link_raw,
286+
:linkcode,
287+
:linktext,
288+
:refering_url,
289+
:url_rebuild,
290+
:is_redirect_url,
291+
:url_link_depth);'
292+
);
292293
}
293294
}
294295

0 commit comments

Comments
 (0)