[sticky-notes] - Depend on pdo instead of mysql - Add a patch to fix a login issue - Add a patch to fix a error whe
Athmane Madjoudj
athmane at fedoraproject.org
Tue Aug 6 23:38:52 UTC 2013
commit 1b21e7088c1d27ff06bc5d019bd68893ed0ea723
Author: Athmane Madjoudj <athmane at fedoraproject.org>
Date: Wed Aug 7 00:38:05 2013 +0100
- Depend on pdo instead of mysql
- Add a patch to fix a login issue
- Add a patch to fix a error when retrieving last insered id
- Misc specfile cleanup
sticky-notes-0.4-dont-use-eval-for-login.patch | 32 +++++
...fix-error-when-retrieving-last-insered-id.patch | 144 ++++++++++++++++++++
sticky-notes.spec | 49 ++++---
3 files changed, 207 insertions(+), 18 deletions(-)
---
diff --git a/sticky-notes-0.4-dont-use-eval-for-login.patch b/sticky-notes-0.4-dont-use-eval-for-login.patch
new file mode 100644
index 0000000..3eb94ca
--- /dev/null
+++ b/sticky-notes-0.4-dont-use-eval-for-login.patch
@@ -0,0 +1,32 @@
+diff --git a/classes/class_auth.php b/classes/class_auth.php
+index 4ca4335..72ad9a9 100644
+--- a/classes/class_auth.php
++++ b/classes/class_auth.php
+@@ -46,22 +46,14 @@ function login($username, $password)
+ {
+ global $config, $db;
+
+- // Get authentication method
+- $method = $config->auth_method;
++ // Get authentication method callback
++ $callback = array($this, "authenticate_{$config->auth_method}");
+
+- // Check if the auth method is implemented
+- if (method_exists($this, "authenticate_{$method}"))
++ // Execute the method if it exists
++ if (is_callable($callback))
+ {
+- // Create a new session
+ $this->create_session();
+-
+- // Generate the delegate and execute the method
+- $delegate = '$auth_status = $this->authenticate_' . $method .
+- '("' . $username . '", "' . $password . '");';
+- eval($delegate);
+-
+- // Return the authentication status returned by the delegate
+- return $auth_status;
++ return call_user_func($callback, $username, $password);
+ }
+
+ // Method not implemented, invalidate user
diff --git a/sticky-notes-0.4-fix-error-when-retrieving-last-insered-id.patch b/sticky-notes-0.4-fix-error-when-retrieving-last-insered-id.patch
new file mode 100644
index 0000000..e868d99
--- /dev/null
+++ b/sticky-notes-0.4-fix-error-when-retrieving-last-insered-id.patch
@@ -0,0 +1,144 @@
+diff --git a/classes/class_db.php b/classes/class_db.php
+index 3a6a65a..81e741e 100755
+--- a/classes/class_db.php
++++ b/classes/class_db.php
+@@ -13,7 +13,6 @@ class db
+ // Class wide variables
+ var $pdo;
+ var $prefix;
+- var $insert_id;
+ var $affected_rows;
+
+ // Function to initialize a db connection
+@@ -92,11 +91,7 @@ function query($sql, $params = array(), $single = false)
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
+ }
+ }
+- else if (strpos($sql, 'insert') === 0)
+- {
+- $this->insert_id = $stmt;
+- }
+- else if (strpos($sql, 'update') === 0 || strpos($sql, 'delete') === 0)
++ else
+ {
+ $this->affected_rows = $stmt->rowCount();
+ }
+@@ -109,6 +104,12 @@ function query($sql, $params = array(), $single = false)
+ }
+ }
+
++ // Gets the last inserted ID
++ function insert_id($column)
++ {
++ return $this->pdo->lastInsertId($column);
++ }
++
+ // Gets the database size
+ function get_size()
+ {
+diff --git a/classes/class_nav.php b/classes/class_nav.php
+index 3228d23..1399ab2 100755
+--- a/classes/class_nav.php
++++ b/classes/class_nav.php
+@@ -18,7 +18,7 @@ function __construct()
+ {
+ $this->rewrite_on = $this->check_rewrite();
+ }
+-
++
+ // Check if mod_rewrite is enabled or not
+ function check_rewrite()
+ {
+@@ -44,7 +44,7 @@ function get($nav_key, $project = '', $page = 1, $age = '')
+ $base = $core->current_uri();
+
+ $arg_project = !empty($project) ? '?project=' . $project : '?';
+- $arg_page = $page > 1 ? "&page={$page}" : "";
++ $arg_page = $page > 1 ? "&page={$page}" : "";
+ $arg_age = !empty($age) ? "&age={$age}" : "";
+
+ $rewrite_base = $core->current_uri() . (!empty($project) ? "~{$project}/" : "");
+@@ -97,7 +97,7 @@ function get($nav_key, $project = '', $page = 1, $age = '')
+ function get_paste($paste_id, $paste_key, $hash, $project, $format = '')
+ {
+ global $core, $config;
+-
++
+ try
+ {
+ // Determine whether to use ID or key
+@@ -109,20 +109,20 @@ function get_paste($paste_id, $paste_key, $hash, $project, $format = '')
+ {
+ $key = $paste_id;
+ }
+-
++
+ if ($this->rewrite_on)
+ {
+ $url = $core->current_uri() . (!empty($project) ? "~{$project}/" : "") .
+- "{$key}/" .
+- (!empty($hash) ? "{$hash}/" : "") .
+- (!empty($format) ? "{$format}/" : "");
++ "{$key}/" .
++ (!empty($hash) ? "{$hash}/" : "") .
++ (!empty($format) ? "{$format}/" : "");
+ }
+ else
+ {
+ $url = $core->current_uri() . "show.php?id={$key}" .
+- (!empty($hash) ? "&hash={$hash}" : "") .
+- (!empty($project) ? "&project={$project}" : "") .
+- (!empty($format) ? "&mode={$format}" : "");
++ (!empty($hash) ? "&hash={$hash}" : "") .
++ (!empty($project) ? "&project={$project}" : "") .
++ (!empty($format) ? "&mode={$format}" : "");
+ }
+
+ return $url;
+diff --git a/index.php b/index.php
+index fc88607..3240581 100755
+--- a/index.php
++++ b/index.php
+@@ -23,7 +23,7 @@
+ $mode = $core->variable('mode', '');
+ $time = time();
+ $skip_insert = false;
+-$db->insert_id = 0;
++$new_id = 0;
+
+ if (empty($project))
+ {
+@@ -173,15 +173,18 @@
+ ':hash' => $hash,
+ ':ip' => $core->remote_ip()
+ ));
++
++ // Get the last inserted paste ID
++ $new_id = $db->insert_id('id');
+ }
+
+ // Address API requests
+ if ($mode == 'xml' || $mode == 'json')
+ {
+- if ($db->insert_id)
++ if ($new_id)
+ {
+ $skin->assign(array(
+- 'paste_id' => $config->url_key_enabled ? "p{$url_key}" : $db->insert_id,
++ 'paste_id' => $config->url_key_enabled ? "p{$url_key}" : $new_id,
+ 'paste_hash' => $private ? $hash : '',
+ ));
+
+@@ -199,10 +202,10 @@
+ }
+ else
+ {
+- if ($db->insert_id)
++ if ($new_id)
+ {
+ $hash_arg = ($private || $password) ? $hash : '';
+- $url = $nav->get_paste($db->insert_id, $url_key, $hash_arg, $project);
++ $url = $nav->get_paste($new_id, $url_key, $hash_arg, $project);
+
+ if (!$password)
+ {
diff --git a/sticky-notes.spec b/sticky-notes.spec
index 8e0ac34..c17ba43 100644
--- a/sticky-notes.spec
+++ b/sticky-notes.spec
@@ -1,21 +1,23 @@
-Summary: Sticky notes is a free and open source paste-bin application
-Name: sticky-notes
-Version: 0.4
-Release: 3%{?dist}
-License: BSD
-Group: Applications/Internet
-URL: https://github.com/sayakb/sticky-notes
-# The source was pulled from upstreams git scm. Use the following
-# commands to generate the tarball
-# wget https://nodeload.github.com/sayakb/sticky-notes/tar.gz/master
-Source0: sticky-notes-%{version}.tar.gz
-Source1: sticky-notes.conf
-Patch0: sticky-notes-unbundle-php-libs.patch
-Patch1: sticky-notes-use-free-url-shortener.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-BuildArch: noarch
-Requires: httpd
-Requires: php, php-geshi, php-mysql, php-swift-Swift
+Summary: Sticky notes is a free and open source paste-bin application
+Name: sticky-notes
+Version: 0.4
+Release: 4%{?dist}
+License: BSD
+Group: Applications/Internet
+URL: https://github.com/sayakb/sticky-notes
+
+# Use the following commands to generate the tarball
+# wget https://github.com/sayakb/sticky-notes/releases/tag/VERSION
+Source0: sticky-notes-%{version}.tar.gz
+Source1: sticky-notes.conf
+Patch0: sticky-notes-unbundle-php-libs.patch
+Patch1: sticky-notes-use-free-url-shortener.patch
+Patch2: sticky-notes-0.4-dont-use-eval-for-login.patch
+Patch3: sticky-notes-0.4-fix-error-when-retrieving-last-insered-id.patch
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+BuildArch: noarch
+Requires: httpd
+Requires: php, php-geshi, php-pdo, php-swift-Swift
%description
Sticky notes is a free and open source paste-bin application.
@@ -24,6 +26,8 @@ Sticky notes is a free and open source paste-bin application.
%setup -q
%patch0 -p1
%patch1 -p1
+%patch2 -p1
+%patch3 -p1
%build
%install
@@ -36,7 +40,10 @@ find . -type f -exec chmod -x {} \;
# Remove bundled php-geshi
rm -rf addons/geshi
rm -rf addons/swiftmailer
+
+# Remove non-required dirs
rm -f lighttpd.conf
+rm -rf cache testing
cp -pr * ${RPM_BUILD_ROOT}%{_datadir}/%{name}
mkdir ${RPM_BUILD_ROOT}%{_sysconfdir}/sticky-notes
cp config.sample.php ${RPM_BUILD_ROOT}%{_sysconfdir}/sticky-notes/config.php
@@ -55,6 +62,12 @@ ln -sf ../../../etc/sticky-notes/install.php ${RPM_BUILD_ROOT}%{_datadir}/%{name
%doc VERSION
%changelog
+* Tue Aug 06 2013 Athmane Madjoudj <athmane at fedoraproject.org> 0.4-4
+- Depend on pdo instead of mysql
+- Add a patch to fix a login issue
+- Add a patch to fix a error when retrieving last insered id
+- Misc specfile cleanup
+
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
More information about the scm-commits
mailing list