Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-12193

Broken HTML when an SQL error occurs during migration

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-a3
    • Fix Version/s: 3.1.0-b3
    • Component/s: None
    • Labels:

      Description

      When a SQL error happens while performing migrations, the output HTML is broken and mostly unreadable.

      From area51:

      <!DOCTYPE html>
      <html dir="ltr" lang="en-gb">
      <head>
      <meta charset="utf-8">
       
      <title>Updating database to latest stable release</title>
       
      <link href="./../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
       
      </head>
       
      <body>
      	<div id="wrap">
      		<div id="page-header">&nbsp;</div>
       
      		<div id="page-body">
      			<div id="acp">
      				<div class="panel">
      					<span class="corners-top"><span></span></span>
      						<div id="content">
      							<div id="main" class="install-body">
       
      								<h1>Updating database to latest stable release</h1>
       
      								<br />
       
      								<p>Database type :: <strong>mysqli</strong><br />
      								Previous version :: <strong>3.1.0-a2</strong><br />
       
      Installed Schema: \phpbb\db\migration\data\v310\profilefield_interests; Time: 0.49 seconds<br />
      <!DOCTYPE html><html dir="ltr"><head><meta charset="utf-8"><title>General Error</title><style type="text/css">
      /* <![CDATA[ */
      * { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } #wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } .panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px  #A9B8C2; } #errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } #errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } 
      /* ]]> */
      </style></head><body id="errorpage"><div id="wrap">	<div id="page-header">		<a href="./../">Return to the index page</a>	</div>	<div id="acp">	<div class="panel">		<div id="content">			<h1>General Error</h1>			<div>SQL ERROR [ mysqli ]<br /><br />Unknown column 'field_show_novalue' in 'field list' [1054]<br /><br />SQL<br /><br />INSERT INTO phpbb_profile_fields  (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_profile, field_hide, field_no_view, field_active, field_order) VALUES ('phpbb_interests', 'profilefields.type.text', 'phpbb_interests', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 1, 0, 0, 1, 3)<br /><br />BACKTRACE<br /><div style="font-family: monospace;"><br /><b>FILE:</b> (not given by php)<br /><b>LINE:</b> (not given by php)<br /><b>CALL:</b> msg_handler()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/driver/driver.php<br /><b>LINE:</b> 803<br /><b>CALL:</b> trigger_error()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/driver/mysqli.php<br /><b>LINE:</b> 181<br /><b>CALL:</b> phpbb\db\driver\driver-&gt;sql_error()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/migration/profilefield_base_migration.php<br /><b>LINE:</b> 70<br /><b>CALL:</b> phpbb\db\driver\mysqli-&gt;sql_query()<br /><br /><b>FILE:</b> (not given by php)<br /><b>LINE:</b> (not given by php)<br /><b>CALL:</b> phpbb\db\migration\profilefield_base_migration-&gt;create_custom_field()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/migrator.php<br /><b>LINE:</b> 455<br /><b>CALL:</b> call_user_func_array()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/migrator.php<br /><b>LINE:</b> 401<br /><b>CALL:</b> phpbb\db\migrator-&gt;run_step()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/migrator.php<br /><b>LINE:</b> 250<br /><b>CALL:</b> phpbb\db\migrator-&gt;process_data_step()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/migrator.php<br /><b>LINE:</b> 202<br /><b>CALL:</b> phpbb\db\migrator-&gt;try_apply()<br /><br /><b>FILE:</b> [ROOT]/phpbb/db/migrator.php<br /><b>LINE:</b> 153<br /><b>CALL:</b> phpbb\db\migrator-&gt;try_apply()<br /><br /><b>FILE:</b> [ROOT]/install/database_update.php<br /><b>LINE:</b> 222<br /><b>CALL:</b> phpbb\db\migrator-&gt;update()<br /></div></div><p>Please notify the board administrator or webmaster: <a href="mailto:null@phpbb.com">null@phpbb.com</a></p>		</div>	</div>	</div>	<div id="page-footer">		Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group	</div></div></body></html>
      

        Activity

        Hide
        VSE Matt Friedman added a comment - - edited

        Yeah, I've seen that happen and I hate it!

        It looks like, the database_update is outputting it's own HTML document on the fly (not using any templates). When a general error occurs, that is output inside its own complete HTML document.

        So you end up with a complete HTML document (the general error) inside another HTML document (the database_update script) which is opened, but never closed, because the script errored.

        So that's what's happening, but not sure how to solve it (easily). I'd say ideally, the database_update should not be outputting any HTML directly within its php code, and instead use templates... but I guess it was made to work this way for some reason ?

        Show
        VSE Matt Friedman added a comment - - edited Yeah, I've seen that happen and I hate it! It looks like, the database_update is outputting it's own HTML document on the fly (not using any templates). When a general error occurs, that is output inside its own complete HTML document. So you end up with a complete HTML document (the general error) inside another HTML document (the database_update script) which is opened, but never closed, because the script errored. So that's what's happening, but not sure how to solve it (easily). I'd say ideally, the database_update should not be outputting any HTML directly within its php code, and instead use templates... but I guess it was made to work this way for some reason ?
        Hide
        nickvergessen Joas Schilling added a comment - - edited

        Using a template there is not much of a help.

        I already started working on this some days back.
        What I did was: Add a new constant into the database_update.php when it starts to output anything.
        And then in msg_handler look whether the constant is defined and if so, just dont give the complete html page but just a p.error box with the error.

        Show
        nickvergessen Joas Schilling added a comment - - edited Using a template there is not much of a help. I already started working on this some days back. What I did was: Add a new constant into the database_update.php when it starts to output anything. And then in msg_handler look whether the constant is defined and if so, just dont give the complete html page but just a p.error box with the error.
        Hide
        bantu Andreas Fischer added a comment -

        Yeah no, that certainly is not the answer. Just turn SQL errors off and check for them manually, then put them into the output HTML properly.

        Show
        bantu Andreas Fischer added a comment - Yeah no, that certainly is not the answer. Just turn SQL errors off and check for them manually, then put them into the output HTML properly.
        Hide
        nickvergessen Joas Schilling added a comment -

        I think we have to do that in msg_handler, because db_tools also has manual calls to trigger_error (e.g. when the index name is too long) which would still break the HTML.

        Show
        nickvergessen Joas Schilling added a comment - I think we have to do that in msg_handler, because db_tools also has manual calls to trigger_error (e.g. when the index name is too long) which would still break the HTML.

          People

          • Assignee:
            nickvergessen Joas Schilling
            Reporter:
            bantu Andreas Fischer
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development