Archive for the ‘Concrete 5’ Category

Concrete 5 SQL errors during installation

Friday, February 3rd, 2012

We have seen this error with Concrete 5.5.1

You try to setup Concrete 5, and get strange SQL errors during the installation:

If installing with an empty site, like this

c5-nosample-content-chosen

you get:

c5-mysql-error

mysql error: [1048: Column 'uID' cannot be null] in EXECUTE("INSERT INTO Config (cfKey,cfValue,uID) VALUES ('NEWSFLOW_LAST_VIEWED','FIRSTRUN',NULL)")

If installing with Sample content with Blog:

c5 with sample content

The error you get is:

Catchable fatal error: Argument 1 passed to ContentImporter::importPageAreas() must be an instance of Page, boolean given, called in /concrete/libraries/content/importer.php on line 75 and defined in /concrete/libraries/content/importer.php on line 197.

 

Solution:

You don't run Varnish by any chance, do you? We do, and we had it set up to … dispose of some cookies. The solution is, in Varnish' case, to enable pass-through for the host you are installing on.

You want to enable cookies.

 

Explanation:

The code which breaks is located in concrete5.5.1\concrete\models\package\starting_point.php

Config::save('SITE', SITE);
Config::save('SITE_APP_VERSION', APP_VERSION);
$u = new User();
$u->saveConfig('NEWSFLOW_LAST_VIEWED', 'FIRSTRUN');

As you see, this is the first time a User is created and used.

The User class is defined in concrete5.5.1\concrete\models\user.php

if (isset($_SESSION['uID'])) {
$this->uID = $_SESSION['uID'];
$this->uName = $_SESSION['uName'];
$this->uTimezone = $_SESSION['uTimezone'];
if (isset($_SESSION['uDefaultLanguage'])) {
$this->uDefaultLanguage = $_SESSION['uDefaultLanguage'];
}
$this->superUser = ($_SESSION['uID'] == USER_SUPER_ID) ? true : false;
} else {
$this->uID = null;
$this->uName = null;
$this->superUser = false;
$this->uDefaultLanguage = null;
$this->uTimezone = null;
}
$this->uGroups = $this->_getUserGroups();
if (!isset($args[2])) {
$_SESSION['uGroups'] = $this->uGroups;
}
}

The constructor checks in the Session for a valid user ID. If no user ID is found, it is set to zero. This happens if you throw away the cookies! Because the session is stored in them.

HTH. Feel free to comment on similar errors and solutions.

Redirection with Concrete 5

Wednesday, September 14th, 2011

URL Shortening is all the rage now. Sometimes you want to give people ridiculously long URLs, which might also be subject to change.

So you want to do it with C5, don't you?

Great, you think – there's the "add external link" menu option in Concrete's sitemap. Unfortunately it does not work the way you expect it to – it just adds the link to the Navigation, but no page alias to point to the external page (i.e. http://www.synapse-redaktion.de/FaceBook won't work after adding a "FaceBook" external link).

What to do to solve this dilemma?

My suggestion is to use both: add a (hidden) page "FaceBook" which does header JavaScript forwarding to the other page, so you can give out the links to the people, and a "real external link" so you don't have to rely on JavaScript for most of your visitors.

The SiteMap will look like this:

sitemap

Adding custom attributes: (Header Extra Content, Exclude from Page List, Exclude from Nav)

header extra content

The page's setup:

setup

The script is easy:

<script type="text/javascript">
<!–
window.location = "http://www.surfnext.com"
//–>
</script>

with surfnext.com being the URL you are forwarding to.

If you have the time, you might want to add a static link or icon to the page (/*comment*/ the window.location = … part to be able to edit the page!) in case some person has their JavaScript turned off.

Privoxy rules to unblock Concrete 5 editing

Friday, May 20th, 2011

In Concrete 5, TinyMCE is used as an editor for Content blocks. If you have Privoxy installed with the default settings, crucial parts of this editor will be blocked, and you would be unable to edit the Content block properly. (no editor appears, you see a small box with the HTML instead).

You can verify that it's indeed Privoxy which is doing it, by checking the Network tab of Dragonfly or Firebug in Opera or FireFox, Privoxy will add a status message to files which have been blocked.

To fix this problem, edit your user.action file (located in the application's toplevel directory), and add a new line under the { fragile } section:

{ fragile }
#.forbes.com
/concrete/js/tiny_mce/plugins/.*
/updates/concrete.*

This should unblock all Concrete 5 – based sites.

Update (23.10.2011): The fix now works with updated Concrete 5 sites.

Developing with Concrete: New Block Type not showing up

Wednesday, November 17th, 2010

Problem: you are adding a new block type to your package. You are updating the package using Concrete's update functionality, but no new block type shows up.

Solution: remove the package completely (uninstall – but leave it in the package directory, when C5 offers to move it to trash!), and install it again. Your block type should show up now.

Concrete 5 site is suddenly down

Wednesday, June 9th, 2010

The symptoms:

Your site is suddenly down. If in production mode, a blank & empty page is displayed.

The solution:

After checking that the MySQL daemon still works, Apache is running, PHP is working and the configuration has not been changed (a test.txt file is served correctly), you might want to look into your PHP error log.

Here's how you add PHP error logging to your .htaccess, if you do not have it already:

# php error logs..
php_flag display_errors off
php_flag log_errors on
php_value track_errors on
php_value error_log /path/to/php.error.log

Be sure to chown the file to www-data:www-data or whatever your PHP process is running under.

In my case, the culprit was a very strange "duplicate entry" error:

[09-Jun-2010 20:18:49] PHP Fatal error: Uncaught exception 'ADODB_Exception' with message 'mysql error: [1062: Duplicate entry '300969' for key 1] in EXECUTE("insert into PageStatistics (cID, uID, date) values ('1', 0, NOW())")
' in /…/concrete5.4.0.5/concrete/libraries/3rdparty/adodb/adodb-exceptions.inc.php:78
Stack trace:
#0 /…/updates/concrete5.4.0.5/concrete/libraries/3rdparty/adodb/adodb.inc.php(1037): adodb_throw('mysql', 'EXECUTE', 1062, 'Duplicate entry…', 'insert into Pag…', false, Object(ADODB_mysql))
#1 /…/concrete5.4.0.5/concrete/libraries/3rdparty/adodb/adodb.inc.php(993): ADOConnection->_Execute('insert into Pag…')
#2 /…/updates/concrete5.4.0.5/concrete/libraries/3rdparty/adodb/adodb.inc.php(761): ADOConnection->Execute('insert into Pag…', Array)
#3 [internal function]: ADOConnection->Query('insert into Pag…', Array)
#4 /…/updates/concrete5.4.0.5/conc in /…/updates/concrete5.4.0.5/concrete/libraries/3rdparty/adodb/adodb-exceptions.inc.php on line 78

After checking the appropriate table (used for logging visits to your C5 page), I could not understand the error – there was no entry for key 300969, the last entry was 300968.

Here's a quick way to turn off page statistics, which will fix this error and bring your site back on: Put this line o'code in your config/site.php

define('STATISTICS_TRACK_PAGE_VIEWS', false);

In PHPMyAdmin there's the option to manually increase the auto_increment value. I increased it by one to 300970 and the site was working again, with statistics (comment the line you just inserted.)

There's a couple of pages out there, currently having this problem (searching with Google helps). I'm offering a low-cost watchdog service for Concrete5 sitesbe back up again before your visitors notice!

Bug in Concrete 5

Tuesday, May 4th, 2010

If a page name contains "/" (the slash), the Concrete5 edit bar does not appear on the page. (At least in Opera 10)

Solution: go to the Dashboard, edit the page name (hint: remove the slash) from the Sitemap there and visit the page again.

PDFGenerator for Concrete 5

Sunday, May 2nd, 2010

After Georg (below) commented, I felt inspired to polish the code into usable Alpha state.

IdeaDay PDF Generator (v3.0 Alpha)

This Concrete 5 package encapsulates mpdf and makes it easy to create PDF versions of your pages.
It was written by ideaday.de
Contact: http://www.ideaday.de/kontakt

mpdf was written by Ian Back (it makes itself heavy use of other OSS projects).
We use Version Version 4.4, released 24/03/10

See the other files for Licensing and Version information. (This blog entry is just a formatted README.txt)

Download

Get your package here:

Installation

1) download the ZIP
2) unzip it
3) upload the folder ideaday_pdf_generator in your packages folder
4) install it using the Dashboard

Usage

Add an Icon / link to the page(s) you want to generate the PDF from, including the query parameter ?ipg_mode=pdf
i.e. http://www.example.com/this/is/a/page/?ipg_mode=pdf

Feel free to edit the default settings in /helpers/pdf.php:
$options['ipg_filename'] = 'website.pdf';
$options['ipg_mode'] = 'I';
$options['ipg_header'] = ";//'{PAGENO}'; //You could set up your own header here.
$options['ipg_footer'] = ";

To modify the way the PDF is shown (streamed / forced download) you currently have to edit the line
$pdf->showPDF();
and change it to the appropriate function.

Functions

public function getHTML()
Returns the actual HTML used to build the PDF.

public function getPDF()
Returns the PDF as a string.

public function streamPDF()
Streams the PDF.

public function showPDF()
Displays the PDF in the browser

Known limitations

  • Floating images are rendered on top of the text instead floating beside it. If you specifically set the image size in pixels (IMG width / height), it will render correctly.
  • I have exposed only a very limited subset of the MPDF package, i.e. it renders in DIN A4, instead of letter, etc.
  • You have to add the icon/link, and tweak the source to change settings. I plan to add a block which will display a link and allow you to set up settings on each page individually.


Concrete5 does not update correctly?

Friday, April 30th, 2010

Starting with the newest version of Concrete, 5.4, updates have been integrated into the web interface.

For me, this update process suddenly did not work anymore correctly:
After running the upgrade script, it would still show that we were using the old version of the code and offer to upgrade again – as if nothing had happened inbetween.

The solution to this problem lies in your config/site.php – look at the very end of it, it will contain a statement similar to this one:

<?php define('DIRNAME_APP_UPDATED', 'concrete5.4.0.5');?>

My config/site.php contained two statements – one having the previous version, one the newest version of the update.

Try removing them both and running the upgrade once again. It will work this time – no upgrade will be offered again.

Does the AdoDB C extension speed up Concrete?

Tuesday, April 6th, 2010

My experiments with a sufficiently complex page (www.vitanit.com) have shown: no. There even may be a slight time penalty.

To enable it, you'll have to download it, compile it, and add the following to your php.ini:

extension=adodb.so

How do you know that it's installed? phpinfo() will show something like:

ADOdbInfo Extension requires ADOdb classes
Download http://php.weblogs.com/adodb
API Version 5.04

It might be useful for the IdeaDay Import Wizard – which relies heavily on the database.

Concrete5 File Uploads with Forms

Sunday, April 4th, 2010

If you use Form Helpers and add a file upload there's a gotcha, which can drive you insane if you don't know about it:

The form encoding type has to be set to multipart, like this:

<form method="post" enctype="multipart/form-data" action="<?php echo $this->action('submit')?>">

If you don't do this, your file will never turn up, and you will be debugging like mad and not understanding where the problem is :-)