Jump to content

[BUG 4.7.0] Upgrade from IPB 3.1.4 + Downloads 2.3.1 throws an "index size length" error


Recommended Posts

I hit the error updating an old 3.1.4 site with Downloads 2.3.1. The problem is that an upgrade script uses the wrong index type when updating the custom fields in the 4.0.0 RC 1 step. I compared the upgrader code to the normal code run when a new custom field is added and noticed the wrong type is being used.

 

Open the file  and find this code on lines 26-54:

	/**
	 * Step 1
	 * Fixing custom fields
	 *
	 * @return	array	If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
	 */
	public function step1()
	{
		foreach( \IPS\Db::i()->select( '*', 'downloads_cfields' ) as $field )
		{
			if( $field['cf_type'] == 'Select' )
			{
				try
				{
					\IPS\Db::i()->dropIndex( 'downloads_ccontent', "field_" . $field['cf_id'] );
					\IPS\Db::i()->dropColumn( 'downloads_ccontent', "field_" . $field['cf_id'] );
				} 
				catch ( \IPS\Db\Exception $e )
				{

				}

				\IPS\Db::i()->addColumn( 'downloads_ccontent', array( 'name' => "field_" . $field['cf_id'], 'type' => 'TEXT' ) );
				\IPS\Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'key', 'name' => "field_" . $field['cf_id'], 'columns' => array( "field_" . $field['cf_id'] ) ) );
			}
		}

		return TRUE;
	}

 

The problem in this case is the addIndex() call on line 49 which uses key as index type instead of fulltext. Here's how I changed it to match the code when adding a new custom field in ACP:

				\IPS\Db::i()->addIndex( 'downloads_ccontent', array( 'type' => 'fulltext', 'name' => "field_" . $field['cf_id'], 'columns' => array( "field_" . $field['cf_id'] ) ) );

 

Link to comment
Share on other sites

Hmm, I kept thinking something felt wrong with this code and then I finally figured it out.

 

The code above to "fix the custom fields" drops the columns + indexes and then re-adds them, but the columns' data is not saved whatsoever? After the upgrade every custom field's data is lost. 🤨

 

The code should be changed to drop the index, run a CHANGE query on the column, and then re-add the fulltext index.

 

===

EDIT

Just noticed I failed to include the file's path in the first post:  

5 hours ago, teraßyte said:

Open the file  and find this code on lines 26-54:

The file is \applications\downloads\setup\upg_100013\upgrade.php

Edited by teraßyte
Link to comment
Share on other sites

Upon further review the file/folder I mentioned above can actually be deleted completely. In another upgrade step later on \applications\downloads\setup\upg_101088\upgrade.php the code does the same thing I described above for the fix:

  1. It drops the index
  2. It changes the column to MEDIUMTEXT (instead of TEXT)
  3. It re-adds a new fulltext index

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...