claudehohl / Stikked

An advanced and beautiful pastebin written in PHP
992 stars 220 forks source link

Recipe for making it work-ish with php8 #569

Open misterludvigsen opened 1 year ago

misterludvigsen commented 1 year ago

I followed these steps to get rid of all the errors in php8. Hope I didn't leave anything out.

/application/config/stikked.php #36 $config['db_driver'] = 'mysqli';

/system/core/Input.php #568 $which = FILTER_DEFAULT;

/application/libraries/Carabiner.php #466 private function _asset($type, $dev_file, $prod_file = '', $combine = TRUE, $minify = TRUE, $media = 'screen', $group = 'main')

/system/libraries/Pagination.php #525 if ( ! ctype_digit(strval($this->cur_page)) OR ($this->use_page_numbers && (int) $this->cur_page === 0))

Also, use google reCaptcha v2 - I was unable to make the old builtin captcha method to work.

ColdSphinX commented 11 months ago

I got it to php 8.1.23 with these additional changes:

--- ./system/libraries/Session/drivers/Session_database_driver.php      2023-10-05 20:05:42.414960797 +0200
+++ ./system/libraries/Session/drivers/Session_database_driver.php      2023-10-05 20:02:53.452306534 +0200
@@ -126,7 +126,7 @@
         * @param       string  $name           Session cookie name, unused
         * @return      bool
         */
-       public function open($save_path, $name)
+       public function open(string $path, string $name): bool
        {
                if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
                {
@@ -148,7 +148,7 @@
         * @param       string  $session_id     Session ID
         * @return      string  Serialized session data
         */
-       public function read($session_id)
+       public function read($session_id): string|false
        {
                if ($this->_get_lock($session_id) !== FALSE)
                {
@@ -205,7 +205,7 @@
         * @param       string  $session_data   Serialized session data
         * @return      bool
         */
-       public function write($session_id, $session_data)
+       public function write($session_id, $session_data): bool
        {
                // Prevent previous QB calls from messing with our queries
                $this->_db->reset_query();
@@ -277,7 +277,7 @@
         *
         * @return      bool
         */
-       public function close()
+       public function close(): bool
        {
                return ($this->_lock && ! $this->_release_lock())
                        ? $this->_fail()
@@ -294,7 +294,7 @@
         * @param       string  $session_id     Session ID
         * @return      bool
         */
-       public function destroy($session_id)
+       public function destroy($session_id): bool
        {
                if ($this->_lock)
                {
@@ -332,7 +332,7 @@
         * @param       int     $maxlifetime    Maximum lifetime of sessions
         * @return      bool
         */
-       public function gc($maxlifetime)
+       public function gc(int $max_lifetime): int|false
        {
                // Prevent previous QB calls from messing with our queries
                $this->_db->reset_query();
k4bek4be commented 10 months ago

I have opened a pull request fixing all issues i've found. Changes from your comments are also included. Captcha works too. https://github.com/claudehohl/Stikked/pull/570