View Issue Details

IDProjectCategoryView StatusLast Update
0000505WackoWikicorepublic2018-11-19 14:16
ReporterMartinRaatz Assigned Toadministrator  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version5.5.6 
Target Version5.5.7Fixed in Version5.5.7 
Summary0000505: Wacko crashes with installed php-gmp
Description[15-Nov-2018 14:51:48 Europe/Berlin] PHP Fatal error: Uncaught Error: Call to undefined method GMP::intval() in /var/www/wacko1/lib/hashids/Hashids.php:177
Stack trace:
#0 /var/www/wacko1/action/hashid.php(30): Hashids->encode(Array)
#1 /var/www/wacko1/class/wacko.php(4997): include('/var/www/wacko1...')
#2 /var/www/wacko1/class/wacko.php(5066): Wacko->include_buffered('hashid.php', 'Unbekannte ...', Array, 'action')
#3 /var/www/wacko1/theme/default/appearance/footer.php(59): Wacko->action('hashid')
0000004 /var/www/wacko1/class/wacko.php(4997): include('/var/www/wacko1...')
#5 /var/www/wacko1/class/wacko.php(5044): Wacko->include_buffered('footer.php', 'Layout ist besc...', '', 'theme/default/a...')
0000006 /var/www/wacko1/class/wacko.php(7025): Wacko->theme_footer('')
0000007 /var/www/wacko1/index.php(63): Wacko->run('Startseite', 'show')
0000008 {main}
  thrown in /var/www/wacko1/lib/hashids/Hashids.php on line 177
Steps To Reproduceenable php-gmp on Fedora 29 with PHP 7.2.11
TagsNo tags attached.
Attached Files

Relationships

related to 0000504 resolvedadministrator templatest: no main template found in handler/page/template/show.tpl 

Activities

administrator

2018-11-15 15:20

administrator   ~0001012

Last edited: 2018-11-15 15:39

Note: Hashids requires either the BC Math or GMP extension in order to work.

As mentioned in the related bug, this looks like a dependency issue of the hashid lib regarding GMP.
https://secure.php.net/manual/en/book.gmp.php

"Call to undefined method GMP::intval()" indicates a missing or wrong linking/path.
https://bitbucket.org/wackowiki/wackowiki-dev/src/2efa1ea93ca7c8b3729a8f47438b29839aa710e6/wacko/lib/hashids/Math/Gmp.php?at=default&fileviewer=file-view-default

https://bitbucket.org/wackowiki/wackowiki-dev/src/2efa1ea93ca7c8b3729a8f47438b29839aa710e6/wacko/config/autoload.conf?at=default&fileviewer=file-view-default

Can you try it again with the BC Math extension.
https://secure.php.net/manual/en/book.bc.php

MartinRaatz

2018-11-15 15:42

reporter   ~0001013

BC Math and GMP are installed as dependicies of phpMyAdmin

When I disable GMP Hashids my installation runs fine.

administrator

2018-11-15 15:52

administrator   ~0001014

Last edited: 2018-11-15 15:54

So this can be a namespace issue? As you can see the original namespaces were commented out.
If we use the original namespaces again and add them to autoload.conf accordingly, GMP::intval() might work?

lib/hashids/Math/Gmp.php Gmp
->
lib/hashids/Math/Gmp.php Hashids\Math\Gmp

MartinRaatz

2018-11-15 16:12

reporter   ~0001015

When I try "lib/hashids/Math/Gmp.php Hashids\Math\Gmp",
i get:

[15-Nov-2018 17:06:47 Europe/Berlin] PHP Fatal error: Uncaught Error: Call to undefined method GMP::greaterThan() in /var/www/wacko/lib/hashids/Hashids.php:256
Stack trace:
#0 /var/www/wacko/class/urirouter.php(251): Hashids->decode('Anleitungen')
#1 /var/www/wacko/class/urirouter.php(77): UriRouter->route(Array)
#2 /var/www/wacko/index.php(16): UriRouter->run(Array)
#3 {main}
  thrown in /var/www/wacko/lib/hashids/Hashids.php on line 256


my only solution is changing the order in wacko/lib/hashids/Hashids.php:protected function getMathExtension()

administrator

2018-11-15 16:26

administrator   ~0001016

Thanks for the feedback. At least a hotfix is found but this solves not the issue at the core. The issue needs further investigation.

I assume a namespace conflict with GMP::function(), if so we should reinstate all out commented namespaces within the hashid lib and add them to autoload.conf.

administrator

2018-11-18 09:00

administrator   ~0001018

I added in this patch the original namespace for hashids.

When it threw the error message "Uncaught Error: Call to undefined method GMP::intval()" either there is a wrong naming/typo in the autoload.conf or there is a namespace issue, another class with the same name is loaded, or did I miss something?

Can you test the patch with the original order in the getMathExtension() function.
hashids_namespace.patch (3,752 bytes)   
diff --git a/wacko/action/hashid.php b/wacko/action/hashid.php
--- a/wacko/action/hashid.php
+++ b/wacko/action/hashid.php
@@ -7,6 +7,8 @@
 
 // {{hashid}}
 
+// Import the Hashids class into the global namespace
+use Hashids\Hashids;
 $hashids = new Hashids($this->db->hashid_seed);
 
 if (isset($this->page['version_id']))
diff --git a/wacko/class/urirouter.php b/wacko/class/urirouter.php
--- a/wacko/class/urirouter.php
+++ b/wacko/class/urirouter.php
@@ -6,6 +6,8 @@
 {
 	exit;
 }
+// Import the Hashids class into the global namespace
+use Hashids\Hashids;
 
 class UriRouter
 {
diff --git a/wacko/config/autoload.conf b/wacko/config/autoload.conf
--- a/wacko/config/autoload.conf
+++ b/wacko/config/autoload.conf
@@ -17,11 +17,11 @@
 formatter/class/typografica.php					Typografica
 formatter/class/wackoformatter.php				WackoFormatter
 lib/safehtml/safehtml.php						SafeHTML
-lib/hashids/Hashids.php							Hashids
-lib/hashids/HashidsInterface.php				HashidsInterface
-lib/hashids/Math/Bc.php							Bc
-lib/hashids/Math/Gmp.php						Gmp
-lib/hashids/Math/MathInterface.php				MathInterface
+lib/hashids/Hashids.php							Hashids\Hashids
+lib/hashids/HashidsInterface.php				Hashids\HashidsInterface
+lib/hashids/Math/Bc.php							Hashids\Math\Bc
+lib/hashids/Math/Gmp.php						Hashids\Math\Gmp
+lib/hashids/Math/MathInterface.php				Hashids\Math\MathInterface
 lib/php-diff/Diff.php							Diff
 lib/php-diff/Diff/Renderer/Html/Array.php		Diff_Renderer_Html_Array
 lib/php-diff/Diff/Renderer/Html/Inline.php		Diff_Renderer_Html_Inline
diff --git a/wacko/lib/hashids/Hashids.php b/wacko/lib/hashids/Hashids.php
--- a/wacko/lib/hashids/Hashids.php
+++ b/wacko/lib/hashids/Hashids.php
@@ -9,11 +9,11 @@
  * file that was distributed with this source code.
  */
 
-# namespace Hashids;
+namespace Hashids;
 
-# use Hashids\Math\Bc;
-# use Hashids\Math\Gmp;
-# use RuntimeException;
+use Hashids\Math\Bc;
+use Hashids\Math\Gmp;
+use RuntimeException;
 
 /**
  * This is the hashids class.
diff --git a/wacko/lib/hashids/HashidsException.php b/wacko/lib/hashids/HashidsException.php
--- a/wacko/lib/hashids/HashidsException.php
+++ b/wacko/lib/hashids/HashidsException.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-# namespace Hashids;
+namespace Hashids;
 
-# use InvalidArgumentException;
+use InvalidArgumentException;
 
 /**
  * This is the hashids exception class.
diff --git a/wacko/lib/hashids/HashidsInterface.php b/wacko/lib/hashids/HashidsInterface.php
--- a/wacko/lib/hashids/HashidsInterface.php
+++ b/wacko/lib/hashids/HashidsInterface.php
@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-# namespace Hashids;
+namespace Hashids;
 
 /**
  * This is the hashids interface.
diff --git a/wacko/lib/hashids/Math/Bc.php b/wacko/lib/hashids/Math/Bc.php
--- a/wacko/lib/hashids/Math/Bc.php
+++ b/wacko/lib/hashids/Math/Bc.php
@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-# namespace Hashids\Math;
+namespace Hashids\Math;
 
 /**
  * This is the Bc math class.
diff --git a/wacko/lib/hashids/Math/Gmp.php b/wacko/lib/hashids/Math/Gmp.php
--- a/wacko/lib/hashids/Math/Gmp.php
+++ b/wacko/lib/hashids/Math/Gmp.php
@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-# namespace Hashids\Math;
+namespace Hashids\Math;
 
 /**
  * This is the Gmp math class.
diff --git a/wacko/lib/hashids/Math/MathInterface.php b/wacko/lib/hashids/Math/MathInterface.php
--- a/wacko/lib/hashids/Math/MathInterface.php
+++ b/wacko/lib/hashids/Math/MathInterface.php
@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-# namespace Hashids\Math;
+namespace Hashids\Math;
 
 /**
  * Interface for different math extensions.
hashids_namespace.patch (3,752 bytes)   

MartinRaatz

2018-11-19 12:00

reporter   ~0001019

the patch ist working with the original order in the getMathExtension()

administrator

2018-11-19 14:16

administrator   ~0001020

Thanks for testing. Committed patch:

https://sourceforge.net/p/wackowiki/dev/ci/459ff1dcc628de549cb0bb59b9a4286c13854cbb

Issue History

Date Modified Username Field Change
2018-11-15 14:13 MartinRaatz New Issue
2018-11-15 15:04 administrator Relationship added related to 0000504
2018-11-15 15:20 administrator Note Added: 0001012
2018-11-15 15:24 administrator Note Edited: 0001012
2018-11-15 15:39 administrator Note Edited: 0001012
2018-11-15 15:42 MartinRaatz Note Added: 0001013
2018-11-15 15:52 administrator Note Added: 0001014
2018-11-15 15:54 administrator Note Edited: 0001014
2018-11-15 16:12 MartinRaatz Note Added: 0001015
2018-11-15 16:26 administrator Note Added: 0001016
2018-11-15 16:26 administrator Assigned To => administrator
2018-11-15 16:26 administrator Status new => confirmed
2018-11-15 16:28 administrator Target Version => 5.5.7
2018-11-18 09:00 administrator File Added: hashids_namespace.patch
2018-11-18 09:00 administrator Note Added: 0001018
2018-11-19 12:00 MartinRaatz Note Added: 0001019
2018-11-19 14:16 administrator Status confirmed => resolved
2018-11-19 14:16 administrator Resolution open => fixed
2018-11-19 14:16 administrator Fixed in Version => 5.5.7
2018-11-19 14:16 administrator Note Added: 0001020