aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhatto <rhatto@riseup.net>2023-08-30 20:09:49 -0300
committerGitHub <noreply@github.com>2023-08-30 20:09:49 -0300
commit7e5536c3f641567143b31fb9f54468184083ebce (patch)
tree6864121f35e2f2ba9fd06cc1fb096671ace5e6fa
parent856e975127fff8f82b14f2886bb4ffb239541555 (diff)
parent8726754cb10f5c8db09f7012574450907af97cfa (diff)
downloadsemanticscuttle-7e5536c3f641567143b31fb9f54468184083ebce.tar.gz
semanticscuttle-7e5536c3f641567143b31fb9f54468184083ebce.tar.bz2
Merge pull request #2 from jasonmm/rector
Update code to work with modern PHP.
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php8
-rw-r--r--src/SemanticScuttle/db/db2.php4
-rw-r--r--src/SemanticScuttle/db/mssql-odbc.php6
-rw-r--r--src/SemanticScuttle/db/mssql.php8
-rw-r--r--src/SemanticScuttle/db/mysql.php12
-rw-r--r--src/SemanticScuttle/db/mysql4.php12
-rw-r--r--src/SemanticScuttle/db/mysqli.php14
-rw-r--r--src/SemanticScuttle/db/oracle.php4
-rw-r--r--src/SemanticScuttle/db/postgres.php10
-rw-r--r--src/SemanticScuttle/db/sqlite.php4
-rw-r--r--src/SemanticScuttle/utf8.php12
-rw-r--r--src/php-gettext/gettext.php2
-rw-r--r--src/php-gettext/streams.php9
13 files changed, 50 insertions, 55 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index 1315350..ea8762d 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -734,6 +734,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$tags = explode('+', trim($tags));
}
+ if(!is_array($tags)) {
+ $tags = [];
+ }
+
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i ++) {
$tags[$i] = trim($tags[$i]);
@@ -852,6 +856,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$aTerms = explode(' ', $terms);
$aTerms = array_map('trim', $aTerms);
+ if(!is_array($tags)){
+ $tags = [];
+ }
+
// Search terms in tags as well when none given
if (!count($tags)) {
$query_2 .= ' LEFT JOIN '. $b2tservice->getTableName() .' AS T'
diff --git a/src/SemanticScuttle/db/db2.php b/src/SemanticScuttle/db/db2.php
index b1abf1a..117ecae 100644
--- a/src/SemanticScuttle/db/db2.php
+++ b/src/SemanticScuttle/db/db2.php
@@ -36,7 +36,7 @@ class sql_db
//
// Constructor
//
- function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
+ function __construct($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
@@ -414,4 +414,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/mssql-odbc.php b/src/SemanticScuttle/db/mssql-odbc.php
index a2d3d02..f8b7db3 100644
--- a/src/SemanticScuttle/db/mssql-odbc.php
+++ b/src/SemanticScuttle/db/mssql-odbc.php
@@ -184,7 +184,7 @@ class sql_db
function _odbc_execute_query($query)
{
$result = false;
-
+
if (eregi("^SELECT ", $query))
{
$result = @odbc_exec($this->db_connect_id, $query);
@@ -459,7 +459,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -573,4 +573,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/mssql.php b/src/SemanticScuttle/db/mssql.php
index 2b17b9e..8358d27 100644
--- a/src/SemanticScuttle/db/mssql.php
+++ b/src/SemanticScuttle/db/mssql.php
@@ -134,7 +134,7 @@ class sql_db
if (!$this->query_result)
{
$this->num_queries++;
-
+
if (($this->query_result = @mssql_query($query, $this->db_connect_id)) === false)
{
$this->sql_error($query);
@@ -285,7 +285,7 @@ class sql_db
}
$row = @mssql_fetch_array($query_id, MSSQL_ASSOC);
-
+
if ($row)
{
foreach ($row as $key => $value)
@@ -431,7 +431,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -548,4 +548,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/mysql.php b/src/SemanticScuttle/db/mysql.php
index a646e0d..88b59d8 100644
--- a/src/SemanticScuttle/db/mysql.php
+++ b/src/SemanticScuttle/db/mysql.php
@@ -94,7 +94,7 @@ class sql_db
case 'commit':
$result = @mysql_query('COMMIT', $this->db_connect_id);
$this->transaction = false;
-
+
if (!$result)
{
@mysql_query('ROLLBACK', $this->db_connect_id);
@@ -291,7 +291,7 @@ class sql_db
}
return $result;
}
-
+
return false;
}
@@ -372,7 +372,7 @@ class sql_db
return mysql_escape_string($msg);
}
}
-
+
function sql_error($sql = '')
{
if (!$this->return_on_error)
@@ -386,7 +386,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -463,7 +463,7 @@ class sql_db
{
$html_table = TRUE;
$html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>';
-
+
foreach (array_keys($row) as $val)
{
$html_hold .= '<th nowrap="nowrap">' . (($val) ? ucwords(str_replace('_', ' ', $val)) : '&nbsp;') . '</th>';
@@ -549,4 +549,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/mysql4.php b/src/SemanticScuttle/db/mysql4.php
index 0639518..c13bcbd 100644
--- a/src/SemanticScuttle/db/mysql4.php
+++ b/src/SemanticScuttle/db/mysql4.php
@@ -94,7 +94,7 @@ class sql_db
case 'commit':
$result = @mysql_query('COMMIT', $this->db_connect_id);
$this->transaction = false;
-
+
if (!$result)
{
@mysql_query('ROLLBACK', $this->db_connect_id);
@@ -291,7 +291,7 @@ class sql_db
}
return $result;
}
-
+
return false;
}
@@ -372,7 +372,7 @@ class sql_db
return mysql_escape_string($msg);
}
}
-
+
function sql_error($sql = '')
{
if (!$this->return_on_error)
@@ -386,7 +386,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -463,7 +463,7 @@ class sql_db
{
$html_table = TRUE;
$html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>';
-
+
foreach (array_keys($row) as $val)
{
$html_hold .= '<th nowrap="nowrap">' . (($val) ? ucwords(str_replace('_', ' ', $val)) : '&nbsp;') . '</th>';
@@ -549,4 +549,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/mysqli.php b/src/SemanticScuttle/db/mysqli.php
index 9a2709a..fcff848 100644
--- a/src/SemanticScuttle/db/mysqli.php
+++ b/src/SemanticScuttle/db/mysqli.php
@@ -129,7 +129,7 @@ class sql_db
}
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
-
+
if (!$this->query_result)
{
$this->num_queries++;
@@ -286,7 +286,7 @@ class sql_db
unset($this->rowset[$cur_index]);
unset($this->row[$cur_index]);
-
+
$result = array();
while ($this->rowset[$cur_index] = $this->sql_fetchrow($query_id))
{
@@ -316,7 +316,7 @@ class sql_db
else
{
$cur_index = (is_object($query_id)) ? $query_id->cur_index : $query_id;
-
+
if (empty($this->row[$cur_index]) && empty($this->rowset[$cur_index]))
{
if ($this->row[$cur_index] = $this->sql_fetchrow($query_id))
@@ -382,7 +382,7 @@ class sql_db
function sql_escape($msg) {
return mysqli_real_escape_string($this->db_connect_id, $msg);
}
-
+
function sql_error($sql = '')
{
if (!$this->return_on_error)
@@ -396,7 +396,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -473,7 +473,7 @@ class sql_db
{
$html_table = TRUE;
$html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>';
-
+
foreach (array_keys($row) as $val)
{
$html_hold .= '<th nowrap="nowrap">' . (($val) ? ucwords(str_replace('_', ' ', $val)) : '&nbsp;') . '</th>';
@@ -559,4 +559,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/oracle.php b/src/SemanticScuttle/db/oracle.php
index 7ef10e5..8b983d3 100644
--- a/src/SemanticScuttle/db/oracle.php
+++ b/src/SemanticScuttle/db/oracle.php
@@ -34,7 +34,7 @@ class sql_db
//
// Constructor
//
- function sql_db($sqlserver, $sqluser, $sqlpassword, $database="", $persistency = true)
+ function __construct($sqlserver, $sqluser, $sqlpassword, $database="", $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
@@ -465,4 +465,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/postgres.php b/src/SemanticScuttle/db/postgres.php
index b5bad20..2085359 100644
--- a/src/SemanticScuttle/db/postgres.php
+++ b/src/SemanticScuttle/db/postgres.php
@@ -58,7 +58,7 @@ class sql_db
{
$this->connect_string .= "host=$sqlserver ";
}
-
+
if ($port)
{
$this->connect_string .= "port=$port ";
@@ -152,7 +152,7 @@ class sql_db
}
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
-
+
if (!$this->query_result)
{
$this->num_queries++;
@@ -308,7 +308,7 @@ class sql_db
}
$result = @pg_fetch_array($query_id, NULL, PGSQL_ASSOC);
-
+
if ($result)
{
$this->rownum[$query_id]++;
@@ -477,7 +477,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -594,4 +594,4 @@ class sql_db
} // if ... defined
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/db/sqlite.php b/src/SemanticScuttle/db/sqlite.php
index 1591396..64d4371 100644
--- a/src/SemanticScuttle/db/sqlite.php
+++ b/src/SemanticScuttle/db/sqlite.php
@@ -368,7 +368,7 @@ class sql_db
{
$this->sql_transaction('rollback');
}
-
+
trigger_error($message, E_USER_ERROR);
}
@@ -384,4 +384,4 @@ class sql_db
} // if ... define
-?> \ No newline at end of file
+?>
diff --git a/src/SemanticScuttle/utf8.php b/src/SemanticScuttle/utf8.php
index 9ef8113..810c50c 100644
--- a/src/SemanticScuttle/utf8.php
+++ b/src/SemanticScuttle/utf8.php
@@ -42,18 +42,6 @@ function utf8_decodeFN($file){
}
/**
- * Checks if a string contains 7bit ASCII only
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-function utf8_isASCII($str){
- for($i=0; $i<strlen($str); $i++){
- if(ord($str{$i}) >127) return false;
- }
- return true;
-}
-
-/**
* Tries to detect if a string is in Unicode encoding
*
* @author <bmorel@ssi.fr>
diff --git a/src/php-gettext/gettext.php b/src/php-gettext/gettext.php
index a121f9c..5b3886e 100644
--- a/src/php-gettext/gettext.php
+++ b/src/php-gettext/gettext.php
@@ -98,7 +98,7 @@ class gettext_reader {
* @param object Reader the StreamReader object
* @param boolean enable_cache Enable or disable caching of strings (default on)
*/
- function gettext_reader($Reader, $enable_cache = true) {
+ function __construct($Reader, $enable_cache = true) {
// If there isn't a StreamReader, turn on short circuit mode.
if (! $Reader || isset($Reader->error) ) {
$this->short_circuit = true;
diff --git a/src/php-gettext/streams.php b/src/php-gettext/streams.php
index 3cdc158..de59a9a 100644
--- a/src/php-gettext/streams.php
+++ b/src/php-gettext/streams.php
@@ -46,12 +46,11 @@ class StreamReader {
};
class StringReader {
- var $_pos;
+ var $_pos = 0;
var $_str;
- function StringReader($str='') {
+ function __construct($str='') {
$this->_str = $str;
- $this->_pos = 0;
}
function read($bytes) {
@@ -86,7 +85,7 @@ class FileReader {
var $_fd;
var $_length;
- function FileReader($filename) {
+ function __construct($filename) {
if (file_exists($filename)) {
$this->_length=filesize($filename);
@@ -143,7 +142,7 @@ class FileReader {
// Preloads entire file in memory first, then creates a StringReader
// over it (it assumes knowledge of StringReader internals)
class CachedFileReader extends StringReader {
- function CachedFileReader($filename) {
+ function __construct($filename) {
if (file_exists($filename)) {
$length=filesize($filename);