Project

General

Profile

Anomalie #1483

SQL error on invoices/receipt direct download

Added by Johan Cwiklinski 2 months ago. Updated 2 months ago.

Status:
Fermé
Priority:
Normal
Category:
Files generation
Target version:
Start date:
08/26/2020
Due date:
% Done:

100%

Estimated time:
Version utilisée:
Vote:

Description

::1 - 2020-08-25 14:19:31 - ERROR - Query error: SELECT `galette_cotisations`.* FROM `galette_cotisations` WHERE id_cotis = 106 AND id_adh = 
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe près de '' à la ligne 1 in 
B:\galettenightly\galette\vendor\laminas\laminas-db\src\Adapter\Driver\Pdo\Connection.php:378

> #0 B:\galettenightly\galette\vendor\laminas\laminas-db\src\Adapter\Driver\Pdo\Connection.php(378): PDO->query('SELECT `galette...')
> #1 B:\galettenightly\galette\vendor\laminas\laminas-db\src\Adapter\Adapter.php(204): Laminas\Db\Adapter\Driver\Pdo\Connection->execute('SELECT `galette...')
> #2 B:\galettenightly\galette\lib\Galette\Core\Db.php(800): Laminas\Db\Adapter\Adapter->query('SELECT `galette...', 'execute')
> #3 B:\galettenightly\galette\lib\Galette\Entity\Contribution.php(269): Galette\Core\Db->execute(Object(Laminas\Db\Sql\Select))
> #4 B:\galettenightly\galette\lib\Galette\Entity\Contribution.php(162): Galette\Entity\Contribution->load(106)
> #5 B:\galettenightly\galette\lib\Galette\Controllers\PdfController.php(702): Galette\Entity\Contribution->__construct(Object(Galette\Core\Db), Object(Galette\Core\Login), 106)
> #6 [internal function]: Galette\Controllers\PdfController->directlinkDocument(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)

Contribution::load() method checks if the user is admin or staff member, and if not, it adds the current logged in id... But noone should be logged at this time.


Files

PdfController1.php (22.9 KB) PdfController1.php fichier modifié est il correct ? Alain Paris, 08/26/2020 12:04 PM
#1

Updated by Johan Cwiklinski 2 months ago

A possible fix:

//wrong patch removed

#2

Updated by Johan Cwiklinski 2 months ago

Better one:

diff --git a/galette/lib/Galette/Controllers/PdfController.php b/galette/lib/Galette/Controllers/PdfController.php
index 4efdf253..d8ddbf95 100644
--- a/galette/lib/Galette/Controllers/PdfController.php
+++ b/galette/lib/Galette/Controllers/PdfController.php
@@ -670,7 +670,22 @@ class PdfController extends AbstractController
         }

         $target = $valid[0];
-        $id = $valid[1];
+        $id = (int)$valid[1];
+
+        //get user information (like id...) from DB since its missing
+        $select = $this->zdb->select(Adherent::TABLE, 'a');
+        $select->where(['email_adh' => $post['email']]);
+        $results = $this->zdb->execute($select);
+        $row = $results->current();
+
+        //create a new login instance, to not break current session if any
+        //this will be passed directly to Contribution constructor
+        $login = new Galette\Core\Login(
+            $this->zdb,
+            $this->i18n,
+            $this->session
+        );
+        $login->id = (int)$row['id_adh'];

         if ($target === Links::TARGET_MEMBERCARD) {
             $m = new Members();
@@ -699,7 +714,7 @@ class PdfController extends AbstractController
             $pdf = new PdfMembersCards($this->preferences);
             $pdf->drawCards($members);
         } else {
-            $contribution = new Contribution($this->zdb, $this->login, $id);
+            $contribution = new Contribution($this->zdb, $login, $id);
             if ($contribution->id == '') {
                 //not possible to load contribution, exit
                 $this->flash->addMessage(

[edit]: fix double `$` in patch

#3

Updated by Alain Paris 2 months ago

Bonjour,

Avec le fichier original ,Je n'avais le problème que sur la récupération de la facture ,je pouvais télécharger sans problème la carte de membre.

En modifiant comme ci dessus le fichier PdfController.php :
J'ai une nouvelle erreur, et Je ne peux plus telecharger la carte de membre.

Message: Class 'Galette\Controllers\Galette\Core\Login' not found
File: B:\galettenightly\galette\lib\Galette\Controllers\PdfController.php
Line: 683
Trace: #0 [internal function]: Galette\Controllers\PdfController->directlinkDocument(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#1 B:\galettenightly\galette\vendor\slim\slim\Slim\Handlers\Strategies\RequestResponse.php(40): call_user_func(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#2 B:\galettenightly\galette\vendor\slim\slim\Slim\Route.php(281): Slim\Handlers\Strategies\RequestResponse->_invoke(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#3 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(117): Slim\Route->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#4 B:\galettenightly\galette\vendor\slim\slim\Slim\Route.php(268): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#5 B:\galettenightly\galette\vendor\slim\slim\Slim\App.php(503): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#6 B:\galettenightly\galette\vendor\akrabat\rka-slim-session-middleware\RKA\SessionMiddleware.php(47): Slim\App->_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#7 [internal function]: RKA\SessionMiddleware->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#8 B:\galettenightly\galette\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Object(RKA\SessionMiddleware), Array)
#9 [internal function]: Slim\DeferredCallable->_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#10 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#11 B:\galettenightly\galette\lib\Galette\Middleware\TrailingSlash.php(81): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#12 [internal function]: Galette\Middleware\TrailingSlash->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#13 B:\galettenightly\galette\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Array, Array)
#14 [internal function]: Slim\DeferredCallable->_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#15 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#16 B:\galettenightly\galette\lib\Galette\Middleware\Language.php(103): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#17 [internal function]: Galette\Middleware\Language->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#18 B:\galettenightly\galette\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Array, Array)
#19 [internal function]: Slim\DeferredCallable->_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#20 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#21 B:\galettenightly\galette\lib\Galette\Middleware\Telemetry.php(144): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#22 [internal function]: Galette\Middleware\Telemetry->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#23 B:\galettenightly\galette\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Array, Array)
#24 [internal function]: Slim\DeferredCallable->_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#25 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#26 B:\galettenightly\galette\lib\Galette\Middleware\CheckAcls.php(143): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#27 [internal function]: Galette\Middleware\CheckAcls->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#28 B:\galettenightly\galette\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Array, Array)
#29 [internal function]: Slim\DeferredCallable->_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#30 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#31 B:\galettenightly\galette\plugins\plugin-maps-develop\_routes.php(54): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#32 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#33 B:\galettenightly\galette\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#34 [internal function]: Slim\DeferredCallable->
_invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#35 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#36 B:\galettenightly\galette\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#37 B:\galettenightly\galette\vendor\slim\slim\Slim\App.php(392): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#38 B:\galettenightly\galette\vendor\slim\slim\Slim\App.php(297): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#39 B:\galettenightly\galette\includes\main.inc.php(187): Slim\App->run()
#40 B:\galettenightly\galette\webroot\index.php(57): require_once('B:\\galettenight...')
#41 {main}

#4

Updated by Johan Cwiklinski 2 months ago

Alain Paris a écrit (#note-3):

Bonjour,

Avec le fichier original ,Je n'avais le problème que sur la récupération de la facture ,je pouvais télécharger sans problème la carte de membre.

En modifiant comme ci dessus le fichier PdfController.php :
J'ai une nouvelle erreur, et Je ne peux plus telecharger la carte de membre.

Message: Class 'Galette\Controllers\Galette\Core\Login' not found
File: B:\galettenightly\galette\lib\Galette\Controllers\PdfController.php
Line: 683

Une erreur de ma part en effet... À cette ligne, il faudrait $login = new \Galette\Core\Login (un \ ajouté juste avant Galette).

#5

Updated by Alain Paris 2 months ago

Il semble que l'antislash est corrigé le soucis.
J'ai réussi a recuperer la facture et la carte de membre....

#6

Updated by Johan Cwiklinski 2 months ago

  • Status changed from Nouveau to In Progress

Alain Paris a écrit (#note-5):

Il semble que l'antislash est corrigé le soucis.
J'ai réussi a recuperer la facture et la carte de membre....

Super, merci d'avoir testé :)

Je vais essayer de pousser le correctif ce jour, ça devrait donc être réglé dans la prochaine nightly.

#7

Updated by Johan Cwiklinski 2 months ago

  • Status changed from In Progress to Résolu
  • % Done changed from 0 to 100
#8

Updated by Johan Cwiklinski 2 months ago

  • Status changed from Résolu to Fermé

Also available in: Atom PDF