The "Text Ad" (field_ad_text) field is defined with the Field Type "Text"; it should be "Long text".

Attempting to change the widget properly allows only the "Text field" widget type to be selected, where if the field were defined correctly it would allow widgets that work with Long text fields to be selected.

Comments

jbulcher’s picture

Additionally, the text ad field only supports 255 characters. When designing html text ads with inline css, this can be a showstopper.

jbulcher’s picture

The following script is a quick hack to make the ad_text field work as intended. Hopefully we'll see a fix for this bug.

$fieldInfo = field_info_field("field_ad_text");
$fieldInfoID = $fieldInfo['id'];

/**
 * Collect the field configuration
 */
$q = <<<SQL
SELECT `data`
FROM `field_config`
WHERE `id`=$fieldInfoID
SQL;

$res = db_select('field_config', 'c')
	->fields('c', array('data'))
	->condition('id', $fieldInfoID)
	->execute()
	->fetchAssoc();
$data = $res['data'];
$dataA = unserialize($data);
$dataA['settings'] = array();

if (1 > $dataA['settings']) {
	// the field configuration is wrong; correct the configuration
	$data = serialize($dataA);


	$q = <<<SQL
UPDATE `field_config`
SET `type`=:type, `data`=:data
WHERE `id`=$fieldInfoID
SQL;

	db_query($q, array(':type' => "text_long", ':data' => $data));

	/**
	 * Correct field_ad_text column definition
	 */
	$dbs = array('field_data_field_ad_text', 'field_revision_field_ad_text');
	foreach ($dbs as $db) {
		$q = <<<SQL
ALTER TABLE `$db`
CHANGE `field_ad_text_value` `field_ad_text_value` LONGTEXT
SQL;
		db_query($q);
	}

	/**
	 * Clear the cache so our new settings take effect
	 */
	field_cache_clear();
}
SimonD’s picture

This is causing a problem on one of my sites. An advertiser is asking for specific styling for an advert which I want to style inline but the character limit prevents me from achieving what they want.

Also it is very limiting not being able to use widgets.

Hope this bug gets fixed soon.

jbulcher’s picture

Simon,

Did you try running the script I wrote to fix the field? Let me know if it works for you. I've tied my script into a dev module's install file, and so far it seems to work just fine.

It would be nice to see the field fixed in the module, though.

fpap’s picture

Where do I should paste this code? Into an existing file? Should I create a new file?

Thanks in advance!

Anonymous’s picture

Where do we put this code, the 255 limit is really hard to use HTML in.

felixodie’s picture

Are there any updates on this? I simply can not use google adsense with this module because of the 255 character limit. :(

jbulcher’s picture

I ran the code through drush as a one-time update. Depending on your setup, there may be other ways to do it.

liquidcms’s picture

the correct solution here is not a script to fix the db but a patch to create an _update function in the .install file to fix this.

Anonymous’s picture

So, would it be possible, to construct that for me. I have yet to create a module to have that ... Do I just take that script in #2 and put it into a function?

emptyvoid’s picture

Priority: Normal » Major
Issue summary: View changes

I consider this a major issue for the text ad type otherwise it is totally useless.

Anonymous’s picture

Up added this to _7006 update in the simpleads.update.inc file.
I can see in the DB that the fields are now long text fields, but Drupal is still reporting that there is a text character limit of 255.

I had a look in the field_config table and field_text_ad is set to type:text and module: text
I changed that to type:text_long, and then manual cleared flushed caches.
Still nothing. What am I missing? I tried to run the field_cache_clear(); again, but it didn't seem like that helped.
Here is what I added to the update file

function simpleads_update_7007(&$sandbox) {

$fieldInfo = field_info_field("field_ad_text");
$fieldInfoID = $fieldInfo['id'];
/**
 * Collect the field configuration
 */
$q = <<<SQL
SELECT `data`
FROM `field_config`
WHERE `id`=$fieldInfoID
SQL;
$res = db_select('field_config', 'c')
    ->fields('c', array('data'))
    ->condition('id', $fieldInfoID)
    ->execute()
    ->fetchAssoc();
$data = $res['data'];
$dataA = unserialize($data);
$dataA['settings'] = array();
if (1 > $dataA['settings']) {
    // the field configuration is wrong; correct the configuration
    $data = serialize($dataA);
    $q = <<<SQL
UPDATE `field_config`
SET `type`=:type, `data`=:data
WHERE `id`=$fieldInfoID
SQL;
    db_query($q, array(':type' => "text_long", ':data' => $data));
    /**
     * Correct field_ad_text column definition
     */
    $dbs = array('field_data_field_ad_text', 'field_revision_field_ad_text');
    foreach ($dbs as $db) {
        $q = <<<SQL
ALTER TABLE `$db`
CHANGE `field_ad_text_value` `field_ad_text_value` LONGTEXT
SQL;
        db_query($q);
    }
    /**
     * Clear the cache so our new settings take effect
     */
    field_cache_clear();
}


}
Andre-B’s picture

this seems to be fixed in 7.x-1.x-dev, at least for a fresh installation.

minnur’s picture

Status: Active » Closed (won't fix)