Coder Social home page Coder Social logo

silverstripe / silverstripe-lessons-v4 Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 68.0 5.44 MB

The source code for the SilverStripe.org Lessons section, version 4.x

License: Other

PHP 3.25% HTML 6.38% Scheme 8.89% CSS 2.05% JavaScript 45.71% Less 33.73%

silverstripe-lessons-v4's People

Contributors

andrewandante avatar dhensby avatar emteknetnz avatar kinglozzer avatar pieht avatar robbieaverill avatar tiller1010 avatar zzdjk6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

silverstripe-lessons-v4's Issues

Lesson 20's SQL Query is too inefficient; causes PHP timeout.

It may not be the query (13 rows with the provided database), but the iteration of it's results.
It seems that maybe while($record = $result->nextRecord()) may no longer do as expected, and in any case take far too long to do it's work, reaching the timeout of 30 seconds before the requested page can be rendered.

Below is an example, although the code is modified to demonstrate the issue:

Fatal error: Maximum execution time of 30 seconds exceeded in /usr/local/var/www/ss4/mysite/code/ArticleHolder.php on line 58
[Alert] Maximum execution time of 30 seconds exceeded
GET /ss4/travel-guides/
Line 58 in /usr/local/var/www/ss4/mysite/code/ArticleHolder.php

Source
49             ->setSelect([])
50             ->selectField("DATE_FORMAT(`Date`,'%Y_%M_%m')", "DateString")
51             ->setFrom($tableName)
52             ->setOrderBy("DateString", "ASC")
53             ->setDistinct(true);
54         $result = $query->execute();
55 //die($query->sql());
56         if ($result) {
57             $c=0;
*58             while($thing = $result->nextRecord()) {
59                 $c++;
60             }
61             die("$c");
62             while ($record = $result->nextRecord()) {
63                 list($year, $monthName, $monthNumber) = explode('_', $record['DateString']);
64                 $list->push(ArrayData::create([
Trace

(no trace).
The die is never hit. When commenting the loop, it is.

Bug in lesson-05 (or Silver Stripe)

At end of lesson-05 try adding a new page that is a child of "Travel Guides".

At "Choose Page Type" 'Article Holder' is available but 'Article Page' is greyed out.

Rename or somehow tag vimeo ss3 vids as being for SS3

Although technically not directly related to this repository...
Currently there's a bit of confusion, particularly if someone new to the system googles and receives a link directly to vimeo. It's not clear that e.g. the _ss_enviornment.php file is not for the version they are probably trying to use (latest stable: ie. SS4).

If we could prefix the video names with e.g. ss3- or something similar (does vimeo support tags?) this could help relieve confusion.

Perhaps also adding a blurb at the top of the description for each video that links off to the latest stable release equivalent would also be more ideal.

Composer files seem to be out of date

Instructions on this page Lesson Content say to run "composer install" in each "lesson-begin" directory.

However running composer install (or composer update) fails to load dependencies & install completely and creates errors when running in browser... it appears that the composer file settings are significantly out of date - Running "composer install" says it's out of date... then running "composer update" writes to the composer.json file to include the old "mysite" + "mysite/code" directories under "extra -> project-files-installed" ... even thou the silverstripe/lessons git repo's folder structure has already been changed from mysite to app (the composer file appears to create a mysite directory and write to the composer.json file)

This creates an error when trying to run silverstripe-lessons in the browser...

Fatal error: Uncaught Exception: There are two files containing the "Page" class: "C:\www\silverstripe-lessons-v4\Lesson-04-begin/app/src/Page.php" and "C:\www\silverstripe-lessons-v4\Lesson-04-begin/mysite/code/Page.php"

These lessons are an amazing learning resource - please update them so we can continue to enjoy learning SS.

Lesson 00 installation set up is not correct

In lesson 00 we describe how to set up a Silverstripe instance:
https://www.silverstripe.org/learn/lessons/v4/up-and-running-setting-up-a-local-silverstripe-dev-environment-1

In the Creating a Silverstripe project section the lesson uses the installer wizard. The installer wizard was removed in Silverstripe 4.5.0 and moved to it's own module. These instructions will not work.

Lesson 00 needs to be updated either to also install the installer wizard module, or to remove the description of the installer wizard and instead get the user to set up a .env at that stage.

This issue was brought up on Stackoverflow by a new user following the lessons for the first time.

index.php is out of date

The index.php file in the root of the lessons appears to be out of date.

Is it from SS3? The last line require_once 'framework/main.php'; fails. That is not where framework is anymore

Please update the lessons!

These lessons are really out of date. Setting up the dev environment didn't go as per lesson 0 (the installer has been removed since the lesson was written) and now I'm stuck on the Working with multiple templates lesson due to an issue with namespaces.

Please could we get some up-to-date lessons with the latest version???

Out of Date

Is it just me or are these lesson out of date?

Undefined Offset:1 for ArticleHolder.php (Lesson 20)

So I was browsing the PR and Issues here and noticed a few people had issues with the results section of the ArchiveDates() section on ArticleHolder.

public function ArchiveDates()
{
$list = ArrayList::create();
$stage = Versioned::get_stage();
$baseTable = ArticlePage::getSchema()->tableName(ArticlePage::class);
$tableName = $stage === Versioned::LIVE ? "{$baseTable}_Live" : $baseTable;
$query = SQLSelect::create()
->setSelect([])
->selectField("DATE_FORMAT(`Date`,'%Y_%M_%m')", "DateString")
->setFrom($tableName)
->setOrderBy("DateString", "ASC")
->setDistinct(true);
$result = $query->execute();
if ($result) {
foreach ($result as $record) {
list($year, $monthName, $monthNumber) = explode('_', $record['DateString']);
$list->push(ArrayData::create([
'Year' => $year,
'MonthName' => $monthName,
'MonthNumber' => $monthNumber,
'Link' => $this->Link("date/$year/$monthNumber"),
'ArticleCount' => ArticlePage::get()->where([
"DATE_FORMAT(\"Date\",'%Y_%m')" => "{$year}_{$monthNumber}",
"\"ParentID\"" => $this->ID
])->count()
]));
}
}
return $list;
}

I've tried a fix, even reverted to the initial configuration and are still having an issue. The problem seems to be around this one function as if I comment it out, and undo changes it said, I'm working again (Lesson 19).

Here's my error:
capture

PHP 7.2.2 using XAMPP.
Windows 7 Professional.

$owns not described

In lesson 09 it says "As described in a previous tutorial, the $owns array is used to ensure that when regions are saved..." but I cannot find that previous tutorial using search engines.

Lessons and documentation todos

@dnsl48 commented on Tue Feb 05 2019

Affected Version

4

Description

Some suggestions to improve the lessons and the documentation on https://silverstripe.org

  • Index links are broken - #84
  • Learners experience could be improved with docker. E.g. we could use prepared database containers rather than ask people to roll SQL dumps manually.
  • The app from the Lesson 0 is not the one which we work on in Lesson 1
  • Might be worth explicitly asking to checkout lesson source codes and not reuse the ones from previous lessons
  • Could be much handier to copy stuff straight from snippets rather than go to the github repository and look up for a file (e.g. templates)
  • Code snippets do not contain opening <?php tags
  • lesson 1 - mysite/code/ folder instead of mysite/src/
  • lesson 2 - broken link to the "Code repository"
  • lesson 2 - does not explicitly ask to checkout the app, rather than use stuff from previous lessons
  • lesson 5 - does not state the files static/article-holder.html and static/article-page.html are actually in __assets folder
  • lesson 7 - add the link to the other tutorial covering the image resampling functions
  • lesson 7 - $Image.FixMax(width, height) - typo, should be FitMax
  • lesson 9 - Attached to this lesson is a download link to a new static template - not clear that I have to look into the Code Repository __assets folder
  • lesson 11 - rewrite the example with validating length of a field not in the controller, but a Validator attached to the field itself
  • lesson 11 - add an example how to leverage HTML5 minlength/maxlength attributes
  • lesson 11 - Form::addErrorMessage has been deleted [https://github.com/silverstripe/silverstripe-framework/blob/4/docs/en/04_Changelogs/4.0.0.md] (#77)
  • lesson 11 - rewrite the example to use $comment = ArticleComment::create($data) rather than assigning each field separately
  • lesson 11 - rewrite the example to "include" comments block in the template
  • lesson 11 - handleComment on ArticlePage.php instead of ArticlePageController.php (a typo)
  • lesson 11 - Controller gets the same fields as the Model... nothing said about that in the prior lessons
  • lesson 12 - the first part of the lesson leaves you with hard feelings, the second part clarifies that Extensions is not a reinvented wheel (DI+Traits), but also solves "events" and "hooks" use cases. Potentially could be rewritten.
  • lesson 12 - _app/config/app.yml does not exist, it's app/_config/app.yml
  • lesson 13 - app/src/Property.php snippet doesn't have peculiarity ->setEmptyString(). It appears below in the next one.
  • lesson 14 - $Photo.SetWidth(750) does not work. Should be ScaleWidth (typo)
  • lesson 14 - lack of use SilverStripe\Forms\HTMLEditor\HTMLEditorField; in the snippet where we update the Region's getCMSFields method
  • lesson 14 - class sidebar with the simple theme concealed the Regions section and it wouldn't appear. May be confusing for beginners.
  • lesson 14 - MetaTags(false) + title bit could be irrelevant as it comes with the theme in the Lesson 0
  • lessons 15 and further - To be checked
  • https://docs.silverstripe.org/en/4/contributing/code/ - supported versions link is broken
  • https://docs.silverstripe.org/en/4/developer_guides/testing/ - Documentation on unit and integration testing is too old (https://www.slideshare.net/maetl/getting-to-grips-with-silverstripe-testing)
  • add a lesson around YAML configuration
  • add a lesson about routing
  • add a lesson about caching
  • add a lesson about logging

@robbieaverill commented on Tue Feb 05 2019

I've adjusted the impact rating since these are documentation issues.

Also FYI, the lessons issues could be tracked on the https://github.com/silverstripe/silverstripe-lessons-v4 repository if we want to move them out of framework

Markdown Inside of HTML Tags are not Rendered

On the website markdown-tags inside of html-blocks aren't rendered.

<div class="alert alert-danger">
The `.env` file is meant for development environments only. While it could theoretically be used in production this is *not* recommended, and should only be used as a last resort in hosting environments where setting server level or true environment variables is not an option. Please see the documentation for your web server for more information. E.g. [Apache](https://httpd.apache.org/docs/2.4/mod/mod_env.html#setenv)
</div>

This issue can be solved by either not using markdown-syntax inside of HTML-elements or by using a markdown-engine which supports Markdown-syntax inside of HTML.

In Kramdown, for example, you can use markdown-language inside of HTML-elements by adding a markdown="1"-attribute to the HTML-tag:

### Warning

<div class="alert alert-danger" markdown="1">
Markdown is **supported** inside this html-tag!
</div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.