Jan 26
Da ich während der Arbeit schon mehrmals auf das Problem gestoßen bin, würde ich es gerne hier skizzieren, damit sich jemand anders die Arbeit vielleicht nicht mehr machen muss. Das Problem ist folgendes: In einem TYPO3-Plugin soll die Seiten-ID ermittelt werden um sie weiterzuverwenden, zum Beispiel um Records eines bestimmten Typs aus der Datenbank zu laden die an dieser Seite hängen.
Unsaubererweise gibt es global verfügbare Variablen im TYPO3-Pluginkonstrukt, die diese Information enthalten. So kann über $GLOBALS['TSFE']->id die ID der aktuell AUFGERUFENEN Seite ermittelt werden. Das funktioniert so lange, bis es einen Unterschied macht, welche Seite aufgerufen und welche angezeigt wird. Es gibt zum Beispiel die Möglichkeit der internen Links (Shortcuts) oder auch die der Mountpoints (Seiteninhalt einer anderen Seite anzeigen). Kommt man auf so eine Seite, dann funktioniert die Methode von vorhin nicht, denn die Inhalte die angezeigt werden, liegen nicht auf der Seite die aufgerufen wurde. Dieses Manko lässt sich nun dadurch beheben, dass man einfach die Seiten-ID der Inhaltselemente abfragt: $this->cObj->data['pid'] Das Array “data” enthält alle Felder aus der Tabelle tt_content und damit auch die ID der Seite zu der das Element gehört.
Vielleicht ist das ja hilfreich wenn jemand sich mal fragt, warum diese IDs verschieden sind…
Nov 13
Ich habe gerade eine TYPO3-Installation von TYPO3 4.1.x auf 4.2.3 geupdated, was mir promt die ganze Seite zerschossen hat. PHP5 ist mit der Fehlermeldung abgebrochen, dass die Methode array_merge_recursive_overrule in der Klasse “t3lib_div” einen Parameter vom Typ “array” erwartet, jedoch “null” bekommen hat. Auslöser des Problems war bei mir die Extension “dam”. Wenn ich sie im BE deaktiviere läuft es wieder, natürlich mit eingeschränkter Funktionalität.
Ich habe aus diesem Grund die Parameterdefinition in t3lib_div in der Methode entfernt (das “array” bei $arr1 und $arr2 weglöschen) damit es wieder geht.
Liebe Core-Entwickler, bevor ihr solche tollen PHP5-Features in den Core integriert, solltet ihr das den Extension-Autoren sagen, damit die ggf. ein Update bereitstellen können!!!
DANKE!
UPDATE: Die Extension “date2cal” scheint mit 4.2.3 ebenfalls NICHT zu laufen!
Okt 01
Sometimes, you might need to check whether a string has already been urlencoded with PHP or not. Sadly, PHP doesn’t offer such a function but because I recently needed it, I tried this one:
/**
* Returns true if given string is url encoded
*
* @param string $string
* @return boolean
*/
function is_urlencoded($string) {
return $string === urlencode(urldecode($string));
}
This works fine for me (as far as I have tested), so maybe it is a litte help for anyone with the same problem
Aug 29
If you program PHP code with Eclipse PDT, you surely missed the auto generate getter and setter refactoring option which is known from the JDT. So you had to write hundreds of thousands of lines of code to create those methods for the uncountable amount of data objects you wrote until now.
To speed things up, here’s a solution with templates:
Click Window – Preferences – PHP – Templates and create a new template with the following content:
/**
* Set the ${word_selection} value
* @param unknown_type $$${word_selection}
*/
public function set${variable}($$${word_selection}) {
$$this->${word_selection} = $$${word_selection};
}
/**
* Returns the ${word_selection} value.
* @return unknown_type
*/
public function get${variable}() {
return $$this->${word_selection};
}
${cursor}
To use this template, type the template shortcut you have chosen in a PHP file of your choice (e.g. “getset”), followed by a variable name of your class (z.B. getsetcolor). Now highlight the word “color” (or yours, if different) and then press ctrl+space. Voila, there you have the desired methods. The cursor is on the right position for the variable type in the javadoc comment. Type “string” (or your type) and then jump to the method names with tab. You should type e.g. “Color” (starts with capital letter) and that’s it!
This method should save you at least 1-2 minutes per property – try it!
Mrz 27
I have added some new features and fixed some bugs:
- members can now provide an email address for paypal donations. When they have already done something on the website, this link is displayed in their profile
- the filesize of the uncompressed files is now shown on the plugin detailpage and the download basket page
- there have been some bugs in the edit profile action. They are gone now.
- some SEO for the detail pages
I hope these improvements are useful
Mrz 25
To offer my blog to more people, I decided to publish my posts also in english some time ago. To do with wordpress as easy as possible, I used the jLnguage Plugin. After a little while, the category feed for eSteak was not working any more. I noticed that quickly because this feed is displayed on the eSteak homepage. I did not really find a reason for that, so my only solution was, to put that post into another category.
During the last few days, I realized that my feedburner feed had no readers any more and I asked myself why. At least the news services with wich I signed up should have been there. After checking it myself, I got timeout, plus a cpu load of almost 100% caused by a single httpd2 process. Weiterlesen »
Mrz 12
After editing one single class file in my project (one in /lib that has nothing to do with the database), I unpredictably got the error “wrapped: Cannot fetch TableMap for undefined table: xxx” in the prod mode as well as in the dev mode.
XXX stands for a random table name in my database.
I tried to clear symfony cache, browser cache and finally I replaced the file with the old version, with any improvement of the situation. My last chance was a restart of the apache server, then everything was running like before. I have absolutely no clue where this error came from…
UPDATE: The restart was not the solution! The error just took some time to reappear. Thus, I added some debug code before the actual php exception is thrown. Then I found out that “lib/model/om/BaseXXXPeer.php” could not include the file “lib/model/XXXPeer.php” which is very logical for me, because the controller is located in “web/”. Seen from there, tha path should be “../lib/model …“. After adding “../” to the include_path variable in the php.ini, the error seems to be gone.
I don’t get why those includes do not use absolute paths. It would be very nice to see this in the next version of symfony.
Mrz 12
After upgrading from php 5.0.4 to 5.2.5 on my server, I got a blank page as output several times. In dev mode, the error message said, that a creole file could not be loaded. I had to change the include_path value in the php.inito get it working. I just added “/usr/share/php/pear/symfony/lib/vendor”, then the error was gone. Depending on whether you installed your symfony via pear or via svn, the path has to be changed of course.
Finally, don’t forget to clear the symfony cache (symfony cc).
Feb 25
After further investigation of the problem I posted last Thursday, I finally found a solution to get it to work! I took a closer look at the subversion repository and found another branch (which is described nowhere). So you have to add an svn:external to the plugin folder named sfPHPUnitPlugin and targetting to http://svn.symfony-project.com/plugins/sfPHPUnitPlugin/branches/1.0/. Then you need to update the plugin folder. If you then type symfony -T, the new tasks are visible.
Hurray! But wait a minute: it still doesn’t work! There seems to be one mistake in the file “sfPHPUnitTestPrinterTap.php” in the “lib” directory of the plugin. In line 159, you need to replace the “$suite->testCount()” by “$suite->count()” and then it finally works! Unbelievable, but true. After a long journey, I made it – symfony runs with PHPUnit. Thank God.
Feb 21
I am currently working on a small project and I decided to use symfony, because this framework has some good features. I follow the given tutorial to come to the 15th day today, the unit test day. Symfony uses an own “Framework” (it’s 1 file) called lime. Sadly the whole testfile looks very weird and not really useable. As I used ASUnit and PHPUnit several times in the past, I think this is quite lame.Weiterlesen »