Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-16376

eZDbInterface::prepareSqlQuery does not handle oracle triggers

    Details

      Description

      eZDbInterface::prepareSqlQuery() does not handle oracle triggers correctly.

      How to reproduce the problem :

      CREATE SEQUENCE s_xport_process_logs;
       
      CREATE OR REPLACE TRIGGER ezxport_customers_id_tr
      BEFORE INSERT ON ezxport_customers FOR EACH ROW WHEN ( new.id IS NULL )
      BEGIN
        SELECT s_xport_customers.nextval INTO :new.id FROM dual;
      END;
      /
      

      And now use the following code :

      <?php
      $file = 'path/to/file';
       
      $db = eZDB::instance(  );
      $db->insertFile( $file, 'schema.sql', false );
      ?>
      

      eZDbInterface sees the trigger as two strings :

      string(197) "/
       
      CREATE OR REPLACE TRIGGER ezxport_process_logs_id_tr
      BEFORE INSERT ON ezxport_process_logs FOR EACH ROW WHEN ( new.id IS NULL )
      BEGIN
        SELECT s_xport_process_logs.nextval INTO :new.id FROM dual"
      string(3) "END"
      

      Whereas it should be one string.

        Issue Links

          Activity

          Hide
          Jérôme Renard added a comment -

          The problem is there :

          eZDBInterface::prepareSqlQuery():

          // Split the query into an array
          $sqlQueryArray = preg_split( "/;\n/m", $sqlQuery );
          

          Which generates something like:

          [...]
              [9] =>
          CREATE OR REPLACE TRIGGER ezxport_customers_id_tr
          BEFORE INSERT ON ezxport_customers FOR EACH ROW WHEN ( new.id IS NULL )
          BEGIN
            SELECT s_xport_customers.nextval INTO :new.id FROM dual
              [10] => END
              [11] => /
           
          CREATE OR REPLACE TRIGGER ezxport_exports_id_tr
          BEFORE INSERT ON ezxport_exports FOR EACH ROW WHEN ( new.id IS NULL )
          BEGIN
            SELECT s_xport_exports.nextval INTO :new.id FROM dual
              [12] => END
              [13] => /
           
          CREATE OR REPLACE TRIGGER ezxport_process_logs_id_tr
          BEFORE INSERT ON ezxport_process_logs FOR EACH ROW WHEN ( new.id IS NULL )
          BEGIN
            SELECT s_xport_process_logs.nextval INTO :new.id FROM dual
              [14] => END
              [15] => / 
          [...]
          

          Show
          Jérôme Renard added a comment - The problem is there : eZDBInterface::prepareSqlQuery(): // Split the query into an array $sqlQueryArray = preg_split( "/;\n/m", $sqlQuery ); Which generates something like: [...] [9] => CREATE OR REPLACE TRIGGER ezxport_customers_id_tr BEFORE INSERT ON ezxport_customers FOR EACH ROW WHEN ( new.id IS NULL ) BEGIN SELECT s_xport_customers.nextval INTO :new.id FROM dual [10] => END [11] => /   CREATE OR REPLACE TRIGGER ezxport_exports_id_tr BEFORE INSERT ON ezxport_exports FOR EACH ROW WHEN ( new.id IS NULL ) BEGIN SELECT s_xport_exports.nextval INTO :new.id FROM dual [12] => END [13] => /   CREATE OR REPLACE TRIGGER ezxport_process_logs_id_tr BEFORE INSERT ON ezxport_process_logs FOR EACH ROW WHEN ( new.id IS NULL ) BEGIN SELECT s_xport_process_logs.nextval INTO :new.id FROM dual [14] => END [15] => / [...]
          Hide
          Vidar Langseid added a comment -

          AFAIK, these extensions are affected by this:
          ezxmlexport
          ezstyleeditor

          That means that when installing these extensions on oracle, you either has to use the .sql file directly in the sqlplus client, or use bin/php/ezsqlinsertschema.php to import the .dba file

          Show
          Vidar Langseid added a comment - AFAIK, these extensions are affected by this: ezxmlexport ezstyleeditor That means that when installing these extensions on oracle, you either has to use the .sql file directly in the sqlplus client, or use bin/php/ezsqlinsertschema.php to import the .dba file
          Hide
          Vidar Langseid added a comment -

          also affected:
          ezteamroom
          ezsurvey

          Show
          Vidar Langseid added a comment - also affected: ezteamroom ezsurvey
          Hide
          ezrobot added a comment -

          This issue has been automatically closed due to the lack of activity over a long period of time. It is very likely that it is obsolete, but if you think it is still valid, do not hesitate to reopen it and mention why.

          Show
          ezrobot added a comment - This issue has been automatically closed due to the lack of activity over a long period of time. It is very likely that it is obsolete, but if you think it is still valid, do not hesitate to reopen it and mention why.

            People

            • Assignee:
              unknown
              Reporter:
              Jérôme Renard
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: